diff --git a/app/Http/Controllers/Supplier/DailyStockRecordController.php b/app/Http/Controllers/Supplier/DailyStockRecordController.php index d44c913..c111e9e 100644 --- a/app/Http/Controllers/Supplier/DailyStockRecordController.php +++ b/app/Http/Controllers/Supplier/DailyStockRecordController.php @@ -42,7 +42,13 @@ class DailyStockRecordController extends Controller $query->where('external_sku_id', '=', $request->external_sku_id); }); } - $dailyStockRecord = $build->orderByDesc("id")->paginate($request->get('per_page')); + $start = $request->get("start_time"); + $end = $request->get("end_time"); + $dailyStockRecord = $build->when($start, function ($query) use ($start) { + $query->where("created_at", ">=", $start); + })->when($end, function ($query) use ($end) { + $query->where("created_at", ">=", $end); + })->orderByDesc("id")->paginate($request->get('per_page')); return JsonResource::collection($dailyStockRecord); } @@ -71,7 +77,7 @@ class DailyStockRecordController extends Controller ]; return response($this->res, $this->res['httpCode']); } - $goodsSkuWithInventory = array_merge($goodsSku->toArray(),["inventory"=>$request->inventory]); + $goodsSkuWithInventory = array_merge($goodsSku->toArray(), ["inventory" => $request->inventory]); //同批量逻辑操作 $goodSkuService = new GoodSkuService(); $goodSkuService->inventory([$goodsSkuWithInventory]); @@ -94,7 +100,7 @@ class DailyStockRecordController extends Controller $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); return response($this->res, $this->res['httpCode']); } - $inventoryKeyByExternalSkuIdMap = collect($request->inventoryOrders)->pluck(null,"external_sku_id")->toArray(); + $inventoryKeyByExternalSkuIdMap = collect($request->inventoryOrders)->pluck(null, "external_sku_id")->toArray(); $goodsSkus = GoodsSku::query()->with("combinationGoods")->whereIn('external_sku_id', array_keys($inventoryKeyByExternalSkuIdMap)) ->get()->toArray(); $goodsSkus = collect($goodsSkus)->map(function ($v) use ($inventoryKeyByExternalSkuIdMap) { @@ -103,7 +109,7 @@ class DailyStockRecordController extends Controller return $v; } })->toArray(); - Log::info("goodsSkus",$goodsSkus); + Log::info("goodsSkus", $goodsSkus); $goodSkuService = new GoodSkuService(); $goodSkuService->inventory($goodsSkus); return response($this->res, $this->res['httpCode']);