浏览代码

fix bug $qapp_user 为空

fly 4 年之前
父节点
当前提交
2551758a4b
共有 2 个文件被更改,包括 17 次插入18 次删除
  1. 1 1
      app/Http/Controllers/QuickApp/Book/ChapterController.php
  2. 16 17
      app/Modules/User/Services/QappUserService.php

+ 1 - 1
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -127,7 +127,7 @@ class ChapterController extends BaseController
         $bid    = BookService::decodeBidStatic($bid);
         //获取图书信息
         $book_info = BookConfigService::getBookById($bid);
-        if (!$book_info)
+        if (empty($book_info))
             return response()->error('QAPP_SYS_ERROR');
         if($this->distribution_channel_id == 7477 && $bid == 13765){
             $book_info->is_on_shelf = 2;

+ 16 - 17
app/Modules/User/Services/QappUserService.php

@@ -53,24 +53,23 @@ class QappUserService
             $isNewRegister = true;
             $qapp_user     = $this->createQuickAppUser($data);
         }
-        $user  = $qapp_user->user;
-        $uid   = $user->id;
-        $time  = strtotime("+1 month");
-        $token = JWTAuth::fromUser($user);
-        if ($data['send_order_id']) {
-            UserService::setUserSendOrder((int)$uid, (int)$data['send_order_id']);
-        }
-        // 新注册统计
-        if ($isNewRegister && $qapp_user) {
-            // 注册统计
-            QappAddDeskTopService::incrAddDeskTop($uid, QuickConst::FIELD_REGISTER);
-
-            // 释放锁
-            //            if ($lockToken) {
-            //                LockCache::releaseLock($lockToken);
-            //            }
+        if ($qapp_user) {
+            $user  = $qapp_user->user;
+            $uid   = $user->id;
+            $time  = strtotime("+1 month");
+            $token = JWTAuth::fromUser($user);
+            if ($data['send_order_id']) {
+                UserService::setUserSendOrder((int)$uid, (int)$data['send_order_id']);
+            }
+            // 新注册统计
+            if ($isNewRegister && $qapp_user) {
+                // 注册统计
+                QappAddDeskTopService::incrAddDeskTop($uid, QuickConst::FIELD_REGISTER);
+            }
+            return compact('token', 'time', 'uid');
+        } else {
+            return [];
         }
-        return compact('token', 'time', 'uid');
     }
 
     public function getGolableUser()