|
|
@@ -178,13 +178,39 @@ class TestController extends Controller
|
|
|
|
|
|
return array(null,null);
|
|
|
}
|
|
|
- public function restoreWaybill()
|
|
|
+ public function restoreAreaReport()
|
|
|
{
|
|
|
ini_set('max_execution_time', 2500);
|
|
|
- $waybills = Waybill::query()->whereNotNull("wms_bill_number")->whereNull("order_id")->get();
|
|
|
- foreach ($waybills as $waybill){
|
|
|
- $order = Order::query()->where("code",$waybill->wms_bill_number)->first();
|
|
|
- if ($order)$waybill->update(["order_id"=>$order->id]);
|
|
|
+ foreach (Owner::query()->get() as $owner) {
|
|
|
+ if (!$owner->ownerStoragePriceModels) continue;
|
|
|
+ foreach ($owner->ownerStoragePriceModels as $model) {
|
|
|
+ $report = OwnerAreaReport::query()
|
|
|
+ ->where("counting_month", ">=", date("Y-m") . "-01")
|
|
|
+ ->where("owner_id", $owner->id)
|
|
|
+ ->where("owner_storage_price_model_id", $model->id)->first();
|
|
|
+ if (!$report) {
|
|
|
+ OwnerAreaReport::query()->create([
|
|
|
+ "owner_id" => $owner->id,
|
|
|
+ "counting_month" => date('Y-m-d'),
|
|
|
+ "user_owner_group_id" => $owner->user_owner_group_id,
|
|
|
+ "created_at" => date('Y-m-d H:i:s'),
|
|
|
+ "owner_storage_price_model_id" => $model->id,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ $report = OwnerAreaReport::query()
|
|
|
+ ->where("counting_month", ">=", "2021-03-01")
|
|
|
+ ->where("owner_id", $owner->id)
|
|
|
+ ->where("owner_storage_price_model_id", $model->id)->first();
|
|
|
+ if (!$report) {
|
|
|
+ OwnerAreaReport::query()->create([
|
|
|
+ "owner_id" => $owner->id,
|
|
|
+ "counting_month" => "2021-03-01",
|
|
|
+ "user_owner_group_id" => $owner->user_owner_group_id,
|
|
|
+ "created_at" => date('Y-m-d H:i:s'),
|
|
|
+ "owner_storage_price_model_id" => $model->id,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
public function restoreBatch()
|