Prechádzať zdrojové kódy

Merge branch 'kuaiyingyong' into kuaiyingyong_push_stat

Wang Chen 4 rokov pred
rodič
commit
f3f7b90f69

+ 35 - 3
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -112,6 +112,14 @@ class ChapterController extends BaseController
         }
 
         if ($chapter->is_vip == 0) {
+            ReadRecordService::addReadLog($this->uid, [
+                'distribution_channel_id' => $this->distribution_channel_id,
+                'bid' => $bid,
+                'cid' => $chapter->id,
+                'uid' => $this->uid,
+                'send_order_id' => $this->send_order_id,
+                'sequence' => $chapter->sequence,
+            ]);
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
                 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
@@ -122,15 +130,23 @@ class ChapterController extends BaseController
         // 书籍是否限免
         $free = BookConfigService::judgeBookIsFree($bid);
         if ($free) {
+            ReadRecordService::addReadLog($this->uid, [
+                'distribution_channel_id' => $this->distribution_channel_id,
+                'bid' => $bid,
+                'cid' => $chapter->id,
+                'uid' => $this->uid,
+                'send_order_id' => $this->send_order_id,
+                'sequence' => $chapter->sequence,
+            ]);
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
                 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
             ]);
-            if($chapter->is_vip == 1){
+            if ($chapter->is_vip == 1) {
                 $fee  = $this->getPrice($book_info, $chapter->size);
                 $now = date('Y-m-d');
-                Redis::hincrby('qapp:book:free:virtual:'.$free->id,$now,$fee);
-                Redis::sadd('qapp:free:virtual'.$now,$free->id);
+                Redis::hincrby('qapp:book:free:virtual:' . $free->id, $now, $fee);
+                Redis::sadd('qapp:free:virtual' . $now, $free->id);
             }
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
         }
