From 665c8e89d2f3c2198ed83fd1cddafe8004686fb4 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 27 Jul 2024 15:55:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=B5=81=E7=A8=8B=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E8=B0=83=E6=95=B4=E4=BA=86=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E5=85=B6=E6=9B=B4=E7=AC=A6=E5=90=88=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionProductLogic.php | 73 +++++++++++---------- app/common/logic/PayNotifyLogic.php | 2 +- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index d580dc0a..ab1597fe 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -17,82 +17,87 @@ class CommissionProductLogic extends BaseLogic /** * 根据毛利率计算 */ - function calculate_product_flow($find,$oid, $store_id, $product_id, $village_uid = 0, $brigade_uid = 0, $uid = 0, $spread_uid = 0) + function calculate_product_flow($find, $order, $village_uid = 0, $brigade_uid = 0, $user_ship = 0) { - $product = StoreBranchProduct::where('store_id', $store_id)->where('product_id', $product_id)->find(); + $product = StoreBranchProduct::where('store_id', $order['store_id'])->where('product_id', $find['product_id'])->find(); if ($product && $product['rose'] > 0) { + if ($order['spread_uid'] > 0) { + $uid = $order['spread_uid']; + } if ($product['rose'] >= 4 && $product['rose'] < 8) { $rose = bcdiv($product['rose'], 100, 2); - $total_price=bcmul($product['purchase'],$find['cart_num']); + $total_price = bcmul($product['purchase'], $find['cart_num']); $commission = bcmul($total_price, $rose, 2); StoreFinanceFlowProduct::create([ - 'store_id' => $store_id, - 'product_id' => $product_id, + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], 'number' => $commission, - 'oid' => $oid, + 'oid' => $order['id'], 'type' => 2, 'status' => 1, ]); } elseif ($product['rose'] >= 8) { $rose = bcdiv($product['rose'], 100, 2); - $total_price=bcmul($product['purchase'],$find['cart_num']); + $total_price = bcmul($product['purchase'], $find['cart_num']); $Distribution = Distribution::where('rate', $rose)->find(); //门店 $data[] = [ - 'store_id' => $store_id, - 'product_id' => $product_id, + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], 'number' => bcmul($total_price, $Distribution['store'], 2), - 'oid' => $oid, + 'oid' => $order['id'], 'type' => 1, 'status' => 1, ]; //平台 $data[] = [ - 'store_id' => $store_id, - 'product_id' => $product_id, - 'number' => bcmul($total_price, $Distribution['platform'],2), - 'oid' => $oid, + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'number' => bcmul($total_price, $Distribution['platform'], 2), + 'oid' => $order['id'], 'type' => 2, 'status' => 1, ]; //村长 $data[] = [ - 'store_id' => $store_id, - 'product_id' => $product_id, + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], 'other_uid' => $village_uid, 'number' => bcmul($total_price, $Distribution['village'], 2), - 'oid' => $oid, + 'oid' => $order['id'], 'type' => 3, 'status' => 1, ]; //队长 $data[] = [ - 'store_id' => $store_id, - 'product_id' => $product_id, + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], 'other_uid' => $brigade_uid, 'number' => bcmul($total_price, $Distribution['brigade'], 2), - 'oid' => $oid, + 'oid' => $order['id'], 'type' => 4, 'status' => 1, ]; //会员 - $data[] = [ - 'store_id' => $store_id, - 'product_id' => $product_id, - 'other_uid' => $uid, - 'number' => bcmul($total_price, $Distribution['user'], 2), - 'oid' => $oid, - 'type' => 0, - 'status' => 1, - ]; - //个人店铺 - if ($spread_uid > 0) { + if ($user_ship == 1) { $data[] = [ - 'store_id' => $store_id, - 'product_id' => $product_id, + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'other_uid' => $uid, + 'number' => bcmul($total_price, $Distribution['user'], 2), + 'oid' => $order['id'], + 'type' => 0, + 'status' => 1, + ]; + } + //个人店铺 + if ($order['spread_uid'] > 0) { + $data[] = [ + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], 'other_uid' => $uid, 'number' => bcmul($total_price, $Distribution['person_store'], 2), - 'oid' => $oid, + 'oid' => $order['id'], 'type' => 5, 'status' => 1, ]; diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index eaef64e9..098835c7 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -646,7 +646,7 @@ class PayNotifyLogic extends BaseLogic $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($v, $order['id'], $order['store_id'], $v['product_id'], $village_uid, $brigade_uid, $order['uid'], $order['spread_uid']); + $comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid,$user_ship); } CommissionLogic::setStore($order,$village_uid, $brigade_uid, $transaction_id); return true;