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()
{
try {
[$goodsCode, $skuCode] = explode('_', $this->businessOrderItem['external_sku_id']);
$this->goodsSku = GoodsSku::query()->where('sku_code', $skuCode)
->whereHas('goods', function ($query) use ($goodsCode) {
$query->where('goods_code', $goodsCode);
})
->first();
} catch (\Exception $e) {
return false;
}
if ($this->goodsSku) {
$this->goodsSku->stock += $this->num;
$this->goodsSku->save();