feat(OrderLogic, PayNotifyLogic): 修改订单和支付逻辑,增加异常捕获和处理,修复了库存更新错误,并优化了相关代码。
This commit is contained in:
parent
6641010821
commit
c6bcec76fa
@ -446,6 +446,7 @@ class OrderLogic extends BaseLogic
|
|||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
|
d($e);
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -742,11 +742,14 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
'product_id' => $v['product_id'],
|
'product_id' => $v['product_id'],
|
||||||
]
|
]
|
||||||
)->withTrashed()->find();
|
)->withTrashed()->find();
|
||||||
$updateData[] = [
|
if($StoreBranchProduct){
|
||||||
'id' => $StoreBranchProduct['id'],
|
$updateData[] = [
|
||||||
'stock' => $StoreBranchProduct['stock'] - $v['cart_num'],
|
'id' => $StoreBranchProduct['id'],
|
||||||
'sales' => ['inc', $v['cart_num']]
|
'stock' => $StoreBranchProduct['stock'] - $v['cart_num'],
|
||||||
];
|
'sales' => ['inc', $v['cart_num']]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(new StoreBranchProduct())->saveAll($updateData);
|
(new StoreBranchProduct())->saveAll($updateData);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user