From 0718d0635b9b9f0019524009fe6fee8c7c0f42ee Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 19 Sep 2024 22:26:48 +0800 Subject: [PATCH] feat(CommissionProductLogic): updated calc logic for prod comm, added loss calc, & updated rel db fields --- app/common/logic/CommissionProductLogic.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index 6fda2101..42772ac1 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -156,12 +156,20 @@ class CommissionProductLogic extends BaseLogic $purchase_price = bcmul($product['purchase'], $find['cart_num'], 2); $price = $product['cost']; + $rose=0; + $rose_price = bcsub($product['cost'], $product['purchase'], 2); + if ($rose_price > 0) { + //利润除于零售 + $price_div = bcdiv($rose_price, $product['cost'], 2); + $rose=bcmul($price_div, 100, 2); + } + $platform_number = 0; $attrition_number = 0; - if ($product['rose'] >= 6) { + if ($rose >= 6) { $platform_number = bcmul($total_price, 0.02, 2); //平台 } - if ($product['rose'] >= 10) { + if ($rose >= 10) { $attrition_number = bcmul($total_price, 0.02, 2); //损耗 } //零售-供货价 @@ -181,10 +189,10 @@ class CommissionProductLogic extends BaseLogic } $data[] =$this->store('商户价门店',$order,$find,$price,$total_price,$store_number,$rate); //平台 - if ($product['rose'] >= 6) { + if ($rose >= 6) { $data[] =$this->platform('商户价平台',$order,$find,$price,$total_price,$platform_number); } - if ($product['rose'] >= 10) { + if ($rose >= 10) { $data[] = $this->attrition('商户价损耗',$order,$find,$price,$total_price,$attrition_number); } (new StoreFinanceFlowProduct())->saveAll($data);