feat: 修改了CommissionProductLogic类中的计算逻辑,根据用户等级和商品rose值进行不同的计算和存储操作。
This commit is contained in:
parent
b5e2707c3c
commit
58423f1b01
@ -21,48 +21,20 @@ class CommissionProductLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
$product = StoreBranchProduct::where('store_id', $order['store_id'])->where('product_id', $find['product_id'])->find();
|
$product = StoreBranchProduct::where('store_id', $order['store_id'])->where('product_id', $find['product_id'])->find();
|
||||||
if ($product && $product['rose'] > 0) {
|
if ($product && $product['rose'] > 0) {
|
||||||
if ($product['rose'] >= 0 && $product['rose'] < 8) {
|
if(in_array($user_ship,[4, 6, 7])){
|
||||||
$rose = bcdiv($product['rose'], 100, 2);
|
$this->b($find, $order,$product);
|
||||||
$total_price = bcmul($product['purchase'], $find['cart_num']);
|
return true;
|
||||||
$commission = bcmul($total_price, $rose, 2);
|
|
||||||
|
|
||||||
//供货价
|
|
||||||
$total_cost = bcmul($product['cost'], $find['cart_num']);
|
|
||||||
$total = bcsub($total_cost, $total_price, 2);
|
|
||||||
$number = bcsub($total, $commission, 2);
|
|
||||||
if ($product['rose'] <= 4) {
|
|
||||||
//门店
|
|
||||||
$data = [
|
|
||||||
'store_id' => $order['store_id'],
|
|
||||||
'product_id' => $find['product_id'],
|
|
||||||
'number' => $total,
|
|
||||||
'oid' => $order['id'],
|
|
||||||
'type' => 1,
|
|
||||||
'status' => 1,
|
|
||||||
];
|
|
||||||
StoreFinanceFlowProduct::create($data);
|
|
||||||
} else {
|
|
||||||
//门店
|
|
||||||
$data[] = [
|
|
||||||
'store_id' => $order['store_id'],
|
|
||||||
'product_id' => $find['product_id'],
|
|
||||||
'number' => $number,
|
|
||||||
'oid' => $order['id'],
|
|
||||||
'type' => 1,
|
|
||||||
'status' => 1,
|
|
||||||
];
|
|
||||||
//平台
|
|
||||||
$data[] = [
|
|
||||||
'store_id' => $order['store_id'],
|
|
||||||
'product_id' => $find['product_id'],
|
|
||||||
'number' => $commission,
|
|
||||||
'oid' => $order['id'],
|
|
||||||
'type' => 2,
|
|
||||||
'status' => 1,
|
|
||||||
];
|
|
||||||
(new StoreFinanceFlowProduct())->saveAll($data);
|
|
||||||
}
|
}
|
||||||
|
if ($product['rose'] >= 0 && $product['rose'] < 8) {
|
||||||
|
$this->b($find, $order,$product);
|
||||||
} elseif ($product['rose'] >= 8) {
|
} elseif ($product['rose'] >= 8) {
|
||||||
|
$this->a($find, $order, $village_uid, $brigade_uid, $user_ship, $product);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function a($find, $order, $village_uid = 0, $brigade_uid = 0, $user_ship = 0, $product)
|
||||||
|
{
|
||||||
$rose = bcdiv($product['rose'], 100, 2);
|
$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();
|
$Distribution = Distribution::where('rate', $rose)->find();
|
||||||
@ -135,6 +107,48 @@ class CommissionProductLogic extends BaseLogic
|
|||||||
|
|
||||||
(new StoreFinanceFlowProduct())->saveAll($data);
|
(new StoreFinanceFlowProduct())->saveAll($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function b($find, $order, $product)
|
||||||
|
{
|
||||||
|
$rose = bcdiv($product['rose'], 100, 2);
|
||||||
|
$total_price = bcmul($product['purchase'], $find['cart_num']);
|
||||||
|
$commission = bcmul($total_price, $rose, 2);
|
||||||
|
|
||||||
|
//供货价
|
||||||
|
$total_cost = bcmul($product['cost'], $find['cart_num']);
|
||||||
|
$total = bcsub($total_cost, $total_price, 2);
|
||||||
|
$number = bcsub($total, $commission, 2);
|
||||||
|
if ($product['rose'] <= 4) {
|
||||||
|
//门店
|
||||||
|
$data = [
|
||||||
|
'store_id' => $order['store_id'],
|
||||||
|
'product_id' => $find['product_id'],
|
||||||
|
'number' => $total,
|
||||||
|
'oid' => $order['id'],
|
||||||
|
'type' => 1,
|
||||||
|
'status' => 1,
|
||||||
|
];
|
||||||
|
StoreFinanceFlowProduct::create($data);
|
||||||
|
} else {
|
||||||
|
//门店
|
||||||
|
$data[] = [
|
||||||
|
'store_id' => $order['store_id'],
|
||||||
|
'product_id' => $find['product_id'],
|
||||||
|
'number' => $number,
|
||||||
|
'oid' => $order['id'],
|
||||||
|
'type' => 1,
|
||||||
|
'status' => 1,
|
||||||
|
];
|
||||||
|
//平台
|
||||||
|
$data[] = [
|
||||||
|
'store_id' => $order['store_id'],
|
||||||
|
'product_id' => $find['product_id'],
|
||||||
|
'number' => $commission,
|
||||||
|
'oid' => $order['id'],
|
||||||
|
'type' => 2,
|
||||||
|
'status' => 1,
|
||||||
|
];
|
||||||
|
(new StoreFinanceFlowProduct())->saveAll($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user