|
@@ -217,4 +217,57 @@ class JuliangAccountController extends CatchController
|
|
|
//插入设置最新的时间段百分比
|
|
|
DB::table('juliang_account_promotion_config_time')->insert($data);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 回传开关
|
|
|
+ * @param Request $request
|
|
|
+ * @throws \Illuminate\Validation\ValidationException
|
|
|
+ */
|
|
|
+ public function turnCallbackState(Request $request) {
|
|
|
+ $this->validate($request, ['state' => 'required|integer|in:0,1',
|
|
|
+ 'id' => 'required']);
|
|
|
+ $now = date('Y-m-d H:i:s');
|
|
|
+ $config = DB::table('juliang_account_callback_config')
|
|
|
+ ->where([
|
|
|
+ 'id' => $request->input('id'),
|
|
|
+ 'company_uid' => $this->getOptimizerUid(),
|
|
|
+ ])->first();
|
|
|
+ if(!$config) {
|
|
|
+ CommonBusinessException::throwError(Errors::JULIANG_ACCOUNT_CONFIG_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ DB::table('juliang_account_callback_config')
|
|
|
+ ->where('id', $request->input('id'))
|
|
|
+ ->update([
|
|
|
+ 'state' => $request->input('state'),
|
|
|
+ 'updated_at' => $now
|
|
|
+ ]);
|
|
|
+ if(1 == $request->input('state')) {
|
|
|
+ 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';
|
|
|
+ }
|
|
|
}
|