瀏覽代碼

Merge branch 'kuaiyingyong' of iqiyoo:zhuishuyun_wap into kuaiyingyong

fly 5 年之前
父節點
當前提交
f22d0a6848

+ 29 - 19
app/Http/Controllers/QuickApp/User/ShortcutController.php

@@ -36,15 +36,20 @@ class ShortcutController extends BaseController
      */
 
     function delete(Request $request){
-        $uid = $this->uid;
-        $data = [
-            'uid'=>$uid,
-            'status'=>0,
-            'created_at'=>date("Y-m-d H:i:s"),
-            'updated_at'=>date("Y-m-d H:i:s"),
+        $res = DB::table('quickapp_shortcuts')->where('uid',$this->uid)->first();
+        if($res){
+            $res->status = 0;
+            $res->save();
+        }else{
+            $data = [
+                'uid'=>$this->uid,
+                'status'=>0,
+                'created_at'=>date("Y-m-d H:i:s"),
+                'updated_at'=>date("Y-m-d H:i:s"),
 
-        ];
-        $res = DB::table('quickapp_shortcuts')->insert($data);
+            ];
+            $res = DB::table('quickapp_shortcuts')->insert($data);
+        }
         return response()->success();
     }
 
@@ -70,18 +75,23 @@ class ShortcutController extends BaseController
      */
 
 
-    function add(Request $request){
-        $uid = $this->uid;
-        $data = [
-            'uid'=>$uid,
-            'status'=>1,
-            'created_at'=>date("Y-m-d H:i:s"),
-            'updated_at'=>date("Y-m-d H:i:s"),
+    function add(Request $request)
+    {
+        $res = DB::table('quickapp_shortcuts')->where('uid', $this->uid)->first();
+        if ($res) {
+            $res->status = 1;
+            $res->save();
+        } else {
+            $data = [
+                'uid' => $this->uid,
+                'status' => 1,
+                'created_at' => date("Y-m-d H:i:s"),
+                'updated_at' => date("Y-m-d H:i:s"),
 
-        ];
-        $res = DB::table('quickapp_shortcuts')->insert($data);
+            ];
+            $res = DB::table('quickapp_shortcuts')->insert($data);
+        }
         return response()->success();
-    }
-
 
+    }
 }

+ 4 - 5
app/Http/Controllers/QuickApp/User/UserShelfBooksController.php

@@ -84,7 +84,7 @@ class UserShelfBooksController extends BaseController
 //        $record=array([
 //            'bid'=>1,
 //            'time'=>3,
-//            'cid'=>4,
+//            'cid'=>1,
 //        ],[
 //            'bid'=>2,
 //            'time'=>3,
@@ -93,15 +93,14 @@ class UserShelfBooksController extends BaseController
         foreach ($res as &$v){
             $bid=$v['bid'];
             $last_cid = $v['last_cid'];
-            $last_chapter = ChapterService::getChapterNameById($last_cid,$bid);
-            $v['last_chapter']="最后章节:第{$last_cid}章 {$last_chapter['name']}";
+            $last_chapter = ChapterService::getChapterNameByID($last_cid,$bid);
+            $v['last_chapter']="最后章节:{$last_chapter['name']}";
             foreach ($record as $val){
                 if($v['bid'] == $val['bid']){
                     $v['updated_at'] = $val['time'];
                     $recent_reading_cid = $val['cid'];
-//                    dd($recent_reading_cid);
                     $recent_reading_chapter = ChapterService::getChapterNameById($recent_reading_cid,$bid);
-                    $v['recent_reading_chapter'] = "最近阅读:第{$recent_reading_cid}章 {$recent_reading_chapter['name']}";
+                    $v['recent_reading_chapter'] = "最近阅读:{$recent_reading_chapter['name']}";
                     break;
                 }
             }

+ 1 - 1
app/Modules/BaseService.php

@@ -7,7 +7,7 @@ trait BaseService
 {
     private static $_instance;
 
-    public function __callStatic($name, $arguments)
+    public  function __callStatic($name, $arguments)
     {
         $name = preg_replace('/Static$/', '', $name);
         if (self::$_instance == null) {