|
|
|
@ -106,13 +106,11 @@ class CommissionScoreLog |
|
|
|
|
//1.非用户角色下单立即反积分 |
|
|
|
|
if ($initLevel > self::LEVEL_1 && $currentCommissionLevel == 1) { |
|
|
|
|
$amount = bcsub($order['goods_price'], $current_level_price, 2); |
|
|
|
|
|
|
|
|
|
$amount = bcmul($amount, $order['goods_num'], 2); |
|
|
|
|
//算积分 |
|
|
|
|
Wallet::change($currentAgent->user->id, 'score', $amount, 'back_score', [], '下单返现'); |
|
|
|
|
//如果没有上级 给公司账户返积分 |
|
|
|
|
if(empty($parentUserId)) { |
|
|
|
|
$this->calcCompany($current_level_price, $company_level_price, $order); |
|
|
|
|
$this->calcCompany($current_level_price, $company_level_price); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -155,7 +153,6 @@ class CommissionScoreLog |
|
|
|
|
\think\Log::info('当前商品价格'.$current_level_price); |
|
|
|
|
if (!empty($amount) && $amount> 0) { |
|
|
|
|
//算积分 |
|
|
|
|
$amount = bcmul($amount, $order['goods_num'], 2); |
|
|
|
|
Wallet::change($parentAgent->user->id, 'score', $amount, 'team_order', [], '团队下单'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -167,9 +164,8 @@ class CommissionScoreLog |
|
|
|
|
|
|
|
|
|
if ($level5 == 0) { |
|
|
|
|
$amount = bcmul($order['goods_price'], '0.02', 2); |
|
|
|
|
$this->calcCompany($parent_level_price, $company_level_price, $order, $amount); |
|
|
|
|
$this->calcCompany($parent_level_price, $company_level_price, $amount); |
|
|
|
|
//算积分 |
|
|
|
|
$amount = bcmul($amount, $order['goods_num'], 2); |
|
|
|
|
Wallet::change($parentAgent->user->id, 'score', $amount, 'team_order', [], '团队下单'); |
|
|
|
|
} |
|
|
|
|
$level5++; |
|
|
|
@ -188,7 +184,7 @@ class CommissionScoreLog |
|
|
|
|
} else { |
|
|
|
|
//7.只有最后一级是高级时反公司积分 |
|
|
|
|
if ($currentLevel == self::LEVEL_5 && $sonLevel != self::LEVEL_5 && $currentCommissionLevel > 1) { |
|
|
|
|
$this->calcCompany($current_level_price, $company_level_price, $order); |
|
|
|
|
$this->calcCompany($current_level_price, $company_level_price); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -199,13 +195,12 @@ class CommissionScoreLog |
|
|
|
|
* @param $order |
|
|
|
|
* 公司账户算佣金 |
|
|
|
|
*/ |
|
|
|
|
public function calcCompany($currentPrice, $companyPrice, $order, $amountRate = 0) { |
|
|
|
|
public function calcCompany($currentPrice, $companyPrice, $amountRate = 0) { |
|
|
|
|
$amount = bcsub($currentPrice, $companyPrice, 2); |
|
|
|
|
//同级奖励佣金 算差额 |
|
|
|
|
if ($amountRate > 0) { |
|
|
|
|
$amount = bcsub($amount, $amountRate, 2); |
|
|
|
|
} |
|
|
|
|
$amount = bcmul($amount, $order['goods_num'], 2); |
|
|
|
|
Wallet::change(2, 'score', $amount, 'team_order', [], '用户下单'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|