User.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\library\Ems;
  5. use app\common\library\Sms;
  6. use fast\Random;
  7. use think\Config;
  8. use think\Validate;
  9. use app\common\library\Token;
  10. use think\Db;
  11. use app\common\model\UserDeviceInfo;
  12. /**
  13. * 会员接口,登录,注册,修改资料等
  14. */
  15. class User extends Api
  16. {
  17. protected $noNeedLogin = ['login', 'mobilelogin', 'register', 'resetpwd', 'changeemail', 'changemobile', 'third'];
  18. protected $noNeedRight = '*';
  19. public function _initialize()
  20. {
  21. parent::_initialize();
  22. if (!Config::get('fastadmin.usercenter')) {
  23. $this->error(__('User center already closed'));
  24. }
  25. }
  26. /**
  27. * 会员中心
  28. */
  29. public function index()
  30. {
  31. $this->success('', ['welcome' => $this->auth->nickname]);
  32. }
  33. /**
  34. * 会员登录
  35. *
  36. * @ApiMethod (POST)
  37. * @param string $account 账号
  38. * @param string $password 密码
  39. */
  40. public function login()
  41. {
  42. $account = input('account');
  43. $password = input('password');
  44. if (!$account || !$password) {
  45. $this->error(__('Invalid parameters'));
  46. }
  47. $ret = $this->auth->login($account, $password);
  48. if ($ret) {
  49. $data = $this->userInfo('return');
  50. $this->success(__('Logged in successful'), $data);
  51. } else {
  52. $this->error($this->auth->getError());
  53. }
  54. }
  55. /**
  56. * 手机验证码登录
  57. *
  58. * @ApiMethod (POST)
  59. * @param string $mobile 手机号
  60. * @param string $captcha 验证码
  61. */
  62. public function mobilelogin()
  63. {
  64. $mobile = input('mobile');
  65. $captcha = input('captcha');
  66. if (!$mobile || !$captcha) {
  67. $this->error(__('Invalid parameters'));
  68. }
  69. if (!Validate::regex($mobile, "^1\d{10}$")) {
  70. $this->error(__('Mobile is incorrect'));
  71. }
  72. if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
  73. $this->error(__('Captcha is incorrect'));
  74. }
  75. $user = \app\common\model\User::getByMobile($mobile);
  76. if ($user) {
  77. if ($user->status != 1) {
  78. $this->error(__('Account is locked'));
  79. }
  80. //如果已经有账号则直接登录
  81. $ret = $this->auth->direct($user->id);
  82. } else {
  83. $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []);
  84. }
  85. if ($ret) {
  86. Sms::flush($mobile, 'mobilelogin');
  87. $data = $this->userInfo('return');
  88. $this->success(__('Logged in successful'), $data);
  89. } else {
  90. $this->error($this->auth->getError());
  91. }
  92. }
  93. /**
  94. * 注册会员
  95. *
  96. * @ApiMethod (POST)
  97. * @param string $username 用户名
  98. * @param string $password 密码
  99. * @param string $email 邮箱
  100. * @param string $mobile 手机号
  101. * @param string $code 验证码
  102. */
  103. /*public function register()
  104. {
  105. $username = $this->request->post('username');
  106. $password = $this->request->post('password');
  107. $email = $this->request->post('email');
  108. $mobile = $this->request->post('mobile');
  109. $code = $this->request->post('code');
  110. if (!$username || !$password) {
  111. $this->error(__('Invalid parameters'));
  112. }
  113. if ($email && !Validate::is($email, "email")) {
  114. $this->error(__('Email is incorrect'));
  115. }
  116. if ($mobile && !Validate::regex($mobile, "^1\d{10}$")) {
  117. $this->error(__('Mobile is incorrect'));
  118. }
  119. $ret = Sms::check($mobile, $code, 'register');
  120. if (!$ret) {
  121. $this->error(__('Captcha is incorrect'));
  122. }
  123. $ret = $this->auth->register($username, $password, $email, $mobile, []);
  124. if ($ret) {
  125. $data = $this->userInfo('return');
  126. $this->success(__('Sign up successful'), $data);
  127. } else {
  128. $this->error($this->auth->getError());
  129. }
  130. }*/
  131. //用户详细资料
  132. public function userInfo($type = 1){
  133. $info = $this->auth->getUserinfo();
  134. if($type == 'return'){
  135. return $info;
  136. }
  137. $this->success(__('success'),$info);
  138. }
  139. //用户邀请信息
  140. public function userintroinfo(){
  141. $intro_num = Db::name('user')->where('intro_uid',$this->auth->id)->count();
  142. $money_sum = Db::name('user_money_log')->where(['user_id'=>$this->auth->id,'log_type'=>63])->sum('change_value');
  143. $user_list = Db::name('user')->field('id,avatar,nickname,createtime')->where('intro_uid',$this->auth->id)->autopage()->select();
  144. $rs = [
  145. 'intro_num' => $intro_num,
  146. 'money_sum' => $money_sum,
  147. 'user_list' => $user_list,
  148. ];
  149. $this->success('success',$rs);
  150. }
  151. public function testhaibao(){
  152. $haibao = $this->haibao($this->auth->id,['introcode'=>$this->auth->introcode]);
  153. dump($haibao);
  154. }
  155. //海报
  156. public function haibao($player_id,$data){
  157. //下载页二维码,没必要保留
  158. $params = [
  159. 'text' => config('site.domain_name').'/index/index/appdownload',
  160. 'size' => 90,
  161. 'logo' => false,
  162. 'label' => false,
  163. 'padding' => 5,
  164. ];
  165. $qrCode = \addons\qrcode\library\Service::qrcode($params);
  166. $qrcode_path = 'uploads/hbplayer/'.date('Ymd');
  167. mk_dir($qrcode_path);
  168. $download_qrcode = $qrcode_path.'/download.png';
  169. $qrCode->writeFile($download_qrcode);
  170. //海报
  171. $haibao = $this->createhaibao($download_qrcode,$player_id,$data);
  172. return $haibao;
  173. }
  174. public function createhaibao($download_qrcode,$player_id,$sub_data){
  175. //背景图
  176. $background = config('site.domain_name').'/assets/img/haibao.png';
  177. //海报图片路径
  178. $new_path = 'uploads/hbplayer/'.date("Ymd").'/';
  179. mk_dir($new_path);
  180. $wap_file_name = $new_path .'wap_player_'. $player_id . '.png';
  181. //二维码
  182. $download_qrcode= config('site.domain_name').'/'.$download_qrcode;
  183. //合成wap图片
  184. $image = new \addons\poster\library\Image2();
  185. $imgurl = $image->createPosterImage($background,$download_qrcode,$sub_data['introcode'],$wap_file_name);
  186. return '/'.$wap_file_name;
  187. }
  188. //申请真人认证
  189. public function apply_real_confirm(){
  190. $avatar = input('avatar', '', 'trim,strip_tags,htmlspecialchars');
  191. if(!$avatar){
  192. $this->error('请上传真人头像');
  193. }
  194. Db::startTrans();
  195. $data = [
  196. 'avatar' => $avatar,
  197. 'real_status' => 1,
  198. ];
  199. $rs = Db::name('user')->where('id',$this->auth->id)->update($data);
  200. if($rs === false){
  201. Db::rollback();
  202. $this->error('认证失败');
  203. }
  204. //tag任务赠送金币
  205. //完成本人基本资料 +15金币《所有资料完善,包括真人认证和实名认证》
  206. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,5);
  207. if($task_rs === false){
  208. Db::rollback();
  209. $this->error('完成任务赠送奖励失败');
  210. }
  211. //完成真人头像 +5金币
  212. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,7);
  213. if($task_rs === false){
  214. Db::rollback();
  215. $this->error('完成任务赠送奖励失败');
  216. }
  217. //邀请人拿奖励,男性3元
  218. $intro_money = $this->auth->gender == 1 ? config('site.intro_man_money') : config('site.intro_woman_money');
  219. if($this->auth->idcard_status == 1 && !empty($this->auth->intro_uid) && $intro_money > 0){
  220. $task_rs = model('wallet')->lockChangeAccountRemain($this->auth->intro_uid,'money',$intro_money,63,$remark='');
  221. if($task_rs['status'] === false){
  222. Db::rollback();
  223. $this->error($task_rs['msg']);
  224. }
  225. }
  226. //系统消息
  227. $msg_id = \app\common\model\Message::addMessage($this->auth->id,'真人认证','真人认证已经审核通过');
  228. Db::commit();
  229. $this->success();
  230. }
  231. //实名认证信息
  232. public function idcard_confirm_info(){
  233. $check = Db::name('user_idconfirm')->where('user_id',$this->auth->id)->order('id desc')->find();
  234. $this->success('success',$check);
  235. }
  236. //申请实名认证
  237. public function apply_idcard_confirm(){
  238. $truename = input('truename','');
  239. $idcard = input('idcard','');
  240. $idcard_images = input('idcard_images','');
  241. $alipay_account = input('alipay_account','');
  242. if(empty($truename) || empty($idcard) || empty($idcard_images) || empty($alipay_account)){
  243. $this->error('实名认证信息必填');
  244. }
  245. if($this->auth->idcard_status == 1){
  246. $this->error('您已经完成实名认证');
  247. }
  248. if($this->auth->idcard_status == 0){
  249. $this->error('您已经提交实名认证,请等待审核');
  250. }
  251. Db::startTrans();
  252. $check = Db::name('user_idconfirm')->where('user_id',$this->auth->id)->lock(true)->find();
  253. if(!empty($check)){
  254. if($check['status'] == 0){
  255. Db::rollback();
  256. $this->error('您已经提交实名认证,请等待审核');
  257. }
  258. if($check['status'] == 1){
  259. Db::rollback();
  260. $this->error('您已经完成实名认证');
  261. }
  262. }
  263. $data = [
  264. 'user_id' => $this->auth->id,
  265. 'truename' => $truename,
  266. 'idcard' => $idcard,
  267. 'idcard_images' => $idcard_images,
  268. 'alipay_account' => $alipay_account,
  269. 'status' => 0,
  270. 'createtime' => time(),
  271. 'updatetime' => time(),
  272. ];
  273. //更新
  274. $update_rs = Db::name('user')->where('id',$this->auth->id)->update(['idcard_status'=>0]);
  275. if(!empty($check)){
  276. $rs = Db::name('user_idconfirm')->where('id',$check['id'])->update($data);
  277. }else{
  278. $rs = Db::name('user_idconfirm')->insertGetId($data);
  279. }
  280. if(!$rs || !$update_rs){
  281. Db::rollback();
  282. $this->error('提交失败');
  283. }
  284. Db::commit();
  285. $this->success('提交成功,请等待审核');
  286. }
  287. /**
  288. * 退出登录
  289. * @ApiMethod (POST)
  290. */
  291. public function logout()
  292. {
  293. if (!$this->request->isPost()) {
  294. $this->error(__('Invalid parameters'));
  295. }
  296. //退出im
  297. $tenIm = new Tenim();
  298. $tenIm->loginoutim($this->auth->id);
  299. $this->auth->logout();
  300. $this->success(__('Logout successful'));
  301. }
  302. /**
  303. * 修改会员个人信息
  304. *
  305. * @ApiMethod (POST)
  306. * @param string $avatar 头像地址
  307. * @param string $username 用户名
  308. * @param string $nickname 昵称
  309. * @param string $bio 个人简介
  310. */
  311. public function profile()
  312. {
  313. $field_array = ['nickname','introcode','gender','birthday','height','weight','bio','audio_bio','avatar','photo_images','education_id','hobby_ids','job_id','marital_id','tag_ids','wages_id','hometown_cityid','hide_is_finishinfo'];
  314. $data = [];
  315. foreach($field_array as $key => $field){
  316. if(!input('?'.$field)){
  317. continue;
  318. }
  319. $newone = input($field);
  320. if($field == 'avatar'){
  321. $newone = input('avatar', '', 'trim,strip_tags,htmlspecialchars');
  322. }
  323. if($field == 'photo_images'){
  324. $newone = input('photo_images', '', 'trim,strip_tags,htmlspecialchars');
  325. }
  326. $data[$field] = $newone;
  327. }
  328. if(isset($data['birthday'])){
  329. $data['birthday'] = strtotime($data['birthday']);
  330. }
  331. if(isset($data['avatar'])){
  332. $data['real_status'] = -1; //或许应该改成0。性别不能改所以不需要
  333. }
  334. if(isset($data['hobby_ids'])){
  335. $data['hobby_ids'] = implode(',',explode(',',$data['hobby_ids']));
  336. }
  337. if(isset($data['tag_ids'])){
  338. $data['tag_ids'] = implode(',',explode(',',$data['tag_ids']));
  339. }
  340. if(isset($data['introcode'])){
  341. $intro_user = Db::name('user')->where('introcode',$data['introcode'])->value('id');
  342. if(!$intro_user){
  343. $this->error('不存在的邀请人');
  344. }
  345. unset($data['introcode']);//别人的邀请码,不能改了自己的
  346. $data['intro_uid'] = $intro_user;
  347. }
  348. //dump($data);
  349. if(empty($data)){
  350. $this->error('没有任何改变');
  351. }
  352. Db::startTrans();
  353. $update_rs = Db::name('user')->where('id',$this->auth->id)->update($data);
  354. if($update_rs === false){
  355. Db::rollback();
  356. $this->error('修改资料失败');
  357. }
  358. //tag任务赠送金币
  359. //上传头像加5金币
  360. if(isset($data['avatar'])){
  361. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,1);
  362. if($task_rs === false){
  363. Db::rollback();
  364. $this->error('完成任务赠送奖励失败');
  365. }
  366. }
  367. //上传本人语音介绍 10金币
  368. if(isset($data['audio_bio'])){
  369. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,6);
  370. if($task_rs === false){
  371. Db::rollback();
  372. $this->error('完成任务赠送奖励失败');
  373. }
  374. }
  375. //上传本人五张照片 10金币
  376. if(isset($data['photo_images']) && count(explode(',',$data['photo_images'])) >= 5){
  377. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,8);
  378. if($task_rs === false){
  379. Db::rollback();
  380. $this->error('完成任务赠送奖励失败');
  381. }
  382. }
  383. //所有资料完成
  384. $user_info = Db::name('user')->where('id',$this->auth->id)->find();
  385. if($user_info['avatar'] && $user_info['nickname'] && $user_info['mobile'] && $user_info['audio_bio'] && $user_info['photo_images']){
  386. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,5);
  387. if($task_rs === false){
  388. Db::rollback();
  389. $this->error('完成任务赠送奖励失败');
  390. }
  391. }
  392. Db::commit();
  393. $this->success();
  394. }
  395. public function set_status_switch(){
  396. }
  397. /*
  398. * 修改用户的坐标
  399. * */
  400. public function change_longlat(){
  401. $longitude = input_post('longitude');
  402. $latitude = input_post('latitude');
  403. $cityname = input_post('cityname');
  404. if(empty($longitude) || empty($latitude) || empty($cityname)){
  405. $this->error();
  406. }
  407. $data = [
  408. 'longitude' => $longitude,
  409. 'latitude' => $latitude,
  410. 'cityname' => $cityname,
  411. ];
  412. Db::name('user')->where('id',$this->auth->id)->update($data);
  413. $this->success();
  414. }
  415. /**
  416. * 修改邮箱
  417. *
  418. * @ApiMethod (POST)
  419. * @param string $email 邮箱
  420. * @param string $captcha 验证码
  421. */
  422. /*public function changeemail()
  423. {
  424. $user = $this->auth->getUser();
  425. $email = $this->request->post('email');
  426. $captcha = $this->request->post('captcha');
  427. if (!$email || !$captcha) {
  428. $this->error(__('Invalid parameters'));
  429. }
  430. if (!Validate::is($email, "email")) {
  431. $this->error(__('Email is incorrect'));
  432. }
  433. if (\app\common\model\User::where('email', $email)->where('id', '<>', $user->id)->find()) {
  434. $this->error(__('Email already exists'));
  435. }
  436. $result = Ems::check($email, $captcha, 'changeemail');
  437. if (!$result) {
  438. $this->error(__('Captcha is incorrect'));
  439. }
  440. $verification = $user->verification;
  441. $verification->email = 1;
  442. $user->verification = $verification;
  443. $user->email = $email;
  444. $user->save();
  445. Ems::flush($email, 'changeemail');
  446. $this->success();
  447. }*/
  448. /**
  449. * 修改手机号
  450. *
  451. * @ApiMethod (POST)
  452. * @param string $mobile 手机号
  453. * @param string $captcha 验证码
  454. */
  455. public function changemobile()
  456. {
  457. $user = $this->auth->getUser();
  458. $oldcaptcha = $this->request->request('oldcaptcha');
  459. $mobile = $this->request->request('mobile');
  460. $captcha = $this->request->request('captcha');
  461. if (!$oldcaptcha || !$mobile || !$captcha) {
  462. $this->error(__('Invalid parameters'));
  463. }
  464. if (!Validate::regex($mobile, "^1\d{10}$")) {
  465. $this->error(__('Mobile is incorrect'));
  466. }
  467. if($user->mobile == $mobile){
  468. $this->error('新手机号不能与旧手机号相同');
  469. }
  470. if (\app\common\model\User::where('mobile', $mobile)->find()) {
  471. $this->error(__('Mobile already exist'));
  472. }
  473. $result = Sms::check($user->mobile, $oldcaptcha, 'changemobile');
  474. if (!$result) {
  475. $this->error(__('Captcha is incorrect'));
  476. }
  477. $result = Sms::check($mobile, $captcha, 'changemobile');
  478. if (!$result) {
  479. $this->error(__('Captcha is incorrect'));
  480. }
  481. $verification = $user->verification;
  482. $verification->mobile = 1;
  483. $user->verification = $verification;
  484. $user->mobile = $mobile;
  485. $user->save();
  486. Sms::flush($user->mobile, 'changemobile');
  487. Sms::flush($mobile, 'changemobile');
  488. $this->success();
  489. }
  490. /**
  491. * 第三方登录
  492. *
  493. * @ApiMethod (POST)
  494. * @param string $platform 平台名称
  495. * @param string $code Code码
  496. */
  497. /*public function third()
  498. {
  499. $url = url('user/index');
  500. $platform = $this->request->post("platform");
  501. $code = $this->request->post("code");
  502. $config = get_addon_config('third');
  503. if (!$config || !isset($config[$platform])) {
  504. $this->error(__('Invalid parameters'));
  505. }
  506. $app = new \addons\third\library\Application($config);
  507. //通过code换access_token和绑定会员
  508. $result = $app->{$platform}->getUserInfo(['code' => $code]);
  509. if ($result) {
  510. $loginret = \addons\third\library\Service::connect($platform, $result);
  511. if ($loginret) {
  512. $data = [
  513. 'userinfo' => $this->auth->getUserinfo(),
  514. 'thirdinfo' => $result
  515. ];
  516. $this->success(__('Logged in successful'), $data);
  517. }
  518. }
  519. $this->error(__('Operation failed'), $url);
  520. }*/
  521. /**
  522. * 重置密码
  523. *
  524. * @ApiMethod (POST)
  525. * @param string $mobile 手机号
  526. * @param string $newpassword 新密码
  527. * @param string $captcha 验证码
  528. */
  529. public function resetpwd()
  530. {
  531. //$type = input("type");
  532. $type = 'mobile';
  533. $mobile = input("mobile");
  534. $email = input("email");
  535. $newpassword = input("newpassword");
  536. $captcha = input("captcha");
  537. if (!$newpassword || !$captcha) {
  538. $this->error(__('Invalid parameters'));
  539. }
  540. if ($type == 'mobile') {
  541. if (!Validate::regex($mobile, "^1\d{10}$")) {
  542. $this->error(__('Mobile is incorrect'));
  543. }
  544. $user = \app\common\model\User::getByMobile($mobile);
  545. if (!$user) {
  546. $this->error(__('User not found'));
  547. }
  548. $ret = Sms::check($mobile, $captcha, 'resetpwd');
  549. if (!$ret) {
  550. $this->error(__('Captcha is incorrect'));
  551. }
  552. Sms::flush($mobile, 'resetpwd');
  553. } else {
  554. if (!Validate::is($email, "email")) {
  555. $this->error(__('Email is incorrect'));
  556. }
  557. $user = \app\common\model\User::getByEmail($email);
  558. if (!$user) {
  559. $this->error(__('User not found'));
  560. }
  561. $ret = Ems::check($email, $captcha, 'resetpwd');
  562. if (!$ret) {
  563. $this->error(__('Captcha is incorrect'));
  564. }
  565. Ems::flush($email, 'resetpwd');
  566. }
  567. //模拟一次登录
  568. $this->auth->direct($user->id);
  569. $ret = $this->auth->changepwd($newpassword, '', true);
  570. if ($ret) {
  571. $this->success(__('Reset password successful'));
  572. } else {
  573. $this->error($this->auth->getError());
  574. }
  575. }
  576. /**
  577. * 修改密码
  578. *
  579. * @ApiMethod (POST)
  580. * @param string $newpassword 新密码
  581. * @param string $oldpassword 旧密码
  582. */
  583. public function changepwd(){
  584. $newpassword = input('newpassword');
  585. $oldpassword = input('oldpassword','');
  586. if (!$newpassword) {
  587. $this->error(__('Invalid parameters'));
  588. }
  589. if($this->auth->password && empty($oldpassword)){
  590. $this->error('原密码必填');
  591. }
  592. if(empty($this->auth->password)){
  593. $ret = $this->auth->changepwd($newpassword, '', true);
  594. }else{
  595. $ret = $this->auth->changepwd($newpassword,$oldpassword,false);
  596. }
  597. if ($ret) {
  598. $this->success(__('Reset password successful'));
  599. } else {
  600. $this->error($this->auth->getError());
  601. }
  602. }
  603. /**
  604. * 记录当前登陆的设备ID,设备信息,IP等
  605. */
  606. public function changeDeviceIp()
  607. {
  608. // 接口防并发
  609. if (!$this->apiLimit(1, 5000)) {
  610. return ;
  611. }
  612. $user = $this->auth->getUser();
  613. $ip = request()->ip();
  614. $deviceId = $this->request->request('device_id','');
  615. $phoneModel = $this->request->request('phone_model','');
  616. $brand = $this->request->request('brand','');
  617. $apiVersion = $this->request->request('api_version','');
  618. $deviceOs = $this->request->request('device_os','');
  619. if ($ip !== $user->loginip){
  620. $update = [];
  621. $update['id'] = $user->id;
  622. $update['loginip'] = $ip;
  623. \app\common\model\User::update($update);
  624. }
  625. $userDeviceInfo = UserDeviceInfo::get(['user_id'=>$user->u_id]);
  626. if (empty($userDeviceInfo)){
  627. $userDeviceInfo = new UserDeviceInfo();
  628. $userDeviceInfo->user_id = $user->u_id;
  629. }
  630. $userDeviceInfo->device_os = $deviceOs;
  631. $userDeviceInfo->device_id = $deviceId;
  632. $userDeviceInfo->phone_model = $phoneModel;
  633. $userDeviceInfo->brand = $brand;
  634. $userDeviceInfo->api_version = $apiVersion;
  635. $userDeviceInfo->save();
  636. //首页接口调用,这里不反回信息
  637. // $this->success("更新成功!");
  638. }
  639. }