Browse Source

free stats

zz 4 years ago
parent
commit
6457944d08

+ 7 - 4
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -209,6 +209,7 @@ class ChapterController extends BaseController
                 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);
+                Redis::sadd('qapp:free:virtual:uids'.$free->id,$this->uid);
             }
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
         }
@@ -281,10 +282,12 @@ class ChapterController extends BaseController
             $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);
+                    if(Redis::Sismember('qapp:free:virtual:uids'.$free_book->id,$this->uid)){
+                        $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));

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

@@ -557,10 +557,13 @@ class BookConfigService
     }
 
     public static function chargeStats($id,$amount,$uid){
+        if(!Redis::Sismember('qapp:free:virtual:uids'.$id,$uid)){
+            return ;
+        }
         $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:charge'.$now,$id);
         Redis::sadd('qapp:free:actuality' . $now, $id);
         Redis::sadd('qapp:free:charge:uids'.$now.$id,$uid);
     }