Ver código fonte

安卓添加按日输入专线费

haozi 4 anos atrás
pai
commit
d15d1e330e

+ 6 - 0
app/Http/ApiControllers/WaybillController.php

@@ -104,6 +104,9 @@ class WaybillController
         $result = Waybill::query()->where("id",$request->input("id"))
         $result = Waybill::query()->where("id",$request->input("id"))
             ->update($request->validated());
             ->update($request->validated());
         if ($result==0)$this->response(false,204,"单据状态发生变化,修改失败");
         if ($result==0)$this->response(false,204,"单据状态发生变化,修改失败");
+//        $startDate = "";
+//        $endDate = "";
+//        $res = ["2021-10-08"=>20,"2021-10-09"=>21];
         $this->response(true);
         $this->response(true);
     }
     }
 
 
@@ -133,6 +136,9 @@ class WaybillController
         $fee        = $request->input("fee");
         $fee        = $request->input("fee");
         if (!$deliverAt || !$fee || !is_numeric($fee) || !$fee<0)
         if (!$deliverAt || !$fee || !is_numeric($fee) || !$fee<0)
             $this->response(false,400,"非法参数或不满足需求");
             $this->response(false,400,"非法参数或不满足需求");
+        $param=array('screenDate'=>$deliverAt,'billing'=>$fee);
+        $waybills=app('waybillService')->dailyBilling($param);
+        if ($waybills===0 || $waybills===1 || !isset($waybills)) $this->response(false);
         $this->response(true);
         $this->response(true);
     }
     }
 }
 }

+ 2 - 1
app/Http/Controllers/WaybillController.php

@@ -1100,7 +1100,8 @@ SQL;
         && !Gate::allows('运输管理-承运商调度')){return ['success'=>false,'message'=>'没有权限'];}
         && !Gate::allows('运输管理-承运商调度')){return ['success'=>false,'message'=>'没有权限'];}
         $dailyBilling=$request->input('param');
         $dailyBilling=$request->input('param');
         $waybills=app('waybillService')->dailyBilling($dailyBilling);
         $waybills=app('waybillService')->dailyBilling($dailyBilling);
-        if ($waybills=='无数据')return ['success'=>false,'message'=>'当前选定发货日期没有任何记录'];
+        if ($waybills===0)return ['success'=>false,'message'=>'请输入相应的发货日期和费用!'];
+        if ($waybills===1)return ['success'=>false,'message'=>'当前选定发货日期没有任何记录'];
         if (!isset($waybills))return ['success'=>false,'message'=>'该日有记录未填写重量'];
         if (!isset($waybills))return ['success'=>false,'message'=>'该日有记录未填写重量'];
         return ['success'=>true,'data'=>$waybills];
         return ['success'=>true,'data'=>$waybills];
     }
     }

+ 6 - 5
app/Services/WaybillService.php

@@ -149,19 +149,20 @@ class WaybillService
         return $waybills->get();
         return $waybills->get();
     }
     }
     public function dailyBilling(array $param){
     public function dailyBilling(array $param){
+        if (($param['screenDate']??false)==false || ($param['billing']??false)==false) return 0; //入参错误
         $waybills = Waybill::query()->with(['owner','logistic','originationCity','destinationCity.parent',
         $waybills = Waybill::query()->with(['owner','logistic','originationCity','destinationCity.parent',
             'uploadFiles','amountUnit','warehouseWeightUnit','carrierWeightUnit','district','order',
             'uploadFiles','amountUnit','warehouseWeightUnit','carrierWeightUnit','district','order',
-            'warehouseWeightUnitOther','carrierWeightUnitOther','carType','uploadFiles','waybillAuditLogs.user'])
+            'warehouseWeightUnitOther','carrierWeightUnitOther','carType','waybillAuditLogs.user'])
             ->selectRaw('waybills.* ,waybill_on_tops.id top_id,waybill_on_tops.remark,waybill_on_tops.updated_at top_update')
             ->selectRaw('waybills.* ,waybill_on_tops.id top_id,waybill_on_tops.remark,waybill_on_tops.updated_at top_update')
             ->leftJoin('waybill_on_tops','waybill_on_tops.waybill_id','=','waybills.id')
             ->leftJoin('waybill_on_tops','waybill_on_tops.waybill_id','=','waybills.id')
             ->whereNull('waybill_on_tops.deleted_at')
             ->whereNull('waybill_on_tops.deleted_at')
             ->orderBy('waybill_on_tops.updated_at','desc')
             ->orderBy('waybill_on_tops.updated_at','desc')
             ->orderBy('waybills.id','desc')
             ->orderBy('waybills.id','desc')
             ->where('waybills.type','专线')
             ->where('waybills.type','专线')
-            ->where('waybills.amount','>',0);
-        if ($param['screenDate'] ?? false)$waybills->where('waybills.deliver_at','like',$param['screenDate'].'%');
-        $waybills = $waybills->get();
-        if ($waybills->isEmpty()) return '无数据';
+            ->where('waybills.amount','>',0)
+            ->where('waybills.deliver_at','like',$param['screenDate'].'%')
+            ->get();
+        if ($waybills->isEmpty()) return 1;//无数据
         foreach ($waybills as $waybill){
         foreach ($waybills as $waybill){
             if (!$waybill['carrier_weight_other'] && !$waybill['carrier_weight']) return null;
             if (!$waybill['carrier_weight_other'] && !$waybill['carrier_weight']) return null;
             if (!$waybill['carrier_weight_other'] || $waybill['carrier_weight_other']<=0) $waybill['carrier_weight_other']=($waybill['carrier_weight']/0.25*100);
             if (!$waybill['carrier_weight_other'] || $waybill['carrier_weight_other']<=0) $waybill['carrier_weight_other']=($waybill['carrier_weight']/0.25*100);