feat: add vip payment and member center
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:后台 VIP 支付配置保存请求
|
||||
* 负责校验聊天室接入 NovaLink 支付中心所需的后台配置项
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateVipPaymentConfigRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 判断当前请求是否允许执行
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表单校验规则
|
||||
*
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'vip_payment_enabled' => ['required', 'in:0,1'],
|
||||
'vip_payment_base_url' => ['nullable', 'url', 'max:255', 'required_if:vip_payment_enabled,1'],
|
||||
'vip_payment_app_key' => ['nullable', 'string', 'max:100', 'required_if:vip_payment_enabled,1'],
|
||||
'vip_payment_app_secret' => ['nullable', 'string', 'max:255', 'required_if:vip_payment_enabled,1'],
|
||||
'vip_payment_timeout' => ['nullable', 'integer', 'min:3', 'max:30'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取中文错误提示
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'vip_payment_enabled.required' => '请先选择是否启用 VIP 支付',
|
||||
'vip_payment_base_url.required_if' => '启用 VIP 支付时,支付中心地址不能为空',
|
||||
'vip_payment_base_url.url' => '支付中心地址格式不正确',
|
||||
'vip_payment_app_key.required_if' => '启用 VIP 支付时,App Key 不能为空',
|
||||
'vip_payment_app_secret.required_if' => '启用 VIP 支付时,App Secret 不能为空',
|
||||
'vip_payment_timeout.integer' => '请求超时时间必须是整数',
|
||||
'vip_payment_timeout.min' => '请求超时时间不能小于 3 秒',
|
||||
'vip_payment_timeout.max' => '请求超时时间不能大于 30 秒',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:创建 VIP 支付订单请求
|
||||
* 负责校验前台用户发起 VIP 购买时提交的会员等级参数
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateVipPaymentOrderRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 判断当前用户是否允许发起购买
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段校验规则
|
||||
*
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'vip_level_id' => ['required', 'integer', 'exists:vip_levels,id'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取中文错误提示
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'vip_level_id.required' => '请选择要购买的 VIP 等级',
|
||||
'vip_level_id.exists' => '所选 VIP 等级不存在或已被删除',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user