IndexController.php 23 KB

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