|
@@ -6,6 +6,7 @@ use Catch\Base\CatchController;
|
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
+use Modules\Callback\Models\JLEventCallbackConfigModel;
|
|
|
use Modules\Callback\Services\CallbackConst;
|
|
|
use Modules\Callback\Services\JLEventService;
|
|
|
use Modules\Common\Errors\Errors;
|
|
@@ -68,17 +69,19 @@ class JLEventController extends CatchController
|
|
|
'charge_money_map' => 'required_if:is_roi,2|array',
|
|
|
'charge_money_map.*.min_money' => 'integer|min:0',
|
|
|
]);
|
|
|
- $now = date('Y-m-d H:i:s');
|
|
|
if(2 == $request->input('is_roi') &&
|
|
|
(!JLEventService::judgeChargeMoneyOk($request->input('charge_money_map')))) {
|
|
|
CommonBusinessException::throwError(Errors::CALLBACK_CHARGE_MONEY_MAP_ERROR);
|
|
|
}
|
|
|
- DB::table('jl_event_callback_config')
|
|
|
- ->insert(array_merge($request->only('name', 'is_roi', 'charge_type'), [
|
|
|
- 'created_at' => $now, 'updated_at' => $now,
|
|
|
- 'charge_money_map' => \json_encode($request->input('charge_money_map')),
|
|
|
- 'user_id' => $this->getLoginUserId()
|
|
|
- ]));
|
|
|
+ $userId = $this->getLoginUserId();
|
|
|
+
|
|
|
+
|
|
|
+ $model = JLEventCallbackConfigModel::create(array_merge($request->only('name', 'is_roi', 'charge_type'), [
|
|
|
+ 'charge_money_map' => \json_encode($request->input('charge_money_map')),
|
|
|
+ 'user_id' => $userId,
|
|
|
+ ]));
|
|
|
+
|
|
|
+ JLEventService::saveRateConfigLog($userId, $model->id, $request->input('charge_money_map', []));
|
|
|
|
|
|
return 'ok';
|
|
|
}
|
|
@@ -106,14 +109,20 @@ class JLEventController extends CatchController
|
|
|
$updateData = $request->only('is_roi', 'charge_type');
|
|
|
}
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
- DB::table('jl_event_callback_config')
|
|
|
+ $userId = $this->getLoginUserId();
|
|
|
+ $configIds = DB::table('jl_event_callback_config')
|
|
|
->whereIn('id', $request->input('ids'))
|
|
|
- ->where('user_id', $this->getLoginUserId())
|
|
|
+ ->where('user_id', $userId)
|
|
|
+ ->select('id')->get()->pluck('id');
|
|
|
+ DB::table('jl_event_callback_config')
|
|
|
+ ->whereIn('id', $configIds)
|
|
|
->update(array_merge($updateData, [
|
|
|
'charge_money_map' => \json_encode($request->input('charge_money_map', [])),
|
|
|
'updated_at' => $now,
|
|
|
]));
|
|
|
- // todo: 更新对应配置的计算比例信息
|
|
|
+ foreach ($configIds as $configId) {
|
|
|
+ JLEventService::saveRateConfigLog($userId, $configId, $request->input('charge_money_map', []));
|
|
|
+ }
|
|
|
return 'ok';
|
|
|
}
|
|
|
}
|