@@ -138,6 +154,14 @@ class ChapterController extends BaseController
 
         //已经付费
         if ($this->getOrderRecord($bid, $cid)) {
+            ReadRecordService::addReadLog($this->uid, [
+                'distribution_channel_id' => $this->distribution_channel_id,
+                'bid' => $bid,
+                'cid' => $chapter->id,
+                'uid' => $this->uid,
+                'send_order_id' => $this->send_order_id,
+                'sequence' => $chapter->sequence,
+            ]);
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
                 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
@@ -179,6 +203,14 @@ class ChapterController extends BaseController
         //付费 不提醒
         if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, 0)) {
             UserTaskService::addUserTaskQueue($this->uid, BaseTask::read, UserTaskService::judge_trigger);
+            ReadRecordService::addReadLog($this->uid, [
+                'distribution_channel_id' => $this->distribution_channel_id,
+                'bid' => $bid,
+                'cid' => $chapter->id,
+                'uid' => $this->uid,
+                'send_order_id' => $this->send_order_id,
+                'sequence' => $chapter->sequence,
+            ]);
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
                 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence

+ 6 - 5
app/Http/Controllers/QuickApp/User/Transformers/ReadRecordTransformer.php

@@ -9,12 +9,13 @@ class ReadRecordTransformer
     public function transform($res)
     {
         return [
-            'book_id' => Hashids::encode($res->bid),
-            'cid' => $res->cid,
-            'book_name' => $res->book_name,
+            'book_id'      => Hashids::encode($res->bid),
+            'cid'          => $res->cid,
+            'book_name'    => $res->book_name,
             'chapter_name' => $res->chapter_name,
-            'time' => $res->time,
-            'cover' => $res->cover,
+            'time'         => $res->time,
+            'cover_url'    => $res->cover,
+            'cover'        => $res->cover,
             'last_chapter' => $res->last_chapter
         ];
     }

+ 7 - 4
app/Modules/AdPosition/Services/AdPositionService.php

@@ -97,7 +97,7 @@ class AdPositionService
         $order  = OrderService::getUserLastestOrder($uid);
         $isPaid = $order ? 1 : 0;
 
-        return compact('registerUnix', 'isPaid');
+        return compact('uid', 'registerUnix', 'isPaid');
     }
 
     /**
@@ -114,6 +114,8 @@ class AdPositionService
             return true;
         }
 
+        myLog('getAdPositions')->info('', compact('filterContent', 'userData'));
+
         // 判断注册时间
         $registerFilter = true;
         $registerAtArr  = getProp($filterContent, 'registerAt');
@@ -141,15 +143,16 @@ class AdPositionService
         $paidFilter = true;
         if (getProp($filterContent, 'isPaid') !== '') {
             // 获取用户付费情况
-            $isPaid = getProp($userData, 'isPaid', 0);
+            $isPaid     = getProp($userData, 'isPaid', 0);
+            $paidFilter = false;
 
             // 有付费
-            if ($isPaid && getProp($filterContent, 'isPaid') === 1) {
+            if ($isPaid && (int)getProp($filterContent, 'isPaid') === 1) {
                 $paidFilter = true;
             }
 
             // 未付费
-            if (!$isPaid && getProp($filterContent, 'isPaid') === 0) {
+            if (!$isPaid && (int)getProp($filterContent, 'isPaid') === 0) {
                 $paidFilter = true;
             }
         }

+ 30 - 0
app/Modules/User/Models/ReadLog.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Modules\User\Models;
+
+use App\Modules\TableSuffix;
+use Illuminate\Database\Eloquent\Model;
+
+class ReadLog extends Model
+{
+    use TableSuffix;
+
+    protected $table = 'record_logs';
+    protected $fillable = [
+        'distribution_channel_id',
+        'bid',
+        'cid',
+        'uid',
+        'send_order_id',
+        'from',
+        'attach',
+        'sequence',
+    ];
+    protected $connection = 'qapp_log_mysql';
+
+    public static function model(int $uid)
+    {
+        self::suffix($uid % 1024);
+        return new static;
+    }
+}

+ 10 - 0
app/Modules/User/Services/ReadRecordService.php

@@ -14,6 +14,7 @@ use Redis;
 use Hashids;
 use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Book\Models\Chapter;
+use App\Modules\User\Models\ReadLog;
 use DB;
 
 class ReadRecordService
@@ -663,4 +664,13 @@ class ReadRecordService
             }
         }
     }
+
+    /**
+     * 添加用户的阅读记录
+     */
+    public static function addReadLog(int $uid, array $data)
+    {
+        $log = ReadLog::model($uid);
+        $log->create($data);
+    }
 }

+ 5 - 1
config/audit.php

@@ -1,6 +1,10 @@
 <?php
 return [
-    'com.app.kyy.xjxs' => [
+    'com.app.kyy.xjxs'       => [
+        'brand'       => 'huawei',
+        'codeVersion' => '0.0.2'
+    ],
+    'com.juyu.kuaiying.rmyq' => [
         'brand'       => 'huawei',
         'codeVersion' => '0.0.2'
     ],

+ 13 - 0
config/database.php

@@ -97,6 +97,19 @@ return [
             'strict' => false,
             'engine' => null,
         ],
+        'qapp_log_mysql' => [
+            'driver' => 'mysql',
+            'host' => env('QAPP_LOG_DB_HOST', 'localhost'),
+            'port' => env('QAPP_LOG_DB_PORT', '3306'),
+            'database' => env('QAPP_LOG_DB_DATABASE', 'forge'),
+            'username' => env('QAPP_LOG_DB_USERNAME', 'forge'),
+            'password' => env('QAPP_LOG_DB_PASSWORD', ''),
+            'charset' => 'utf8',
+            'collation' => 'utf8_unicode_ci',
+            'prefix' => '',
+            'strict' => false,
+            'engine' => null,
+        ],
         'new_yunqi' => [
             'driver' => 'mysql',
             'host' => env('NEW_YUNQI_DB_HOST', 'localhost'),