IndexController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Events\WechatMessageEvent;
  4. use App\Handlers\UploadFilesHandler;
  5. use App\Http\Requests\UserRequest;
  6. use App\Models\Address;
  7. use App\Models\Banner;
  8. use App\Models\BigGiftApply;
  9. use App\Models\Demo;
  10. use App\Models\Demodemo;
  11. use App\Models\DemoTest;
  12. use App\Models\Enroll;
  13. use App\Models\Infos;
  14. use App\Models\MoneyUser;
  15. use App\Models\Notice;
  16. use App\Models\OrderDetailW;
  17. use App\Models\Ordertest;
  18. use App\Models\OrderW;
  19. use App\Models\RecomCodeExpire;
  20. use App\Models\ShareUser;
  21. use App\Models\Store;
  22. use App\Models\User;
  23. use App\Models\UserPay;
  24. use App\Models\UserW;
  25. use Carbon\Carbon;
  26. use Illuminate\Http\Request;
  27. use GuzzleHttp\Client;
  28. use Illuminate\Support\Facades\Auth;
  29. use Illuminate\Support\Facades\Cache;
  30. use Illuminate\Support\Facades\Config;
  31. use Illuminate\Support\Facades\DB;
  32. use Illuminate\Support\Facades\File;
  33. use Illuminate\Support\Facades\Log;
  34. use Qiniu\Storage\UploadManager;
  35. use Qiniu\Auth as Auths;
  36. use Validator;
  37. use Intervention\Image\Facades\Image as Image;
  38. use Endroid\QrCode\LabelAlignment;
  39. use Endroid\QrCode\ErrorCorrectionLevel;
  40. use Endroid\QrCode\QrCode;
  41. class IndexController extends Controller{
  42. public function AddQrCodeStatus(){
  43. $time=Carbon::now()->toDateTimeString();
  44. if ($time>'2022-03-18 09:00:00'){
  45. return $this->success([]);
  46. }
  47. return $this->error(50021);
  48. }
  49. public function AddQrCode(Request $request){
  50. // $imgA=Image::make(env('APP_URL').'/public/uploads/weihu.png');
  51. // return $imgA->response("png");
  52. $id=Auth::user()->id;
  53. $user=User::find($id);
  54. $phone=$request->input('phone');
  55. $share=ShareUser::where('phone',$phone)->first();
  56. if ($share->imgurl){
  57. $data=$share->imgurl;
  58. }else{
  59. $data=$this->make_code($phone);
  60. }
  61. $imgA=Image::canvas(343,552,'#FFFFFF');
  62. $img=Image::make($data)->resize(160,160);
  63. $imgB=Image::make(env('APP_URL').'/bg_red.png')->resize(343,552);
  64. $imgC=Image::make(env('APP_URL').'/bg_white.png')->resize(283,365);
  65. $imgL=Image::make(env('APP_URL').'/bg_logo.png')->resize(267,44);
  66. $imgA->insert($imgB,'',0,0);
  67. $imgA->insert($imgC,'',30,100);
  68. $imgA->insert($imgL,'',38,32);
  69. $imgA->insert($img,'',91,237);
  70. //匹配Unicode编码表对应字符
  71. $nickname=preg_replace("/[^\x{4e00}-\x{9fa5}^\x{0021}-\x{007e}]+/u", '', $user->nickname);
  72. if (mb_strlen($nickname)>6){
  73. $nickname=mb_substr($nickname,0,6);
  74. }
  75. if(empty($nickname)){
  76. $nickname=substr_replace($user->mobile,'****',3,4);
  77. }
  78. $imgA->text($nickname, 178, 160,function ($font){
  79. $font->file('./ziti/fangzheng.TTF');
  80. $font->size(24);
  81. $font->color('333333');
  82. $font->align('center');
  83. $font->angle(0);
  84. });
  85. $imgA->text('邀请你('.hide_phone($phone).')加入大卫博士', 72, 190,function ($font){
  86. $font->file('./ziti/fangzheng.TTF');
  87. $font->size(12);
  88. $font->color('333333');
  89. $font->angle(0);
  90. });
  91. $imgA->text('识别图中二维码填写信息', 85, 429,function ($font){
  92. $font->file('./ziti/fangzheng.TTF');
  93. $font->size(14);
  94. $font->color('333333');
  95. $font->angle(0);
  96. });
  97. // $imgA->text('有效期至:'.$expire_time, 75, 480,function ($font){
  98. // $font->file('./ziti/fangzheng.TTF');
  99. // $font->size(12);
  100. // $font->color('FFFFFF');
  101. // $font->angle(0);
  102. // });
  103. return $imgA->response("png");
  104. }
  105. public function AddQrCodeUp(Request $request){
  106. $user_id=$request->input('id');
  107. if(empty($user_id)){
  108. return $this->error('450001','','未获取到客户信息');
  109. }
  110. $id=Auth::user()->id;
  111. $expire_time=Carbon::parse('+72 hours')->toDateTimeString();
  112. $data=$this->make_code($id,$user_id,$expire_time);
  113. $imgA=Image::canvas(310,469,'#FFFFFF');
  114. $img=Image::make($data)->resize(178,178);
  115. $imgB=Image::make(env('APP_URL').'/bg_tan.png')->resize(310,469);
  116. $imgA->insert($imgB,'',0,0);
  117. $imgA->insert($img,'',67,122);
  118. $user=UserW::find($user_id);
  119. //匹配Unicode编码表对应字符
  120. $nickname=preg_replace("/[^\x{4e00}-\x{9fa5}^\x{0021}-\x{007e}]+/u", '', $user->nickname);
  121. if (mb_strlen($nickname)>6){
  122. $nickname=mb_substr($nickname,0,6);
  123. }
  124. if(empty($nickname)){
  125. $nickname=substr_replace($user->phone,'****',3,4);
  126. }
  127. $imgA->text($nickname, 157, 60,function ($font){
  128. $font->file('./ziti/fangzheng.TTF');
  129. $font->size(24);
  130. $font->color('FFFFFF');
  131. $font->align('center');
  132. $font->angle(0);
  133. });
  134. $imgA->text('· 欢迎您加入大卫博士 ·', 70, 90,function ($font){
  135. $font->file('./ziti/fangzheng.TTF');
  136. $font->size(14);
  137. $font->color('FFFFFF');
  138. $font->angle(0);
  139. });
  140. $imgA->text('识别图中二维码填写信息', 65, 340,function ($font){
  141. $font->file('./ziti/fangzheng.TTF');
  142. $font->size(14);
  143. $font->color('FFFFFF');
  144. $font->angle(0);
  145. });
  146. $imgA->text('有效期至:'.$expire_time, 50, 365,function ($font){
  147. $font->file('./ziti/fangzheng.TTF');
  148. $font->size(12);
  149. $font->color('FE9C9C');
  150. $font->angle(0);
  151. });
  152. return $imgA->response("png");
  153. }
  154. public function AddQrCodess(Request $request){
  155. $id=39516;
  156. // $id=$request->id;
  157. // $id=39516;
  158. $user=User::find($id);
  159. $data=$this->make_code($id);
  160. $imgA=Image::canvas(380,560,'#FFFFFF');
  161. $img=Image::make($data)->resize(300,300);
  162. // $img=Image::make($qrCode);
  163. $imgB=Image::make(env('APP_URL').'/logo.jpg')->resize(80,80);
  164. $imgA->insert($img,'',40,160);
  165. $imgA->insert($imgB,'',150,10);
  166. $user=User::find($id);
  167. // try{
  168. // $imgC=Image::make($user->headimgurl)->resize(80,80);
  169. // }catch (\Exception $exception){
  170. $imgC=Image::make(env('APP_URL').'/logo.jpg')->resize(80,80);
  171. // }
  172. $imgA->insert($imgC,'',150,270);
  173. if (mb_strlen($user->nickname)>=6){
  174. $x=120;
  175. }elseif (mb_strlen($user->nickname)>=4 && mb_strlen($user->nickname)<6){
  176. $x=140;
  177. }elseif (mb_strlen($user->nickname)>=2 && mb_strlen($user->nickname)<4){
  178. $x=160;
  179. }else{
  180. $x=200;
  181. }
  182. $imgA->text('"'.mb_substr($user->nickname,0,6).'"', $x, 120,function ($font){
  183. $font->file('./ziti/fangzheng.TTF');
  184. $font->size(25);
  185. $font->color('000000');
  186. $font->angle(0);
  187. });
  188. $imgA->text('邀请你加入大卫博士', 90, 150,function ($font){
  189. $font->file('./ziti/fangzheng.TTF');
  190. $font->size(22);
  191. $font->color('000000');
  192. $font->angle(0);
  193. });
  194. $imgA->text('长按-识别二维码-填写信息', 45, 510,function ($font){
  195. $font->file('./ziti/fangzheng.TTF');
  196. $font->size(22);
  197. $font->color('F76454');
  198. $font->angle(0);
  199. });
  200. return $imgA->encode('data-url');
  201. }
  202. public function GetCrown(){
  203. $ids=User::where('level',3)->pluck('id');
  204. $re=Store::whereIn('user_id',$ids)->select('name','username','idCard')->get();
  205. return $this->success($re);
  206. }
  207. public function AddQrCodes(Request $request){
  208. $id=Auth::user()->id;
  209. // $id=$request->id;
  210. // $id=39516;
  211. $user=User::find($id);
  212. // $re=new WechatController();
  213. // $data=$re->makeQrCode();
  214. $data=$this->make_code($id);
  215. $imgA=Image::canvas(380,560,'#FFFFFF');
  216. $img=Image::make($data)->resize(300,300);
  217. // $img=Image::make($qrCode);
  218. $imgB=Image::make(env('APP_URL').'/logo.jpg')->resize(80,80);
  219. $imgA->insert($img,'',40,160);
  220. $imgA->insert($imgB,'',150,10);
  221. try{
  222. $imgC=Image::make($user->headimgurl)->resize(80,80);
  223. }catch (\Exception $exception){
  224. $imgC=Image::make(env('APP_URL').'/logo.jpg')->resize(80,80);
  225. }
  226. $imgA->insert($imgC,'',150,270);
  227. $imgA->text('"'.$user->nickname.'"', 120, 120,function ($font){
  228. $font->file('./ziti/fangzheng.TTF');
  229. $font->size(25);
  230. $font->color('000000');
  231. $font->angle(0);
  232. });
  233. $imgA->text('邀请你加入大卫博士', 90, 150,function ($font){
  234. $font->file('./ziti/fangzheng.TTF');
  235. $font->size(22);
  236. $font->color('000000');
  237. $font->angle(0);
  238. });
  239. $imgA->text('长按-识别二维码-填写信息', 45, 510,function ($font){
  240. $font->file('./ziti/fangzheng.TTF');
  241. $font->size(22);
  242. $font->color('F76454');
  243. $font->angle(0);
  244. });
  245. return $imgA->response('png');
  246. }
  247. public function make_code($mobile){
  248. $share=ShareUser::where('phone',$mobile)->first();
  249. $url=env('APP_URL').'/api/gzh?uuid='.$share->uuid;
  250. $qrCode = new \Endroid\QrCode\QrCode($url);
  251. // 内容区域宽高,默认为300
  252. $qrCode->setSize(600);
  253. // 外边距大小,默认为10
  254. // $qrCode->setMargin(10);
  255. // 设置编码
  256. $qrCode->setEncoding('UTF-8');
  257. // 设置容错等级
  258. $qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH());
  259. // 设置二维码颜色,默认为黑色
  260. $qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
  261. // 设置二维码背景色,默认为白色
  262. $qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
  263. // 设置二维码下方的文字
  264. $qrCode->setLogoPath('./logo.jpg');
  265. $qrCode->setLogoSize(200, 200);
  266. // $qrCode->setLogoPath('/www/wwwroot/test.woaidakele.cn/app-api/public/logo.jpg');
  267. // $qrCode->setLogoSize(80, 80);
  268. // $path='public/code/';
  269. // $path = public_path().'/code/';
  270. // File::makeDirectory($path,$mode = 0777,true,true);
  271. // $folder_name = "upload/images/Qrcode/202103";
  272. // $folder_name = "upload/images/Qrcode/" . date("Ym", time());
  273. // 文件具体存储的物理路径,`public_path()` 获取的是 `public` 文件夹的物理路径。
  274. // 值如:/home/vagrant/Code/larabbs/public/uploads/images/avatars/201709/21/
  275. // $upload_path = 'public/' . $folder_name;
  276. // 获取文件的后缀名,因图片从剪贴板里黏贴时后缀名为空,所以此处确保后缀一直存在
  277. $extension = 'png';
  278. // 拼接文件名,加前缀是为了增加辨析度,前缀可以是相关数据模型的 ID
  279. // 值如:1_1493521050_7BVc9v9ujP.png
  280. $filename = $mobile. '_' . time() . '_' . str_random(10) . '.' . $extension;
  281. $config = [
  282. 'driver' => 'qiniu',
  283. 'domain' => 'http://image.chuliu.cc', //七牛域名
  284. 'access_key' => 'cIbo9JAqHBgO6uw97gT5fJOlEHiTiGrpB84unVEn', //AccessKey
  285. 'secret_key' => '4f0nTNNrvzOsFc6Rz0GC5DntiJRnk2GcfkyJFNQp', //SecretKey
  286. 'bucket' => 'daweiboshi-app', //Bucket名字
  287. 'dirname'=> 'qr_code'
  288. ];
  289. // 构建鉴权对象
  290. $auth = new Auths($config['access_key'], $config['secret_key']);
  291. // 生成上传 Token
  292. $token = $auth->uploadToken($config['bucket']);
  293. $uploadMgr = new UploadManager();
  294. // 调用 UploadManager 的 putFile 方法进行文件的上传。
  295. $dirname=$config['dirname'];
  296. $pathname= $dirname.'/'.date('Ymd').'/'.$filename;
  297. try{
  298. $uploadMgr->putFile($token, $pathname, $qrCode->writeDataUri());//$qrCode->writeDataUri()
  299. }catch(\Exception $e){
  300. return $this->error('450001',$e->getMessage(),$e->getMessage());
  301. }
  302. $qr_code_url=$config['domain'].'/'.$pathname;
  303. DB::beginTransaction();
  304. try{
  305. $share->imgurl=$qr_code_url;
  306. $share->save();
  307. DB::commit();
  308. }catch(\Exception $e){
  309. DB::rollback();
  310. }
  311. return $qr_code_url;
  312. }
  313. public function getStoreMeetFive(Request $request){
  314. return $this->success([]);
  315. }
  316. public function getMeetFiveDetail123(Request $request){
  317. }
  318. public function getMeetFiveDetail(Request $request){
  319. }
  320. public function get_address(Request $request){
  321. $Address=Address::groupBy('mobile','province','address')->get()->toArray();
  322. foreach ($Address as $k=>$v){
  323. $re=Address::where('mobile',$v->mobile)->get();
  324. if (count($re)>1){
  325. Log::error(json_encode($re));
  326. }
  327. }
  328. dd(1);
  329. }
  330. public function rand_code($num){
  331. $code='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  332. $str=$num."_";
  333. $str_1='';
  334. for ($i=0;$i<20;$i++){
  335. $int=rand(0,34);
  336. $str_1.=mb_substr($code,$int,1);
  337. }
  338. $str=$str.mb_substr(time(),2,3).$str_1;
  339. return $str.mb_substr(time(),7,3);
  340. }
  341. public function login(){
  342. $app=app('wechat.official_account');
  343. $shortUrl = $app->url->shorten('https://easywechat.com');
  344. dd($shortUrl['short_url']);
  345. $user=User::where('mobile',15236877164)->first();
  346. $token = Auth::guard('api')->fromUser($user);
  347. return $this->success($token);
  348. }
  349. public function demo(){
  350. $demo=new Demodemo();
  351. $demo->name='kele';
  352. $demo->names='kele';
  353. $demo->save();
  354. }
  355. public function test(Request $request){
  356. $client=new Client();
  357. $url="https://api.weixin.qq.com/sns/userinfo";
  358. $array=[
  359. 'query' => [
  360. 'access_token' =>$request->access_token,
  361. 'openid'=>$request->openid
  362. ]
  363. ];
  364. $data=$client->request('GET',$url,$array);
  365. $ad = json_decode($data->getBody()->getContents());
  366. echo $ad->nickname;
  367. dd($ad);
  368. // $address=Address::find(1);
  369. }
  370. public function json(Request $request){
  371. return md5_file('https://api.jiuweiyun.cn/public/uploads/images/img/201912/24/5850_1577162472_WD3doBoiDT.png');
  372. $data='1000050001202001071103128744231';
  373. $d='100005000120200107110312844231';
  374. similar_text($data,$d,$percent);
  375. return $percent;
  376. $address=new Address();
  377. $address->provice='河南';
  378. $address->uid=120;
  379. $address->save();
  380. return $address->id;
  381. $data=[
  382. [
  383. "name"=> "男款(黑色)",
  384. "size"=> 's',
  385. 'num'=>'2',
  386. ],
  387. [
  388. "name"=> "男款(黑色)",
  389. "size"=> 'l',
  390. 'num'=>'3,'
  391. ],
  392. [
  393. "name"=> "男款(黑色)",
  394. "size"=> 'xl',
  395. 'num'=>'4',
  396. ],
  397. [
  398. "name"=> "男款(肤色)",
  399. "size"=> 'l',
  400. 'num'=>'5,'
  401. ],
  402. [
  403. "name"=> "男款(肤色)",
  404. "size"=> 's',
  405. 'num'=>'6',
  406. ],
  407. [
  408. "name"=> "女款(黑色)",
  409. "size"=> 'l',
  410. 'num'=>'10,'
  411. ]
  412. ];
  413. $result= array();
  414. foreach ($data as $key => $value) {
  415. $result[$value['name']][] = $value;
  416. }
  417. $i=0;
  418. foreach ($result as $k=>$v){
  419. foreach ($v as $key=>$val){
  420. $dat[$key]=$val['size'];
  421. $dats[$key]=$val['num'];
  422. }
  423. $datas[$i]['name']=$v[0]['name'];
  424. $datas[$i]['size']=$dat;
  425. $datas[$i]['num']=$dats;
  426. $i++;
  427. }
  428. return $datas;
  429. // for($i=0;$i<$count-1;$i++){
  430. // for ($j=$i+1;$j<$count;$j++){
  431. // if ($data[$i]['name']==$data[$j]['name']){
  432. // $name[$i]=$data[$i]['name'];
  433. // $size=$data[$i]['size'];
  434. // }
  435. // }
  436. // $dat[$i]=$data[$i]['size'];
  437. // }
  438. return $dat;
  439. }
  440. public function getMessageInfo(){
  441. $user_id=Auth::user()->id;
  442. $notice=Notice::where('user_id',$user_id)->orderByDesc('id')->limit(1)->get();
  443. $info=Infos::where('disabled','0')->orderBy('is_top','desc')->orderBy('top_at','desc')->limit(2)->get();
  444. if(count($notice)>0){
  445. $data['notice']=$notice[0];
  446. }else{
  447. $data['notice']=null;
  448. }
  449. $data['info']=$info;
  450. $data['banner']=Banner::where('status',1)->orderBy('sort')->orderByDesc('id')->get();
  451. return $this->success_list($data);
  452. }
  453. //获取公告通知列表
  454. public function getMessageList(Request $request){
  455. $page_index=$request->input('page_index');
  456. $page_size=$request->input('page_size');
  457. $num=$page_size*($page_index-1);
  458. $user_id=Auth::user()->id;
  459. $data=Infos::query()->where(function($query){
  460. $query->whereIn('type',[1,4])->where('disabled','0');
  461. })
  462. ->orWhere(function($query)use($user_id){
  463. $query->whereIn('type',[2,3,5,6])->where('user_id',$user_id);
  464. });
  465. $count=$data->count();
  466. $list=$data->orderByDesc('is_top','top_at')
  467. ->skip($num)->take($page_size)->get();
  468. return $this->success_list($list,'',$count);
  469. }
  470. public function get_infos(){
  471. $order=Ordertest::where('is_deleted',0)->where('created_at','>=','2020-08-24 21:00:00')->with(['order_detail','get_pay'=>function($q){
  472. $q->whereIn('type',[1,2,3]);
  473. },'get_user'])->get();
  474. $i=0;
  475. foreach ($order as $k=>$v){
  476. $money=0;
  477. $pay_money=0;
  478. $pay=0;
  479. $pay1=0;
  480. $pay2=0;
  481. foreach ($v->order_detail as $ke=>$va){
  482. $money+=$va->money;
  483. // $pay_money+=$va->pay_money;
  484. //该订单总金额
  485. }
  486. foreach ($v->get_pay as $ke=>$value){
  487. //订单支付的金额
  488. if ($value->type==1){
  489. $pay+=$value->pay_money;
  490. }elseif ($value->type==2){
  491. //带订单退款金额
  492. $pay1+=$value->pay_money;
  493. }elseif ($value->type==3){
  494. $pay2+=$value->money;
  495. }
  496. }
  497. if (($pay1-$pay2)>$money){
  498. echo $v->order_num.'<br/>';
  499. }
  500. }
  501. // echo 1;
  502. }
  503. public function get_count(){
  504. $re=MoneyUser::with(['get_pay'=>function($q){
  505. $q->whereIn('user_pay_log.type',[0,3])->where('user_pay_log.created_at','>','2020-08-23 00:00:00');
  506. }])->get();
  507. foreach ($re as $k=>$v){
  508. $money=0;
  509. $moneys=0;
  510. if ($v->get_pay->isEmpty()){
  511. $money=0;
  512. }else{
  513. foreach ($v->get_pay as $ke=>$va){
  514. if ($va->type==0){
  515. $money+=$va->pay_money;
  516. }else{
  517. $moneys+=$va->pay_money;
  518. }
  519. }
  520. }
  521. if ($moneys>20){
  522. $money-=$moneys;
  523. }
  524. if ($money!=$v->money){
  525. echo '充值金额为'.$money.'------------'.$v->mobile.'-----Excel数据中的金额-----'.$v->money.'<br/>';
  526. }
  527. }
  528. }
  529. public function ImageBigGift(Request $request){
  530. $re=new UploadFilesHandler();
  531. $result=$re->save($request->file('image'),'biggift',2012,'image');
  532. return $this->success($result);
  533. }
  534. public function SubmitUpdateBigGift(Request $request){
  535. $data=$request->all();
  536. $apply_id=$request->input('id')??null;
  537. $id=Auth::user()->id;
  538. DB::beginTransaction();
  539. if (!$apply_id){
  540. if (Carbon::now()->toDateTimeString()>'2025-02-27 12:00:00'){
  541. return $this->error(50021,'','提交时间已过!');
  542. }
  543. if (BigGiftApply::where('user_id',$id)->exists()){
  544. return $this->error(50021,'','已经提交,请退出刷新重试!!');
  545. }
  546. $apply=new BigGiftApply();
  547. }else{
  548. $apply=BigGiftApply::find($apply_id);
  549. if ($apply->user_id!=$id){
  550. return $this->error(50021,'','异常请求!');
  551. }
  552. }
  553. try {
  554. //账单截图
  555. $imgList=$data['imgList'];
  556. $apply->imgList=json_encode($imgList,true);
  557. //商品详情
  558. $detail=$data['detail'];
  559. $apply->detail=json_encode($detail,true);
  560. //批发商信息
  561. $apply->c_mobile=$data['c_mobile'];
  562. $apply->c_name=$data['c_name'];
  563. //客服信息
  564. $kefu=$data['kefu'];
  565. $apply->kefu=$kefu;
  566. //地址信息
  567. $apply->province=$data['province'];
  568. $apply->city=$data['city'];
  569. $apply->area=$data['area'];
  570. $apply->address=$data['address'];
  571. $apply->name=$data['name'];
  572. $apply->mobile=$data['mobile'];
  573. $apply->status=0;
  574. $apply->user_id=$id;
  575. $apply->save();
  576. DB::commit();
  577. return $this->success([]);
  578. }catch (\Exception $exception){
  579. DB::rollBack();
  580. Log::error('提交大礼包申请出错'.$exception->getMessage());
  581. return $this->error(50021,'',$exception->getMessage());
  582. }
  583. }
  584. public function GetBigGift(){
  585. $id=Auth::user()->id;
  586. $apply=BigGiftApply::where('user_id',$id)
  587. ->first();
  588. if ($apply){
  589. $apply->imgList=json_decode($apply->imgList,true);
  590. $apply->detail=json_decode($apply->detail,true);
  591. }
  592. return $this->success($apply);
  593. }
  594. }