Browse Source

Merge branch 'liuzj-1001016-dev' into test

liuzejian 1 năm trước cách đây
mục cha
commit
93b1b30464

+ 4 - 1
app/Console/Commands/ContentManage/ContentTest.php

@@ -44,8 +44,11 @@ class ContentTest extends Command
             'charge_num' => '1-1',
             'remain_coin' => '0-1',
             'last_charge_day' => '0-4',
+            'video_watch' => [1,2,3],
+            'video_charge' => [4,5]
         ];
 
-        $sql = UserGroupService::getSQL($tags);
+        $sql = UserGroupService::getSQL($tags)->distinct()->count('a.uid');
+        dump($sql);
     }
 }

+ 17 - 13
modules/Audience/Http/Controllers/UserGroupController.php

@@ -8,6 +8,7 @@ use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Modules\Audience\Models\GzhUgMapModel;
 use Modules\Audience\Models\UserGroupModel;
+use Modules\Audience\Services\UserGroupService;
 
 class UserGroupController extends CatchController
 {
@@ -42,19 +43,22 @@ class UserGroupController extends CatchController
                 'id' => $request->input('id')
             ])->first();
         if($obj) {
-            // ToDo:完善
-            $obj->user_num = '-1';
-            $obj->tags_arr = \json_decode($obj->tags, true);
-            $obj->gzh_names = DB::table('gzh_ug_maps as a')
-                            ->join('wechat_authorization_infos as b', function($query) use ($uid) {
-                                $query->on('a.gzh_id', '=', 'b.id')
-                                    ->where([
-                                        'b.is_enabled' => 1,
-                                        'b.user_id' => $uid
-                                    ]);
-                            })->where([
-                                'a.ug_id' => $request->input('id')
-                ])->select('b.nick_name')->get()->pluck('nick_name')->toArray();
+            $gzhInfo = DB::table('gzh_ug_maps as a')
+                ->join('wechat_authorization_infos as b', function($query) use ($uid) {
+                    $query->on('a.gzh_id', '=', 'b.id')
+                        ->where([
+                            'b.is_enabled' => 1,
+                            'b.user_id' => $uid
+                        ]);
+                })->where([
+                    'a.ug_id' => $request->input('id')
+                ])->select('b.nick_name', 'b.authorizer_appid')->get();
+            $tags = \json_decode($obj->tags, true);
+            $tags['gzh_appids'] = $gzhInfo->pluck('authorizer_appid')->toArray();
+            $tags['in_48_hour'] = 1;
+            $obj->user_num = UserGroupService::getSQL($tags)->distinct()->count('a.uid');
+            $obj->tags_arr = $tags;
+            $obj->gzh_names = $gzhInfo->pluck('nick_name')->toArray();
         }
 
         return $obj;

+ 9 - 1
modules/Audience/Services/UserGroupService.php

@@ -62,7 +62,7 @@ class UserGroupService
             }
         }
 
-        if($tags['charge_type']){
+        if($tags['charge_type'] ?? ''){
             switch ($tags['charge_type']) {
                 case 4:
                     $sql->where('a.is_vip', 1)
@@ -110,6 +110,14 @@ class UserGroupService
             $sql->where('b.uid', $tags['uid']);
         }
 
+        if($tags['video_watch'] ?? []) {
+            $sql->whereRaw(sprintf("json_contains(a.video_watch, cast('[%s]' as json))",
+                join(',', $tags['video_watch'])));
+        }
+        if($tags['video_charge'] ?? []) {
+            $sql->whereRaw(sprintf("json_contains(a.video_charge, cast('[%s]' as json))",
+                join(',', $tags['video_charge'])));
+        }
         return $sql;
     }
 

+ 1 - 1
modules/WechatPlatform/Http/Controllers/KFMessageController.php

@@ -159,7 +159,7 @@ class KFMessageController extends CatchController
             ['status', '=', WechatPlatformConstService::KF_MESSAGE_STATUS_PRE_SEND],
             ['is_enabled', '=', 1],
         ])->first();
-        if(!$message) {
+        if($message) {
             $allGzhIds = $request->input('gzh_ids');
             if(2 == $message->u_type) {
                 $configGzhIds = DB::table('gzh_ug_maps')

+ 2 - 2
tests/WechatPlatform/Http/KFMessageControllerTest.php

@@ -62,8 +62,8 @@ AAA;
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
         ])->json('post','http://localhost/api/wechatPlatform/kfMessage/updateGZH', [
-            'id' => 4,
-            'gzh_ids' => [1,2]
+            'id' => 2,
+            'gzh_ids' => [1,2,3]
         ]);
         $this->dumpJson($res);
     }