Quellcode durchsuchen

引流管理,推广配置

liuzejian vor 1 Jahr
Ursprung
Commit
e541da88fe

+ 25 - 6
modules/Tuiguang/Http/Controllers/PromotionController.php

@@ -14,6 +14,12 @@ class PromotionController extends CatchController
 {
     use UserTrait;
     use ValidatesRequests;
+
+    /**
+     * 推广列表
+     * @param Request $request
+     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
+     */
     public function list(Request $request) {
         $callbackTypeMap = [
             '0' => '无',
@@ -52,16 +58,19 @@ class PromotionController extends CatchController
             })->when($endTime, function ($query, $endTime){
                 return $query->where('promotions.created_at', '<=', $endTime . ' 23:59:59');
             })->orderBy('created_at', 'desc')
-            ->select('promotions.id', 'promotions.name', 'promotions.created_at',
-            'videos.name as video_name', 'promotions.series_sequence', 'promotions.callback_type',
-                'promotions.callback_config_id', 'promotions.video_id', 'promotions.remark', 'promotions.status',
-            'promotions.first_charge_template_id', 'promotions.not_first_charge_template_id')
+            ->select('promotions.*', 'videos.name as video_name')
             ->paginate($request->input('limit', 15));
         $chargeTemplateIds = $result->pluck('first_charge_template_id')->merge($result->pluck('not_first_charge_template_id'))->unique();
 
         $payTemplates = DB::table('pay_templates')->whereIn('id', $chargeTemplateIds)
             ->select('id', 'name')
             ->get()->keyBy('id')->toArray();
+        $yinliuGzhids = $result->pluck('yinliu_gzhid')->diff([0]);
+
+        $gzhs = $yinliuGzhids->isEmpty() ? collect() :
+            DB::table('wechat_authorization_infos')
+            ->whereIn('id', $yinliuGzhids)
+            ->select('id', 'nick_name')->get()->keyBy('id');
 
         foreach ($result as $item) {
             $item->status_str = $item->status ? '启用':'禁用';
@@ -74,7 +83,8 @@ class PromotionController extends CatchController
                 '&adid=__AID__&cid=__CID__&imei=__IMEI__&oaid=__OAID__&mac=__MAC__&os=__OS__&ip=__IP__&androidid=__ANDROIDID__&ua=__UA__&timestamp=__TS__&callback_url=__CALLBACK_URL__&projectid=__PROJECT_ID__&promotionid=__PROMOTION_ID__&advertiser_id=__ADVERTISER_ID__&campaign_id=__CAMPAIGN_ID__';
             $item->first_charge_template_str = $payTemplates[$item->first_charge_template_id]->name ?? '';
             $item->not_first_charge_template_str = $payTemplates[$item->not_first_charge_template_id]->name ?? '';
-
+            $item->yinliu_type_str = 1 == $item->yinliu_type ? '公众号引流' : '';
+            $item->yinliu_gzhid_str = $gzhs->get($item->yinliu_gzhid)->nick_name ?? '';
         }
         return $result;
 
@@ -94,7 +104,12 @@ class PromotionController extends CatchController
         $this->validate($request, ['id' => 'required',
             'series_sequence' => 'required', 'remark' => 'nullable|string|max:140',
             'first_charge_template_id' => 'required',
-            'not_first_charge_template_id' => 'required',]);
+            'not_first_charge_template_id' => 'required',
+            'yinliu_enabled' => 'required|in:0,1',
+            'yinliu_type' => 'required_if:yinliu_enabled,1|in:1',
+            'yinliu_gzhid' => 'required_if:yinliu_enabled,1',
+            'yinliu_sequence' => 'required_if:yinliu_enabled,1|min:1'
+            ]);
 
         DB::table('promotions')
             ->where(['id' => $request->input('id'), 'uid' => $this->getLoginUserId(), 'is_enabled' => 1])
@@ -102,6 +117,10 @@ class PromotionController extends CatchController
                 'remark' => $request->input('remark') ?? '',
                 'first_charge_template_id' => $request->input('first_charge_template_id'),
                 'not_first_charge_template_id' => $request->input('not_first_charge_template_id'),
+                'yinliu_enabled' => $request->input('yinliu_enabled'),
+                'yinliu_type' => $request->input('yinliu_type',1),
+                'yinliu_gzhid' => $request->input('yinliu_gzhid', 0),
+                'yinliu_sequence' => $request->input('yinliu_sequence', 0),
                 'updated_at' => date('Y-m-d H:i:s')]);
 
         return 'ok';

+ 2 - 0
modules/Yinliu/Http/Controllers/YinliuManageController.php

@@ -51,7 +51,9 @@ class YinliuManageController extends CatchController
         $this->validate($request, [
             'focus_type' => 'required|in:1',
             'gzh_id' => 'required',
+            // 播放页弹窗设置:1-强制关注,2-引导关注,3-不关注
             'pop_type' => 'required|in:1,2,3',
+            // pop_type == 2 时,弹窗设置:1-仅设置剧集弹窗,2-设置剧集及后每集弹窗
             'pop_type_sub' => 'required_if:pop_type,2|in:1,2',
             'link_type' => 'required|in:1,2',
             'link_url' => 'required',

+ 11 - 7
tests/Tuiguang/Http/Controllers/PromotionControllerTest.php

@@ -42,11 +42,15 @@ class PromotionControllerTest extends UsedTestCase
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
         ])->json('post','http://localhost/api/tuiguang/promotion/updateSeriesSequence', [
-            'id' => 136,
-            'series_sequence' => 5,
+            'id' => 10,
+            'series_sequence' => 6,
             'remark' => '',
             'first_charge_template_id' => 1,
-            'not_first_charge_template_id' => 2
+            'not_first_charge_template_id' => 2,
+            'yinliu_enabled' => 1,
+            'yinliu_type' => 1,
+            'yinliu_gzhid' => 8,
+            'yinliu_sequence' => 3
         ]);
 
         $res->dump();
@@ -57,12 +61,12 @@ class PromotionControllerTest extends UsedTestCase
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
         ])->json('get','http://localhost/api/tuiguang/promotion/list', [
-//            'is_config' => 0,
-//            'name' => 'kkk'
+            'is_config' => 1,
+//            'name' => 'kkk',
+            'id' => 10
         ]);
 
-        $res->dump();
-//        $this->dumpJson($res);
+        $this->dumpJson($res);
     }
 
     public function testupdateCallbackConfig() {