feat(OrderLogic, PayNotifyLogic): 修改订单和支付逻辑,增加异常捕获和处理,修复了库存更新错误,并优化了相关代码。

This commit is contained in:
mkm 2024-06-23 19:56:55 +08:00
parent 6641010821
commit c6bcec76fa
2 changed files with 9 additions and 5 deletions

View File

@ -446,6 +446,7 @@ class OrderLogic extends BaseLogic
return true;
} catch (\Exception $e) {
Db::rollback();
d($e);
self::setError($e->getMessage());
return false;
}

View File

@ -742,11 +742,14 @@ class PayNotifyLogic extends BaseLogic
'product_id' => $v['product_id'],
]
)->withTrashed()->find();
$updateData[] = [
'id' => $StoreBranchProduct['id'],
'stock' => $StoreBranchProduct['stock'] - $v['cart_num'],
'sales' => ['inc', $v['cart_num']]
];
if($StoreBranchProduct){
$updateData[] = [
'id' => $StoreBranchProduct['id'],
'stock' => $StoreBranchProduct['stock'] - $v['cart_num'],
'sales' => ['inc', $v['cart_num']]
];
}
}
(new StoreBranchProduct())->saveAll($updateData);