|
@@ -22,20 +22,26 @@ class RanseConfigController extends CatchController
|
|
|
$this->validate($request, [
|
|
|
'no_charge_user_duration' => 'required|integer|min:0',
|
|
|
'charge_user_duration' => 'required|integer|gte:no_charge_user_duration',
|
|
|
+ 'miniprogram_id' => 'required|min:1',
|
|
|
]);
|
|
|
- $uid = $this->getOptimizerUid();
|
|
|
+ $uid = $this->getLoginUserId();
|
|
|
if(!$uid) {
|
|
|
CommonBusinessException::throwError(Errors::NO_OPERATE_PERMISSION);
|
|
|
}
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
- DB::table('ranse_config')->where('user_id', $uid)
|
|
|
- ->where('is_enabled', 1)
|
|
|
+ DB::table('ranse_config')
|
|
|
+ ->where([
|
|
|
+ ['user_id', '=', $uid],
|
|
|
+ ['is_enabled', '=', 1],
|
|
|
+ ['miniprogram_id', '=', $request->input('miniprogram_id')]
|
|
|
+ ])
|
|
|
->update(['is_enabled' => 0, 'updated_at' => $now]);
|
|
|
DB::table('ranse_config')
|
|
|
->insert([
|
|
|
'user_id' => $uid, 'is_enabled' => 1,
|
|
|
'no_charge_user_duration' => $request->input('no_charge_user_duration'),
|
|
|
'charge_user_duration' => $request->input('charge_user_duration'),
|
|
|
+ 'miniprogram_id' => $request->input('miniprogram_id'),
|
|
|
'created_at' => $now, 'updated_at' => $now,
|
|
|
]);
|
|
|
|
|
@@ -53,8 +59,12 @@ class RanseConfigController extends CatchController
|
|
|
CommonBusinessException::throwError(Errors::NO_OPERATE_PERMISSION);
|
|
|
}
|
|
|
|
|
|
- $config = DB::table('ranse_config')->where('user_id', $uid)
|
|
|
- ->where('is_enabled', 1)
|
|
|
+ $config = DB::table('ranse_config')
|
|
|
+ ->where([
|
|
|
+ ['user_id', '=', $uid],
|
|
|
+ ['is_enabled', '=', 1],
|
|
|
+ ['miniprogram_id', '=', $request->input('miniprogram_id')]
|
|
|
+ ])
|
|
|
->first();
|
|
|
if(!$config) {
|
|
|
$config = DB::table('ranse_config')
|