zhaojs
2023-07-07 feb23da8c1660517aba5f90345607decfa7b1f5c
application/api/controller/User.php
@@ -18,6 +18,8 @@
use app\api\logic\UserWithdrawal as LogicUserWithdrawal;
use app\api\logic\SettlementRecord as LogicSettlementRecord;
use app\api\logic\UserMoneyLog as LogicUserMoneyLog;
use think\log;
/**
 * 会员接口
 */
@@ -47,6 +49,20 @@
        $userInfo['token'] = $this->auth->getToken();
        $data = ['userinfo' => $userInfo];
        $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);
    }
    /**
@@ -84,6 +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);
        if (!$mobile || !$captcha) {
            $this->error(__('Invalid parameters'));
        }
@@ -211,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}$")) {
@@ -278,20 +296,26 @@
    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');
        $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();
        //判断当前手机号是否已经绑定微信
@@ -299,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) {
@@ -430,7 +454,7 @@
        $this->success([],'删除成功');
    }
    /**
     * 标记浏览0元购商品记录
     *
@@ -442,15 +466,36 @@
        $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());
        $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],'非首单客户');
    }
     /**
     * 用户收藏记录