|
@@ -33,7 +33,7 @@ class JuliangAccountController extends CatchController
|
|
|
->get()->pluck('callback_config_id')->toArray();
|
|
|
}
|
|
|
|
|
|
- return DB::table('juliang_account_callback_config')
|
|
|
+ $list = DB::table('juliang_account_callback_config')
|
|
|
->where(['company_uid' => $this->getOptimizerUid()])
|
|
|
->when($advAccountId, function ($query, $advAccountId) {
|
|
|
return $query->where('adv_account_id' , $advAccountId);
|
|
@@ -44,6 +44,22 @@ class JuliangAccountController extends CatchController
|
|
|
})
|
|
|
->orderBy('id', 'desc')
|
|
|
->paginate($request->input('limit', 30));
|
|
|
+ $ids = collect($list->items())->pluck('id');
|
|
|
+ $promotions = DB::table('promotions')
|
|
|
+ ->where([
|
|
|
+ 'uid' => $this->getOptimizerUid(),
|
|
|
+ 'callback_type' => 1,
|
|
|
+ 'status' => 1,
|
|
|
+ 'is_enabled' => 1,
|
|
|
+ ])->whereIn('callback_config_id', $ids)
|
|
|
+ ->select('name', 'id', 'callback_config_id')
|
|
|
+ ->get()->keyBy('callback_config_id');
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $item->promotion_name = $promotions->get($item->id)->name ?? '';
|
|
|
+ $item->promotion_id = $promotions->get($item->id)->id ?? '';
|
|
|
+ }
|
|
|
+
|
|
|
+ return $list;
|
|
|
}
|
|
|
|
|
|
public function addAccount(Request $request) {
|
|
@@ -307,7 +323,7 @@ class JuliangAccountController extends CatchController
|
|
|
CommonBusinessException::throwError(Errors::JULIANG_ACCOUNT_CONFIG_NOT_EXISTS);
|
|
|
}
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
- DB::table('promotions')
|
|
|
+ $affected = DB::table('promotions')
|
|
|
->where([
|
|
|
'callback_type' => 1,
|
|
|
'callback_config_id' => $request->input('id'),
|
|
@@ -317,30 +333,33 @@ class JuliangAccountController extends CatchController
|
|
|
'status' => 0,
|
|
|
'updated_at' => $now,
|
|
|
]);
|
|
|
- DB::table('juliang_account_rate_config_log')
|
|
|
- ->where('company_uid', $this->getOptimizerUid())
|
|
|
- ->where('account_id', $config->adv_account_id)
|
|
|
- ->where('is_enabled', 1)
|
|
|
- ->update(['is_enabled' => 0, 'updated_at' => $now]);
|
|
|
- DB::table('juliang_account_promotion_protect_record')
|
|
|
- ->where('optimizer_uid', $this->getOptimizerUid())
|
|
|
- ->where('advertiser_id', $config->adv_account_id)
|
|
|
- ->where('is_enabled', 1)
|
|
|
- ->update(['is_enabled' => 0, 'updated_at' => $now]);
|
|
|
- DB::table('juliang_account_rate_config_log')
|
|
|
- ->insert([
|
|
|
- 'company_uid' => $this->getOptimizerUid(),
|
|
|
- 'account_id' => $config->adv_account_id,
|
|
|
- 'config_per' => $config->default_rate,
|
|
|
- 'created_at' => $now,
|
|
|
- 'updated_at' => $now,
|
|
|
- ]);
|
|
|
- // 让所有的时间区间比例配置,在定时任务中,重新执行一遍
|
|
|
- DB::table('juliang_account_promotion_config_time')
|
|
|
- ->where('is_enable',1)
|
|
|
- ->where('company_uid',$this->getOptimizerUid())
|
|
|
- ->where('account_id',$config->adv_account_id)
|
|
|
- ->update(['next_exec_time' => date('Y-m-d'), 'updated_at' => $now]);
|
|
|
+ if($affected) {
|
|
|
+ DB::table('juliang_account_rate_config_log')
|
|
|
+ ->where('company_uid', $this->getOptimizerUid())
|
|
|
+ ->where('account_id', $config->adv_account_id)
|
|
|
+ ->where('is_enabled', 1)
|
|
|
+ ->update(['is_enabled' => 0, 'updated_at' => $now]);
|
|
|
+ DB::table('juliang_account_promotion_protect_record')
|
|
|
+ ->where('optimizer_uid', $this->getOptimizerUid())
|
|
|
+ ->where('advertiser_id', $config->adv_account_id)
|
|
|
+ ->where('is_enabled', 1)
|
|
|
+ ->update(['is_enabled' => 0, 'updated_at' => $now]);
|
|
|
+ DB::table('juliang_account_rate_config_log')
|
|
|
+ ->insert([
|
|
|
+ 'company_uid' => $this->getOptimizerUid(),
|
|
|
+ 'account_id' => $config->adv_account_id,
|
|
|
+ 'config_per' => $config->default_rate,
|
|
|
+ 'created_at' => $now,
|
|
|
+ 'updated_at' => $now,
|
|
|
+ ]);
|
|
|
+ // 让所有的时间区间比例配置,在定时任务中,重新执行一遍
|
|
|
+ DB::table('juliang_account_promotion_config_time')
|
|
|
+ ->where('is_enable',1)
|
|
|
+ ->where('company_uid',$this->getOptimizerUid())
|
|
|
+ ->where('account_id',$config->adv_account_id)
|
|
|
+ ->update(['next_exec_time' => date('Y-m-d'), 'updated_at' => $now]);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return 'ok';
|
|
|
}
|