修复:经销商平级奖判断错误导致平级奖未成功发放的问题

修复:经销商提成明细中心的经销商等级显示错误(文创等级提现显示的普通经销商等级)
This commit is contained in:
wuhui_zzw 2023-11-24 10:14:01 +08:00
parent 7f22303acb
commit 5ebec37964
4 changed files with 18 additions and 29 deletions

View File

@ -397,7 +397,7 @@ class TeamAgencyController extends BaseController
// $set = \Setting::get('plugin.team_dividend'); // $set = \Setting::get('plugin.team_dividend');
// (new NewUpgrateJob($model->uid, $set, $model->uniacid, TeamDividendLevelUpgrade::ORDER_PAY, $model))->handle(); // (new NewUpgrateJob($model->uid, $set, $model->uniacid, TeamDividendLevelUpgrade::ORDER_PAY, $model))->handle();
// $order = Order::find(87); // $order = Order::find(169);
// $TeamReturnService = ReturnConfig::getClass(); // $TeamReturnService = ReturnConfig::getClass();
// if (app('plugins')->isEnabled('team-sideways')) debug('经销商订单创建终止:team-sideways'); // if (app('plugins')->isEnabled('team-sideways')) debug('经销商订单创建终止:team-sideways');
// $set = $order->getSetting('plugin.team_dividend'); // $set = $order->getSetting('plugin.team_dividend');

View File

@ -29,9 +29,9 @@ class GetAgentsService
$parents = MemberParent::with([ $parents = MemberParent::with([
'hasOneTeam' => function ($team) { 'hasOneTeam' => function ($team) {
$team->with(['hasOneLevel'=>function($query){ $team->with(['hasOneLevel'=>function($query){
$query->select(['id','award_gratitude','award_ratio','dividend_ratio','level_weight']); // $query->select(['id','award_gratitude','award_ratio','dividend_ratio','level_weight']);
},'culturalLevel'=>function($query){ },'culturalLevel'=>function($query){
$query->select(['id','award_gratitude','award_ratio','dividend_ratio','level_weight']); // $query->select(['id','award_gratitude','award_ratio','dividend_ratio','level_weight']);
}]); }]);
} }
])->whereHas('hasOneParentMember') ])->whereHas('hasOneParentMember')

View File

