StorageController.php 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\Express;
  4. use App\Models\ExpressStorage;
  5. use App\Models\Goodtest;
  6. use App\Models\Ordertest;
  7. use App\Models\StorageLog;
  8. use App\Models\StoragePutLog;
  9. use App\Models\UserStorage;
  10. use Carbon\Carbon;
  11. use Illuminate\Http\Request;
  12. use Illuminate\Support\Facades\Auth;
  13. use Illuminate\Support\Facades\DB;
  14. use Illuminate\Support\Facades\Log;
  15. class StorageController extends Controller{
  16. /**查看货物**/
  17. public function look_good(Request $request){
  18. $id=$request->id;
  19. $ids=Auth::user()->id;
  20. // $ids=39516;
  21. $re=Express::where('order_id',$id)->with(['get_express'=>function($q)use($id){
  22. $q->where('order_id',$id);
  23. },'get_order'])->orderByDesc('number')->groupBy('number')->get();
  24. $data=[];
  25. //app下级循环无法获取上级is_per数据,添加下级is_per
  26. foreach ($re as $k=>$v){
  27. $data[$k]=$v;
  28. $data[$k]['get_order']['address']=$v->get_order->address;
  29. if ($ids==$v->get_order->good_user_id){
  30. $data[$k]['is_per']=true;
  31. $is_per=true;
  32. }else{
  33. $data[$k]['is_per']=false;
  34. $is_per=false;
  35. }
  36. $express=$v->get_express;
  37. foreach($express as $key=>$val){
  38. if (!$val->put_status){
  39. $express[$key]->put_status=0;
  40. }
  41. if($is_per){
  42. $express[$key]->is_per=true;
  43. }else{
  44. $express[$key]->is_per=false;
  45. }
  46. }
  47. $data[$k]->get_express=$express;
  48. }
  49. return $this->success_list($data);
  50. }
  51. /*
  52. * 货物详情
  53. * **/
  54. public function good_detail(Request $request){
  55. $re=ExpressStorage::where('express_id',$request->id)->groupBy('type')->get();
  56. $datas=Goodtest::where('is_deleted',0)->where('id','>',57)->groupBy('main_attr')->get();
  57. foreach ($datas as $k=>$v){
  58. $r[$v->main_attr]=$v->main_img;
  59. }
  60. $data=[
  61. 'hard'=>['spec'=>[],'imgurl'=>$r['大卫博士精装版'],'name'=>'大卫博士精装版'],
  62. 'simple'=>['spec'=>[],'imgurl'=>$r['大卫博士简约版'],'name'=>'大卫博士简约版'],
  63. 'old'=>['spec'=>[],'imgurl'=>$r['大卫博士高腰版'],'name'=>'大卫博士高腰版'],
  64. 'new_old'=>['spec'=>[],'imgurl'=>$r['大卫博士纯棉老人版'],'name'=>'大卫博士纯棉老人版'],
  65. 'youth'=>['spec'=>[],'imgurl'=>$r['大卫博士青春版'],'name'=>'大卫博士青春版'],
  66. ];
  67. foreach ($re as $k=>$v){
  68. $res=ExpressStorage::where('express_id',$request->id)->where('type',$v->type)->select('size','sex','type','num')->get()->toArray();
  69. if ($v->type==0){
  70. $data['hard']['spec']=$res;
  71. }elseif ($v->type==1){
  72. $data['simple']['spec']=$res;
  73. }elseif ($v->type==2){
  74. $data['old']['spec']=$res;
  75. }elseif(($v->type==3)){
  76. $data['new_old']['spec']=$res;
  77. }elseif(($v->type==4)){
  78. $data['youth']['spec']=$res;
  79. }
  80. }
  81. return $this->success($data);
  82. }
  83. /*
  84. * 我的库存
  85. * **/
  86. public function my_storage(){
  87. $id=Auth::user()->id;
  88. // $id=39516;
  89. $re=UserStorage::where('user_id',$id)->groupBy('type')->select(DB::raw('sum(num) as total'),'type')->get();
  90. $res=UserStorage::where('user_id',$id)->first();
  91. $data=['hard'=>0,'simple'=>0,'old'=>0,'new_old'=>0,'youth'=>0];
  92. foreach ($re as $k=>$v){
  93. if ($v->type==0){
  94. $data['hard']=$v->total;
  95. }elseif ($v->type==1){
  96. $data['simple']=$v->total;
  97. }elseif ($v->type==2){
  98. $data['old']=$v->total;
  99. }elseif($v->type==3){
  100. $data['new_old']=$v->total;
  101. }elseif($v->type==4){
  102. $data['youth']=$v->total;
  103. }
  104. }
  105. if ($res){
  106. $data['status']=false;
  107. }else{
  108. $data['status']=true;
  109. }
  110. return $this->success($data);
  111. }
  112. /*
  113. *库存详情
  114. * **/
  115. public function storage_detail(Request $request){
  116. $id=Auth::user()->id;
  117. // $id=39516;
  118. $re=UserStorage::where('user_id',$id)->groupBy('type')->get();
  119. $datas=Goodtest::where('is_deleted',0)->where('id','>',57)->groupBy('main_attr')->get();
  120. foreach ($datas as $k=>$v){
  121. $r[$v->main_attr]=$v->main_img;
  122. }
  123. $data=[
  124. 'hard'=>['spec'=>[],'imgurl'=>$r['大卫博士精装版'],'name'=>'大卫博士精装版'],
  125. 'simple'=>['spec'=>[],'imgurl'=>$r['大卫博士简约版'],'name'=>'大卫博士简约版'],
  126. 'old'=>['spec'=>[],'imgurl'=>$r['大卫博士高腰版'],'name'=>'大卫博士高腰版'],
  127. 'new_old'=>['spec'=>[],'imgurl'=>$r['大卫博士纯棉老人版'],'name'=>'大卫博士纯棉版'],
  128. 'youth'=>['spec'=>[],'imgurl'=>$r['大卫博士青春版'],'name'=>'大卫博士青春版'],
  129. ];
  130. $goodtest=new Goodtest();
  131. $storage_hard=$goodtest->storage_hard;
  132. foreach($storage_hard as $key=>$val){
  133. $storage_hard[$key]['num']=UserStorage::where('user_id',$id)->where('size',$val['size'])->where('sex',$val['sex'])->where('type',$val['type'])->value('num')??0;
  134. }
  135. $data['hard']['spec']=$storage_hard;
  136. $storage_simple=$goodtest->storage_simple;
  137. foreach($storage_simple as $key=>$val){
  138. $storage_simple[$key]['num']=UserStorage::where('user_id',$id)->where('size',$val['size'])->where('sex',$val['sex'])->where('type',$val['type'])->value('num')??0;
  139. }
  140. $data['simple']['spec']=$storage_simple;
  141. $storage_old=$goodtest->storage_old;
  142. foreach($storage_old as $key=>$val){
  143. $storage_old[$key]['num']=UserStorage::where('user_id',$id)->where('size',$val['size'])->where('sex',$val['sex'])->where('type',$val['type'])->value('num')??0;
  144. }
  145. $data['old']['spec']=$storage_old;
  146. $storage_new_old=$goodtest->storage_new_old;
  147. foreach($storage_new_old as $key=>$val){
  148. $storage_new_old[$key]['num']=UserStorage::where('user_id',$id)->where('size',$val['size'])->where('sex',$val['sex'])->where('type',$val['type'])->value('num')??0;
  149. }
  150. $data['new_old']['spec']=$storage_new_old;
  151. $storage_youth=$goodtest->storage_youth;
  152. foreach($storage_youth as $key=>$val){
  153. $storage_youth[$key]['num']=UserStorage::where('user_id',$id)->where('size',$val['size'])->where('sex',$val['sex'])->where('type',$val['type'])->value('num')??0;
  154. }
  155. $data['youth']['spec']=$storage_youth;
  156. // foreach ($re as $k=>$v){
  157. // $res=UserStorage::where('user_id',$id)->where('type',$v->type)->select('size','sex','type','num')->get();
  158. // if ($v->type==0){
  159. // $data['hard']['spec']=$res?$res:$goodtest->storage_hard;
  160. // }elseif ($v->type==1){
  161. // $data['simple']['spec']=$res?$res:$goodtest->storage_simple;
  162. // }elseif ($v->type==2){
  163. // $data['old']['spec']=$res?$res:$goodtest->storage_old;
  164. // }elseif($v->type==3){
  165. // $data['new_old']['spec']=$res?$res:$goodtest->storage_new_old;
  166. // }elseif($v->type==4){
  167. // $data['youth']['spec']=$res?$res:$goodtest->storage_youth;
  168. // }
  169. // }
  170. return $this->success($data);
  171. }
  172. /*
  173. *app库存详情
  174. * **/
  175. public function app_storage_detail(Request $request){
  176. $id=Auth::user()->id;
  177. // $id=39516;
  178. $re_total=UserStorage::where('user_id',$id)->groupBy('type')->select(DB::raw('sum(num) as total'),'type')->get();
  179. // $data=['hard'=>0,'simple'=>0,'old'=>0,'new_old'=>0,'youth'=>0];
  180. $num=0;$money=0;
  181. foreach ($re_total as $k=>$v){
  182. $num+=$v->total;
  183. if ($v->type==0){
  184. // $data['hard']=$v->total;
  185. $money+=$v->total* 149;
  186. }elseif ($v->type==1){
  187. // $data['simple']=$v->total;
  188. $money+=$v->total* 79;
  189. }elseif ($v->type==2){
  190. // $data['old']=$v->total;
  191. $money+=$v->total* 89;
  192. }elseif($v->type==3){
  193. // $data['new_old']=$v->total;
  194. $money+=$v->total* 47;
  195. }elseif($v->type==4){
  196. // $data['youth']=$v->total;
  197. $money+=$v->total* 89;
  198. }
  199. }
  200. $re=UserStorage::where('user_id',$id)->groupBy('type')->get();
  201. $datas=Goodtest::where('is_deleted',0)->where('id','>',57)->groupBy('main_attr')->get();
  202. foreach ($datas as $k=>$v){
  203. $r[$v->main_attr]=$v->main_img;
  204. }
  205. $data=[
  206. 'hard'=>['spec'=>[],'imgurl'=>$r['大卫博士精装版'],'name'=>'大卫博士精装版'],
  207. 'simple'=>['spec'=>[],'imgurl'=>$r['大卫博士简约版'],'name'=>'大卫博士简约版'],
  208. 'old'=>['spec'=>[],'imgurl'=>$r['大卫博士高腰版'],'name'=>'大卫博士高腰版'],
  209. 'new_old'=>['spec'=>[],'imgurl'=>$r['大卫博士纯棉老人版'],'name'=>'大卫博士纯棉版'],
  210. 'youth'=>['spec'=>[],'imgurl'=>$r['大卫博士青春版'],'name'=>'大卫博士青春版'],
  211. ];
  212. foreach ($re as $k=>$v){
  213. $res=UserStorage::where('user_id',$id)->where('type',$v->type)->select('size','sex','type','num')->get();
  214. if ($v->type==0){
  215. $data['hard']['spec']=$res;
  216. }elseif ($v->type==1){
  217. $data['simple']['spec']=$res;
  218. }elseif ($v->type==2){
  219. $data['old']['spec']=$res;
  220. }elseif($v->type==3){
  221. $data['new_old']['spec']=$res;
  222. }elseif($v->type==4){
  223. $data['youth']['spec']=$res;
  224. }
  225. }
  226. $data['all']['total']=$num;
  227. $data['all']['money']=$money;
  228. return $this->success($data);
  229. }
  230. /*
  231. * 待入库
  232. * ***/
  233. public function put_storage(Request $request){
  234. $input=$request->all();
  235. $id=Auth::user()->id;
  236. // $id=39516;
  237. $page_index=$input['page_index'];
  238. $data=Ordertest::where('user_id',$id)->where('good_user_id',$id)
  239. ->where('track_status','<>',0)
  240. ->where('created_at','>','2020-01-01 00:00:00')
  241. ->where('put_status',0)->select('id as order_id','created_at','number','order_num');
  242. $count=$data->count();
  243. $data=$data->take(20)->skip(($page_index-1)*20)->get();
  244. return $this->success_list($data,'',$count);
  245. }
  246. /*
  247. * 入库记录
  248. * ***/
  249. public function put_storage_group(Request $request){
  250. $input=$request->all();
  251. $id=Auth::user()->id;
  252. // $id=39516;
  253. $datas=Goodtest::where('is_deleted',0)->where('id','>',57)->groupBy('main_attr')->get();
  254. foreach ($datas as $k=>$v){
  255. $r[$v->main_attr]=$v->main_img;
  256. }
  257. $data=[
  258. 'hard'=>['imgurl'=>$r['大卫博士精装版'],'name'=>'大卫博士精装版','woman'=>0,'man'=>0],
  259. 'simple'=>['imgurl'=>$r['大卫博士简约版'],'name'=>'大卫博士简约版','woman'=>0,'man'=>0],
  260. 'old'=>['imgurl'=>$r['大卫博士高腰版'],'name'=>'大卫博士高腰版','woman'=>0,'man'=>0],
  261. 'new_old'=>['imgurl'=>$r['大卫博士纯棉老人版'],'name'=>'大卫博士纯棉老人版','woman'=>0,'man'=>0],
  262. 'youth'=>['imgurl'=>$r['大卫博士青春版'],'name'=>'大卫博士青春版','woman'=>0,'man'=>0],
  263. ];
  264. $where_type=[];
  265. $type=$input['record_type'];
  266. $status=$input['status'];
  267. if ($type){
  268. if ($type==1){
  269. if ($status==-1){
  270. $where_type=function ($q)use($type,$status){
  271. $q->where('storage_type',$type);
  272. };
  273. }else{
  274. $where_type=function ($q)use($type,$status){
  275. $q->where('storage_type',$type)->where('out_type',$status);
  276. };
  277. }
  278. }else{
  279. $where_type=function ($q)use($type,$status){
  280. $q->where('storage_type',$type);
  281. };
  282. }
  283. }
  284. $express=ExpressStorage::where('user_id',$id)->where($where_type);
  285. $where_start=[];
  286. $start=$input['start_time'];
  287. if ($start){
  288. $where_start=function ($q)use($start){
  289. $q->where('created_at','>=',$start);
  290. };
  291. }
  292. $where_end=[];
  293. $end=$input['end_time'];
  294. if ($end){
  295. $where_end=function ($q)use($end){
  296. $q->where('created_at','<=',$end);
  297. };
  298. }
  299. $re=$express->where($where_start)->where($where_end)->groupBy('type')->get();
  300. foreach ($re as $k=>$v){
  301. $woman=0;
  302. $man=0;
  303. if ($type==1){
  304. $res=ExpressStorage::where('user_id',$id)->where('type',$v->type)->where('storage_type',$type)->where($where_start)->where($where_end);
  305. if ($input['status']==-1){
  306. $res=$res->groupBy('sex')->select(DB::raw('sum(num) as total'),'sex')->get()->toArray();
  307. }else{
  308. $res=$res->where('out_type',$input['status'])->groupBy('sex')->select(DB::raw('sum(num) as total'),'sex')->get()->toArray();
  309. }
  310. foreach ($res as $ke=>$va){
  311. if ($va['sex']==0){
  312. $woman=$va['total'];
  313. }else{
  314. $man=$va['total'];
  315. }
  316. }
  317. }else{
  318. $res=ExpressStorage::where('user_id',$id)->where('type',$v->type)->where('storage_type',$type)->where($where_start)->where($where_end)->groupBy('sex')->select(DB::raw('sum(num) as total'),'sex')->get()->toArray();
  319. foreach ($res as $ke=>$va){
  320. if ($va['sex']==0){
  321. $woman=$va['total'];
  322. }else{
  323. $man=$va['total'];
  324. }
  325. }
  326. }
  327. if ($v->type==0){
  328. $data['hard']['man']=$man;
  329. $data['hard']['woman']=$woman;
  330. }elseif ($v->type==1){
  331. $data['simple']['man']=$man;
  332. $data['simple']['woman']=$woman;
  333. }elseif ($v->type==2){
  334. $data['old']['man']=$man;
  335. $data['old']['woman']=$woman;
  336. }elseif($v->type==3){
  337. $data['new_old']['man']=$man;
  338. $data['new_old']['woman']=$woman;
  339. }elseif($v->type==4){
  340. $data['youth']['man']=$man;
  341. $data['youth']['woman']=$woman;
  342. }
  343. }
  344. return $this->success($data);
  345. }
  346. public function put_storage_detail(Request $request){
  347. $input=$request->all();
  348. $id=Auth::user()->id;
  349. // $id=39516;
  350. $where_type=[];
  351. $status=$input['status'];
  352. if ($input['record_type']){
  353. $type=$input['record_type'];
  354. if ($type==1){
  355. if ($status!=-1){
  356. $where_type=function ($q)use($type,$status){
  357. $q->where('storage_type',$type)->where('out_type',$status);
  358. };
  359. }else{
  360. $where_type=function ($q)use($type,$status){
  361. $q->where('storage_type',$type);
  362. };
  363. }
  364. }else{
  365. $where_type=function ($q)use($type,$status){
  366. $q->where('storage_type',$type);
  367. };
  368. }
  369. }
  370. $express=ExpressStorage::where('user_id',$id)->where($where_type)->where('type',$input['type']);
  371. $where_start=[];
  372. $start=$input['start_time'];
  373. if ($start){
  374. if ($input['record_type']==1){
  375. $where_start=function ($q)use($start){
  376. $q->where('out_time','>=',$start);
  377. };
  378. }else{
  379. $where_start=function ($q)use($start){
  380. $q->where('created_at','>=',$start);
  381. };
  382. }
  383. }
  384. $where_end=[];
  385. $end=$input['end_time'];
  386. if ($end){
  387. if ($input['record_type']==1){
  388. $where_end=function ($q)use($end){
  389. $q->where('out_time','<=',$end);
  390. };
  391. }else{
  392. $where_end=function ($q)use($end){
  393. $q->where('created_at','<=',$end);
  394. };
  395. }
  396. }
  397. $re=$express->where($where_start)->where($where_end);
  398. $count=$re->count();
  399. $data=$re->take(20)->skip(($input['page_index']-1)*20)->get();
  400. return $this->success_list($data,'',$count);
  401. }
  402. public function put_good_storage(Request $request){
  403. // return $this->error(50026,'','入库操作暂停使用!如有疑问请联系政委!');
  404. $input=$request->all();
  405. $id=Auth::user()->id;
  406. // $id=39516;
  407. $d=UserStorage::where('user_id',$id)->first();
  408. if (!$d){
  409. return $this->error(50026,'','请盘库!');
  410. }
  411. $express=Express::find($input['id']);
  412. if ($express->put_status==1){
  413. return $this->error(50026,'','该货物已经入库,请退出刷新');
  414. }
  415. DB::beginTransaction();
  416. try{
  417. //查找这一箱的货物量
  418. $re=ExpressStorage::where('express_id',$input['id'])->select('sex','size','type','num')->get();
  419. //查找这一箱的信息
  420. foreach ($re as $k=>$v){
  421. //查找库存中有没有这个商品的记录
  422. $res=UserStorage::where('user_id',$id)->where('sex',$v->sex)->where('size',$v->size)->where('type',$v->type)->first();
  423. //有则加
  424. if ($res){
  425. if ($v->type==1||$v->type==2){
  426. $num=$v->num*4;
  427. }elseif ($v->type==3){
  428. $num=$v->num*6;
  429. }else{
  430. $num=$v->num;
  431. }
  432. $res->num+=$num;
  433. if (!$res->save()){
  434. throw new \Exception(1);
  435. }
  436. }else{
  437. //没有则新建
  438. $storage=new UserStorage();
  439. if ($v->type==1||$v->type==2){
  440. $storage->num=$v->num*4;
  441. }elseif ($v->type==3){
  442. $storage->num=$v->num*6;
  443. }else{
  444. $storage->num=$v->num;
  445. }
  446. $storage->size=$v->size;
  447. $storage->user_id=$id;
  448. $storage->sex=$v->sex;
  449. $storage->type=$v->type;
  450. if (!$storage->save()){
  451. throw new \Exception('1');
  452. }
  453. }
  454. $log=new StoragePutLog();
  455. $log->size=$v->size;
  456. $log->sex=$v->sex;
  457. $log->type=$v->type;;
  458. $log->user_id=$id;
  459. if ($v->type==1||$v->type==2){
  460. $log->num=$v->num*4;
  461. }elseif ($v->type==3){
  462. $log->num=$v->num*6;
  463. }else{
  464. $log->num=$v->num;
  465. }
  466. if (!$log->save()){
  467. throw new \Exception(1);
  468. }
  469. }
  470. //更改这一箱的状态为入库
  471. ExpressStorage::where('express_id',$input['id'])->select('sex','size','type','num')->update(['sure_time'=>Carbon::now(),'storage_type'=>2]);
  472. //更改这一样的装填为已完成
  473. $express->put_status=1;
  474. $express->put_time=Carbon::now();
  475. if (!$express->save()){
  476. throw new \Exception('1');
  477. }
  478. //查找订单
  479. $order=Ordertest::find($express->order_id);
  480. if ($order->track_status==2){
  481. //查看一下这个订单是不是都已经入库
  482. $count=Express::where('order_id',$order->id)->where('put_status',0)->count();
  483. if ($count==0){
  484. //全部入库后更改 订单状态为已完成的状态
  485. $order->put_status=1;
  486. if (!$order->save()){
  487. throw new \Exception(1);
  488. }
  489. }
  490. }
  491. DB::commit();
  492. return $this->success([]);
  493. }catch (\Exception $exception){
  494. DB::rollBack();
  495. return $this->error(50021,'','入库出错:'.$exception);
  496. }
  497. }
  498. /*
  499. * 判断是不是第一次盘库
  500. * ***/
  501. public function get_goodimg(){
  502. $datas=Goodtest::where('is_deleted',0)->where('id','>',57)->groupBy('main_attr')->get();
  503. foreach ($datas as $k=>$v){
  504. $r[$v->main_attr]=$v->main_img;
  505. }
  506. $data=[
  507. 'hard'=>['imgurl'=>$r['大卫博士精装版'],'name'=>'大卫博士精装版'],
  508. 'simple'=>['imgurl'=>$r['大卫博士简约版'],'name'=>'大卫博士简约版'],
  509. 'old'=>['imgurl'=>$r['大卫博士高腰版'],'name'=>'大卫博士高腰版'],
  510. 'new_old'=>['imgurl'=>$r['大卫博士纯棉老人版'],'name'=>'大卫博士纯棉老人版'],
  511. 'youth'=>['imgurl'=>$r['大卫博士青春版'],'name'=>'大卫博士青春版'],
  512. ];
  513. return $this->success($data);
  514. }
  515. /**一次性盘库**/
  516. public function one_sure_storage(Request $request){
  517. $id=Auth::user()->id;
  518. $re=UserStorage::where('user_id',$id)->first();
  519. if ($re){
  520. return $this->error(50024,'','该用户不能使用一次性盘货功能');
  521. }
  522. $input=$request->all();
  523. DB::beginTransaction();
  524. try{
  525. foreach ($input as $k=>$v){
  526. if($k=='hard'){
  527. $type=0;
  528. }elseif ($k=='simple'){
  529. $type=1;
  530. }elseif ($k=='old'){
  531. $type=2;
  532. }elseif($k=='new_old'){
  533. $type=3;
  534. }elseif($k=='youth'){
  535. $type=4;
  536. }
  537. foreach ($v as $ke=>$va){
  538. $storage=new UserStorage();
  539. $storage->user_id=$id;
  540. $storage->type=$type;
  541. $storage->size=$va['size'];
  542. $storage->num=$va['num'];
  543. $storage->sex=$va['sex'];
  544. $st_log=new StorageLog();
  545. $st_log->user_id=$id;
  546. $st_log->type=$type;
  547. $st_log->size=$va['size'];
  548. $st_log->num=$va['num'];
  549. $st_log->sex=$va['sex'];
  550. $st_log->number=1;
  551. $st_log->old_num=0;
  552. if (!$st_log->save()){
  553. throw new \Exception('1');
  554. }
  555. if (!$storage->save()){
  556. throw new \Exception('1');
  557. }
  558. }
  559. }
  560. DB::commit();
  561. return $this->success([]);
  562. }catch (\Exception $exception){
  563. DB::rollBack();
  564. return $this->error(50021,'',$exception);
  565. }
  566. }
  567. /*
  568. * 获取库存信息
  569. * ***/
  570. public function get_storage(Request $request){
  571. // $id=39516;
  572. $id=Auth::user()->id;
  573. $re=UserStorage::where('user_id',$id)->with(['get_storage'=>function($q)use($id){
  574. $q->where('user_id',$id)->select('sex','size','type','num');
  575. }])->groupBy('type')->get();
  576. $data=[
  577. 'hard'=>[],
  578. 'simple'=>[],
  579. 'old'=>[],
  580. 'new_old'=>[],
  581. 'youth'=>[],
  582. ];
  583. foreach ($re as $k=>$v){
  584. if ($v->type==0){
  585. $data['hard']=$v->get_storage;
  586. }elseif ($v->type==1){
  587. $data['simple']=$v->get_storage;
  588. }elseif ($v->type==2){
  589. $data['old']=$v->get_storage;
  590. }elseif ($v->type==4){
  591. $data['youth']=$v->get_storage;
  592. }else{
  593. $data['new_old']=$v->get_storage;
  594. }
  595. }
  596. return $this->success($data);
  597. }
  598. /**一次性盘库**/
  599. public function sure_storage(Request $request){
  600. $id=Auth::user()->id;
  601. $re=UserStorage::where('user_id',$id)->first();
  602. if (!$re){
  603. return $this->error(50024,'','该用户需要使用一次性盘货功能');
  604. }
  605. $number=StorageLog::where('user_id',$id)->max('number');
  606. //适配app数据结构
  607. if($request->has('data')){
  608. $input=$request->input('data');
  609. }else{
  610. $input=$request->all();
  611. }
  612. Log::info($input);
  613. DB::beginTransaction();
  614. try{
  615. foreach ($input as $k=>$v){
  616. if($k=='hard'){
  617. $type=0;
  618. }elseif ($k=='simple'){
  619. $type=1;
  620. }elseif ($k=='old'){
  621. $type=2;
  622. }elseif ($k=='youth'){
  623. $type=4;
  624. }else{
  625. $type=3;
  626. }
  627. foreach ($v as $ke=>$va){
  628. $storage=UserStorage::where('type',$type)->where('user_id',$id)->where('size',$va['size'])->where('sex',$va['sex'])->first();
  629. $st_log=new StorageLog();
  630. $st_log->number=$number+1;
  631. $st_log->sure_time=Carbon::now()->toDateTimeString();
  632. if ($storage){
  633. $st_log->old_num=$storage->num;
  634. if ($va['num']>$storage->num){
  635. $put_st=new StoragePutLog();
  636. $put_st->user_id=$id;
  637. $put_st->type=$type;
  638. $put_st->size=$va['size'];
  639. $put_st->num=$va['num']-$storage->num;
  640. $put_st->sex=$va['sex'];
  641. $put_st->storage_type=0;
  642. if (!$put_st->save()){
  643. throw new \Exception('1');
  644. }
  645. }elseif ($va['num']<$storage->num){
  646. $out_st=new ExpressStorage();
  647. $out_st->user_id=$id;
  648. $out_st->type=$type;
  649. $out_st->size=$va['size'];
  650. $out_st->num=$storage->num-$va['num'];
  651. $out_st->sex=$va['sex'];
  652. $out_st->storage_type=1;
  653. $out_st->out_time=Carbon::now();
  654. if (!$out_st->save()){
  655. throw new \Exception('1');
  656. }
  657. }
  658. $storage->num=$va['num'];
  659. }else{
  660. $storage=new UserStorage();
  661. $storage->user_id=$id;
  662. $storage->type=$type;
  663. $storage->size=$va['size'];
  664. $storage->num=$va['num'];
  665. $storage->sex=$va['sex'];
  666. $st_log->old_num=0;
  667. }
  668. $st_log->user_id=$id;
  669. $st_log->type=$type;
  670. $st_log->size=$va['size'];
  671. $st_log->num=$va['num'];
  672. $st_log->sex=$va['sex'];
  673. if (!$storage->save()){
  674. throw new \Exception('1');
  675. }
  676. if (!$st_log->save()){
  677. throw new \Exception('1');
  678. }
  679. }
  680. }
  681. DB::commit();
  682. return $this->success([],'盘库成功','盘库成功');
  683. }catch (\Exception $exception){
  684. DB::rollBack();
  685. return $this->error(50021,'',$exception);
  686. }
  687. }
  688. /***出库**/
  689. public function out_storage(Request $request){
  690. $id=Auth::user()->id;
  691. $re=UserStorage::where('user_id',$id)->first();
  692. if (!$re){
  693. return $this->error(50024,'','该用户需要使用一次性盘货功能');
  694. }
  695. $input=$request->all();
  696. //app适配统一参数data
  697. if($request->has('arr')){
  698. $arr=$input['arr'];
  699. }elseif($request->has('data')){
  700. $arr=$input['data'];
  701. }else{
  702. $arr=[];
  703. }
  704. DB::beginTransaction();
  705. try{
  706. foreach ($arr as $k=>$v){ //$input['arr']
  707. if($k=='hard'){
  708. $type=0;
  709. }elseif ($k=='simple'){
  710. $type=1;
  711. }elseif ($k=='old'){
  712. $type=2;
  713. }elseif ($k=='youth'){
  714. $type=4;
  715. }else{
  716. $type=3;
  717. }
  718. foreach ($v as $ke=>$va){
  719. if ($va['num']!=0){
  720. $storage=UserStorage::where('type',$type)->where('user_id',$id)->where('size',$va['size'])->where('sex',$va['sex'])->first();
  721. if (!$storage){
  722. return $this->error(50023,'','没有该商品的库存,请先使用盘库功能');
  723. }
  724. if ($storage->num<$va['num']){
  725. return $this->error(50023,'','该商品的出库量大于库存量,请先使用盘库修改库存');
  726. }
  727. $storage->num-=$va['num'];
  728. if (!$storage->save()){
  729. throw new \Exception('1');
  730. }
  731. $eStorage=new ExpressStorage();
  732. $eStorage->num=$va['num'];
  733. $eStorage->user_id=$id;
  734. $eStorage->out_type=$input['type'];
  735. $eStorage->size=$va['size'];
  736. $eStorage->sex=$va['sex'];
  737. $eStorage->type=$type;
  738. $eStorage->storage_type=1;
  739. $eStorage->out_time=Carbon::now();
  740. if (!$eStorage->save()){
  741. throw new \Exception('1');
  742. }
  743. }
  744. }
  745. }
  746. DB::commit();
  747. return $this->success([],'出库成功','出库成功');
  748. }catch (\Exception $exception){
  749. DB::rollBack();
  750. return $this->error(50021,'',$exception);
  751. }
  752. }
  753. /*
  754. * 盘库记录
  755. **/
  756. public function sure_storage_group(Request $request){
  757. $input=$request->all();
  758. $id=Auth::user()->id;
  759. // $id=39516;
  760. $datas=Goodtest::where('is_deleted',0)->where('id','>',57)->groupBy('main_attr')->get();
  761. foreach ($datas as $k=>$v){
  762. $r[$v->main_attr]=$v->main_img;
  763. }
  764. $data=[
  765. 'hard'=>['imgurl'=>$r['大卫博士精装版'],'name'=>'大卫博士精装版','woman'=>0,'man'=>0],
  766. 'simple'=>['imgurl'=>$r['大卫博士简约版'],'name'=>'大卫博士简约版','woman'=>0,'man'=>0],
  767. 'old'=>['imgurl'=>$r['大卫博士高腰版'],'name'=>'大卫博士高腰版','woman'=>0,'man'=>0],
  768. 'new_old'=>['imgurl'=>$r['大卫博士纯棉老人版'],'name'=>'大卫博士纯棉老人版','woman'=>0,'man'=>0],
  769. 'youth'=>['imgurl'=>$r['大卫博士青春版'],'name'=>'大卫博士青春版','woman'=>0,'man'=>0],
  770. ];
  771. $storage_log=StorageLog::where('user_id',$id);
  772. $where_start=[];
  773. $start=$input['start_time'];
  774. if ($start){
  775. $where_start=function ($q)use($start){
  776. $q->where('created_at','>=',$start);
  777. };
  778. }
  779. $where_end=[];
  780. $end=$input['end_time'];
  781. if ($end){
  782. $where_end=function ($q)use($end){
  783. $q->where('created_at','<=',$end);
  784. };
  785. }
  786. $re=$storage_log->where($where_start)->where($where_end)->groupBy('type')->get();
  787. foreach ($re as $k=>$v){
  788. $woman=0;
  789. $man=0;
  790. $res=StorageLog::where('user_id',$id)->where('type',$v->type)->where($where_start)->where($where_end)->groupBy('sex')->select(DB::raw('sum(num) as total'),'sex')->get()->toArray();
  791. foreach ($res as $ke=>$va){
  792. if ($va['sex']==0){
  793. $woman=$va['total'];
  794. }else{
  795. $man=$va['total'];
  796. }
  797. }
  798. if ($v->type==0){
  799. $data['hard']['man']=$man;
  800. $data['hard']['woman']=$woman;
  801. }elseif ($v->type==1){
  802. $data['simple']['man']=$man;
  803. $data['simple']['woman']=$woman;
  804. }elseif ($v->type==2){
  805. $data['old']['man']=$man;
  806. $data['old']['woman']=$woman;
  807. }elseif ($v->type==3){
  808. $data['new_old']['man']=$man;
  809. $data['new_old']['woman']=$woman;
  810. }elseif ($v->type==4){
  811. $data['youth']['man']=$man;
  812. $data['youth']['woman']=$woman;
  813. }
  814. }
  815. return $this->success($data);
  816. }
  817. public function sure_storage_detail(Request $request){
  818. $input=$request->all();
  819. $id=Auth::user()->id;
  820. // $id=39516;
  821. $express=StorageLog::where('user_id',$id)->where('type',$input['type']);
  822. $where_start=[];
  823. $start=$input['start_time'];
  824. if ($start){
  825. $where_start=function ($q)use($start){
  826. $q->where('created_at','>=',$start);
  827. };
  828. }
  829. $where_end=[];
  830. $end=$input['end_time'];
  831. if ($end){
  832. $where_end=function ($q)use($end){
  833. $q->where('created_at','<=',$end);
  834. };
  835. }
  836. $re=$express->where($where_start)->where($where_end);
  837. $count=$re->count();
  838. $data=$re->take(20)->skip(($input['page_index']-1)*20)->get();
  839. return $this->success_list($data,'',$count);
  840. }
  841. /*
  842. *订货入库和退货入库
  843. ***/
  844. public function put_storages(Request $request){
  845. $id=Auth::user()->id;
  846. $re=UserStorage::where('user_id',$id)->first();
  847. if (!$re){
  848. return $this->error(50024,'','该用户需要使用一次性盘货功能');
  849. }
  850. $input=$request->all();
  851. $data=$input['data'];
  852. // $put_type=0;
  853. $put_type=$input['put_type'];
  854. DB::beginTransaction();
  855. try{
  856. foreach ($data as $k=>$v){
  857. if($k=='hard'){
  858. $type=0;
  859. }elseif ($k=='simple'){
  860. $type=1;
  861. }elseif ($k=='old'){
  862. $type=2;
  863. }elseif ($k=='youth'){
  864. $type=4;
  865. }else{
  866. $type=3;
  867. }
  868. foreach ($v as $ke=>$va){
  869. if ($va['num']!=0){
  870. $st_log=new StoragePutLog();
  871. $storage=UserStorage::where('type',$type)->where('user_id',$id)->where('size',$va['size'])->where('sex',$va['sex'])->first();
  872. if ($put_type==0){
  873. if ($type==2||$type==1 || $type==4){
  874. $va['num']=$va['num']*4;
  875. }elseif ($type==3){
  876. $va['num']=$va['num']*6;
  877. }
  878. }
  879. if ($storage){
  880. $storage->num+=$va['num'];
  881. }else{
  882. $storage=new UserStorage();
  883. $storage->user_id=$id;
  884. $storage->type=$type;
  885. $storage->size=$va['size'];
  886. $storage->num=$va['num'];
  887. $storage->sex=$va['sex'];
  888. }
  889. $st_log->user_id=$id;
  890. $st_log->type=$type;
  891. $st_log->size=$va['size'];
  892. $st_log->num=$va['num'];
  893. $st_log->sex=$va['sex'];
  894. $st_log->put_type=$put_type;
  895. $st_log->storage_type=0;
  896. if (!$storage->save()){
  897. throw new \Exception('1');
  898. }
  899. if (!$st_log->save()){
  900. throw new \Exception('1');
  901. }
  902. }
  903. }
  904. }
  905. DB::commit();
  906. return $this->success([],'入库成功','入库成功');
  907. }catch (\Exception $exception){
  908. DB::rollBack();
  909. return $this->error(50021,'',$exception);
  910. }
  911. }
  912. /*
  913. * 入库记录
  914. * ***/
  915. public function put_storage_groups(Request $request){
  916. $input=$request->all();
  917. $id=Auth::user()->id;
  918. // $id=39516;
  919. $datas=Goodtest::where('is_deleted',0)->where('id','>',57)->groupBy('main_attr')->get();
  920. foreach ($datas as $k=>$v){
  921. $r[$v->main_attr]=$v->main_img;
  922. }
  923. $data=[
  924. 'hard'=>['imgurl'=>$r['大卫博士精装版'],'name'=>'大卫博士精装版','woman'=>0,'man'=>0],
  925. 'simple'=>['imgurl'=>$r['大卫博士简约版'],'name'=>'大卫博士简约版','woman'=>0,'man'=>0],
  926. 'old'=>['imgurl'=>$r['大卫博士高腰版'],'name'=>'大卫博士高腰版','woman'=>0,'man'=>0],
  927. 'new_old'=>['imgurl'=>$r['大卫博士纯棉老人版'],'name'=>'大卫博士纯棉老人版','woman'=>0,'man'=>0],
  928. 'youth'=>['imgurl'=>$r['大卫博士青春版'],'name'=>'大卫博士青春版','woman'=>0,'man'=>0],
  929. ];
  930. $where_type=[];
  931. $type=$input['record_type'];
  932. if ($type){
  933. if ($type==1){
  934. $where_type=function ($q)use($type){
  935. $q->where('storage_type',$type);
  936. };
  937. }else{
  938. $where_type=function ($q)use($type){
  939. $q->where('storage_type',$type);
  940. };
  941. }
  942. }
  943. $express=StoragePutLog::where('user_id',$id)->where($where_type);
  944. $where_start=[];
  945. $start=$input['start_time'];
  946. if ($start){
  947. $where_start=function ($q)use($start){
  948. $q->where('created_at','>=',$start);
  949. };
  950. }
  951. $where_end=[];
  952. $end=$input['end_time'];
  953. if ($end){
  954. $where_end=function ($q)use($end){
  955. $q->where('created_at','<=',$end);
  956. };
  957. }
  958. $re=$express->where($where_start)->where($where_end)->groupBy('type')->get();
  959. foreach ($re as $k=>$v){
  960. $woman=0;
  961. $man=0;
  962. if ($type==1){
  963. $res=StoragePutLog::where('user_id',$id)->where('type',$v->type)->where('storage_type',$type)->where($where_start)->where($where_end);
  964. if ($input['status']==-1){
  965. $res=$res->groupBy('sex')->select(DB::raw('sum(num) as total'),'sex')->get()->toArray();
  966. }else{
  967. $res=$res->where('out_type',$input['status'])->groupBy('sex')->select(DB::raw('sum(num) as total'),'sex')->get()->toArray();
  968. }
  969. foreach ($res as $ke=>$va){
  970. if ($va['sex']==0){
  971. $woman=$va['total'];
  972. }else{
  973. $man=$va['total'];
  974. }
  975. }
  976. }else{
  977. $res=StoragePutLog::where('user_id',$id)->where('type',$v->type)->where('storage_type',$type)->where($where_start)->where($where_end)->groupBy('sex')->select(DB::raw('sum(num) as total'),'sex')->get()->toArray();
  978. foreach ($res as $ke=>$va){
  979. if ($va['sex']==0){
  980. $woman=$va['total'];
  981. }else{
  982. $man=$va['total'];
  983. }
  984. }
  985. }
  986. if ($v->type==0){
  987. $data['hard']['man']=(int)$man;
  988. $data['hard']['woman']=(int)$woman;
  989. }elseif ($v->type==1){
  990. $data['simple']['man']=(int)$man;
  991. $data['simple']['woman']=(int)$woman;
  992. }elseif ($v->type==2){
  993. $data['old']['man']=(int)$man;
  994. $data['old']['woman']=(int)$woman;
  995. }elseif ($v->type==3){
  996. $data['new_old']['man']=(int)$man;
  997. $data['new_old']['woman']=(int)$woman;
  998. }elseif ($v->type==4){
  999. $data['youth']['man']=(int)$man;
  1000. $data['youth']['woman']=(int)$woman;
  1001. }
  1002. }
  1003. return $this->success($data);
  1004. }
  1005. public function put_storage_details(Request $request){
  1006. $input=$request->all();
  1007. $id=Auth::user()->id;
  1008. // $id=39516;
  1009. $where_type=[];
  1010. if ($input['record_type']){
  1011. $type=$input['record_type'];
  1012. $where_type=function ($q)use($type){
  1013. $q->where('storage_type',$type);
  1014. };
  1015. }
  1016. $express=StoragePutLog::where('user_id',$id)->where($where_type)->where('type',$input['type']);
  1017. $where_start=[];
  1018. $start=$input['start_time'];
  1019. if ($start){
  1020. $where_start=function ($q)use($start){
  1021. $q->where('created_at','>=',$start);
  1022. };
  1023. }
  1024. $where_end=[];
  1025. $end=$input['end_time'];
  1026. if ($end){
  1027. $where_end=function ($q)use($end){
  1028. $q->where('created_at','<=',$end);
  1029. };
  1030. }
  1031. $re=$express->where($where_start)->where($where_end);
  1032. $count=$re->count();
  1033. $data=$re->take(20)->skip(($input['page_index']-1)*20)->get();
  1034. return $this->success_list($data,'',$count);
  1035. }
  1036. /*
  1037. * 按照时间分组
  1038. * ***/
  1039. public function get_group(Request $request){
  1040. // $data=DB::select('SELECT SUM(foo), DATE(mydate) FROM a_table GROUP BY DATE(a_table.mydate)');
  1041. $id=Auth::user()->id;
  1042. $data=Express::where('user_id',$id)->selectRaw('DATE_FORMAT(created_at,"%Y-%m-%d") as date')
  1043. ->groupBy('date')->orderByDesc('date');
  1044. $count=$data->get()->count();
  1045. $data=$data->take($request->page_size)->skip(($request->page_index-1)*$request->page_size)->get();
  1046. $arr=[];
  1047. foreach ($data as $k=>$v){
  1048. $start_time=date('Y-m-d H:i:s',strtotime($v->date));
  1049. $end_time=Carbon::parse($start_time)->endOfDay();
  1050. $counts=Express::where('user_id',$id)->whereBetween('created_at',[$start_time,$end_time])->groupBy('order_id')->get()->count();
  1051. $arr[$k]=$v;
  1052. $arr[$k]['count']=$counts;
  1053. // $time=$v->date;
  1054. // $start_time=date('Y-m-d H:i:s',strtotime($time));
  1055. // $end_time=Carbon::parse($start_time)->endOfDay();
  1056. // $id=Auth::user()->id;
  1057. $data=Express::where('user_id',$id)->whereBetween('created_at',[$start_time,$end_time])->with(['get_order'=>function($q)use($start_time,$end_time,$id){
  1058. $q->with(['get_express'=>function($qu)use($start_time,$end_time){
  1059. $qu->whereBetween('created_at',[$start_time,$end_time])->select('id','express_com','order_id','express_number','put_status','is_gift','notes','remark');
  1060. },'address'])->where('user_id',$id)->select('order_num','put_status','id','address_id','user_id','good_user_id','track_status');
  1061. }])->select('order_id','user_id','created_at')->groupBy('order_id')->get();
  1062. $array=[];
  1063. foreach ($data as $key=>$val){
  1064. $array[$key]=$val;
  1065. if ($val['get_order']){
  1066. $n=0;
  1067. if ($id==$val['get_order']->good_user_id){
  1068. $data[$key]['get_order']['is_per']=true;
  1069. $is_per=true;
  1070. }else{
  1071. $data[$key]['get_order']['is_per']=false;
  1072. $is_per=false;
  1073. }
  1074. foreach ($val['get_order']['get_express'] as $ke=>$va){
  1075. $n++;
  1076. $arrs[$ke]=$va;
  1077. $arrs[$ke]['count']=$n;
  1078. $arrs[$ke]['user_id']=$val['get_order']['user_id'];
  1079. $arrs[$ke]['good_user_id']=$val['get_order']['good_user_id'];
  1080. if ($va['is_gift']!=1){
  1081. $arrs[$ke]['notes']=null;
  1082. }
  1083. if (!$va['put_status']){
  1084. $arrs[$ke]['put_status']=0;
  1085. }
  1086. if($is_per){
  1087. $arrs[$ke]['is_per']=true;
  1088. }else{
  1089. $arrs[$ke]['is_per']=false;
  1090. }
  1091. }
  1092. $array[$key]['get_order']['get_express']=$arrs;
  1093. }
  1094. }
  1095. $arr[$k]['detail']=$array;
  1096. }
  1097. return $this->success_list($arr,'',$count);
  1098. }
  1099. public function get_detail(Request $request){
  1100. $time=$request->time;
  1101. $start_time=date('Y-m-d H:i:s',strtotime($time));
  1102. $end_time=Carbon::parse($start_time)->endOfDay();
  1103. $id=Auth::user()->id;
  1104. $data=Express::where('user_id',$id)->whereBetween('created_at',[$start_time,$end_time])->with(['get_order'=>function($q)use($start_time,$end_time,$id){
  1105. $q->with(['get_express'=>function($qu)use($start_time,$end_time){
  1106. $qu->whereBetween('created_at',[$start_time,$end_time])->select('id','express_com','order_id','express_number','put_status','is_gift','notes','remark');
  1107. },'address'])->where('user_id',$id)->select('order_num','put_status','id','address_id','user_id','good_user_id','track_status');
  1108. }])->select('order_id','user_id','created_at')->groupBy('order_id')->get();
  1109. $arr=[];
  1110. foreach ($data as $k=>$v){
  1111. $arr[$k]=$v;
  1112. if ($v['get_order']){
  1113. foreach ($v['get_order']['get_express'] as $ke=>$va){
  1114. $arrs[$ke]=$va;
  1115. $arrs[$ke]['user_id']=$v['get_order']['user_id'];
  1116. $arrs[$ke]['good_user_id']=$v['get_order']['good_user_id'];
  1117. if ($va['is_gift']!=1){
  1118. $arrs[$ke]['notes']=null;
  1119. }
  1120. if (!$va['put_status']){
  1121. $arrs[$ke]['put_status']=0;
  1122. }
  1123. }
  1124. $arr[$k]['get_order']['get_express']=$arrs;
  1125. }
  1126. }
  1127. return $this->success_list($arr);
  1128. }
  1129. }