WaybillController.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Services\CarrierService;
  4. use App\Services\CarTypeService;
  5. use App\Services\CityService;
  6. use App\Services\OwnerService;
  7. use App\Services\UnitService;
  8. use App\Services\WaybillPayoffService;
  9. use App\Services\WaybillPriceModelService;
  10. use App\Services\WaybillService;
  11. use App\UploadFile;
  12. use App\WaybillAuditLog;
  13. use App\WaybillOnTop;
  14. use App\WaybillPriceModel;
  15. use App\City;
  16. use App\Owner;
  17. use App\Unit;
  18. use App\Waybill;
  19. use App\WaybillPayoff;
  20. use App\WaybillFinancialExcepted;
  21. use App\WaybillFinancialSnapshot;
  22. use Carbon\Carbon;
  23. use Exception;
  24. use Illuminate\Http\Request;
  25. use Illuminate\Support\Facades\Auth;
  26. use Illuminate\Support\Facades\DB;
  27. use Illuminate\Support\Facades\Gate;
  28. use Illuminate\Support\Facades\Http;
  29. use Illuminate\Support\Facades\Validator;
  30. use Intervention\Image\Facades\Image;
  31. use Ramsey\Uuid\Uuid;
  32. class WaybillController extends Controller
  33. {
  34. public function __construct()
  35. {
  36. app()->singleton('waybillService',WaybillService::class);
  37. }
  38. /**
  39. * @param Request $request
  40. * @param OwnerService $ownerService
  41. * @param CarrierService $carrierService
  42. * @return void
  43. */
  44. public function index(Request $request,OwnerService $ownerService,CarrierService $carrierService)
  45. {
  46. if(!Gate::allows('运输管理-查询')){ return redirect(url('/')); }
  47. $paginateParams = $request->input();
  48. $waybills=app('waybillService')->paginate($request->input());
  49. return view('waybill.index', [
  50. 'waybills' => $waybills,
  51. 'carriers' => $carrierService->getSelection(),
  52. 'owners' => $ownerService->getSelection(),
  53. 'paginateParams'=>$paginateParams,
  54. 'uriType'=>$request->uriType??'']);
  55. }
  56. public function create(Request $request,OwnerService $ownerService)
  57. {
  58. if(!Gate::allows('运输管理-录入')){ return redirect(url('/')); }
  59. $type=$request->type ?? "";
  60. if ($type==='ZF')$type='直发车';
  61. if ($type==='ZX')$type='专线';
  62. return view('waybill.create',['owners'=>$ownerService->getSelection(),'type'=>$type]);
  63. }
  64. public function store(Request $request)
  65. {
  66. if(!Gate::allows('运输管理-录入')){ return redirect(url('/')); }
  67. $id=false;
  68. $this->validatorWaybill($request,$id)->validate();
  69. /** @var WaybillService */
  70. $waybill=app('waybillService')->store($request);
  71. $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
  72. return redirect('waybill/index')->with('successTip','新运单“'.$waybill->waybill_number.'”录入成功');
  73. }
  74. public function edit($id,CarrierService $carrierService,CarTypeService $carTypeService,
  75. CityService $cityService,UnitService $unitService)
  76. {
  77. if(!Gate::allows('运输管理-编辑')){ return redirect(url('/')); }
  78. /** @var WaybillService */
  79. $waybill = app('waybillService')->find($id);
  80. if ($waybill->deliver_at){
  81. $waybill->deliver_at_date=Carbon::parse($waybill->deliver_at)->format('Y-m-d');
  82. $waybill->deliver_at_time=Carbon::parse($waybill->deliver_at)->format('H:i:s');
  83. }
  84. $cities=$cityService->getSelection();
  85. $units=$unitService->getSelection();
  86. $carTypes=$carTypeService->getSelection();
  87. return view('waybill/edit',['waybill'=>$waybill,'carriers'=>$carrierService->getSelection(),'cities'=>$cities,'units'=>$units,'carTypes'=>$carTypes]);
  88. }
  89. public function update(Request $request, $id,WaybillPriceModelService $waybillPriceModelService,
  90. CarrierService $carrierService,WaybillPayoffService $waybillPayoffService)
  91. {
  92. if(!Gate::allows('运输管理-调度')){ return redirect(url('/')); }
  93. if (!$request->warehouse_weight && $request->warehouse_weight_unit_id){
  94. $request->offsetUnset('warehouse_weight_unit_id');
  95. }
  96. if (!$request->warehouse_weight_other && $request->warehouse_weight_unit_id_other){
  97. $request->offsetUnset('warehouse_weight_unit_id_other');
  98. }
  99. if (!$request->carrier_weight && $request->carrier_weight_unit_id){
  100. $request->offsetUnset('carrier_weight_unit_id');
  101. }
  102. if (!$request->carrier_weight_other && $request->carrier_weight_unit_id_other){
  103. $request->offsetUnset('carrier_weight_unit_id_other');
  104. }
  105. $this->validatorWaybillDispatch($request,$id)->validate();
  106. $waybillPayoffParam = [];
  107. $waybillPayoffParam['total_receivable']=0;
  108. /** @var WaybillService */
  109. $waybill = app('waybillService')->update($request,$id);
  110. if ($waybill->type=="直发车"){
  111. if ($waybill->charge)$waybillPayoffParam['total_receivable'] = ($waybill->charge);
  112. elseif ($waybill->collect_fee)$waybillPayoffParam['total_receivable'] = ($waybill->collect_fee);
  113. $waybillPayoffParam['total_expense'] = ($waybill->fee)+($waybill->other_fee)-($waybill->collect_fee);
  114. }else {
  115. $waybillPriceModel_id=$request->input('waybillPriceModel');
  116. if ($waybillPriceModel_id){
  117. $carrier_weight=$request->input('carrier_weight');
  118. $waybillPriceModel=$waybillPriceModelService->find($waybillPriceModel_id);
  119. $carrier=$carrierService->find($waybill->carrier_id);
  120. if ($carrier_weight<$waybillPriceModel->initial_weight){
  121. $fee=(($waybillPriceModel->unit_price)*($waybillPriceModel->initial_weight))+$carrier->delivery_fee;
  122. }else{
  123. $fee=(($waybillPriceModel->unit_price)*$carrier_weight)+$carrier->delivery_fee;
  124. }
  125. if ($waybillPriceModel->base_fee&&$fee<$waybillPriceModel->base_fee){
  126. $fee=$waybillPriceModel->base_fee;
  127. }
  128. $waybill->fee=$fee;
  129. $waybill->waybill_price_model_id=$waybillPriceModel_id;
  130. }
  131. $waybill->save();
  132. if ($waybill->charge)$waybillPayoffParam['total_receivable'] = ($waybill->charge);
  133. elseif($waybill->collect_fee) {
  134. $waybillPayoffParam['total_receivable'] = $waybill->collect_fee;
  135. }
  136. $waybillPayoffParam['total_expense'] = ($waybill->pick_up_fee)+($waybill->other_fee)+($waybill->fee);
  137. }
  138. if ($waybillPayoffParam['total_receivable'] > 0){
  139. $waybillPayoffParam['waybill_id'] = $id;
  140. $waybillPayoffParam['gross_margin'] = $waybillPayoffParam['total_receivable'] - $waybillPayoffParam['total_expense'];
  141. $waybillPayoffParam['gross_profit_rate'] = $waybillPayoffParam['gross_margin']/$waybillPayoffParam['total_receivable'];
  142. $waybillPayoffService->updateOrCreate($waybillPayoffParam);
  143. }
  144. $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
  145. return redirect('waybill/index')->with('successTip','运单“'.$waybill->waybill_number.'”调度成功');
  146. }
  147. public function checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id){
  148. //确保承运商计数与计数单位为一个数组且长度2
  149. if(!$carrier_id)return false;
  150. if(!$destination_city_id)return false;
  151. if(!$carrier_weight)return false;
  152. if(!$carrier_weight_unit_id)return false;
  153. //多个计数标准,计算价格,取最贵
  154. if ($carrier_weight[0]&&$carrier_weight[1]&&$carrier_weight_unit_id[0]&&$carrier_weight_unit_id[1]){
  155. //城市价格区间不为空
  156. $waybillPriceModelOne=WaybillPriceModel::query()->where('carrier_id',$carrier_id)->where('city_id',$destination_city_id)
  157. ->where('range_min','<',$carrier_weight[0])->where('range_max','>=',$carrier_weight[0])
  158. ->where('unit_id',$carrier_weight_unit_id[0])->first();
  159. $waybillPriceModelTwo=WaybillPriceModel::query()->where('carrier_id',$carrier_id)->where('city_id',$destination_city_id)
  160. ->where('range_min','<',$carrier_weight[1])->where('range_max','>=',$carrier_weight[1])
  161. ->where('unit_id',$carrier_weight_unit_id[1])->first();
  162. if ($waybillPriceModelOne&&$waybillPriceModelTwo){
  163. if ($waybillPriceModelOne->unit_price*$carrier_weight[0]>=$waybillPriceModelTwo->unit_price*$carrier_weight[1]){
  164. return $waybillPriceModelOne->id;
  165. }else{
  166. return $waybillPriceModelTwo->id;
  167. }
  168. }
  169. if ($waybillPriceModelOne)return $waybillPriceModelOne->id;
  170. if ($waybillPriceModelTwo)return $waybillPriceModelTwo->id;
  171. //价格区间为空
  172. $waybillPriceModelRangeOne=WaybillPriceModel::query()->whereRaw('carrier_id = ? AND city_id = ? AND unit_id = ? AND range_max IS NULL',[$carrier_id,$destination_city_id,$carrier_weight_unit_id[0]])->first();
  173. $waybillPriceModelRangeTwo=WaybillPriceModel::query()->whereRaw('carrier_id = ? AND city_id = ? AND unit_id = ? AND range_max IS NULL',[$carrier_id,$destination_city_id,$carrier_weight_unit_id[1]])->first();
  174. if ($waybillPriceModelRangeOne&&$waybillPriceModelRangeTwo){
  175. if ($waybillPriceModelRangeOne->unit_price*$carrier_weight[0]>=$waybillPriceModelRangeTwo->unit_price*$carrier_weight[1]){
  176. return $waybillPriceModelRangeOne->id;
  177. }else{
  178. return $waybillPriceModelRangeTwo->id;
  179. }
  180. }
  181. if ($waybillPriceModelRangeOne)return $waybillPriceModelRangeOne->id;
  182. if ($waybillPriceModelRangeTwo)return $waybillPriceModelRangeTwo->id;
  183. //城市为空
  184. $city=City::query()->where('id',$destination_city_id)->select('province_id')->first();
  185. $waybillPriceModelProvinceOne=WaybillPriceModel::query()->whereRaw('carrier_id = ? AND province_id = ? AND unit_id = ? AND range_max >= ? AND range_min < ? AND city_id IS NULL',
  186. [$carrier_id,$city->province_id,$carrier_weight_unit_id[0],$carrier_weight[0],$carrier_weight[0]])->first();
  187. $waybillPriceModelProvinceTwo=WaybillPriceModel::query()->whereRaw('carrier_id = ? AND province_id = ? AND unit_id = ? AND range_max >= ? AND range_min < ? AND city_id IS NULL',
  188. [$carrier_id,$city->province_id,$carrier_weight_unit_id[1],$carrier_weight[1],$carrier_weight[1]])->first();
  189. if ($waybillPriceModelProvinceOne&&$waybillPriceModelProvinceTwo){
  190. if ($waybillPriceModelProvinceOne->unit_price*$carrier_weight[0]>=$waybillPriceModelProvinceTwo->unit_price*$carrier_weight[1]){
  191. return $waybillPriceModelProvinceOne->id;
  192. }else{
  193. return $waybillPriceModelProvinceTwo->id;
  194. }
  195. }
  196. if ($waybillPriceModelProvinceOne)return $waybillPriceModelProvinceOne->id;
  197. if ($waybillPriceModelProvinceTwo)return $waybillPriceModelProvinceTwo->id;
  198. //城市价格区间都为空
  199. $waybillPriceModelProvinceRangeOne=WaybillPriceModel::query()->whereRaw('carrier_id = ? AND province_id = ? AND unit_id = ? AND range_max IS NULL AND city_id IS NULL',
  200. [$carrier_id,$city->province_id,$carrier_weight_unit_id[0]])->first();
  201. $waybillPriceModelProvinceRangeTwo=WaybillPriceModel::query()->whereRaw('carrier_id = ? AND province_id = ? AND unit_id = ? AND range_max IS NULL AND city_id IS NULL',
  202. [$carrier_id,$city->province_id,$carrier_weight_unit_id[1]])->first();
  203. if ($waybillPriceModelProvinceRangeOne&&$waybillPriceModelProvinceRangeTwo){
  204. if ($waybillPriceModelProvinceRangeOne->unit_price*$carrier_weight[0]>=$waybillPriceModelProvinceRangeTwo->unit_price*$carrier_weight[1]){
  205. return $waybillPriceModelProvinceRangeOne->id;
  206. }else{
  207. return $waybillPriceModelProvinceRangeOne->id;
  208. }
  209. }
  210. if ($waybillPriceModelProvinceRangeOne)return $waybillPriceModelProvinceRangeOne->id;
  211. if ($waybillPriceModelProvinceRangeTwo)return $waybillPriceModelProvinceRangeTwo->id;
  212. };
  213. for ($i=0;$i<count($carrier_weight);$i++){
  214. if ($carrier_weight[$i]&&$carrier_weight_unit_id[$i]){
  215. //城市价格区间不为空
  216. $waybillPriceModel=WaybillPriceModel::query()->where('carrier_id',$carrier_id)->where('city_id',$destination_city_id)
  217. ->where('range_min','<',$carrier_weight[$i])->where('range_max','>=',$carrier_weight[$i])
  218. ->where('unit_id',$carrier_weight_unit_id[$i])->first();
  219. if($waybillPriceModel)return $waybillPriceModel->id;
  220. //价格区间为空
  221. $waybillPriceModelRange=WaybillPriceModel::query()->whereRaw('carrier_id = ? AND city_id = ? AND unit_id = ? AND range_max IS NULL',[$carrier_id,$destination_city_id,$carrier_weight_unit_id[$i]])->first();
  222. if ($waybillPriceModelRange){ return $waybillPriceModelRange->id;}
  223. //城市为空
  224. $city=City::where('id',$destination_city_id)->select('province_id')->first();
  225. $waybillPriceModelProvince=WaybillPriceModel::query()->whereRaw('carrier_id = ? AND province_id = ? AND unit_id = ? AND range_max >= ? AND range_min < ? AND city_id IS NULL',
  226. [$carrier_id,$city->province_id,$carrier_weight_unit_id[$i],$carrier_weight[$i],$carrier_weight[$i]])->first();
  227. if ($waybillPriceModelProvince){return $waybillPriceModelProvince->id;}
  228. //城市价格区间都为空
  229. $waybillPriceModelProvinceRange=WaybillPriceModel::query()->whereRaw('carrier_id = ? AND province_id = ? AND unit_id = ? AND range_max IS NULL AND city_id IS NULL',
  230. [$carrier_id,$city->province_id,$carrier_weight_unit_id[$i]])->first();
  231. if ($waybillPriceModelProvinceRange){return $waybillPriceModelProvinceRange->id;}
  232. }
  233. }
  234. return false;
  235. }
  236. /*三层条件:无优先级,找到第一个直接返回
  237. * 无论是否为KG||T,计数单位一为KG,计数单位一为T,计数单位二为KG,计数单位二为T
  238. * 计数一与计数二同时存在取最贵价格:
  239. * 计数一存在,二不存在:
  240. * 计数二存在,一不存在:
  241. * 城市价格区间不为空,城市价格区间都为空,城市为空,价格区间为空
  242. * */
  243. public function isWaybillPriceModel(Request $request){
  244. $carrier_id=$request->input('carrier_id');
  245. $destination_city_id=$request->input('destination_city_id');
  246. $carrier_weight=$request->input('carrier_weight');
  247. $carrier_weight_unit_id=$request->input('carrier_weight_unit_id');
  248. $validatorData=["carrier_id"=>$carrier_id,"destination_city_id"=>$destination_city_id,
  249. 'carrier_weight'=>$carrier_weight[0],"carrier_weight_unit_id"=>$carrier_weight_unit_id[0],
  250. "carrier_weight_other"=>$carrier_weight[1],"carrier_weight_unit_id_other"=>$carrier_weight_unit_id[1]];
  251. $errors=Validator::make($validatorData,[
  252. 'carrier_id'=>'required|integer',
  253. 'destination_city_id'=>'required|integer',
  254. 'carrier_weight'=>'nullable|min:0|numeric|max:999999',
  255. 'carrier_weight_unit_id'=>'required_with:carrier_weight',
  256. 'carrier_weight_other'=>'nullable|min:0|numeric|max:999999',
  257. 'carrier_weight_unit_id_other'=>'required_with:carrier_weight_other',
  258. ],[
  259. 'required'=>':attribute 为必填项',
  260. 'max'=>':attribute 字符过多或输入值过大',
  261. 'min'=>':attribute 不得为负',
  262. 'numeric'=>':attribute 应为数字',
  263. 'unique'=>':attribute 已存在',
  264. 'required_with'=>':attribute 未填',
  265. 'integer'=>':attribute 必须为数字',
  266. ],[
  267. 'carrier_weight'=>'承运商计数(抛)',
  268. 'carrier_id'=>'承运商',
  269. 'destination_city_id'=>'目的市',
  270. 'carrier_weight_unit_id'=>'承运商计数单位',
  271. 'carrier_weight_other'=>'承运商计数二',
  272. 'carrier_weight_unit_id_other'=>'承运商计数单位二',
  273. ])->errors();
  274. if (count($errors)>0)return ['error'=>$errors];
  275. $result=$this->checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id);
  276. if (!$result){
  277. //单位为kg,T时
  278. $unitKG=Unit::query()->where('name','kg')->first();
  279. $unitT=Unit::query()->where('name','T')->first();
  280. if ($carrier_weight_unit_id[0]==$unitKG->id){
  281. $carrier_weight_unit_id[0]=$unitT->id;
  282. $carrier_weight[0]=$carrier_weight[0]/1000;
  283. $result=$this->checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id);
  284. if ($result)return ['success'=>$result];
  285. }
  286. if ($carrier_weight_unit_id[1]==$unitKG->id){
  287. $carrier_weight_unit_id[1]=$unitT->id;
  288. $carrier_weight[1]=$carrier_weight[1]/1000;
  289. $result=$this->checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id);
  290. if ($result)return ['success'=>$result];
  291. }
  292. if ($carrier_weight_unit_id[0]==$unitT->id){
  293. $carrier_weight_unit_id[0]=$unitKG->id;
  294. $carrier_weight[0]=$carrier_weight[0]*1000;
  295. $result=$this->checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id);
  296. if ($result)return ['success'=>$result];
  297. }
  298. if ($carrier_weight_unit_id[1]==$unitT->id){
  299. $carrier_weight_unit_id[1]=$unitKG->id;
  300. $carrier_weight[1]=$carrier_weight[1]*1000;
  301. $result=$this->checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id);
  302. if ($result)return ['success'=>$result];
  303. }
  304. }
  305. return ['success'=>$result];
  306. }
  307. public function waybillUpdate(Request $request, $id){
  308. if(!Gate::allows('运输管理-编辑')){ return redirect(url('/')); }
  309. $this->validatorWaybill($request,$id)->validate();
  310. $data=$request->input();
  311. $waybill=app('waybillService')->find($id);
  312. $waybill->fill($data);
  313. if ($waybill->save()){
  314. $this->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']);
  315. return redirect('waybill/index')->with('successTip','运单“'.$waybill->waybill_number.'”修改成功');
  316. }
  317. }
  318. public function waybillAudit(Request $request){
  319. if(!Gate::allows('运输管理-运单审核')){ return redirect(url('/')); }
  320. $id=$request->input('id');
  321. $waybill=app('waybillService')->find($id);
  322. $isAudit=WaybillAuditLog::whereRaw('waybill_id = ? and audit_stage = ?',[$id,"运单阶段"])->first();
  323. if (empty($isAudit)){
  324. $waybillAuditLog=new WaybillAuditLog([
  325. 'waybill_id'=>$id,
  326. 'audit_stage'=>'运单阶段',
  327. 'user_id'=>Auth::id(),
  328. ]);
  329. $waybillAuditLog->save();
  330. $waybillAuditLog['user']=Auth::user();
  331. $waybill->status='已审核';
  332. $result=$waybill->save();
  333. $this->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']);
  334. return ['success'=>$result,'status'=>$waybill->status,'waybillAuditLog'=>$waybillAuditLog];
  335. }
  336. return ['exception'=>'请勿重复审核!'];
  337. }
  338. public function waybillEdit($id){
  339. if(!Gate::allows('运输管理-编辑')){ return redirect(url('/')); }
  340. $waybill=app('waybillService')->find($id);
  341. $owners=Owner::get();
  342. return view('waybill.waybillEdit',['waybill'=>$waybill,'owners'=>$owners]);
  343. }
  344. public function waybillRetreatAudit(Request $request){
  345. if(!Gate::allows('运输管理-调度')){ return redirect(url('/')); }
  346. $id=$request->input('id');
  347. $waybill=app('waybillService')->find($id);
  348. WaybillAuditLog::whereRaw('waybill_id = ? and audit_stage = ?',[$id,"运单阶段"])->delete();
  349. $waybill->status='待重审';
  350. $result=$waybill->save();
  351. $this->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']);
  352. return ['success'=>$result,'status'=>$waybill->status];
  353. }
  354. public function waybillEndAudit(Request $request){
  355. if(!Gate::allows('运输管理-调度审核')){ return redirect(url('/')); }
  356. $id=$request->input('id');
  357. $waybill=Waybill::query()->with(["owner","carrier","originationCity","destinationCity","carType",'priceModel',"amountUnit",
  358. "warehouseWeightUnit","carrierWeightUnit","warehouseWeightUnitOther","carrierWeightUnitOther"])->find($id);
  359. if (!$waybill->charge&&!$waybill->collect_fee)return ['exception'=>'收费或到付费用未填!'];
  360. if ($waybill->charge==0&&$waybill->collect_fee==0)return ['exception'=>'收费与到付费用都为0!'];
  361. if ($waybill->type=='专线'){
  362. if (!$waybill->carrier_weight_other||$waybill->carrier_weight_other==0)return ['exception'=>'承运商计重未填或为0!'];
  363. if (!$waybill->carrier_weight_unit_id_other)return ['exception'=>'承运商计重单位未选!'];
  364. }
  365. $isAudit=WaybillAuditLog::query()->whereRaw('waybill_id = ? and audit_stage = ?',[$id,"调度阶段"])->first();
  366. if (empty($isAudit)){
  367. $waybillAuditLog=new WaybillAuditLog([
  368. 'waybill_id'=>$id,
  369. 'audit_stage'=>'调度阶段',
  370. 'user_id'=>Auth::id(),
  371. ]);
  372. $waybillAuditLog->save();
  373. $waybillAuditLog['user']=Auth::user();
  374. if ($waybill->waybill_price_model_id||$waybill->type=='直发车'){
  375. $waybill->status='已完结';
  376. $result=$waybill->save();
  377. $waybillPayoff=WaybillPayoff::query()->where('waybill_id','=',$id)->first();
  378. $waybillPayoffJson=json_encode($this->createReportData($waybill,$waybillPayoff),JSON_UNESCAPED_UNICODE);
  379. WaybillFinancialSnapshot::query()->create([
  380. 'waybill_id'=>$id,
  381. 'json_content'=>$waybillPayoffJson,
  382. ]);
  383. }else{
  384. $waybill->status='无模型';
  385. $result=$waybill->save();
  386. $waybillPayoff=WaybillPayoff::query()->where('waybill_id','=',$id)->first();
  387. if ($waybillPayoff){
  388. $waybillPayoffJson=json_encode($this->createReportData($waybill,$waybillPayoff),JSON_UNESCAPED_UNICODE);
  389. WaybillFinancialExcepted::query()->create([
  390. 'waybill_id'=>$id,
  391. 'json_content'=>$waybillPayoffJson,
  392. ]);
  393. }
  394. }
  395. $this->log(__METHOD__,__FUNCTION__,$waybillPayoffJson,Auth::id());
  396. return ['success'=>$result,'status'=>$waybill->status,'waybillAuditLog'=>$waybillAuditLog];
  397. }
  398. return ['exception'=>'请勿重复审核!'];
  399. }
  400. //生成报表数据
  401. private function createReportData($waybill,$waybillPayoff){
  402. return [
  403. "type"=>$waybill->type,
  404. "waybill_number"=>$waybill->waybill_number,
  405. "owner_name"=>$waybill->owner ? $waybill->owner->name : null,
  406. "wms_bill_number"=>$waybill->wms_bill_number,
  407. "source_bill"=>$waybill->source_bill,
  408. "origination"=>$waybill->origination,
  409. "destination"=>$waybill->destination,
  410. "recipient"=>$waybill->recipient,
  411. "recipient_mobile"=>$waybill->recipient_mobile,
  412. "charge"=>$waybill->charge,
  413. "collect_fee"=>$waybill->collect_fee,
  414. "ordering_remark"=>$waybill->ordering_remark,
  415. "carrier_name"=>$waybill->carrier ? $waybill->carrier->name : null,
  416. "carrier_bill"=>$waybill->carrier_bill,
  417. "origination_city_name"=>$waybill->originationCity ? $waybill->originationCity->name : null,
  418. "destination_city_name"=>$waybill->destinationCity ? $waybill->destinationCity->name : null,
  419. "warehouse_weight"=>$waybill->warehouse_weight.($waybill->warehouseWeightUnit ? $waybill->warehouseWeightUnit->name : ''),
  420. "carrier_weight"=>$waybill->carrier_weight.($waybill->carrierWeightUnit ? $waybill->carrierWeightUnit->name : ''),
  421. "warehouse_weight_other"=>$waybill->warehouse_weight_other.($waybill->warehouseWeightUnitOther ? $waybill->warehouseWeightUnitOther->name : ''),
  422. "carrier_weight_other"=>$waybill->carrier_weight_other.($waybill->carrierWeightUnitOther ? $waybill->carrierWeightUnitOther->name : ''),
  423. "car_type_name"=>$waybill->carType ? $waybill->carType->name : null,
  424. "fee"=>$waybill->fee,
  425. "pick_up_fee"=>$waybill->pick_up_fee,
  426. "other_fee"=>$waybill->other_fee,
  427. "dispatch_remark"=>$waybill->dispatch_remark,
  428. "price_model_range_min"=>$waybill->priceModel ? $waybill->priceModel->range_min : null,
  429. "price_model_range_max"=>$waybill->priceModel ? $waybill->priceModel->range_max : null,
  430. "price_model_unit_price"=>$waybill->priceModel ? $waybill->priceModel->unit_price : null,
  431. "price_model_base_fee"=>$waybill->priceModel ? $waybill->priceModel->base_fee : null,
  432. "price_model_initial_weight"=>$waybill->priceModel ? $waybill->priceModel->initial_weight : null,
  433. "car_owner_info"=>$waybill->car_owner_info,
  434. "status"=>$waybill->status,
  435. "mileage"=>$waybill->mileage,
  436. 'amount'=>$waybill->amount.($waybill->amountUnit ? $waybill->amountUnit->name : ''),
  437. "inquire_tel"=>$waybill->inquire_tel,
  438. "other_charge"=>$waybill->other_charge,
  439. "other_charge_remark"=>$waybill->other_charge_remark,
  440. "deliver_at"=>$waybill->deliver_at,
  441. "created_at"=>$waybill->created_at,
  442. "auditLog_user_name"=>Auth::user()['name'],
  443. "total_expense"=>$waybillPayoff->total_expense,
  444. "total_receivable"=>$waybillPayoff->total_receivable,
  445. "gross_margin"=>$waybillPayoff->gross_margin,
  446. "gross_profit_rate"=>$waybillPayoff->gross_profit_rate,
  447. ];
  448. }
  449. public function upload(Request $request){
  450. if(!Gate::allows('运输管理-图片上传')){ return '没有权限'; }
  451. $file=$request->file('file');
  452. $waybill_number=$request->input('waybill_number');
  453. $waybill=Waybill::query()->where('waybill_number',$waybill_number)->first();
  454. if (!$waybill){
  455. return ['success'=>false,'error'=>"未找到该运单!"];
  456. }
  457. if ($waybill->upload_file_url){
  458. return ['success'=>false,'error'=>"该运单已存在照片!"];
  459. }
  460. if (!$file){
  461. return ['success'=>false,'error'=>"照片不得为空!"];
  462. }
  463. if (!$file->isValid()){
  464. return ['success'=>false,'error'=>"找不到照片!"];
  465. }
  466. $tmpFile = $file->getRealPath();
  467. if (! is_uploaded_file($tmpFile)) {
  468. return ['success'=>false,'error'=>"文件错误!"];
  469. }
  470. $fileExtension=$file->getClientOriginalExtension();
  471. // 5.存储, 生成一个随机文件名
  472. $fileName = date('ymd').'-'.Uuid::uuid1();//thumbnail common bulky
  473. $thumbnailName=storage_path('app/public/files/'.$fileName.'-thumbnail.'.$fileExtension);
  474. $commonName=storage_path('app/public/files/'.$fileName.'-common.'.$fileExtension);
  475. $bulkyName=storage_path('app/public/files/'.$fileName.'-bulky.'.$fileExtension);
  476. $result=move_uploaded_file ($tmpFile ,$bulkyName);
  477. if ($result){
  478. $img=Image::make($bulkyName);
  479. if ($img->height() > $img->width())
  480. $img->heighten(250)->save($commonName);
  481. else $img->widen(250)->save($commonName);
  482. $img->heighten(28)->save($thumbnailName);
  483. $uploadFile=new UploadFile([
  484. "table_name"=>"waybills",
  485. "table_id"=>$waybill->id,
  486. "url"=>'/files/'.$fileName,
  487. "type"=>$fileExtension,
  488. ]);
  489. if ($uploadFile->save())
  490. $this->log(__METHOD__,'图片上传',json_encode($request),Auth::user()['id']);
  491. $uploadFile->url=asset('/storage'.$uploadFile->url);
  492. return ['success'=>true,'data'=>$uploadFile];
  493. }
  494. return ['success'=>false,'error'=>"图片保存失败!"];
  495. }
  496. //删除照片
  497. public function deleteImg(Request $request){
  498. if(!Gate::allows('运输管理-图片删除')){ return '没有权限'; }
  499. $ids=$request->input('ids');
  500. $uploadFiles=UploadFile::where('table_name','waybills')->whereIn('table_id',$ids)->get();
  501. foreach ($uploadFiles as $uploadFile){
  502. $bulky=storage_path('app/public/'.$uploadFile->url.'-bulky.'.$uploadFile->type);
  503. $common=storage_path('app/public/'.$uploadFile->url.'-common.'.$uploadFile->type);
  504. $thumbnail=storage_path('app/public/'.$uploadFile->url.'-thumbnail.'.$uploadFile->type);
  505. if (file_exists($bulky) && file_exists($common) && file_exists($thumbnail)){
  506. unlink($bulky);unlink($common);unlink($thumbnail);
  507. }
  508. }
  509. UploadFile::where('table_name','waybills')->whereIn('table_id',$ids)->delete();
  510. $this->log(__METHOD__,'图片删除',json_encode($request),Auth::user()['id']);
  511. return ['success'=>true];
  512. }
  513. public function export(Request $request){
  514. if(!Gate::allows('运输管理-查询')){ return '没有权限'; }
  515. if ($request->checkAllSign){
  516. $param = $request->input();
  517. unset($param['checkAllSign']);
  518. $sql = app('waybillService')->getSql($param);
  519. }else $sql = app('waybillService')->getSql(['id'=>$request->data]);
  520. $post = Http::post(config('go.export.url'),['type'=>'waybill','sql'=>$sql]);
  521. if ($post->status() == 500){
  522. throw new Exception($post->header("Msg"));
  523. }
  524. return response($post,200, [
  525. "Content-type"=>"application/octet-stream",
  526. "Content-Disposition"=>"attachment; filename=运单列表-".date('ymdHis').'.xlsx',
  527. ]);
  528. }
  529. public function deliveringExport(Request $request){
  530. if ($request->checkAllSign){
  531. $param = $request->input();
  532. unset($param['checkAllSign']);
  533. $sql = app('waybillService')->getDeliveringSql($param);
  534. }else{
  535. $sql = app('waybillService')->getDeliveringSql(['id'=>$request->data]);
  536. }
  537. $post = Http::post(config('go.export.url'),['type'=>'waybillDelivering','sql'=>$sql]);
  538. if ($post->status() == 500){
  539. throw new Exception($post->header("Msg"));
  540. }
  541. return response($post,200, [
  542. "Content-type"=>"application/octet-stream",
  543. "Content-Disposition"=>"attachment; filename=发运列表-".date('ymdHis').'.xlsx',
  544. ]);
  545. }
  546. //发运
  547. public function delivering(Request $request){
  548. if (!Auth::user())return view('exception.login');
  549. $waybills= app('waybillService')->paginate($request->input());
  550. if (!Auth::user()->isSuperAdmin()){
  551. $carriersUsers=DB::table('carrier_user')->where('user_id',Auth::id())->get();
  552. $carrierIds=array_column($carriersUsers->toArray(),'carrier_id');
  553. $waybills=$waybills->whereIn("carrier_id",$carrierIds);
  554. }
  555. return view('waybill.delivering',compact('waybills'));
  556. }
  557. //承运商提交
  558. public function storeCarrierBill(Request $request){
  559. $errors=Validator::make($request->input(),[
  560. 'id'=>'required|integer',
  561. 'carrier_bill'=>'required',
  562. 'inquire_tel'=>'nullable',
  563. 'amount'=>'nullable|integer',
  564. 'carrier_weight'=>'required_without:carrier_weight_other|nullable|numeric',
  565. 'carrier_weight_other'=>'required_without:carrier_weight|nullable|numeric',
  566. ],[
  567. 'required'=>':attribute 为必填项',
  568. 'integer'=>':attribute 应为整数',
  569. 'numeric'=>':attribute 应为数字',
  570. 'required_with'=>':attribute 重量与体积至少存在一项',
  571. ],[
  572. 'carrier_bill'=>'专线运单号',
  573. 'inquire_tel'=>'查件电话',
  574. 'amount'=>'件数',
  575. 'carrier_weight'=>'体积',
  576. 'carrier_weight_other'=>'重量',
  577. ])->errors();
  578. if (count($errors)>0)return ["errors"=>$errors];
  579. $waybill=Waybill::find($request->input('id'));
  580. if (!$waybill)return ["error"=>"未找到该运单!"];
  581. $waybill->fill($request->input());
  582. $waybill->update();
  583. return $waybill;
  584. }
  585. protected function validatorWaybill(Request $request,$id){
  586. if ($id){$wms_bill_number=$id;};
  587. $validator=Validator::make($request->input(),[
  588. 'owner_id'=>'required',
  589. 'wms_bill_number'=>['nullable','max:50',isset($wms_bill_number)?"unique:waybills,wms_bill_number,$wms_bill_number":'unique:waybills,wms_bill_number'],
  590. 'origination'=>'required|max:255',
  591. 'destination'=>'required|max:255',
  592. 'recipient'=>'required|max:50',
  593. 'recipient_mobile'=>['required','regex:/^(\d{7,11})|(1[3|4|5|7|8][0-9]\d{4,8})$/'],
  594. 'charge'=>'nullable|min:0|max:999999|numeric',
  595. 'collect_fee'=>'nullable|min:0|numeric',
  596. ],[
  597. 'required'=>':attribute 为必填项',
  598. 'alpha_num'=>':attribute 应为字母或数字',
  599. 'max'=>':attribute 字符过多或输入值过大',
  600. 'regex'=>':attribute 输入有误',
  601. 'integer'=>':attribute 应为整数',
  602. 'min'=>':attribute 不得为负',
  603. 'numeric'=>':attribute 应为数字',
  604. 'unique'=>':attribute 已存在',
  605. ],[
  606. 'owner_id'=>'货主',
  607. 'wms_bill_number'=>'WMS单号',
  608. 'origination'=>'始发地',
  609. 'destination'=>'目的地',
  610. 'recipient'=>'收件人',
  611. 'recipient_mobile'=>'收件人电话',
  612. 'charge'=>'收费',
  613. 'collect_fee'=>'到付金额',
  614. ]);
  615. return $validator;
  616. }
  617. protected function validatorWaybillDispatch(Request $request,$id){
  618. $rule=[
  619. 'carrier_id'=>'required|integer',
  620. 'carrier_bill'=>"sometimes|nullable|max:50|unique:waybills,carrier_bill,$id",
  621. 'fee'=>'sometimes|nullable|min:0|numeric|max:999999',
  622. 'other_fee'=>'sometimes|nullable|min:0|numeric|max:999999',
  623. 'charge'=>'sometimes|nullable|min:0|numeric|max:999999',
  624. 'mileage'=>'nullable|numeric|min:0',
  625. 'amount'=>'nullable|numeric|min:0',
  626. 'amount_unit_id'=>'required',
  627. 'origination_city_id'=>'sometimes|required|integer',
  628. 'destination_city_id'=>'sometimes|required|integer',
  629. 'warehouse_weight_other'=>'sometimes|nullable|min:0|numeric|max:999999',
  630. 'warehouse_weight_unit_id_other'=>'sometimes|required_with:warehouse_weight_other|nullable|integer',
  631. 'pick_up_fee'=>'sometimes|nullable|min:0|numeric|max:999999',
  632. 'warehouse_weight'=>'sometimes|nullable|min:0|numeric|max:999999',
  633. 'warehouse_weight_unit_id'=>'sometimes|required_with:warehouse_weight|nullable|integer',
  634. 'carrier_weight'=>'sometimes|nullable|min:0|numeric|max:999999',
  635. 'carrier_weight_unit_id'=>'sometimes|required_with:carrier_weight',
  636. 'carrier_weight_other'=>'sometimes|nullable|min:0|numeric|max:999999',
  637. 'carrier_weight_unit_id_other'=>'sometimes|required_with:carrier_weight_other',
  638. ];
  639. if ($request->type == '专线'){
  640. $rule['origination_city_id']='required|integer';
  641. $rule['destination_city_id']='required|integer';
  642. }
  643. $validator=Validator::make($request->input(),$rule,[
  644. 'required'=>':attribute 为必填项',
  645. 'alpha_num'=>':attribute 应为字母或数字',
  646. 'max'=>':attribute 字符过多或输入值过大',
  647. 'min'=>':attribute 不得为负',
  648. 'numeric'=>':attribute 应为数字',
  649. 'unique'=>':attribute 已存在',
  650. 'required_with'=>':attribute 未填',
  651. 'integer'=>':attribute 必须为数字',
  652. ],[
  653. 'carrier_id'=>'承运商',
  654. 'carrier_bill'=>'承运商单号',
  655. 'fee'=>'运费',
  656. 'other_fee'=>'其他费用',
  657. 'charge'=>'收费',
  658. 'mileage'=>'里程数',
  659. 'amount'=>'计数',
  660. 'amount_unit_id'=>'计数单位',
  661. 'warehouse_weight'=>'仓库计数(抛)',
  662. 'carrier_weight'=>'承运商计数(抛)',
  663. 'pick_up_fee'=>'提货费',
  664. 'destination_city_id'=>'目的市',
  665. 'carrier_weight_unit_id'=>'承运商计数单位',
  666. 'warehouse_weight_unit_id'=>'仓库计数单位',
  667. 'warehouse_weight_other'=>'仓库计数二',
  668. 'carrier_weight_other'=>'承运商计数二',
  669. 'warehouse_weight_unit_id_other'=>'仓库技数单位二',
  670. 'carrier_weight_unit_id_other'=>'承运商计数单位二',
  671. ]);
  672. return $validator;
  673. }
  674. public function addCounty(Request $request){
  675. if ($request->destination_city =='undefined')$request->offsetUnset('destination_city');
  676. $rule =[
  677. 'destination_city' => ['required', 'string','unique:cities,name'],
  678. ];
  679. $messages=[
  680. 'destination_city.required'=>'市/县不能为空',
  681. 'destination_city.string'=>'市/县必须是字符串',
  682. 'destination_city.unique'=>'市/县已存在',
  683. ];
  684. $validator = Validator::make($request->all(),$rule,$messages);
  685. if ($validator->fails()) {
  686. return $validator->errors();
  687. }
  688. $city=new City([
  689. 'name'=>$request->input('destination_city'),
  690. 'type'=>3,
  691. ]);
  692. $city->save();
  693. return $city;
  694. }
  695. // 运单删除 软删除
  696. public function destroy(int $id){
  697. if(!GAte::allows('运输管理-删除')){return['success'=>0,'status'=>'没有权限'];}
  698. if(is_null($id)){return ['success'=>'0','status'=>'传入id为空'];}
  699. $result = Waybill::where('id',$id)->delete();
  700. return ['success'=>$result,'status'=>$result];
  701. }
  702. // 回收站
  703. public function recycle(Request $request){
  704. if(!Gate::allows('运输管理-删除')){return redirect('/');}
  705. $paginate = $request->input('paginate')??50;
  706. $waybills = Waybill::with(['owner','carrier','amountUnit','warehouseWeightUnit','carrierWeightUnit',
  707. 'warehouseWeightUnitOther','carrierWeightUnitOther','carType','waybillAuditLogs' => function ($query) {
  708. $query->with('user');
  709. }])->orderBy('deleted_at', 'DESC')->withTrashed()->whereNotNull('deleted_at')->paginate(50);
  710. $total = $waybills->count();
  711. $paginateParams = [];
  712. $paginateParams['paginate'] = $paginate;
  713. return view('waybill.recycle',compact('waybills','total','paginateParams'));
  714. }
  715. // 软删除恢复
  716. public function apiRestoreSelected(Request $request){
  717. if(!Gate::allows('运输管理-删除')){return ['success'=>'false','fail_info'=>'没有权限'];}
  718. $ids = $request->input('ids')??'';
  719. if($ids == ''){return ['success'=>'false','fail_info'=>'没有可恢复对象'];}
  720. $waybills = Waybill::withTrashed()->whereIn('id',$ids)->get();
  721. $waybills->each(function (Waybill $waybill){
  722. $waybill->restore();
  723. });
  724. $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
  725. return ['success'=>'true','waybills'=>$waybills];
  726. }
  727. // 修改运费
  728. public function changeFee(Request $request){
  729. if(!Gate::allows('运输管理-运费')){return ['success'=>'false','fail_info'=>'没有权限'];}
  730. $wayBillId = $request->input('id');
  731. $waybillFee = $request->input('fee');
  732. if(is_null($wayBillId) or is_null($waybillFee)){
  733. return ['success'=>'false','fail_info'=>'参数异常'];
  734. }
  735. $result = Waybill::where('id',$wayBillId)->update(['fee'=>$waybillFee]);
  736. $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
  737. return ['success'=>$result,'status'=>$result];
  738. }
  739. // 修改运输收费
  740. public function changeCharge(Request $request){
  741. if(!Gate::allows('运输管理-运单编辑')){return ['success'=>'false','fail_info'=>'没有权限'];}
  742. $wayBillId = $request->id;
  743. $waybillCharge = $request->input('charge');
  744. if(is_null($wayBillId) or is_null($waybillCharge)){
  745. return ['success'=>'false','fail_info'=>'参数异常'];
  746. }
  747. $result = Waybill::where('id',$wayBillId)->update(['charge'=>$waybillCharge]);
  748. $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
  749. return ['success'=>$result,'status'=>$result];
  750. }
  751. // 置顶
  752. public function waybillOnTop(Request $request){
  753. $id = $request->input('id');
  754. $detail = $request->input('detail');
  755. if(!Gate::allows('运输管理-置顶')){return ['success'=>'false','fail_info'=>'没有权限'];}
  756. if(is_null($id)){
  757. return ['success'=>'false','fail_info'=>'传参错误'];
  758. }
  759. $wayontop = WaybillOnTop::withTrashed()->where('waybill_id',$id);
  760. if(count($wayontop->get()) == 0){
  761. $wayontop = WaybillOnTop::create(['waybill_id'=>$id,'remark'=>$detail]);
  762. $result = $wayontop->save();
  763. }else{
  764. $result = WaybillOnTop::withTrashed()->where('waybill_id',$id)->restore();
  765. }
  766. return ['success'=>$result,'status'=>$result];
  767. }
  768. // 取消置顶
  769. public function cancelOnTop(Request $request){
  770. $id = $request->input('id');
  771. if(!Gate::allows('运输管理-置顶')){return ['success'=>'false','fail_info'=>'没有权限'];}
  772. if(is_null($id)){
  773. return ['success'=>'false','fail_info'=>'传参错误'];
  774. }
  775. $result = WaybillOnTop::where('waybill_id',$id)->forceDelete();
  776. return ['success'=>$result,'status'=>$result];
  777. }
  778. //同步刷新仓库计重
  779. public function refreshWaveHouseWeight(Request $request){
  780. $wms_bill_number=$request->input('wms_bill_number');
  781. if(is_null($wms_bill_number)) return ['success'=>false,'fail_info'=>'传参错误'];
  782. $waybills=DB::connection('oracle')->table('DOC_ORDER_DETAILS')->where('orderno',$wms_bill_number)->get();
  783. if($waybills->isEmpty()) return ['success'=>false,'fail_info'=>'传参错误'];
  784. $warehouseWeight=0;
  785. foreach ($waybills as $waybill){
  786. if ($waybill->grossweight) $warehouseWeight += $waybill->grossweight;
  787. if (!$waybill->grossweight&& $waybill->netweight) $warehouseWeight +=$waybill->netweight;
  788. }
  789. $warehouseWeight=round($warehouseWeight,2);
  790. $waybill=Waybill::where('wms_bill_number',$wms_bill_number)->first();
  791. if ($warehouseWeight!=0){
  792. if ($waybill['warehouse_weight_other']!=$warehouseWeight){
  793. $waybill['warehouse_weight_other']=$warehouseWeight;
  794. $waybill->update();
  795. $this->log(__METHOD__,'刷新仓库计重'.__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
  796. }
  797. }else{
  798. $warehouseWeight=$waybill['warehouse_weight_other'];
  799. }
  800. return ['success'=>true,'warehouseWeight'=>$warehouseWeight];
  801. }
  802. }