Quellcode durchsuchen

Merge branch 'yang'

zhouzhendong vor 4 Jahren
Ursprung
Commit
2fa33d74e1
2 geänderte Dateien mit 7 neuen und 2 gelöschten Zeilen
  1. 2 0
      app/Jobs/LaborApplyRecordJob.php
  2. 5 2
      app/Services/LaborApplyService.php

+ 2 - 0
app/Jobs/LaborApplyRecordJob.php

@@ -9,6 +9,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
 use Illuminate\Queue\SerializesModels;
+use Illuminate\Support\Facades\Log;
 
 class LaborApplyRecordJob implements ShouldQueue
 {
@@ -37,6 +38,7 @@ class LaborApplyRecordJob implements ShouldQueue
      */
     public function handle()
     {
+        Log::debug("LaborApplyRecordJob isAppend = " . ($this->isAppend + 1) . "");
         $response = $this->service->allocationLaborToLaborCompany($this->isAppend);
         if (!$response['success']) throw new WarningException($response['error_message']);
     }

+ 5 - 2
app/Services/LaborApplyService.php

@@ -92,11 +92,12 @@ class LaborApplyService
         $warehouses = Warehouse::all();
         //给每个仓库计算分配数据 更改申请状态为指派成功
         foreach ($warehouses as $warehouse) {
-            //查询当日的的申请,将申请的男女工分别加和
+            //根据时间,仓库,状态 查询当日的的申请,将申请的男女工分别加和
             $builder = DB::table('labor_applies')
                 ->selectRaw("sum(man_num) as man_num ,sum(woman_num) as woman_num")
                 ->whereBetween('created_at', [now()->startOfDay(), now()->endOfDay()])
-                ->where('warehouse_id', $warehouse->id);
+                ->where('warehouse_id', $warehouse->id)
+                ->where('status', 1);
             //如果是追加模式
             if ($isAppend) {
                 //只查询最后一次分配后的申请
@@ -154,6 +155,8 @@ class LaborApplyService
                 'exceed_max_labor_num_status' => LaborCompanyDispatch::NOT_EXCEED_MAX_LABOR_NUM,//没有超限额
                 'status' => 1,//创建
                 'warehouse_id' => $warehouse_id,
+                'created_at' => now(),
+                'updated_at' => now(),
             ];
         }
         //分配男工