zhaojs
2023-07-07 f881d5b1729370eac90c92302ee93f0d8bac2e30
application/api/controller/User.php
@@ -51,6 +51,20 @@
        $this->success('获取成功', $data);
    }
    /**
     * 更新appclientid
     */
    public function UpdateClientId()
    {
        $pushCid=$this->request->post('pushcid');
        $ModelUser = new ModelUser();
        $userInfo = $ModelUser->where(['id'=>USERID]);
        if(empty($userInfo)) $this->success('成功',true);
        $userInfo->update(['push_cid'=>$pushCid]);
        $this->success('成功', true);
    }
    /**
     * 会员登录
     *
@@ -86,7 +100,7 @@
        $mobile = $this->request->post('mobile');
        $captcha = $this->request->post('captcha');
        $ismobouth=$this->request->post('ismobouth',false);
        $push_cid=$this->request->post('push_cid',false);
        $pushCid=$this->request->post('pushCid',false);
        if (!$mobile || !$captcha) {
            $this->error(__('Invalid parameters'));
        }
@@ -104,7 +118,7 @@
            //如果已经有账号则直接登录
            $ret = $this->auth->direct($user->id);
        } else {
            $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []);
            $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, [],'',[],$pushCid);
        }
        if ($ret) {
            Sms::flush($mobile, 'login');
@@ -214,7 +228,8 @@
        $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}$")) {
@@ -248,7 +263,6 @@
    {
        $openid = request()->param('openid');
        $access_token = request()->param('access_token');
        $push_cid=request()->param('push_cid','');
        $LogicUser = new LogicUser();
        $userId = $LogicUser->getUserByOpenId($openid);
        if ($userId) {
@@ -256,10 +270,6 @@
            if(empty($user)) $this->error("用户信息获取失败");
            if ($user['status'] != 'normal') {
                $this->error(__('Account is locked'));
            }
            if(!empty($push_cid)&&empty($user['push_cid']))
            {//表里push_cid为空,补全push_cid
            }
            //如果已经有账号则直接登录
            $ret = $this->auth->direct($user['id']);
@@ -286,6 +296,7 @@
    public function bind_mobile_login()
    {
        $wxUser = request()->param('wxUser','','urldecode');
        $pushCid= request()->param('pushCid','');
        $wxUser = json_decode($wxUser,true);
        if(empty($wxUser)) $this->error('微信授权信息获取失败');
        $mobile = $this->request->post('mobile');
@@ -312,11 +323,11 @@
        $is_phone_bind = $ModelUser->where(['mobile'=> $mobile])->find();
        if(!empty($is_phone_bind)){
            $LogicUser->bindWechat($is_phone_bind['id'],$wxUser['headimgurl'],$wxUser['sex'],$wxUser['nickname'],$wxUser['openid']);
            $ret = $this->auth->direct($is_phone_bind['id']);
            $ret = $this->auth->direct($is_phone_bind['id'],$pushCid);
        }else{ //判断微信是否已经绑定
            $find_third = $ModelThird->where(['openid'=>$wxUser['openid']])->find();
            if(!empty($find_third)) $this->error('当前微信号已绑定其他账号');
            $ret = $this->auth->register('', Random::alnum(), '', $mobile, [],'wechat',$wxUser);
            $ret = $this->auth->register('', Random::alnum(), '', $mobile, [],'wechat',$wxUser,$pushCid);
        }
        Sms::flush($mobile, 'changemobile');
        if ($ret) {
@@ -455,9 +466,11 @@
        $new_goodsId = request()->param('new_goodsId','');
        $plateform= request()->param('plateform','');
        $LogicUserBrowse = new LogicUserBrowse();
        $res = $LogicUserBrowse->updatefirstfreelog(USERID,$ids,$new_goodsId);
        $res = $LogicUserBrowse->updatefirstfreelog(USERID,$ids,$new_goodsId,$plateform);
        if($res === false) $this->error($LogicUserBrowse->getError());