fix(purchase): 修复采购产品报价中产品不存在的问题

- 在查询产品时使用 withTrashed() 方法,以支持查询包括软删除的产品
- 添加异常捕获时的调试输出,便于排查问题
This commit is contained in:
mkm 2025-01-25 10:51:58 +08:00
parent 304e0d3199
commit 26df751c99

View File

@ -60,7 +60,7 @@ class PurchaseProductOfferLogic extends BaseLogic
if ($mark == '') {
$mark = BeforehandOrderCartInfo::where('bhoid', $params['order_id'])->where('product_id', $params['product_id'])->value('mark');
}
$find = StoreProduct::where('id', $params['product_id'])->find();
$find = StoreProduct::where('id', $params['product_id'])->withTrashed()->find();
$purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find();
if ($purchaseProductOffer) {
$purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num'];
@ -104,6 +104,7 @@ class PurchaseProductOfferLogic extends BaseLogic
return true;
} catch (\Exception $e) {
Db::rollback();
d($e);
throw new BusinessException($e->getMessage());
}
}