mirror of
https://github.com/v2board/v2board.git
synced 2025-02-10 23:49:12 +08:00
update: payment save
This commit is contained in:
parent
8f3281c60e
commit
6a2125794b
@ -51,7 +51,7 @@ class PaymentController extends Controller
|
|||||||
if (!config('v2board.app_url')) {
|
if (!config('v2board.app_url')) {
|
||||||
abort(500, '请在站点配置中配置站点地址');
|
abort(500, '请在站点配置中配置站点地址');
|
||||||
}
|
}
|
||||||
$params = $request->validate([
|
$validateRules = [
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'icon' => 'nullable',
|
'icon' => 'nullable',
|
||||||
'payment' => 'required',
|
'payment' => 'required',
|
||||||
@ -59,19 +59,12 @@ class PaymentController extends Controller
|
|||||||
'notify_domain' => 'nullable|url',
|
'notify_domain' => 'nullable|url',
|
||||||
'handling_fee_fixed' => 'nullable|integer',
|
'handling_fee_fixed' => 'nullable|integer',
|
||||||
'handling_fee_percent' => 'nullable|numeric|between:0.1,100'
|
'handling_fee_percent' => 'nullable|numeric|between:0.1,100'
|
||||||
], [
|
];
|
||||||
'name.required' => '显示名称不能为空',
|
|
||||||
'payment.required' => '网关参数不能为空',
|
|
||||||
'config.required' => '配置参数不能为空',
|
|
||||||
'notify_domain.url' => '自定义通知域名格式有误',
|
|
||||||
'handling_fee_fixed.integer' => '固定手续费格式有误',
|
|
||||||
'handling_fee_percent.between' => '百分比手续费范围须在0.1-100之间'
|
|
||||||
]);
|
|
||||||
if ($request->input('id')) {
|
if ($request->input('id')) {
|
||||||
$payment = Payment::find($request->input('id'));
|
$payment = Payment::find($request->input('id'));
|
||||||
if (!$payment) abort(500, '支付方式不存在');
|
if (!$payment) abort(500, '支付方式不存在');
|
||||||
try {
|
try {
|
||||||
$payment->update($params);
|
$payment->update($request->only(array_keys($validateRules)));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
abort(500, $e->getMessage());
|
abort(500, $e->getMessage());
|
||||||
}
|
}
|
||||||
@ -79,6 +72,14 @@ class PaymentController extends Controller
|
|||||||
'data' => true
|
'data' => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
$params = $request->validate($validateRules, [
|
||||||
|
'name.required' => '显示名称不能为空',
|
||||||
|
'payment.required' => '网关参数不能为空',
|
||||||
|
'config.required' => '配置参数不能为空',
|
||||||
|
'notify_domain.url' => '自定义通知域名格式有误',
|
||||||
|
'handling_fee_fixed.integer' => '固定手续费格式有误',
|
||||||
|
'handling_fee_percent.between' => '百分比手续费范围须在0.1-100之间'
|
||||||
|
]);
|
||||||
$params['uuid'] = Helper::randomChar(8);
|
$params['uuid'] = Helper::randomChar(8);
|
||||||
if (!Payment::create($params)) {
|
if (!Payment::create($params)) {
|
||||||
abort(500, '保存失败');
|
abort(500, '保存失败');
|
||||||
|
Loading…
Reference in New Issue
Block a user