|  | @@ -10,6 +10,7 @@ use think\Db;
 | 
	
		
			
				|  |  |  use app\common\controller\RedisLeaderboard;
 | 
	
		
			
				|  |  |  use Redis;
 | 
	
		
			
				|  |  |  use GatewayClient\Gateway;
 | 
	
		
			
				|  |  | +use think\Exception;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * 会员中心接口
 | 
	
	
		
			
				|  | @@ -1015,4 +1016,83 @@ class UserCenter extends Common
 | 
	
		
			
				|  |  |              $this->error($e->getMessage());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 邀请详情
 | 
	
		
			
				|  |  | +     * @return void
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public function inviteInfo()
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            $userId = $this->auth->id;
 | 
	
		
			
				|  |  | +            $field = 'id,invite_no';
 | 
	
		
			
				|  |  | +            $where['id'] = $userId;
 | 
	
		
			
				|  |  | +            $user = model('User')->field($field)->where($where)->find();
 | 
	
		
			
				|  |  | +            $inviteNo = isset($user['invite_no']) ? $user['invite_no'] : '';
 | 
	
		
			
				|  |  | +            $todayNow = day_now();
 | 
	
		
			
				|  |  | +            $todayStart = $todayNow[0];
 | 
	
		
			
				|  |  | +            $todayEnd = $todayNow[1]+1;
 | 
	
		
			
				|  |  | +            $userMoneyLogWhere['user_id'] = $userId;
 | 
	
		
			
				|  |  | +            $userMoneyLogWhere['type'] = 15;
 | 
	
		
			
				|  |  | +            $appendWhere['createtime'] = [['egt', $todayStart],['lt', $todayEnd],'and'];
 | 
	
		
			
				|  |  | +            $todayMoney = model('UserMoneyLog')->where($userMoneyLogWhere)->where($appendWhere)->sum('value');
 | 
	
		
			
				|  |  | +            $totalMoney = model('UserMoneyLog')->where($userMoneyLogWhere)->sum('value');
 | 
	
		
			
				|  |  | +            //本周
 | 
	
		
			
				|  |  | +            $weekNow = week_now();
 | 
	
		
			
				|  |  | +            $userInviteWhere['user_id'] = $userId;
 | 
	
		
			
				|  |  | +            $userInviteAppendWhere['createtime'] = [['egt', $weekNow[0]],['lt', $weekNow[1]+1],'and'];
 | 
	
		
			
				|  |  | +            $userInviteModel = model('UserInvite');
 | 
	
		
			
				|  |  | +            $weekNowNum = $userInviteModel->where($userInviteWhere)->where($userInviteAppendWhere)->count();
 | 
	
		
			
				|  |  | +            //上周
 | 
	
		
			
				|  |  | +            $lastWeek = last_week();
 | 
	
		
			
				|  |  | +            $appendLastWhere['createtime'] = [['egt', $lastWeek[0]],['lt', $lastWeek[1]+1],'and'];
 | 
	
		
			
				|  |  | +            $lastWeekNum = $userInviteModel->where($userInviteWhere)->where($appendLastWhere)->count();
 | 
	
		
			
				|  |  | +            //全部
 | 
	
		
			
				|  |  | +            $totalNum = $userInviteModel->where($userInviteWhere)->count();
 | 
	
		
			
				|  |  | +            $result = [
 | 
	
		
			
				|  |  | +                'invite_no' => $inviteNo,//邀请码
 | 
	
		
			
				|  |  | +                'today_money' => $todayMoney,//今日收益
 | 
	
		
			
				|  |  | +                'total_money' => $totalMoney,//总收益
 | 
	
		
			
				|  |  | +                'week_now_num' => $weekNowNum,//本周邀请数
 | 
	
		
			
				|  |  | +                'last_week_num' => $lastWeekNum,//上周邀请数
 | 
	
		
			
				|  |  | +                'total_num' => $totalNum,//总邀请数
 | 
	
		
			
				|  |  | +            ];
 | 
	
		
			
				|  |  | +            $this->success('获取成功',$result);
 | 
	
		
			
				|  |  | +        } catch (Exception $e) {
 | 
	
		
			
				|  |  | +            $this->error($e->getMessage());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 邀请列表
 | 
	
		
			
				|  |  | +     * @return void
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public function inviteList()
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            $userId = $this->auth->id;
 | 
	
		
			
				|  |  | +            $where['user_id'] = $userId;
 | 
	
		
			
				|  |  | +            $userInvite = model('UserInvite')->where($where)->with(['user'=>function($uQuery){
 | 
	
		
			
				|  |  | +                $uQuery->field('id,avatar,u_id,nickname');
 | 
	
		
			
				|  |  | +            }])->autopage()->order('createtime desc')->select();
 | 
	
		
			
				|  |  | +            $result = [];
 | 
	
		
			
				|  |  | +            if (!empty($userInvite)) {
 | 
	
		
			
				|  |  | +                foreach ($userInvite as $key => $value) {
 | 
	
		
			
				|  |  | +                    $user = isset($value['user']) ? $value['user'] : [];
 | 
	
		
			
				|  |  | +                    $temp = [
 | 
	
		
			
				|  |  | +                        'user_id'          => isset($user['id']) ? $user['id'] : 0,
 | 
	
		
			
				|  |  | +                        'u_id'             => isset($user['u_id']) ? $user['u_id'] : 0,
 | 
	
		
			
				|  |  | +                        'avatar'           => isset($user['avatar']) ? $user['avatar'] : 0,
 | 
	
		
			
				|  |  | +                        'nickname'         => isset($user['nickname']) ? $user['nickname'] : 0,
 | 
	
		
			
				|  |  | +                        'create_time_text' => !empty($value['createtime']) ? date('Y-m-d', $value['createtime']) : '',
 | 
	
		
			
				|  |  | +                    ];
 | 
	
		
			
				|  |  | +                    $result[] = $temp;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            $this->success('获取成功',$result);
 | 
	
		
			
				|  |  | +        } catch (Exception $e) {
 | 
	
		
			
				|  |  | +            $this->error($e->getMessage());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |