Merge pull request !246 from 杨建炊/fix-release-1.0.0/yjc-migrate
This commit is contained in:
杨建炊 2024-11-11 02:54:54 +00:00 committed by Gitee
commit d6fadaae1e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 12 additions and 5 deletions

View File

@ -72,7 +72,7 @@ class BusinessOrdersUpdate
$updateParam['status'] = GoodsSku::$STATUS_ON_SALE; $updateParam['status'] = GoodsSku::$STATUS_ON_SALE;
} }
Log::info("sku 业务订单库存更:{$this->goodsSku->id}", $updateParam); Log::info("sku 业务订单库存更:{$this->goodsSku->id},num:{$this->num}", [$updateParam, (array)$this->goodsSku]);
//乐观锁更新 //乐观锁更新
return GoodsSku::query()->where('external_sku_id', $this->businessGoodSku['external_sku_id'])-> return GoodsSku::query()->where('external_sku_id', $this->businessGoodSku['external_sku_id'])->
where("stock", "=", $oldStock)->update($updateParam); where("stock", "=", $oldStock)->update($updateParam);

View File

@ -224,6 +224,7 @@ class ShopsController extends Controller
->get() ->get()
->toArray(); ->toArray();
$business->batchIncrQuantity($businessGoodsSkus, $stock, false); $business->batchIncrQuantity($businessGoodsSkus, $stock, false);
usleep(10);
} }
} }

View File

@ -42,7 +42,13 @@ class DailyStockRecordController extends Controller
$query->where('external_sku_id', '=', $request->external_sku_id); $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); return JsonResource::collection($dailyStockRecord);
} }
@ -71,7 +77,7 @@ class DailyStockRecordController extends Controller
]; ];
return response($this->res, $this->res['httpCode']); 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 = new GoodSkuService();
$goodSkuService->inventory([$goodsSkuWithInventory]); $goodSkuService->inventory([$goodsSkuWithInventory]);
@ -94,7 +100,7 @@ class DailyStockRecordController extends Controller
$this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); $this->setValidatorFailResponse($validator->getMessageBag()->getMessages());
return response($this->res, $this->res['httpCode']); 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)) $goodsSkus = GoodsSku::query()->with("combinationGoods")->whereIn('external_sku_id', array_keys($inventoryKeyByExternalSkuIdMap))
->get()->toArray(); ->get()->toArray();
$goodsSkus = collect($goodsSkus)->map(function ($v) use ($inventoryKeyByExternalSkuIdMap) { $goodsSkus = collect($goodsSkus)->map(function ($v) use ($inventoryKeyByExternalSkuIdMap) {
@ -103,7 +109,7 @@ class DailyStockRecordController extends Controller
return $v; return $v;
} }
})->toArray(); })->toArray();
Log::info("goodsSkus",$goodsSkus); Log::info("goodsSkus", $goodsSkus);
$goodSkuService = new GoodSkuService(); $goodSkuService = new GoodSkuService();
$goodSkuService->inventory($goodsSkus); $goodSkuService->inventory($goodsSkus);
return response($this->res, $this->res['httpCode']); return response($this->res, $this->res['httpCode']);