|
@@ -552,27 +552,31 @@ class CustomerController extends Controller
|
|
|
$owner = request("owner");
|
|
$owner = request("owner");
|
|
|
$sql = <<<sql
|
|
$sql = <<<sql
|
|
|
SELECT owner_id,SUM(IFNULL(work_fee,0)) AS work_fee,SUM(IFNULL(logistic_fee,0)) AS logistic_fee
|
|
SELECT owner_id,SUM(IFNULL(work_fee,0)) AS work_fee,SUM(IFNULL(logistic_fee,0)) AS logistic_fee
|
|
|
-FROM owner_fee_details WHERE worked_at LIKE ?
|
|
|
|
|
|
|
+FROM owner_fee_details WHERE worked_at LIKE ? AND ((type = '发货' AND logistic_fee IS NOT NULL AND work_fee IS NOT NULL) OR (type <> '发货' AND work_fee IS NOT NULL))
|
|
|
sql;
|
|
sql;
|
|
|
if ($owner && count($owner)>0){
|
|
if ($owner && count($owner)>0){
|
|
|
$sql.=" AND owner_id IN (''";
|
|
$sql.=" AND owner_id IN (''";
|
|
|
foreach ($owner as $o)$sql .=",'{$o}'";
|
|
foreach ($owner as $o)$sql .=",'{$o}'";
|
|
|
$sql.=")";
|
|
$sql.=")";
|
|
|
}
|
|
}
|
|
|
- $sql .= " AND ((type = '发货' AND logistic_fee IS NOT NULL AND work_fee IS NOT NULL) OR (type <> '发货' AND work_fee IS NOT NULL)) GROUP BY owner_id";
|
|
|
|
|
|
|
+ $sql .= " GROUP BY owner_id";
|
|
|
|
|
|
|
|
$billDetails = DB::select(DB::raw($sql),[$month."%"]);
|
|
$billDetails = DB::select(DB::raw($sql),[$month."%"]);
|
|
|
|
|
|
|
|
- $areas = OwnerAreaReport::query()->with("ownerStoragePriceModel")->where("counting_month","like",$month."%")->get();
|
|
|
|
|
|
|
+ $areas = OwnerAreaReport::query()->with(["ownerStoragePriceModel.timeUnit","ownerStoragePriceModel.taxRate"])->where("counting_month","like",$month."%")->get();
|
|
|
$map = [];
|
|
$map = [];
|
|
|
|
|
+ $mapTax = [];
|
|
|
foreach($areas as $area){
|
|
foreach($areas as $area){
|
|
|
- if (isset($map[$area->owner_id."_".$area->counting_month])){
|
|
|
|
|
|
|
+ $key = $area->owner_id."_".$area->counting_month;
|
|
|
|
|
+ if (isset($map[$key])){
|
|
|
if (!$area->ownerStoragePriceModel)continue;
|
|
if (!$area->ownerStoragePriceModel)continue;
|
|
|
- $map[$area->owner_id."_".$area->counting_month] += app('OwnerStoragePriceModelService')
|
|
|
|
|
|
|
+ list($money,$taxFee) = app('OwnerStoragePriceModelService')
|
|
|
->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
|
|
->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
|
|
|
|
|
+ $map[$key] += $money;
|
|
|
|
|
+ $mapTax[$key] += $taxFee;
|
|
|
}else{
|
|
}else{
|
|
|
if (!$area->ownerStoragePriceModel)continue;
|
|
if (!$area->ownerStoragePriceModel)continue;
|
|
|
- $map[$area->owner_id."_".$area->counting_month] = app('OwnerStoragePriceModelService')
|
|
|
|
|
|
|
+ list($map[$key],$mapTax[$key]) = app('OwnerStoragePriceModelService')
|
|
|
->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
|
|
->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -583,7 +587,7 @@ sql;
|
|
|
$key = $bill->owner_id."_".$month;
|
|
$key = $bill->owner_id."_".$month;
|
|
|
OwnerBillReport::query()->where("owner_id",$bill->owner_id)
|
|
OwnerBillReport::query()->where("owner_id",$bill->owner_id)
|
|
|
->where("counting_month",$month."-01")
|
|
->where("counting_month",$month."-01")
|
|
|
- ->update(["work_fee"=>$bill->work_fee,"logistic_fee"=>$bill->logistic_fee,"storage_fee"=>$map[$key] ?? 0]);
|
|
|
|
|
|
|
+ ->update(["work_fee"=>$bill->work_fee,"logistic_fee"=>$bill->logistic_fee,"storage_fee"=>$map[$key] ?? 0,"storage_tax_fee" => $mapTax[$key] ?? 0]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$this->success();
|
|
$this->success();
|