|
|
@@ -230,13 +230,17 @@ class CustomerController extends Controller
|
|
|
{
|
|
|
if(!Gate::allows('客户管理-项目-面积-编辑')){ return ["success"=>false,'data'=>"无权操作!"]; }
|
|
|
if (!($request->id ?? false) || !($request->area ?? false)) return ["success"=>false,'data'=>"传递错误!"];
|
|
|
- $values = $request->area ?? null;
|
|
|
- if (!$values)return ["success"=>true,"data"=>$values];
|
|
|
- foreach ($values as $column=>$value){
|
|
|
- if ($value && (!is_numeric($value) || $value<0))return ["success"=>false,'data'=>$column."非数字或小于0!"];
|
|
|
- }
|
|
|
- $accounting_area = ((int)$values["area_on_tray"]*2.5) + ((int)$values["area_on_half_tray"]*1.8) + ((int)$values["area_on_flat"]*1.3);
|
|
|
- $values["accounting_area"] = $accounting_area;
|
|
|
+
|
|
|
+ if (!request("accounting_area")){
|
|
|
+ $values = $request->area ?? null;
|
|
|
+ if (!$values)return ["success"=>true,"data"=>$values];
|
|
|
+ foreach ($values as $column=>$value){
|
|
|
+ if ($value && (!is_numeric($value) || $value<0))return ["success"=>false,'data'=>$column."非数字或小于0!"];
|
|
|
+ }
|
|
|
+ $accounting_area = ((int)$values["area_on_tray"]*2.5) + ((int)$values["area_on_half_tray"]*1.8) + ((int)$values["area_on_flat"]*1.3);
|
|
|
+ $values["accounting_area"] = $accounting_area;
|
|
|
+ }else $values = ["accounting_area"=>request("accounting_area")];
|
|
|
+
|
|
|
$row = app('OwnerAreaReportService')->update(["id"=>$request->id],$values);
|
|
|
if ($row==1){
|
|
|
LogService::log(__METHOD__,"客户管理-修改面积",json_encode($request->input()));
|
|
|
@@ -480,7 +484,7 @@ class CustomerController extends Controller
|
|
|
$owners = $service->get(["id"=>$ids],["ownerStoragePriceModels"],false,true);
|
|
|
app("OwnerAreaReportService")->notExistToInsert($owners);
|
|
|
|
|
|
- $reports = OwnerAreaReport::query()
|
|
|
+ $reports = OwnerAreaReport::query()->with(["owner","ownerStoragePriceModel.unit"])
|
|
|
->where("counting_month",">=",date("Y-m")."-01")
|
|
|
->whereIn("owner_id",array_column($owners->toArray(),"id"))->get();
|
|
|
$result = [];
|
|
|
@@ -497,6 +501,7 @@ class CustomerController extends Controller
|
|
|
"accountingArea" => $report->accounting_area,
|
|
|
"status" => $report->status,
|
|
|
"updatedAt" => $report->updated_at,
|
|
|
+ "unitName" => $report->ownerStoragePriceModel ? ($report->ownerStoragePriceModel->unit ? $report->ownerStoragePriceModel->unit->name : '') : '',
|
|
|
"ownerStoragePriceModel"=> $report->ownerStoragePriceModel ? $report->ownerStoragePriceModel->using_type : '' ,
|
|
|
];
|
|
|
}
|