|
@@ -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__×tamp=__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';
|