瀏覽代碼

Merge branch 'liuzj-1000959-dev' into stable

# Conflicts:
#	modules/Channel/Http/Controllers/PayTemplateController.php
#	modules/Tuiguang/Http/Controllers/PromotionController.php
liuzejian 1 年之前
父節點
當前提交
6b0395a867

+ 6 - 5
modules/Channel/Http/Controllers/PayTemplateController.php

@@ -14,12 +14,12 @@ use Modules\Channel\Services\User\UserService;
 
 class PayTemplateController extends CatchController
 {
+
+    use ValidatesRequests;
     public function __construct(protected readonly PayTemplate $payTemplate,protected readonly PayTemplateItem $payTemplateItem,protected readonly PayProduct $payProduct)
     {
 
     }
-
-
     private $sequence_map = [
         '','位置一','位置二','位置三','位置四','位置五','位置六','位置七','位置八'
     ];
@@ -37,9 +37,10 @@ class PayTemplateController extends CatchController
             $uid = 0;
         }
         $name = $request->get('name');
-        $where = [[
-            'uid','=',$uid
-        ]];
+
+        // 1-首充模板,2-非首充模板
+        $type = $request->input('type');
+        $where = [['uid','=',$uid,], ['type', '=', $type,]];
         if($name){
             $where[] = ['name','like','%'.$name.'%'];
         }

+ 1 - 1
modules/Channel/Models/PayTemplate.php

@@ -8,7 +8,7 @@ class PayTemplate extends BaseModel
     protected $table = 'pay_templates';
 
     protected $fillable = [
-        'id', 'name', 'uid','status', 'created_at', 'updated_at',
+        'id', 'name', 'uid','status', 'created_at', 'updated_at','type'
     ];
 
 }

+ 15 - 5
modules/Tuiguang/Http/Controllers/PromotionController.php

@@ -14,7 +14,6 @@ class PromotionController extends CatchController
 {
     use UserTrait;
     use ValidatesRequests;
-
     public function list(Request $request) {
         $callbackTypeMap = [
             '0' => '无',
@@ -54,9 +53,16 @@ class PromotionController extends CatchController
                 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', 'miniprogram.name as miniprogram_name')
+            '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')
             ->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();
+
         foreach ($result as $item) {
             $item->status_str = $item->status ? '启用':'禁用';
             $item->series_sequence_name = '第'. $item->series_sequence . '集';
@@ -66,8 +72,10 @@ class PromotionController extends CatchController
                 '/track?dycallback=1&connection_id='.$item->id.
                 '&link_source=' .( $linkSourceMap[$item->callback_type] ?? '') .
                 '&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 ?? '';
 
+        }
         return $result;
 
     }
@@ -89,7 +97,9 @@ class PromotionController extends CatchController
         DB::table('promotions')
             ->where(['id' => $request->input('id'), 'uid' => $this->getLoginUserId(), 'is_enabled' => 1])
             ->update(['series_sequence' => $request->input('series_sequence'),
-                'remark' => $request->input('remark', ''),
+                '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'),
                 'updated_at' => date('Y-m-d H:i:s')]);
 
         return 'ok';

+ 5 - 2
tests/Tuiguang/Http/Controllers/PromotionControllerTest.php

@@ -40,8 +40,11 @@ class PromotionControllerTest extends UsedTestCase
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
         ])->json('post','http://localhost/api/tuiguang/promotion/updateSeriesSequence', [
-            'id' => 2,
-            'series_sequence' => 5
+            'id' => 136,
+            'series_sequence' => 5,
+            'remark' => '',
+            'first_charge_template_id' => 1,
+            'not_first_charge_template_id' => 2
         ]);
 
         $res->dump();