|
|
@@ -10,6 +10,7 @@ use App\Http\Requests\Api\WaybillDispatch;
|
|
|
use App\Services\WaybillService;
|
|
|
use App\Waybill;
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
class WaybillController
|
|
|
{
|
|
|
@@ -72,11 +73,16 @@ class WaybillController
|
|
|
if ($deliverAt)$query->where("deliver_at","like",$deliverAt."%");
|
|
|
/** @var Collection $waybills */
|
|
|
$waybills = $query->paginate($paginate,'*', 'page',$page)->append(["carrier_name","amount_unit_name","remove_relation"]);
|
|
|
- $result = null;
|
|
|
+ $result = [];
|
|
|
if ($waybills->count()>0){
|
|
|
$startDate = substr($waybills->first()->deliver_at,0,10);
|
|
|
$endDate = substr($waybills->last()->deliver_at,0,10);
|
|
|
- $result = ["2021-10-08"=>2];
|
|
|
+ $sql = <<<sql
|
|
|
+select sum(pick_up_fee) sum,date_format(deliver_at, '%Y-%m-%d') date from waybills where deliver_at between '{$startDate}' and '{$endDate}' group by date
|
|
|
+sql;
|
|
|
+ foreach (DB::select(DB::raw($sql)) as $item){
|
|
|
+ $result[$item->date] = $item->sum!==null ? (double)$item->sum : 0.0;
|
|
|
+ }
|
|
|
}
|
|
|
$this->response(["waybills"=>$waybills,"mapping"=>$result]);
|
|
|
}
|
|
|
@@ -146,7 +152,7 @@ class WaybillController
|
|
|
if (!$deliverAt || !$fee || !is_numeric($fee) || !$fee<0)
|
|
|
$this->response(false,400,"非法参数或不满足需求");
|
|
|
$param=array('screenDate'=>$deliverAt,'billing'=>$fee);
|
|
|
- $waybills=app('waybillService')->dailyBilling($param);
|
|
|
+ $waybills=app('waybillService')->dailyBilling($param,true);
|
|
|
if ($waybills===0 || $waybills===1 || !isset($waybills)) $this->response(false);
|
|
|
$this->response(true);
|
|
|
}
|