From 6d6374db717bfb2e484bc07b415ac6888e154d75 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 26 Jul 2024 16:00:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9CommissionProductLogi?= =?UTF-8?q?c=E5=92=8CPayNotifyLogic=E7=B1=BB=E4=BB=A5=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=B5=81=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionProductLogic.php | 19 ++++++++++--------- app/common/logic/PayNotifyLogic.php | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index 561dd3e7..d580dc0a 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -17,13 +17,14 @@ class CommissionProductLogic extends BaseLogic /** * 根据毛利率计算 */ - function calculate_product_flow($oid, $store_id, $product_id, $village_uid = 0, $brigade_uid = 0, $uid = 0, $spread_uid = 0) + function calculate_product_flow($find,$oid, $store_id, $product_id, $village_uid = 0, $brigade_uid = 0, $uid = 0, $spread_uid = 0) { $product = StoreBranchProduct::where('store_id', $store_id)->where('product_id', $product_id)->find(); if ($product && $product['rose'] > 0) { if ($product['rose'] >= 4 && $product['rose'] < 8) { $rose = bcdiv($product['rose'], 100, 2); - $commission = bcmul($product['purchase'], $rose, 2); + $total_price=bcmul($product['purchase'],$find['cart_num']); + $commission = bcmul($total_price, $rose, 2); StoreFinanceFlowProduct::create([ 'store_id' => $store_id, 'product_id' => $product_id, @@ -34,13 +35,13 @@ class CommissionProductLogic extends BaseLogic ]); } elseif ($product['rose'] >= 8) { $rose = bcdiv($product['rose'], 100, 2); - + $total_price=bcmul($product['purchase'],$find['cart_num']); $Distribution = Distribution::where('rate', $rose)->find(); //门店 $data[] = [ 'store_id' => $store_id, 'product_id' => $product_id, - 'number' => bcmul($product['purchase'], $Distribution['store'], 2), + 'number' => bcmul($total_price, $Distribution['store'], 2), 'oid' => $oid, 'type' => 1, 'status' => 1, @@ -49,7 +50,7 @@ class CommissionProductLogic extends BaseLogic $data[] = [ 'store_id' => $store_id, 'product_id' => $product_id, - 'number' => bcmul($product['purchase'], $Distribution['platform'],2), + 'number' => bcmul($total_price, $Distribution['platform'],2), 'oid' => $oid, 'type' => 2, 'status' => 1, @@ -59,7 +60,7 @@ class CommissionProductLogic extends BaseLogic 'store_id' => $store_id, 'product_id' => $product_id, 'other_uid' => $village_uid, - 'number' => bcmul($product['purchase'], $Distribution['village'], 2), + 'number' => bcmul($total_price, $Distribution['village'], 2), 'oid' => $oid, 'type' => 3, 'status' => 1, @@ -69,7 +70,7 @@ class CommissionProductLogic extends BaseLogic 'store_id' => $store_id, 'product_id' => $product_id, 'other_uid' => $brigade_uid, - 'number' => bcmul($product['purchase'], $Distribution['brigade'], 2), + 'number' => bcmul($total_price, $Distribution['brigade'], 2), 'oid' => $oid, 'type' => 4, 'status' => 1, @@ -79,7 +80,7 @@ class CommissionProductLogic extends BaseLogic 'store_id' => $store_id, 'product_id' => $product_id, 'other_uid' => $uid, - 'number' => bcmul($product['purchase'], $Distribution['user'], 2), + 'number' => bcmul($total_price, $Distribution['user'], 2), 'oid' => $oid, 'type' => 0, 'status' => 1, @@ -90,7 +91,7 @@ class CommissionProductLogic extends BaseLogic 'store_id' => $store_id, 'product_id' => $product_id, 'other_uid' => $uid, - 'number' => bcmul($product['purchase'], $Distribution['person_store'], 2), + 'number' => bcmul($total_price, $Distribution['person_store'], 2), 'oid' => $oid, 'type' => 5, 'status' => 1, diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 4f2258d0..79c15e22 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -645,10 +645,10 @@ class PayNotifyLogic extends BaseLogic } } } - $info = StoreOrderCartInfo::where('oid',$order['id'])->field('store_id,product_id')->select(); + $info = StoreOrderCartInfo::where('oid',$order['id'])->field('store_id,product_id,cart_num')->select(); $comm=new CommissionProductLogic(); foreach ($info as $v) { - $comm->calculate_product_flow($order['id'],$order['store_id'],$v['product_id'],$village_uid,$brigade_uid,$order['uid'],$order['spread_uid']); + $comm->calculate_product_flow($v,$order['id'],$order['store_id'],$v['product_id'],$village_uid,$brigade_uid,$order['uid'],$order['spread_uid']); } switch ($user_ship) { case 1: // 厨师