user = $this->getUser(); // 股东信息 $this->shareholder = ShareholderUserModel::detail($this->user['user_id'],['user','grade']); // 股东设置 $this->setting = Setting::getAll(); // 分销商用户信息 $this->agent = AgentUserModel::detail($this->user['user_id']); } /** * 股东中心 */ public function center() { //如果不是股东,列出条件 by lyzflash $is_shareholder = $this->isShareholderUser(); if (!$is_shareholder){ if ( (new ShareholderApplyModel)->becomeShareholderByTeam($this->user['user_id'],110,$this->user['app_id'])){ // 股东信息 $this->shareholder = ShareholderUserModel::detail($this->user['user_id'],['user','grade']); //如果不是股东,列出条件 by lyzflash $is_shareholder = $this->isShareholderUser(); } } $setting = $this->setting['basic']['values']; $agent_total = $agent_money = $team_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']; } // 累计团队业绩 if ($setting['become'] == '70') { $team_money = TeamOrder::getOrderAllPrice($this->user['user_id']); // 如果计算自己的业绩 if ($setting['self_buy_money'] == '1') { $team_money += $this->user['expend_money']; //log_write($team_money); } } // 购买商品 $productList = []; if ($setting['become'] == '100') { if ($setting['become__buy_product_ids']) { $productList = (new ProductModel)->getListByIds($setting['become__buy_product_ids']); } } return $this->renderSuccess('', [ // 当前是否为分销商 'is_agent' => $this->isAgentUser(), // 当前是否为股东 'is_shareholder' => $is_shareholder, // 当前是否在申请中 'is_applying' => ShareholderApplyModel::isApplying($this->user['user_id']), // 当前用户信息 'user' => $this->user, // 股东用户信息 'shareholder' => $this->shareholder, // 背景图 'background' => $this->setting['background']['values']['index'], //权益说明 'description_pic' => $this->setting['background']['values']['description'], // 页面文字 'words' => $this->setting['words']['values'], //'shareholdernum'=>count($user_ids), // 下级分销商总数 'agent_total' => $agent_total, // 累计佣金 'agent_money' => $agent_money, // 累计团队业绩 'team_money' => $team_money, 'setting' => $setting, 'productList' => $productList ]); } /** * 股东申请状态 */ public function apply($platform= '') { return $this->renderSuccess('', [ // 当前是否为股东 'is_shareholder' => $this->isShareholderUser(), // 当前是否在申请中 'is_applying' => ShareholderApplyModel::isApplying($this->user['user_id']), // 背景图 'background' => $this->setting['background']['values']['apply'], //权益说明 'description' => $this->setting['background']['values']['description'], // 页面文字 'words' => $this->setting['words']['values'], // 申请协议 'license' => $this->setting['license']['values']['license'], // 如果来源是小程序, 则获取小程序订阅消息id.获取售后通知. 'template_arr' => MessageModel::getMessageByNameArr($platform, ['shareholder_apply_user']), ]); } /** * 股东提现信息 */ public function cash($platform = '') { // 如果来源是小程序, 则获取小程序订阅消息id.获取售后通知. $template_arr = MessageModel::getMessageByNameArr($platform, ['shareholder_cash_user']); return $this->renderSuccess('', [ // 股东用户信息 'shareholder' => $this->shareholder, // 结算设置 'settlement' => $this->setting['settlement']['values'], // 背景图 'background' => $this->setting['background']['values']['cash_apply'], // 页面文字 'words' => $this->setting['words']['values'], // 小程序消息 'template_arr' => $template_arr ]); } /** * 当前用户是否为股东 */ private function isShareholderUser() { return !!$this->shareholder && !$this->shareholder['is_delete']; } /** * 当前用户是否为分销商 */ private function isAgentUser() { return !!$this->agent && !$this->agent['is_delete']; } }