|
@@ -19,7 +19,10 @@ class JuliangAccountController extends CatchController
|
|
|
$advAccountId = $request->input('account_id');
|
|
|
$advAccountName = $request->input('account_name');
|
|
|
$unBind = $request->input('unbind', 0);
|
|
|
+ $id = $request->input('id', 0);
|
|
|
$alreadyBindConfigIds = null;
|
|
|
+ $promotionId = $request->input('promotion_id',0);
|
|
|
+
|
|
|
if($unBind) {
|
|
|
$alreadyBindConfigIds = DB::table('promotions')
|
|
|
->where([
|
|
@@ -32,6 +35,24 @@ class JuliangAccountController extends CatchController
|
|
|
->select('callback_config_id')
|
|
|
->get()->pluck('callback_config_id')->toArray();
|
|
|
}
|
|
|
+ $configIds = null;
|
|
|
+ if ($promotionId){
|
|
|
+ $configIds = DB::table('promotions')
|
|
|
+ ->where([
|
|
|
+ 'uid' => $this->getOptimizerUid(),
|
|
|
+ 'id' => $promotionId,
|
|
|
+ 'callback_type' => 1,
|
|
|
+ 'status' => 1,
|
|
|
+ 'is_enabled' => 1,
|
|
|
+ ])->where('callback_config_id' , '<>', 0)
|
|
|
+ ->distinct()
|
|
|
+ ->select('callback_config_id')
|
|
|
+ ->get()->pluck('callback_config_id')->toArray();
|
|
|
+ // 没有数据
|
|
|
+ if (empty($configIds)){
|
|
|
+ return DB::table('juliang_account_callback_config')->where('id','<','0')->paginate($request->input('limit', 30));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
$list = DB::table('juliang_account_callback_config')
|
|
|
->where(['company_uid' => $this->getOptimizerUid()])
|
|
@@ -41,6 +62,10 @@ class JuliangAccountController extends CatchController
|
|
|
return $query->where('adv_account_name', 'like', '%'. $advAccountName. '%');
|
|
|
})->when($alreadyBindConfigIds, function ($query, $alreadyBindConfigIds) {
|
|
|
return $query->whereNotIn('id', $alreadyBindConfigIds);
|
|
|
+ })->when($id,function ($query, $id) {
|
|
|
+ return $query->where('id', $id);
|
|
|
+ })->when($configIds,function ($query, $configIds) {
|
|
|
+ return $query->whereIn('id',$configIds );
|
|
|
})
|
|
|
->orderBy('id', 'desc')
|
|
|
->paginate($request->input('limit', 30));
|
|
@@ -65,7 +90,7 @@ class JuliangAccountController extends CatchController
|
|
|
public function addAccount(Request $request) {
|
|
|
$this->validate($request, [
|
|
|
'account_id' => 'required',
|
|
|
- 'account_name' => 'required|string|max:64',
|
|
|
+ // 'account_name' => 'required|string|max:64',
|
|
|
'state' => 'required|integer|in:0,1',
|
|
|
'protect_num' => 'required|integer|min:0',
|
|
|
'default_rate' => 'required|min:0|max:100',
|
|
@@ -84,20 +109,24 @@ class JuliangAccountController extends CatchController
|
|
|
CommonBusinessException::throwError(Errors::CALLBACK_RATE_TIME_RANGE_ERROR);
|
|
|
}
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
+ $param = [
|
|
|
+ 'adv_account_id' => $request->input('account_id'),
|
|
|
+ 'adv_account_name' => $request->input('account_name',''),
|
|
|
+ 'state' => $request->input('state'),
|
|
|
+ 'protect_num' => $request->input('protect_num'),
|
|
|
+ 'default_rate' => $request->input('default_rate'),
|
|
|
+ 'rate_time_config' => \json_encode($request->input('rate_time_config', [])),
|
|
|
+ 'min_money' => $request->input('min_money'),
|
|
|
+ 'max_money' => $request->input('max_money'),
|
|
|
+ 'company_uid' => $this->getOptimizerUid(),
|
|
|
+ 'created_at' => $now,
|
|
|
+ 'updated_at' => $now,
|
|
|
+ ];
|
|
|
+ if (empty($param['adv_account_name'])){
|
|
|
+ unset($param['adv_account_name']);
|
|
|
+ }
|
|
|
DB::table('juliang_account_callback_config')
|
|
|
- ->insert([
|
|
|
- 'adv_account_id' => $request->input('account_id'),
|
|
|
- 'adv_account_name' => $request->input('account_name'),
|
|
|
- 'state' => $request->input('state'),
|
|
|
- 'protect_num' => $request->input('protect_num'),
|
|
|
- 'default_rate' => $request->input('default_rate'),
|
|
|
- 'rate_time_config' => \json_encode($request->input('rate_time_config', [])),
|
|
|
- 'min_money' => $request->input('min_money'),
|
|
|
- 'max_money' => $request->input('max_money'),
|
|
|
- 'company_uid' => $this->getOptimizerUid(),
|
|
|
- 'created_at' => $now,
|
|
|
- 'updated_at' => $now,
|
|
|
- ]);
|
|
|
+ ->insert($param);
|
|
|
DB::table('juliang_account_rate_config_log')
|
|
|
->insert([
|
|
|
'company_uid' => $this->getOptimizerUid(),
|