parent
65c7244380
commit
71d9d2eb6c
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
// 统计
|
||||
|
|
|
|||
Loading…
Reference in New Issue