!33 代码优化

Merge pull request !33 from develop
This commit is contained in:
赵世界 2022-08-19 02:55:53 +00:00 committed by Gitee
commit 2f4b148d4c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -34,12 +34,16 @@ class BusinessOrdersUpdate
private function updateStock()
{
[$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();
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();