feat(CommissionProductLogic): deleted file, updated calculation logic for product commission
This commit is contained in:
parent
d6dd96af8c
commit
756031dc1f
400
app/common/logic/CommissionProductLogic copy.php → app/common/logic/CommissionProductLogic22.php
400
app/common/logic/CommissionProductLogic copy.php → app/common/logic/CommissionProductLogic22.php
@ -15,7 +15,7 @@ use support\Log;
|
||||
* 产品佣金计算
|
||||
*
|
||||
*/
|
||||
class CommissionProductLogic extends BaseLogic
|
||||
class CommissionProductLogic22 extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
@ -27,7 +27,7 @@ class CommissionProductLogic extends BaseLogic
|
||||
if ($product) {
|
||||
//活动商品
|
||||
if ($product['product_type'] == 4) {
|
||||
$this->c($find, $order, $village_uid, $brigade_uid, $user_ship, $product);
|
||||
$this->c($find, $order, $product);
|
||||
return true;
|
||||
} else {
|
||||
//种养殖用户判断
|
||||
@ -36,19 +36,22 @@ class CommissionProductLogic extends BaseLogic
|
||||
if ($top_cate_id == 15189) {
|
||||
$this->b($find, $order, $product, $user_ship);
|
||||
return true;
|
||||
}else{
|
||||
$this->a($find, $order, $village_uid, $brigade_uid, $user_ship, $product);
|
||||
return true;
|
||||
}
|
||||
} elseif ($user_ship == 0) {
|
||||
//普通用户判断
|
||||
} elseif ($user_ship == 0||$user_ship == 4) {
|
||||
//普通用户利润全部给门店
|
||||
$this->b($find, $order, $product, $user_ship);
|
||||
return true;
|
||||
} else {
|
||||
//会员用户入口
|
||||
$this->a($find, $order, $village_uid, $brigade_uid, $user_ship, $product);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,7 +61,7 @@ class CommissionProductLogic extends BaseLogic
|
||||
{
|
||||
$total_price = bcmul($product['price'], $find['cart_num'], 2);
|
||||
$purchase_price = bcmul($product['purchase'], $find['cart_num'], 2);
|
||||
$price = $product['purchase'];
|
||||
$price = $product['price'];
|
||||
|
||||
$platform_number = 0; //平台
|
||||
$attrition_number = 0; //损耗
|
||||
@ -70,7 +73,7 @@ class CommissionProductLogic extends BaseLogic
|
||||
$platform_number = bcmul($total_price, 0.02, 2); //平台
|
||||
}
|
||||
if ($product['rose'] >= 12) {
|
||||
$attrition_number = bcmul($total_price, 0.01, 2); //损耗
|
||||
$attrition_number = bcmul($total_price, 0.02, 2); //损耗
|
||||
}
|
||||
//零售-供货价
|
||||
$number3 = bcsub($total_price, $purchase_price, 2);
|
||||
@ -87,115 +90,52 @@ class CommissionProductLogic extends BaseLogic
|
||||
if ($user) {
|
||||
if ($user['user_ship'] == 2) {
|
||||
$village_number = bcmul($total_price, 0.04, 2); //村长利润
|
||||
$data[] = [
|
||||
'nickname' => '零售村长',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => 0,
|
||||
'rate' => 0.04,
|
||||
'number' => $village_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 3,
|
||||
'status' => 1,
|
||||
'is_activity' => 0,
|
||||
];
|
||||
$data[] =$this->village('零售村长', $order, $find, $village_uid, $price, $total_price, $village_number,0.04);
|
||||
$number1 = bcadd($number1, $village_number, 2);
|
||||
} elseif ($user['user_ship'] == 3) {
|
||||
$brigade_number = bcmul($total_price, 0.04, 2); //队长利润
|
||||
$data[] = [
|
||||
'nickname' => '零售队长',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => 0,
|
||||
'rate' => 0.04,
|
||||
'number' => $brigade_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 4,
|
||||
'status' => 1,
|
||||
'is_activity' => 0,
|
||||
];
|
||||
$data[] = $this->brigade('零售队长', $order, $find, $brigade_uid, $price, $total_price, $brigade_number,0.04);
|
||||
$number1 = bcadd($number1, $brigade_number, 2);
|
||||
if ($product['rose'] >= 13 && $village_uid>0) {
|
||||
$village_number = bcmul($total_price, 0.01, 2); //村长利润
|
||||
$data[] =$this->village('零售村长', $order, $find, $village_uid, $price, $total_price, $village_number,0.01);
|
||||
$number1 = bcadd($number1, $village_number, 2);
|
||||
}
|
||||
} elseif ($user['user_ship'] == 1) {
|
||||
$vip_number = bcmul($total_price, 0.06, 2); //会员利润
|
||||
$data[] = [
|
||||
'nickname' => '零售会员',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => $uid,
|
||||
'price' => $price,
|
||||
'total_price' => $purchase_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.06,
|
||||
'number' => $vip_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 0,
|
||||
'status' => 1,
|
||||
];
|
||||
$data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06);
|
||||
$number1 = bcadd($number1, $vip_number, 2);
|
||||
if ($product['rose'] >= 13 && $village_uid>0) {
|
||||
$village_number = bcmul($total_price, 0.01, 2); //村长利润
|
||||
$data[] =$this->village('零售村长', $order, $find, $village_uid, $price, $total_price, $village_number,0.01);
|
||||
$number1 = bcadd($number1, $village_number, 2);
|
||||
}
|
||||
if ($product['rose'] >= 14 && $brigade_uid>0) {
|
||||
$brigade_number = bcmul($total_price, 0.01, 2); //队长利润
|
||||
$data[] =$this->village('零售队长', $order, $find, $village_uid, $price, $total_price, $brigade_number,0.01);
|
||||
$number1 = bcadd($number1, $brigade_number, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
//门店利润
|
||||
if ($number3 <= 0) {
|
||||
$store_number = 0;
|
||||
} else {
|
||||
$number2=bcadd($platform_number, $attrition_number, 2);
|
||||
$store_number = bcsub($number3, bcadd($number1,$number2), 2);
|
||||
$number2 = bcadd($platform_number, $attrition_number, 2);
|
||||
$store_number = bcsub($number3, bcadd($number1, $number2,2), 2);
|
||||
}
|
||||
//门店
|
||||
$data[] = [
|
||||
'nickname' => '零售门店',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0,
|
||||
'number' => $store_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
$rate=0;
|
||||
if($store_number>0){
|
||||
$rate=bcdiv($store_number,$total_price,2);
|
||||
}
|
||||
$data[] =$this->store('零售门店', $order, $find, $price, $total_price,$store_number,$rate);
|
||||
//平台
|
||||
if ($product['rose'] >= 6) {
|
||||
$data[] = [
|
||||
'nickname' => '零售平台',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $purchase_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.02,
|
||||
'number' => $platform_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
$data[] = $this->platform('零售平台', $order, $find, $price, $total_price,$platform_number);
|
||||
}
|
||||
if ($product['rose'] >= 12) {
|
||||
$data[] = [
|
||||
'nickname' => '零售消耗',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $purchase_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.01,
|
||||
'number' => $attrition_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 6,
|
||||
'status' => 1,
|
||||
];
|
||||
$data[] =$this->attrition('零售损耗', $order, $find, $price, $total_price,$attrition_number);
|
||||
}
|
||||
|
||||
(new StoreFinanceFlowProduct())->saveAll($data);
|
||||
@ -206,9 +146,9 @@ class CommissionProductLogic extends BaseLogic
|
||||
*/
|
||||
public function b($find, $order, $product, $user_ship)
|
||||
{
|
||||
$total_price = bcmul($product['price'], $find['cart_num'], 2);
|
||||
$total_price = bcmul($product['cost'], $find['cart_num'], 2);
|
||||
$purchase_price = bcmul($product['purchase'], $find['cart_num'], 2);
|
||||
$price = $product['purchase'];
|
||||
$price = $product['cost'];
|
||||
|
||||
$platform_number = 0;
|
||||
$attrition_number = 0;
|
||||
@ -218,7 +158,6 @@ class CommissionProductLogic extends BaseLogic
|
||||
if ($product['rose'] >= 10) {
|
||||
$attrition_number = bcmul($total_price, 0.02, 2); //损耗
|
||||
}
|
||||
|
||||
//零售-供货价
|
||||
$number3 = bcsub($total_price, $purchase_price, 2);
|
||||
|
||||
@ -230,146 +169,185 @@ class CommissionProductLogic extends BaseLogic
|
||||
$store_number = bcsub($number3, bcadd($platform_number, $attrition_number, 2), 2);
|
||||
}
|
||||
//门店
|
||||
$data[] = [
|
||||
'nickname' => '商户价门店',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0,
|
||||
'number' => $store_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
$rate=0;
|
||||
if($store_number>0){
|
||||
$rate=bcdiv($store_number,$total_price,2);
|
||||
}
|
||||
$data[] =$this->store('商户价门店',$order,$find,$price,$total_price,$store_number,$rate);
|
||||
//平台
|
||||
if ($product['rose'] >= 6) {
|
||||
$data[] = [
|
||||
'nickname' => '商户价平台',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $purchase_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.02,
|
||||
'number' => $platform_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
$data[] =$this->platform('商户价平台',$order,$find,$price,$total_price,$platform_number);
|
||||
}
|
||||
if ($product['rose'] >= 10) {
|
||||
$data[] = [
|
||||
'nickname' => '商户价消耗',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $purchase_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.02,
|
||||
'number' => $attrition_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 6,
|
||||
'status' => 1,
|
||||
];
|
||||
if ($product['rose'] >= 12) {
|
||||
$data[] = $this->attrition('商户价损耗',$order,$find,$price,$total_price,$attrition_number);
|
||||
}
|
||||
(new StoreFinanceFlowProduct())->saveAll($data);
|
||||
}
|
||||
|
||||
//活动商品结算
|
||||
public function c($find, $order, $village_uid, $brigade_uid, $user_ship, $product)
|
||||
public function c($find, $order,$product)
|
||||
{
|
||||
// $rose = bcdiv($product['rose'], 100, 2);
|
||||
$total_price = bcmul($product['price'], $find['cart_num'], 2);
|
||||
$purchase_price = bcmul($product['purchase'], $find['cart_num'], 2);
|
||||
$price = $product['price'];
|
||||
$brigade_number = bcmul($total_price, 0.02, 2); //队长
|
||||
$village_number = bcmul($brigade_number, 0.1, 2); //村长
|
||||
$platform_number = bcmul($total_price, 0.02, 2); //平台
|
||||
|
||||
$number1 = bcadd($brigade_number, $village_number, 2);
|
||||
$number2 = bcadd($number1, $platform_number, 2);
|
||||
$price = $product['purchase'];
|
||||
|
||||
$platform_number = 0;
|
||||
$attrition_number = 0;
|
||||
if ($product['rose'] >= 6) {
|
||||
$platform_number = bcmul($total_price, 0.02, 2); //平台
|
||||
}
|
||||
//零售-供货价
|
||||
$number3 = bcsub($total_price, $purchase_price, 2);
|
||||
|
||||
|
||||
//门店利润
|
||||
if ($number3 <= 0) {
|
||||
$store_number = 0;
|
||||
} else {
|
||||
$store_number = bcsub($number3, $number2, 2);
|
||||
$store_number = bcsub($number3, bcadd($platform_number, $attrition_number, 2), 2);
|
||||
}
|
||||
//门店
|
||||
$rate=0;
|
||||
if($store_number>0){
|
||||
$rate=bcdiv($store_number,$total_price,2);
|
||||
}
|
||||
$data[] =$this->store('商户价门店',$order,$find,$price,$total_price,$store_number,$rate,1);
|
||||
//平台
|
||||
if ($product['rose'] >= 6) {
|
||||
$data[] =$this->platform('商户价平台',$order,$find,$price,$total_price,$platform_number,1);
|
||||
}
|
||||
(new StoreFinanceFlowProduct())->saveAll($data);
|
||||
}
|
||||
|
||||
//队长
|
||||
$data[] = [
|
||||
'nickname' => '活动队长',
|
||||
/**
|
||||
* 村长
|
||||
*/
|
||||
public function village($name, $order, $find, $other_uid, $price, $total_price, $number, $rate = 0.01, $is_activity = 0)
|
||||
{
|
||||
$data = [
|
||||
'nickname' => $name,
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => $brigade_uid,
|
||||
'other_uid' => $other_uid,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => 0,
|
||||
'rate' => $rate,
|
||||
'number' => $number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 3,
|
||||
'status' => 1,
|
||||
'is_activity' => $is_activity,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 队长
|
||||
*/
|
||||
public function brigade($name, $order, $find, $other_uid, $price, $total_price, $number, $rate = 0.01, $is_activity = 0)
|
||||
{
|
||||
$data = [
|
||||
'nickname' => $name,
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => $other_uid,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => $rate,
|
||||
'number' => $number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 4,
|
||||
'status' => 1,
|
||||
'is_activity' => $is_activity,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 平台
|
||||
*/
|
||||
public function platform($name, $order, $find, $price, $total_price, $number, $is_activity = 0)
|
||||
{
|
||||
$data = [
|
||||
'nickname' => $name,
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.02,
|
||||
'number' => $brigade_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 4,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
//村长
|
||||
$data[] = [
|
||||
'nickname' => '活动村长',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => $village_uid,
|
||||
'price' => $price,
|
||||
'total_price' => $brigade_number,
|
||||
'cart_num' => 0,
|
||||
'rate' => 0.01,
|
||||
'number' => $village_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 3,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
//门店
|
||||
$data[] = [
|
||||
'nickname' => '活动门店',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $store_number,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0,
|
||||
'number' => $store_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
//平台
|
||||
$data[] = [
|
||||
'nickname' => '活动平台',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $platform_number,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.02,
|
||||
'number' => $platform_number,
|
||||
'number' => $number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
'is_activity' => $is_activity,
|
||||
];
|
||||
(new StoreFinanceFlowProduct())->saveAll($data);
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 门店
|
||||
*/
|
||||
public function store($name, $order, $find, $price, $total_price, $number,$rate = 0.05, $is_activity = 0)
|
||||
{
|
||||
$data = [
|
||||
'nickname' => $name,
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => $rate,
|
||||
'number' => $number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'is_activity' => $is_activity,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 损耗
|
||||
*/
|
||||
public function attrition($name, $order, $find, $price, $total_price, $number, $is_activity = 0)
|
||||
{
|
||||
$data = [
|
||||
'nickname' => $name,
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.02,
|
||||
'number' => $number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 6,
|
||||
'status' => 1,
|
||||
'is_activity' => $is_activity,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员
|
||||
*/
|
||||
public function vip_user($name, $order, $find, $other_uid,$price, $total_price, $number,$rate = 0.06, $is_activity = 0){
|
||||
$data = [
|
||||
'nickname' => $name,
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => $other_uid,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => $rate,
|
||||
'number' => $number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 0,
|
||||
'status' => $is_activity,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user