| | |
| | | use app\api\logic\SettlementRecord as LogicSettlementRecord; |
| | | use app\api\logic\UserMoneyLog as LogicUserMoneyLog; |
| | | use think\log; |
| | | |
| | | use app\api\logic\ActivityInfo as InfoActivityInfo; |
| | | use app\common\model\UserExtend as ModelUserExtend; |
| | | use think\Db; |
| | | use EasyWeChat\Kernel\Support\AES; |
| | | /** |
| | | * 会员接口 |
| | | */ |
| | | class User extends Api |
| | | { |
| | | protected $noNeedLogin = ['GetRecomInviter','login', 'mobilelogin', 'resetpwd', 'changemobile', 'wxapplogin','bind_mobile_login','register']; |
| | | protected $noNeedLogin = ['GetDfgToken','GetRecomInviter','login', 'mobilelogin', 'resetpwd', 'changemobile', 'wxapplogin','bind_mobile_login','register']; |
| | | protected $noNeedRight = '*'; |
| | | |
| | | public function _initialize() |
| | |
| | | $data = ['userinfo' => $userInfo]; |
| | | $this->success('获取成功', $data); |
| | | } |
| | | |
| | | |
| | | public function GetDfgToken() |
| | | { |
| | | $userId=$this->request->post('userid'); |
| | | if (!$userId) { |
| | | $this->error(__('Invalid parameters')); |
| | | } |
| | | //aes加密 |
| | | $enKey="wp4hs3bvu7wq2mud"; |
| | | $iv = 'fedcba9876543210'; |
| | | $decrypted = base64_encode(AES::encrypt($userId,$enKey, $iv)); |
| | | $this->success($decrypted); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | $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')); |
| | | } |
| | |
| | | //如果已经有账号则直接登录 |
| | | $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'); |
| | |
| | | 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'); |
| | |
| | | $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) { |
| | |
| | | public function bind_invitation() |
| | | { |
| | | $invite_code = request()->param('invite_code',''); |
| | | $deviceid=request()->param('deviceid',''); |
| | | if(empty($invite_code)) $this->error('邀请码不能为空'); |
| | | $is_official = false; |
| | | $isOpenOfficialCode = config('site.isOpenOfficialCode'); |
| | |
| | | if($f_user['status'] != 'normal')$this->error('邀请人帐号已被锁定,暂时无法邀请'); |
| | | if($user['invitation_id'] != 0)$this->error('当前已绑定上级用户'); |
| | | $save_data['invitation_id'] = $f_user['id']; |
| | | if(!empty($deviceid)) |
| | | {//设备id |
| | | $save_data['login_deviceid'] = $deviceid; |
| | | } |
| | | else{ |
| | | $save_data['login_deviceid'] = 'cus'.self::guid(); |
| | | } |
| | | if($f_user['invitation_id'] != 0)$save_data['f_invitation_id'] = $f_user['invitation_id']; |
| | | $res2 = $ModelUser->where(['id'=>$f_user['id']])->setInc('fans',1); |
| | | if(!$res2){ |
| | |
| | | $this->error('绑定失败'); |
| | | } |
| | | $ModelUser->commit(); |
| | | //更新招募活动信息 |
| | | $activityInfo=new InfoActivityInfo(); |
| | | $activityInfo->updateRecruitCount($save_data['invitation_id'] ); |
| | | $this->success('绑定成功',[]); |
| | | } |
| | | |
| | | public function guid() |
| | | { |
| | | |
| | | if (function_exists('com_create_guid')) { |
| | | |
| | | return com_create_guid(); |
| | | |
| | | } else { |
| | | |
| | | mt_srand((double)microtime() * 10000); |
| | | $charid = strtoupper(md5(uniqid(rand(), true))); |
| | | $uuid = substr($charid, 0, 8) |
| | | . substr($charid, 8, 4) |
| | | . substr($charid, 12, 4) |
| | | . substr($charid, 16, 4) |
| | | . substr($charid, 20, 12); |
| | | return $uuid; |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | $this->success('获取成功',$user); |
| | | } |
| | | |
| | | /** |
| | | * 检测是否有偏好商品 |
| | | * |
| | | * @return void |
| | | */ |
| | | |
| | | public function check_preference_goods() |
| | | { |
| | | //获取当前登录人用户信息 |
| | | $user = $this->auth->getUser(); |
| | | $ModelUserExtend=new ModelUserExtend(); |
| | | $preference_goods=$ModelUserExtend->where(['id'=>$user['id']])->field('p_cids,p_platefrom')->find(); |
| | | if(empty($preference_goods)||empty($preference_goods['p_cids'])) $this->error('暂无偏好商品'); |
| | | $this->success('获取成功',$preference_goods); |
| | | } |
| | | |
| | | } |