@ -107,7 +107,6 @@ class TeamReturnService
// 额外分红 // 额外分红
$this->extraDividend($agent); $this->extraDividend($agent);
} }
} }
private function totalDividend() private function totalDividend()
@ -179,13 +178,12 @@ class TeamReturnService
// 经销商奖励 // 经销商奖励
private function dividendAward($agent) private function dividendAward($agent)
{ {
//平级跳出 //平级跳出
if ($this->dividend_level_ids[$agent['level']]) { if ($this->dividend_level_ids[$this->dividendType == 1 ? $agent['cultural_level_id'] : $agent['level']]) {
return; return;
} }
// 平级奖处理初始化 // 平级奖处理初始化
$this->dividend_level_ids[$agent['level']]['hierarchy'] = 0; $this->dividend_level_ids[$this->dividendType == 1 ? $agent['cultural_level_id'] : $agent['level']]['hierarchy'] = 0;
$this->hierarchy_uid = $agent['uid']; $this->hierarchy_uid = $agent['uid'];
// 分红比例 // 分红比例
@ -245,21 +243,13 @@ class TeamReturnService
private function hierarchyAward($agent) private function hierarchyAward($agent)
{ {
// 是否开启平级奖 // 是否开启平级奖
if (!$this->set['is_flat_prize']) { if (!$this->set['is_flat_prize']) return;
return;
}
// 商品是否开启平级奖 // 商品是否开启平级奖
if (!$this->amount_service->isHierarchy()) { if (!$this->amount_service->isHierarchy()) return;
return; if ($this->flat_prize_limit) return;
}
if ($this->flat_prize_limit) {
\Log::debug('经销商平级奖限制,取消平级奖', $this->order->id.'_'.$this->order_goods->id.'_'.$agent['uid']);
return;
}
// 经销商奖励层级 经销商等级奖励层级 >= 当前奖励层级 // 经销商奖励层级 经销商等级奖励层级 >= 当前奖励层级
$dividend_level = $this->dividend_level_ids[$agent['level']]; $dividend_level = $this->dividend_level_ids[$this->dividendType == 1 ? $agent['cultural_level_id'] : $agent['level']];
if ($dividend_level == null) { if ($dividend_level == null) {
return; return;
} }
@ -268,6 +258,7 @@ class TeamReturnService
if ($dividend_level && ($award_hierarchy <= $dividend_level['hierarchy'] || $this->hierarchy_uid == $agent['uid'])) { if ($dividend_level && ($award_hierarchy <= $dividend_level['hierarchy'] || $this->hierarchy_uid == $agent['uid'])) {
return; return;
} }
// 平级奖奖励比例 // 平级奖奖励比例
$award_ratio = $this->amount_service->getAwardHierarchyRatio(); $award_ratio = $this->amount_service->getAwardHierarchyRatio();
if (!isset($award_ratio) || $award_ratio <= 0) { if (!isset($award_ratio) || $award_ratio <= 0) {
@ -290,7 +281,7 @@ class TeamReturnService
// 是否开启平级奖下级获得经销商奖励计算方式 // 是否开启平级奖下级获得经销商奖励计算方式
if ($this->set['calculate_formula'] == 1) { if ($this->set['calculate_formula'] == 1) {
$finishPrice = $this->obtainInfos[$agent['level']]; $finishPrice = $this->obtainInfos[$this->dividendType == 1 ? $agent['cultural_level_id'] : $agent['level']];
if (!$finishPrice) { if (!$finishPrice) {
return; return;
} }
@ -367,7 +358,7 @@ class TeamReturnService
} }
// 平级奖层数增加 // 平级奖层数增加
$this->dividend_level_ids[$agent['level']]['hierarchy'] += 1; $this->dividend_level_ids[$this->dividendType == 1 ? $agent['cultural_level_id'] : $agent['level']]['hierarchy'] += 1;
} }
//额外分红 //额外分红
@ -382,12 +373,12 @@ class TeamReturnService
return; return;
} }
if (!$dividend_extra['level_' . $agent['level']]) { if (!$dividend_extra['level_' . ($this->dividendType == 1 ? $agent['cultural_level_id'] : $agent['level'])]) {
return; return;
} }
//计算总获得分红 //计算总获得分红
$dividendData['amount'] = $this->order_goods->total * $dividend_extra['level_' . $agent['level']]; $dividendData['amount'] = $this->order_goods->total * $dividend_extra['level_' . ($this->dividendType == 1 ? $agent['cultural_level_id'] : $agent['level'])];
if($this->dividendType == 1) { if($this->dividendType == 1) {
$agent['cultural_level']['dividend_ratio'] = 1; $agent['cultural_level']['dividend_ratio'] = 1;
@ -430,7 +421,7 @@ class TeamReturnService
} }
$dividendData['member_id'] = $agent['uid']; $dividendData['member_id'] = $agent['uid'];
$dividendData['agent_level'] = $agent['level']; $dividendData['agent_level'] = $this->dividendType == 1 ? $agent['cultural_level_id'] : $agent['level'];
$dividendData['dividend_rate'] = 0; $dividendData['dividend_rate'] = 0;
$dividendData['type'] = 3; $dividendData['type'] = 3;
$dividendData['lower_level_rate'] = $this->finish_ratio; $dividendData['lower_level_rate'] = $this->finish_ratio;
@ -472,7 +463,7 @@ class TeamReturnService
'member_id' => $agent['uid'], 'member_id' => $agent['uid'],
'order_sn' => $this->order->order_sn, 'order_sn' => $this->order->order_sn,
'order_amount' => $this->order->price, 'order_amount' => $this->order->price,
'agent_level' => $agent['level'], 'agent_level' => $this->dividendType == 1 ? $agent['cultural_level_id'] : $agent['level'],
'status' => 0, 'status' => 0,
'create_month' => date('Y-m'), 'create_month' => date('Y-m'),
'settle_days' => $this->set['settle_days'] ?: 0, 'settle_days' => $this->set['settle_days'] ?: 0,
@ -517,7 +508,7 @@ class TeamReturnService
// $this->dividend_level_ids[$agent['level']]['hierarchy'] = 0; // $this->dividend_level_ids[$agent['level']]['hierarchy'] = 0;
// 获得奖励的UID // 获得奖励的UID
$this->award_uid = $agent['uid']; $this->award_uid = $agent['uid'];
$this->obtainInfos[$agent['level']] = $dividend_amount; $this->obtainInfos[$this->dividendType == 1 ? $agent['cultural_level_id'] : $agent['level']] = $dividend_amount;
} }
/** /**

View File

@ -168,9 +168,7 @@
<td> <td>
{{$row['level_name']}} {{$row['level_name']}}
<br> <br>
{{ $row['type_name'] }} {{ $row['type_name'] }} - 比例:{{$row['dividend_rate']}}%</td>
-
比例:{{$row['dividend_rate']}}%</td>
<td>{{$row['order_amount']}}</td> <td>{{$row['order_amount']}}</td>
<td>{{$row['amount']}}</td> <td>{{$row['amount']}}</td>
<td>{{$row['lower_level_rate']}}%</td> <td>{{$row['lower_level_rate']}}%</td>