|
@@ -14,12 +14,6 @@ class PromotionController extends CatchController
|
|
|
{
|
|
|
use UserTrait;
|
|
|
use ValidatesRequests;
|
|
|
-
|
|
|
- /**
|
|
|
- * 推广列表
|
|
|
- * @param Request $request
|
|
|
- * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
|
|
- */
|
|
|
public function list(Request $request) {
|
|
|
$callbackTypeMap = [
|
|
|
'0' => '无',
|
|
@@ -58,19 +52,16 @@ 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.*', 'videos.name as video_name')
|
|
|
+ ->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')
|
|
|
->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 ? '启用':'禁用';
|
|
@@ -83,8 +74,7 @@ class PromotionController extends CatchController
|
|
|
'&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 ?? '';
|
|
|
- $item->yinliu_type_str = 1 == $item->yinliu_type ? '公众号引流' : '';
|
|
|
- $item->yinliu_gzhid_str = $gzhs->get($item->yinliu_gzhid)->nick_name ?? '';
|
|
|
+
|
|
|
}
|
|
|
return $result;
|
|
|
|
|
@@ -104,12 +94,7 @@ 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',
|
|
|
- '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'
|
|
|
- ]);
|
|
|
+ 'not_first_charge_template_id' => 'required',]);
|
|
|
|
|
|
DB::table('promotions')
|
|
|
->where(['id' => $request->input('id'), 'uid' => $this->getLoginUserId(), 'is_enabled' => 1])
|
|
@@ -117,10 +102,6 @@ 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';
|