feat: 修改CommissionProductLogic和PayNotifyLogic类以计算商品流通
This commit is contained in:
parent
a92f33d490
commit
6d6374db71
@ -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,
|
||||
|
@ -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: // 厨师
|
||||
|
Loading…
x
Reference in New Issue
Block a user