|
|
@@ -660,21 +660,30 @@ class WaybillController extends Controller
|
|
|
}
|
|
|
|
|
|
public function export(){
|
|
|
+ $append = \request("append")=='true';
|
|
|
+ request()->offsetUnset("append");
|
|
|
$this->gate('运输管理-运单-查询');
|
|
|
+ /** @var Collection $waybills */
|
|
|
if (request("checkAllSign")){
|
|
|
request()->offsetUnset("checkAllSign");
|
|
|
$waybills = app('waybillService')->get(request()->input());
|
|
|
}else $waybills = app('waybillService')->get(["id"=>request("data")]);
|
|
|
- /** @var Collection $waybills */
|
|
|
+ if ($waybills->count()==0)return "无数据";
|
|
|
$row = [
|
|
|
"运单类型", "货主", "上游单号", "wms订单号", "运单号", "运输收费",
|
|
|
"其他收费", "其他收费备注", "始发地", "目的地","下单备注", "承运商", "承运商单号",
|
|
|
"仓库计抛", "承运商计抛", "仓库计重", "承运商计重", "车型", "车辆信息",
|
|
|
"计件", "里程数", "运费(元)", "提货费(元)", "其他费用(元)", "发货时间",
|
|
|
- "调度备注", "创建时间"
|
|
|
+ "调度备注", "创建时间", "省", "市", "区", "FLUX地址", "FLUX重量", "FLUX数量"
|
|
|
];
|
|
|
$list = [];
|
|
|
- $waybills->each(function ($waybill)use(&$list){
|
|
|
+ $codes = '';
|
|
|
+ $map = [];
|
|
|
+ $waybills->each(function ($waybill,$index)use(&$list,&$codes,&$map){
|
|
|
+ foreach (explode(",",$waybill->wms_bill_number) as $bill){
|
|
|
+ $codes .= "'".$bill."',";
|
|
|
+ $map[$bill] = $index;
|
|
|
+ }
|
|
|
$list[] = [
|
|
|
$waybill->type,
|
|
|
$waybill->owner->name ?? ($waybill->order->owner->name ?? ""),
|
|
|
@@ -703,9 +712,25 @@ class WaybillController extends Controller
|
|
|
$waybill->deliver_at,
|
|
|
$waybill->dispatch_remark,
|
|
|
$waybill->created_at->toDateTimeString(),
|
|
|
-
|
|
|
+ "", "", "","",0,0
|
|
|
];
|
|
|
});
|
|
|
+ $codes = rtrim($codes,",");
|
|
|
+ if ($codes && $append){
|
|
|
+ $sql = <<<SQL
|
|
|
+SELECT H.ORDERNO,SUM(S.GROSSWEIGHT) WEIGHT,SUM(S.QTY) AMOUNT,H.C_ADDRESS1,H.C_DISTRICT,H.C_PROVINCE,H.C_CITY FROM DOC_ORDER_PACKING_SUMMARY S
|
|
|
+LEFT JOIN DOC_ORDER_HEADER H ON S.ORDERNO = H.ORDERNO
|
|
|
+WHERE H.ORDERNO IN ({$codes}) GROUP BY H.ORDERNO,H.C_ADDRESS1,H.C_DISTRICT,H.C_PROVINCE,H.C_CITY
|
|
|
+SQL;
|
|
|
+ foreach (DB::connection("oracle")->select(DB::raw($sql)) as $summary){
|
|
|
+ $list[$map[$summary->orderno]][27] = $summary->c_province;
|
|
|
+ $list[$map[$summary->orderno]][28] = $summary->c_city;
|
|
|
+ $list[$map[$summary->orderno]][29] = $summary->c_district;
|
|
|
+ $list[$map[$summary->orderno]][30] = $summary->c_address1;
|
|
|
+ $list[$map[$summary->orderno]][31] += $summary->weight;
|
|
|
+ $list[$map[$summary->orderno]][32] += $summary->amount;
|
|
|
+ }
|
|
|
+ }
|
|
|
return Export::make($row,$list,"运输记录单-".date("YmdH"));
|
|
|
}
|
|
|
|
|
|
@@ -775,7 +800,7 @@ class WaybillController extends Controller
|
|
|
|
|
|
protected function validatorWaybill(Request $request,$id){
|
|
|
if ($id){$wms_bill_number=$id;};
|
|
|
- $validator=Validator::make($request->input(),[
|
|
|
+ return Validator::make($request->input(),[
|
|
|
'owner_id'=>'required_without:order_id',
|
|
|
'wms_bill_number'=>['nullable','max:50',isset($wms_bill_number)?"unique:waybills,wms_bill_number,$wms_bill_number":'unique:waybills,wms_bill_number'],
|
|
|
'origination'=>'required|max:255',
|
|
|
@@ -804,7 +829,6 @@ class WaybillController extends Controller
|
|
|
'charge'=>'收费',
|
|
|
'collect_fee'=>'到付金额',
|
|
|
]);
|
|
|
- return $validator;
|
|
|
}
|
|
|
protected function validatorWaybillDispatch(Request $request,$id){
|
|
|
$rule=[
|