zz 4 gadi atpakaļ
vecāks
revīzija
2dfa4b5b83

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

@@ -208,6 +208,7 @@ class ChapterController extends BaseController
                 $now = date('Y-m-d');
                 Redis::hincrby('qapp:book:free:virtual:' . $free->id, $now, $fee);
                 Redis::sadd('qapp:free:virtual' . $now, $free->id);
+                Redis::sadd('qapp:free:virtual:uids'.$now.$free->id,$this->uid);
             }
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
         }
@@ -276,7 +277,16 @@ class ChapterController extends BaseController
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
                 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
             ]);
-
+            //限免统计
+            $free_book = BookConfigService::getByBidNoFilter($bid);
+            if($free_book) {
+                if(strtotime($free_book->end_time)+7*86400 >= strtotime(date('Y-m-d')))   {
+                    $now = date('Y-m-d');
+                    Redis::hincrby('qapp:book:free:actuality:' . $free_book->id, $now, $fee);
+                    Redis::sadd('qapp:free:actuality' . $now, $free_book->id);
+                    Redis::sadd('qapp:free:actuality:uids'.$now.$free_book->id,$this->uid);
+                }
+            }
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
         } else {
             if ($book_info->charge_type == 'BOOK') {

+ 3 - 1
app/Modules/Book/Services/BookConfigService.php

@@ -556,11 +556,13 @@ class BookConfigService
             ->first();
     }
 
-    public static function chargeStats($id,$amount){
+    public static function chargeStats($id,$amount,$uid){
         $now = date('Y-m-d');
         $amount = $amount*100;
         Redis::hincrby('qapp:book:free:charge:'.$id,$now,$amount);
         Redis::sadd('qapp:free:charge'.$now,$id);
+        Redis::sadd('qapp:free:actuality' . $now, $id);
+        Redis::sadd('qapp:free:charge:uids'.$now.$id,$uid);
     }
 
     public static function getBookByField($bids,$field){

+ 4 - 4
app/Modules/Trade/Pay/OrderPaySuccess.php

@@ -45,7 +45,7 @@ class OrderPaySuccess
                     'created_at' => date('Y-m-d H:i:s')
                 ]);
             }
-            self::freeBookStats($order->from_bid,$order->price);
+            self::freeBookStats($order->from_bid,$order->price,$order->uid);
             return $status;
         } else {
             return false;
@@ -53,12 +53,12 @@ class OrderPaySuccess
     }
 
 
-    private static function freeBookStats($bid,$price){
+    private static function freeBookStats($bid,$price,$uid){
         if(!$bid) return ;
         $free_book = BookConfigService::getByBidNoFilter($bid);
         if(!$free_book) return ;
-        if(strtotime($free_book->end_time)+14*86400 < time())   return ;
-        BookConfigService::chargeStats($free_book->id,$price);
+        if(strtotime($free_book->end_time)+7*86400 < time())   return ;
+        BookConfigService::chargeStats($free_book->id,$price,$uid);
     }
 
     private static function orderAcrossDay($order_info)