From 71d9d2eb6cba460f15c78822c81b72763bf5cea0 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Thu, 25 Apr 2024 09:54:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E4=BD=A3=E9=87=91?= =?UTF-8?q?=E5=B0=8F=E4=BA=8E0=E6=97=B6=20=20=E4=BE=9D=E7=84=B6=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E7=9A=84=E4=BD=A3=E9=87=91=E7=BB=93=E7=AE=97=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=20=E4=BF=AE=E5=A4=8D=EF=BC=9A=E7=BB=8F=E9=94=80?= =?UTF-8?q?=E5=95=86=E4=BD=A3=E9=87=91=20=E5=BD=93=E5=89=8D=E4=B8=8B?= =?UTF-8?q?=E7=BA=A7=E7=AD=89=E7=BA=A7=E8=B6=85=E8=BF=87=E4=B8=8A=E7=BA=A7?= =?UTF-8?q?=E6=97=B6=20=E4=B8=8A=E7=BA=A7=E5=B9=B3=E7=BA=A7=E5=A5=96?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/admin/TeamDividendController.php | 14 +++---- .../src/services/TeamReturnService.php | 41 +++++++++---------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/plugins/team-dividend/src/admin/TeamDividendController.php b/plugins/team-dividend/src/admin/TeamDividendController.php index f0f4c144..87279d94 100644 --- a/plugins/team-dividend/src/admin/TeamDividendController.php +++ b/plugins/team-dividend/src/admin/TeamDividendController.php @@ -176,13 +176,13 @@ class TeamDividendController extends BaseController public function test(){ - // date_default_timezone_set("PRC"); - // //订单model - // $model = Order::find(80); - // (new OrderCreatedListener())->handle($model); - // - // - // debug("结束"); + date_default_timezone_set("PRC"); + //订单model + $model = Order::find(84); + (new OrderCreatedListener())->handle($model); + + + debug("结束"); // (new \Yunshop\TeamDividend\services\TimedTaskService)->handle(); diff --git a/plugins/team-dividend/src/services/TeamReturnService.php b/plugins/team-dividend/src/services/TeamReturnService.php index b0365e2d..0acade9f 100644 --- a/plugins/team-dividend/src/services/TeamReturnService.php +++ b/plugins/team-dividend/src/services/TeamReturnService.php @@ -117,7 +117,7 @@ class TeamReturnService private function running() { foreach ($this->agents as $agent) { - \Log::debug(' ***************'.$agent['uid']." 开始处理 ***************"); + // \Log::debug(' ***************'.$agent['uid']." 开始处理 ***************"); $this->amount_service = new GetAmountService($agent, $this->order, $this->order_goods, $this->set, $this->team_goods, $this->finish_ratio, $this->finish_price); //商品分红限制 不计入平级奖层级 不算感恩奖 @@ -214,7 +214,7 @@ class TeamReturnService // 经销商奖励 private function dividendAward($agent) { - \Log::debug(' 经销商奖励 - 开始处理'); + // \Log::debug(' 经销商奖励 - 开始处理'); //平级跳出 if ($this->dividend_level_ids[$agent['level']]) { @@ -222,8 +222,8 @@ class TeamReturnService return; } // 平级奖处理初始化 - // $this->hierarchyHandle($agent); - $this->dividend_level_ids[$agent['level']]['hierarchy'] = 0; + $this->hierarchyHandle($agent); + // $this->dividend_level_ids[$agent['level']]['hierarchy'] = 0; $this->hierarchy_uid = $agent['uid']; // 分红比例 @@ -255,19 +255,21 @@ class TeamReturnService if($currentStagesType == 1) $dividend_amount = (float)sprintf("%.2f",$monthInfo * $this->order_goods->total);// 固定金额 else $dividend_amount = $this->amount_service->getDividendAmount($monthInfo);// 百分比 - if($dividend_amount <= 0) continue; // 月月返 级差处理 if($monthIndex > 0) { $this->monthLvDiffMaxMoney = $dividend_amount; $dividend_amount = sprintf("%.2f", $dividend_amount - $lvDiffReduceMoney); } + // 佣金小于等于0 跳出 + if($dividend_amount <= 0) continue; + // todo 调试中... - if($monthIndex == 0 || $monthIndex == 1) { - \Log::debug("经销商奖励 {$agent['uid']} 金额:{$dividend_amount}"); - } + // if($monthIndex == 0 || $monthIndex == 1) { + // \Log::debug("经销商奖励金额 {$agent['uid']} 金额:{$dividend_amount} 类型:".($monthIndex == 0 ? '立即返' : '月月返')); + // } // 计算基数 @@ -364,7 +366,7 @@ class TeamReturnService // 平级奖奖励层级 $award_hierarchy = $this->amount_service->getAwardHierarchy(); // 平级奖信息存在 并且 (平级奖奖励层级 小于等于 当前层级 或者 平级奖用户和代理用户为同一个人 ) 不参加平级奖 - \Log::debug("平级奖励层级:{$award_hierarchy};当前层级:{$dividend_level['hierarchy']}"); + // \Log::debug("平级奖励层级:{$award_hierarchy};当前层级:{$dividend_level['hierarchy']}"); if ($dividend_level && ($award_hierarchy <= $dividend_level['hierarchy'] || $this->hierarchy_uid == $agent['uid'])) { \Log::debug("平级奖奖励层级小于等于当前层级或者平级奖用户和代理用户为同一个人-不参加平级奖"); return; @@ -387,7 +389,7 @@ class TeamReturnService // } // 佣金处理 - \Log::debug("上一个经销商用户ID {$this->upAgent['uid']}"); + // \Log::debug("上一个经销商用户ID {$this->upAgent['uid']}"); $amountList = TeamDividendModel::where('order_sn',$this->order->order_sn) ->select(['amount','status','expect_thaw_time','reality_thaw_time','month']) ->whereIn('type',[7,8]) @@ -395,7 +397,7 @@ class TeamReturnService ->get() ->toArray(); - \Log::debug("列表内容: ",$amountList); + // \Log::debug("列表内容: ",$amountList); foreach($amountList as $amountIndex => $amountInfo){ // 计算基数 @@ -412,9 +414,9 @@ class TeamReturnService 'month' => $amountInfo['month'] ]; - if($amountIndex == 0 || $amountIndex == 1) { - \Log::debug("经销平级奖奖励 {$agent['uid']} 金额:{$dividendData['dividend_amount']}"); - } + // if($amountIndex == 0 || $amountIndex == 1) { + // \Log::debug("经销平级奖奖励 {$agent['uid']} 金额:{$dividendData['dividend_amount']}"); + // } // 分红 $dividend_model = $this->addDividend($agent, $dividendData); @@ -501,14 +503,14 @@ class TeamReturnService } // 平级奖层数增加 - // $this->hierarchyHandle($agent); - $this->dividend_level_ids[$agent['level']]['hierarchy'] += 1; + $this->hierarchyHandle($agent); + // $this->dividend_level_ids[$agent['level']]['hierarchy'] += 1; } private function hierarchyHandle($agent){ // 平级奖层数增加 修改:等级权重大于等于当前经销商用户 都拿平级奖处理 2024-3-15 foreach($this->team_levels as $levelInfo){ - if($agent['has_one_level']['level_weight'] <= $levelInfo['level_weight']){ + if($agent['has_one_level']['level_weight'] >= $levelInfo['level_weight']){ $levelInfoHierarchy = $this->dividend_level_ids[$levelInfo['id']]; if(is_array($levelInfoHierarchy)){ $this->dividend_level_ids[$levelInfo['id']]['hierarchy'] += 1; @@ -517,9 +519,6 @@ class TeamReturnService } } } - - - } @@ -652,7 +651,7 @@ class TeamReturnService } // 插入 - // if($dividendData['order_sn'] != 'SN2404231906E1F45C') { + // if($dividendData['order_sn'] != 'SN2404250911AEB3F5') { // if($agent['uid'] != 216) { if ($model = TeamDividendModel::create($dividendData)) { // 统计