| | |
| | | use app\api\logic\UserWithdrawal as LogicUserWithdrawal; |
| | | use app\api\logic\SettlementRecord as LogicSettlementRecord; |
| | | use app\api\logic\UserMoneyLog as LogicUserMoneyLog; |
| | | use think\log; |
| | | |
| | | /** |
| | | * 会员接口 |
| | | */ |
| | | class User extends Api |
| | | { |
| | | protected $noNeedLogin = ['login', 'mobilelogin', 'resetpwd', 'changemobile', 'wxapplogin','bind_mobile_login','register']; |
| | | protected $noNeedLogin = ['GetRecomInviter','login', 'mobilelogin', 'resetpwd', 'changemobile', 'wxapplogin','bind_mobile_login','register']; |
| | | protected $noNeedRight = '*'; |
| | | |
| | | public function _initialize() |
| | |
| | | $mobile = $this->request->post('mobile'); |
| | | $captcha = $this->request->post('captcha'); |
| | | $ismobouth=$this->request->post('ismobouth',false); |
| | | $push_cid=$this->request->post('push_cid',false); |
| | | if (!$mobile || !$captcha) { |
| | | $this->error(__('Invalid parameters')); |
| | | } |
| | |
| | | $user = $this->auth->getUser(); |
| | | $mobile = $this->request->post('mobile'); |
| | | $captcha = $this->request->post('captcha'); |
| | | if (!$mobile || !$captcha) { |
| | | $isyj=$this->request->post('isyj',false); |
| | | if (!$mobile || (!$isyj&&!$captcha)) { |
| | | $this->error(__('Invalid parameters')); |
| | | } |
| | | if (!Validate::regex($mobile, "^1\d{10}$")) { |
| | |
| | | if(empty($wxUser)) $this->error('微信授权信息获取失败'); |
| | | $mobile = $this->request->post('mobile'); |
| | | $captcha = $this->request->post('captcha'); |
| | | if (!$mobile || !$captcha) { |
| | | $isyj=$this->request->post('isyj',false); |
| | | if (!$mobile || (!$isyj&&!$captcha)) { |
| | | $this->error(__('Invalid parameters')); |
| | | } |
| | | if (!Validate::regex($mobile, "^1\d{10}$")) { |
| | | $this->error('请输入正确手机号'); |
| | | } |
| | | $result = Sms::check($mobile, $captcha, 'changemobile'); |
| | | if (!$result) { |
| | | $this->error(__('Captcha is incorrect')); |
| | | if(!$isyj) |
| | | { |
| | | $result = Sms::check($mobile, $captcha, 'changemobile'); |
| | | if (!$result) { |
| | | $this->error(__('Captcha is incorrect')); |
| | | } |
| | | } |
| | | |
| | | $ModelThird = new ModelThird(); |
| | | $LogicUser = new LogicUser(); |
| | | //判断当前手机号是否已经绑定微信 |
| | |
| | | if($res === false) $this->error($LogicUserBrowse->getError()); |
| | | |
| | | $this->success([],'删除成功'); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 标记浏览0元购商品记录 |
| | | * |
| | | * @return void |
| | | */ |
| | | public function update_first_free_browse() |
| | | { |
| | | $ids = request()->param('goodsid',''); |
| | | |
| | | $new_goodsId = request()->param('new_goodsId',''); |
| | | |
| | | $LogicUserBrowse = new LogicUserBrowse(); |
| | | |
| | | $res = $LogicUserBrowse->updatefirstfreelog(USERID,$ids,$new_goodsId); |
| | | |
| | | if($res === false) $this->error($LogicUserBrowse->getError()); |
| | | |
| | | $this->success([],'添加成功'); |
| | | } |
| | | |
| | | /** |
| | | * 检测是否首单 |
| | | * |
| | | * @return void |
| | | */ |
| | | |
| | | public function check_isfirst_free() |
| | | { |
| | | |
| | | $LogicUserBrowse = new LogicUserBrowse(); |
| | | |
| | | $res = $LogicUserBrowse->checkIsFirstFree(USERID); |
| | | |
| | | if($res === false) $this->error($LogicUserBrowse->getError()); |
| | | Log::write('检测是否首单:'.json_encode($res)); |
| | | if(empty($res)) $this->success(['info'=>1],'首单客户'); |
| | | $this->success(['info'=>0],'非首单客户'); |
| | | } |
| | | |
| | | |
| | |
| | | $user_jjcj_num = $ModelUser->where(['f_invitation_id'=>USERID,'level'=>1])->count(); //间接初级人数 |
| | | $user_zszj_num = $ModelUser->where(['invitation_id'=>USERID,'level'=>2])->count(); //直属中级人数 |
| | | $user_jjzj_num = $ModelUser->where(['f_invitation_id'=>USERID,'level'=>2])->count(); //间接中级人数 |
| | | $user_zong_num = $ModelUser->where(['invitation_id'=>USERID])->count(); //总邀请人数 |
| | | $user_monthly_commission = LogicUser::getUserCommission($user['id'],'month'); //获取近30佣金 |
| | | $user_total_commission = LogicUser::getUserCommission($user['id'],'total'); //获取累计佣金 |
| | | $data = [ |
| | |
| | | 'user_jjcj_num' => $user_jjcj_num, |
| | | 'user_zszj_num' => $user_zszj_num, |
| | | 'user_jjzj_num' => $user_jjzj_num, |
| | | 'user_zong_num'=>$user_zong_num, |
| | | 'user_monthly_commission' => $user_monthly_commission, |
| | | 'total_commission' => $user_total_commission |
| | | ], |
| | |
| | | if($user->level<2){ |
| | | $this->error('当前等级不能修改邀请码'); |
| | | } |
| | | //判断是否有修改记录 |
| | | if (\app\common\model\user\CodeChangeHistory::getByUserId($user->id)) { |
| | | $this->error('邀请码只能修改一次哦'); |
| | | } |
| | | $invitation_code = request()->param('invite_code',''); |
| | | if (!$invitation_code ) { |
| | | $this->error(__('请输入邀请码')); |
| | |
| | | } |
| | | $user->invitation_code = $invitation_code; |
| | | $user->save(); |
| | | |
| | | //保存修改记录 |
| | | \app\common\model\user\CodeChangeHistory::create([ |
| | | 'user_id' => $user->id, |
| | | 'before_code' => $user->invitation_code, |
| | | 'after_code' =>$invitation_code, |
| | | 'create_time' => time() |
| | | ]); |
| | | $this->success(); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | *获取推荐邀请人 |
| | | */ |
| | | public function getRecomInviter() |
| | | { |
| | | $ModelUser=new ModelUser(); |
| | | $user = $ModelUser->join('recommend_inviter', 't_user.id=t_recommend_inviter.user_id') |
| | | ->field('t_user.id,t_user.avatar,t_user.invitation_code,t_user.nickname') |
| | | ->order('recommend_inviter.order_inde asc') |
| | | ->select(); |
| | | $this->success('获取成功',$user); |
| | | } |
| | | |
| | | } |