From d01dbe195c5dc2886ce4bf62d66d7459cefda667 Mon Sep 17 00:00:00 2001 From: zhaojs <349234519@qq.com> Date: 星期四, 13 七月 2023 11:36:39 +0800 Subject: [PATCH] Merge branch 'feature/v1.1.4开发' of http://60.204.153.149:8081/r/dfgApi into feature/v1.1.4开发 --- application/api/controller/User.php | 132 ++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 122 insertions(+), 10 deletions(-) diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 76934e4..a50f2e1 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -18,12 +18,17 @@ use app\api\logic\UserWithdrawal as LogicUserWithdrawal; 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; + /** * 浼氬憳鎺ュ彛 */ 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() @@ -47,6 +52,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 +103,7 @@ $mobile = $this->request->post('mobile'); $captcha = $this->request->post('captcha'); $ismobouth=$this->request->post('ismobouth',false); + $pushCid=$this->request->post('pushCid',false); if (!$mobile || !$captcha) { $this->error(__('Invalid parameters')); } @@ -101,7 +121,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'); @@ -211,7 +231,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 +299,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 +326,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) { @@ -428,6 +455,48 @@ 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',''); + + $plateform= request()->param('plateform',''); + + $LogicUserBrowse = new LogicUserBrowse(); + + $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],'闈為鍗曞鎴�'); } @@ -658,6 +727,9 @@ $this->error('缁戝畾澶辫触'); } $ModelUser->commit(); + //鏇存柊鎷涘嫙娲诲姩淇℃伅 + $activityInfo=new InfoActivityInfo(); + $activityInfo->updateRecruitCount($save_data['invitation_id'] ); $this->success('缁戝畾鎴愬姛',[]); } @@ -743,6 +815,7 @@ $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浣i噾 $user_total_commission = LogicUser::getUserCommission($user['id'],'total'); //鑾峰彇绱浣i噾 $data = [ @@ -751,6 +824,7 @@ '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 ], @@ -934,6 +1008,10 @@ 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(__('璇疯緭鍏ラ個璇风爜')); @@ -950,10 +1028,44 @@ } $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); + } + /** + * 妫�娴嬫槸鍚︽湁鍋忓ソ鍟嗗搧 + * + * @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); + } } -- Gitblit v1.9.3