WaybillController.php 44 KB

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