quanwei
2026-01-17 e1e2fe5710a5b5cd9c19bd3aa99c998a1a613ca8
1
<?php namespace app\api\controller\user; use app\api\controller\Controller; use app\api\model\plus\team\Referee; use app\api\model\plus\team\Setting; use app\api\model\plus\team\User as TeamUserModel; use app\api\model\plus\team\Apply as TeamApplyModel; use app\api\model\settings\Message as MessageModel; use app\common\model\plus\team\Referee as TeamRefereeModel; use app\api\model\plus\agent\User as AgentUserModel; /**  * 分销中心  */ class Team extends Controller {     // 用户     private $user;     // 队长     private $team;     // 分销设置     private $setting;     /**      * 构造方法      */     public function initialize()     {         // 用户信息         $this->user = $this->getUser();         // 队长用户信息         $this->team = TeamUserModel::detail($this->user['user_id'],['user', 'referee','grade']);         // 队长设置         $this->setting = Setting::getAll();         // 分销商用户信息         $this->agent = AgentUserModel::detail($this->user['user_id']);     }     /**      * 队长中心      */     public function center()     {         //如果不是队长,列出条件 by lyzflash         $is_team = $this->isTeamUser();         $setting = $this->setting['basic']['values'];         $agent_total = $agent_money = 0;         //统计下级分销商总数         if ($setting['become'] == '40' && $this->agent) {             $agent_total = $this->agent['first_num'] + $this->agent['second_num']+ $this->agent['third_num'];         }         // 累计佣金         if ($setting['become'] == '50' && $this->agent) {             $agent_money = $this->agent['total_money'];         }         return $this->renderSuccess('', [             // 当前是否为分销商             'is_agent' => $this->isAgentUser(),             // 当前是否为队长             'is_team' => $is_team,             // 当前是否在申请中             'is_applying' => TeamApplyModel::isApplying($this->user['user_id']),             // 当前用户信息             'user' => $this->user,             // 队长用户信息             'team' => $this->team,             // 背景图             'background' => $this->setting['background']['values']['index'],             // 页面文字             'words' => $this->setting['words']['values'],             //'teamnum'=>count($user_ids),             // 下级分销商总数             'agent_total' => $agent_total,             // 累计佣金             'agent_money' => $agent_money,             'setting' => $setting         ]);     }     /**      * 队长申请状态      */     public function apply($referee_id = null, $platform= '')     {         return $this->renderSuccess('', [             // 当前是否为队长             'is_team' => $this->isTeamUser(),             // 当前是否在申请中             'is_applying' => TeamApplyModel::isApplying($this->user['user_id']),             // 背景图             'background' => $this->setting['background']['values']['apply'],             // 页面文字             'words' => $this->setting['words']['values'],             // 申请协议             'license' => $this->setting['license']['values']['license'],             // 如果来源是小程序, 则获取小程序订阅消息id.获取售后通知.             'template_arr' => MessageModel::getMessageByNameArr($platform, ['team_apply_user']),         ]);     }     /**      * 队长提现信息      */     public function cash($platform = '')     {         // 如果来源是小程序, 则获取小程序订阅消息id.获取售后通知.         $template_arr = MessageModel::getMessageByNameArr($platform, ['team_cash_user']);         return $this->renderSuccess('', [             // 队长用户信息             'team' => $this->team,             // 结算设置             'settlement' => $this->setting['settlement']['values'],             // 背景图             'background' => $this->setting['background']['values']['cash_apply'],             // 页面文字             'words' => $this->setting['words']['values'],             // 小程序消息             'template_arr' => $template_arr         ]);     }     /**      * 当前用户是否为队长      */     private function isTeamUser()     {         return !!$this->team && !$this->team['is_delete'];     }     /**      * 当前用户是否为分销商      */     private function isAgentUser()     {         return !!$this->agent && !$this->agent['is_delete'];     } }