input('inviteCode', ''); if (!empty($invite_code)) { $p_member = Member::where([['invite_code','=', $invite_code,'or'],['address','=', $invite_code,'or']])->select(['id', 'address'])->first(); } if (empty($p_member)) { return $this->apiResponseError('member.no_invite'); } $address = request()->input('address', ''); if (empty($address)) { return $this->apiResponseError('地址信息异常'); } $member = Member::where('address', $address)->where('status',1)->select(['id', 'token_str'])->first(); if ($member) { $token_str = PassServer::creatServer()->getMemberToken($member->{'id'}); Member::where('id', $member->{'id'})->update(['token_str' => $token_str]); return $this->apiResponseSuccess('登陆成功', [ 'token' => $token_str]); } else { $ret = MemberServer::creatServer()->register($address, $p_member->{'id'}, '', ''); if (empty($ret)) { return $this->apiResponseError('注册失败'); } else { return $this->apiResponseSuccess('注册成功', $ret); } } } /** * 会员登录 * @return \Illuminate\Http\JsonResponse */ function login() { $mobile = request()->input('address', ''); if (empty($mobile)) { return $this->apiResponseError('地址信息错误'); } $member = Member::where('address', $mobile)->select(['id', 'password', 'encrypt'])->first(); if (empty($member)) { return $this->apiResponseError('当前账户未注册'); } $token_str = PassServer::creatServer()->getMemberToken($member->{'id'}); Member::where('id', $member->{'id'})->update(['token_str' => $token_str]); return $this->apiResponseSuccess('登陆成功', ['token' => $token_str]); } /** * 设置支付密码 * @return \Illuminate\Http\JsonResponse */ function setPayPass() { $password = request()->input('pay_pass', '123456'); $password = str_replace(' ', '', $password); if (empty($password)) { return $this->apiResponseError('请设置登录密码'); } $pass_two = request()->input('pass_two', '123456'); if ($password != $pass_two) { return $this->apiResponseError('两次密码输入不一致'); } if (!is_numeric($password) || strlen($password) != 6) { return $this->apiResponseError('支付密码必须为6为数字'); } $member = Member::where('id', request()->member['id'])->where('status',1)->select(['id', 'password', 'encrypt', 'phone'])->first(); $update=[]; $code = request()->input('code', '1234'); if (empty($code)) { return $this->apiResponseError('请输入验证码'); } $ret = SmsServer::creatServer()->verifyCode($member->{'phone'}, $code, 'set_pay_pass'); if (empty($ret)) { return $this->apiResponseError('验证码错误'); } $pass_server = PassServer::creatServer($password, $member->{'encrypt'}); $new_pass = $pass_server->creatPassword(); $update['pay_pass']=$new_pass['password']; $update['encrypt']=$new_pass['encrypt']; $ret = $member->update($update); if (empty($ret)) { return $this->apiResponseError('支付密码修改失败'); } else { MemberServer::creatServer()->delMemberCache($member->{'id'}); return $this->apiResponseSuccess('支付密码修改成功'); } } function getIconList(){ $mId=request()->member['id']; $totalPrice=0; $totalUsdt=0; $usdtPrice=CommonServer::creatServer()->getConfigValue('usdt'); $luckyPrice=CommonServer::creatServer()->getConfigValue('lucky'); $list=MemberCoins::where('m_id',$mId)->select(['coin_name','coin_id','num','lock_num'])->get(); foreach ($list as $value){ if($value->{'coin_id'}==1){ $value->{'price'}=round(($value->{'num'}+$value->{'lock_num'})*$usdtPrice*$luckyPrice,6); $value->{'totalUsdt'}=round(($value->{'num'}+$value->{'lock_num'})*$luckyPrice,6); }else{ $value->{'price'}=round(($value->{'num'}+$value->{'lock_num'})*$usdtPrice,6); $value->{'totalUsdt'}=round($value->{'num'}+$value->{'lock_num'},6); } $totalPrice+=$value->{'price'}; $totalUsdt+=$value->{'totalUsdt'}; } return $this->apiResponseSuccess('获取信息成功',['totalPrice'=>$totalPrice,'totalUsdt'=>$totalUsdt,'list'=>$list]); } /** * 获取用户资产信息 */ function getMoneyInfo() { $member = Member::where('id', request()->member['id'])->where('status',1)->select(['id', 'money'])->first(); return $this->apiResponseSuccess('获取成功', $member); } /** * 获取会员详情 */ function getMemberInfo() { $m_id = request()->member['id']; $member = RedisDataServer::creatServer()->getData('member_' . $m_id, 'json'); if (empty($member) ) { $member = Member::where('id', $m_id)->select(['id', 'address', 'invite_code', 'level_id'])->first(); if (empty($member)) { return $this->apiResponseError('账户信息错误', 401); } //获取推荐关联信息 if($member->{'level_id'}<=0){ $member->{'levelName'}='V0'; }else{ $member->{'levelName'}=Level::where('id',$member->{'level_id'})->value('name'); } $member->{'recommendNum'}=Member::where('recom_id',$member->{'id'})->count(); $teamIds=MemberClan::where('m_id',$member->{'id'})->value('m_ids'); $teamIds=array_filter(explode(',',$teamIds)); $member->{'teamNum'}=count($teamIds); $member->{'orderNum'}=Contract::where('m_id',$member->{'id'})->whereIn('status',[2,4])->count(); RedisDataServer::creatServer()->setData('member_' . $m_id, $member, 'json', 30); } return $this->apiResponseSuccess('获取信息成功', $member); } /** * 获取推广团队基本信息 * @return \Illuminate\Http\JsonResponse */ function getTeamInfo() { $m_id = request()->member['id']; $member = Member::where('id', $m_id)->select(['id', 'address', 'level_id', 'recom_id'])->first(); $member->{'team_num'} = MemberClan::from('member_clans as c') ->leftJoin('members as m', 'm.id', '=', 'c.m_id') ->where('c.one_m_id', $m_id) ->count(); return $this->apiResponseSuccess('获取数据成功', $member); } /** * 获取团队列表 * @return \Illuminate\Http\JsonResponse */ function getTeamList() { $type = request()->input('type', '1'); $m_id = request()->member['id']; $where = []; if ($type == 1) { $where[] = ['c.one_m_id', $m_id]; } elseif ($type == 2) { $where[] = ['c.two_m_id', $m_id]; } else { $where[] = ['c.one_m_id', '=', $m_id, 'or']; $where[] = ['c.two_m_id', '=', $m_id, 'or']; } $list = MemberClan::from('member_clans as c') ->leftJoin('members as m', 'm.id', '=', 'c.m_id') ->where($where) ->select(['m.id', 'm.address', 'level_id', 'm.created_at']) ->paginate(15); return $this->apiResponseSuccess('获取数据成功', ['total_num' => $list->total(), 'items' => $list->items()]); } }