refactor(purchase_product_offer): 重构采购产品报价逻辑

- 注释掉 ProductOffer::push($offer) 行,暂时不推送报价信息
- 在 catch 块中添加调试信息输出,便于排查错误
- 修复商户和供货商价格计算逻辑,优化价格计算过程
This commit is contained in:
mkm 2024-12-24 10:47:55 +08:00
parent 71d861dd78
commit b2a3df87c4

View File

@ -221,10 +221,11 @@ class PurchaseProductOfferLogic extends BaseLogic
}else{
$offer['pay_type_name']='没设置';
}
ProductOffer::push($offer);
// ProductOffer::push($offer);
return true;
} catch (\Throwable $e) {
Db::rollback();
d($e);
throw new BusinessException($e->getMessage());
}
}
@ -359,7 +360,7 @@ class PurchaseProductOfferLogic extends BaseLogic
$storeProductGroupPrice = StoreProductGroupPrice::where('product_id', $product['id'])->select()->toArray();
$storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id');
$purchase=0;
foreach ($storeProductGroupPrice as $k => $v) {
foreach ($productCatePriceRate as $k => $v) {
if ($v['id'] == 100001) {
//供货
$data['purchase_lv'] = bcdiv($v['rate'], 100, 2);
@ -368,13 +369,10 @@ class PurchaseProductOfferLogic extends BaseLogic
break;
}
}
foreach ($productCatePriceRate as $k => $v) {
if ($v['id'] == 4 &&$purchase>0) {
//商户
$data['cost_lv'] = bcdiv($v['rate'], 100, 2);
$data['purchase_lv'] = bcdiv($v['rate'], 100, 2);
$purchase=bcmul($purchase, bcadd($data['purchase_lv'], 1, 2), 2);
$data['cost'] = bcmul($purchase, bcadd($data['cost_lv'], 1, 2), 2);
continue;
}elseif ($v['id'] == 100002 &&$purchase>0) {