feat: #20220819 代码优化

This commit is contained in:
赵世界 2022-08-19 10:54:13 +08:00
parent 622467c64c
commit 5a2ef8745f

View File

@ -34,12 +34,16 @@ class BusinessOrdersUpdate
private function updateStock() private function updateStock()
{ {
try {
[$goodsCode, $skuCode] = explode('_', $this->businessOrderItem['external_sku_id']); [$goodsCode, $skuCode] = explode('_', $this->businessOrderItem['external_sku_id']);
$this->goodsSku = GoodsSku::query()->where('sku_code', $skuCode) $this->goodsSku = GoodsSku::query()->where('sku_code', $skuCode)
->whereHas('goods', function ($query) use ($goodsCode) { ->whereHas('goods', function ($query) use ($goodsCode) {
$query->where('goods_code', $goodsCode); $query->where('goods_code', $goodsCode);
}) })
->first(); ->first();
} catch (\Exception $e) {
return false;
}
if ($this->goodsSku) { if ($this->goodsSku) {
$this->goodsSku->stock += $this->num; $this->goodsSku->stock += $this->num;
$this->goodsSku->save(); $this->goodsSku->save();