mirror of
https://gitee.com/technical-laohu/mpay_v2_webman.git
synced 2026-04-21 09:24:33 +08:00
重构初始化
This commit is contained in:
113
app/http/api/validation/EpayValidator.php
Normal file
113
app/http/api/validation/EpayValidator.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* ePay 兼容层请求校验器。
|
||||
*
|
||||
* 根据 submit、mapi、api.php 的不同入口场景做分场景校验,不依赖隐藏标记字段。
|
||||
*/
|
||||
class EpayValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'act' => 'required|string|in:query,settle,order,orders,refund',
|
||||
'pid' => 'required|integer|gt:0',
|
||||
'key' => 'required|string|min:1|max:255',
|
||||
'type' => 'sometimes|string|max:32',
|
||||
'out_trade_no' => 'sometimes|string|min:1|max:64',
|
||||
'notify_url' => 'sometimes|url|max:255',
|
||||
'return_url' => 'sometimes|url|max:255',
|
||||
'name' => 'sometimes|string|min:1|max:255',
|
||||
'money' => 'sometimes|numeric|gt:0|regex:/^\d+(?:\.\d{1,2})?$/',
|
||||
'sign' => 'sometimes|string|min:1|max:255',
|
||||
'sign_type' => 'sometimes|string|in:MD5,md5',
|
||||
'device' => 'sometimes|string|in:pc,mobile,qq,wechat,alipay,jump',
|
||||
'clientip' => 'sometimes|ip',
|
||||
'param' => 'sometimes|string|max:2000',
|
||||
'trade_no' => 'sometimes|string|min:1|max:64',
|
||||
'refund_no' => 'sometimes|string|min:1|max:64',
|
||||
'reason' => 'sometimes|string|max:255',
|
||||
'limit' => 'sometimes|integer|gt:0|max:50',
|
||||
'page' => 'sometimes|integer|gt:0',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'act' => '操作类型',
|
||||
'pid' => '商户ID',
|
||||
'key' => '商户密钥',
|
||||
'type' => '支付方式',
|
||||
'out_trade_no' => '商户订单号',
|
||||
'trade_no' => '易支付订单号',
|
||||
'notify_url' => '异步通知地址',
|
||||
'return_url' => '跳转通知地址',
|
||||
'name' => '商品名称',
|
||||
'money' => '商品金额',
|
||||
'sign' => '签名字符串',
|
||||
'sign_type' => '签名类型',
|
||||
'device' => '设备类型',
|
||||
'clientip' => '用户IP地址',
|
||||
'param' => '业务扩展参数',
|
||||
'refund_no' => '退款单号',
|
||||
'reason' => '退款原因',
|
||||
'limit' => '查询订单数量',
|
||||
'page' => '页码',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'submit' => ['pid', 'type', 'out_trade_no', 'notify_url', 'return_url', 'name', 'money', 'sign', 'sign_type', 'param'],
|
||||
'mapi' => ['pid', 'type', 'out_trade_no', 'notify_url', 'return_url', 'name', 'money', 'clientip', 'device', 'sign', 'sign_type', 'param'],
|
||||
'query' => ['act', 'pid', 'key'],
|
||||
'settle' => ['act', 'pid', 'key'],
|
||||
'order_trade_no' => ['act', 'pid', 'key', 'trade_no'],
|
||||
'order_out_trade_no' => ['act', 'pid', 'key', 'out_trade_no'],
|
||||
'orders' => ['act', 'pid', 'key', 'limit', 'page'],
|
||||
'refund_trade_no' => ['act', 'pid', 'key', 'trade_no', 'money', 'refund_no', 'reason'],
|
||||
'refund_out_trade_no' => ['act', 'pid', 'key', 'out_trade_no', 'money', 'refund_no', 'reason'],
|
||||
];
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = parent::rules();
|
||||
|
||||
return match ($this->scene()) {
|
||||
'submit' => array_merge($rules, [
|
||||
'type' => 'sometimes|string|max:32',
|
||||
'out_trade_no' => 'required|string|min:1|max:64',
|
||||
'notify_url' => 'required|url|max:255',
|
||||
'return_url' => 'required|url|max:255',
|
||||
'name' => 'required|string|min:1|max:255',
|
||||
'money' => 'required|numeric|gt:0|regex:/^\d+(?:\.\d{1,2})?$/',
|
||||
'sign' => 'required|string|min:1|max:255',
|
||||
'sign_type' => 'required|string|in:MD5,md5',
|
||||
]),
|
||||
'mapi' => array_merge($rules, [
|
||||
'type' => 'required|string|max:32',
|
||||
'out_trade_no' => 'required|string|min:1|max:64',
|
||||
'notify_url' => 'required|url|max:255',
|
||||
'return_url' => 'sometimes|url|max:255',
|
||||
'name' => 'required|string|min:1|max:255',
|
||||
'money' => 'required|numeric|gt:0|regex:/^\d+(?:\.\d{1,2})?$/',
|
||||
'clientip' => 'required|ip',
|
||||
'sign' => 'required|string|min:1|max:255',
|
||||
'sign_type' => 'required|string|in:MD5,md5',
|
||||
]),
|
||||
'order_trade_no' => array_merge($rules, [
|
||||
'trade_no' => 'required|string|min:1|max:64',
|
||||
]),
|
||||
'order_out_trade_no' => array_merge($rules, [
|
||||
'out_trade_no' => 'required|string|min:1|max:64',
|
||||
]),
|
||||
'refund_trade_no' => array_merge($rules, [
|
||||
'trade_no' => 'required|string|min:1|max:64',
|
||||
'money' => 'required|numeric|gt:0|regex:/^\d+(?:\.\d{1,2})?$/',
|
||||
]),
|
||||
'refund_out_trade_no' => array_merge($rules, [
|
||||
'out_trade_no' => 'required|string|min:1|max:64',
|
||||
'money' => 'required|numeric|gt:0|regex:/^\d+(?:\.\d{1,2})?$/',
|
||||
]),
|
||||
default => $rules,
|
||||
};
|
||||
}
|
||||
}
|
||||
49
app/http/api/validation/NotifyChannelValidator.php
Normal file
49
app/http/api/validation/NotifyChannelValidator.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 渠道通知参数校验器。
|
||||
*
|
||||
* 用于校验渠道通知日志入参。
|
||||
*/
|
||||
class NotifyChannelValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'notify_no' => 'sometimes|string|min:1|max:64',
|
||||
'channel_id' => 'required|integer|min:1|exists:ma_payment_channel,id',
|
||||
'notify_type' => 'sometimes|integer|in:0,1',
|
||||
'biz_no' => 'required|string|min:1|max:64',
|
||||
'pay_no' => 'sometimes|string|min:1|max:64',
|
||||
'channel_request_no' => 'sometimes|string|min:1|max:64',
|
||||
'channel_trade_no' => 'sometimes|string|min:1|max:64',
|
||||
'raw_payload' => 'nullable|array',
|
||||
'verify_status' => 'sometimes|integer|in:0,1,2',
|
||||
'process_status' => 'sometimes|integer|in:0,1,2',
|
||||
'retry_count' => 'sometimes|integer|min:0',
|
||||
'next_retry_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
'last_error' => 'nullable|string|max:255',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'notify_no' => '通知单号',
|
||||
'channel_id' => '通道ID',
|
||||
'notify_type' => '通知类型',
|
||||
'biz_no' => '业务单号',
|
||||
'pay_no' => '支付单号',
|
||||
'channel_request_no' => '渠道请求号',
|
||||
'channel_trade_no' => '渠道交易号',
|
||||
'raw_payload' => '原始通知数据',
|
||||
'verify_status' => '验签状态',
|
||||
'process_status' => '处理状态',
|
||||
'retry_count' => '重试次数',
|
||||
'next_retry_at' => '下次重试时间',
|
||||
'last_error' => '最后错误',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'store' => ['notify_no', 'channel_id', 'notify_type', 'biz_no', 'pay_no', 'channel_request_no', 'channel_trade_no', 'raw_payload', 'verify_status', 'process_status', 'retry_count', 'next_retry_at', 'last_error'],
|
||||
];
|
||||
}
|
||||
47
app/http/api/validation/NotifyMerchantValidator.php
Normal file
47
app/http/api/validation/NotifyMerchantValidator.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 商户通知参数校验器。
|
||||
*
|
||||
* 用于校验商户通知任务入参。
|
||||
*/
|
||||
class NotifyMerchantValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'notify_no' => 'sometimes|string|min:1|max:64',
|
||||
'merchant_id' => 'required|integer|min:1|exists:ma_merchant,id',
|
||||
'merchant_group_id' => 'required|integer|min:1|exists:ma_merchant_group,id',
|
||||
'biz_no' => 'required|string|min:1|max:64',
|
||||
'pay_no' => 'sometimes|string|min:1|max:64',
|
||||
'notify_url' => 'required|url|max:255',
|
||||
'notify_data' => 'nullable|array',
|
||||
'status' => 'sometimes|integer|min:0',
|
||||
'retry_count' => 'sometimes|integer|min:0',
|
||||
'next_retry_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
'last_notify_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
'last_response' => 'nullable|string|max:255',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'notify_no' => '通知单号',
|
||||
'merchant_id' => '商户ID',
|
||||
'merchant_group_id' => '商户分组ID',
|
||||
'biz_no' => '业务单号',
|
||||
'pay_no' => '支付单号',
|
||||
'notify_url' => '通知地址',
|
||||
'notify_data' => '通知内容',
|
||||
'status' => '状态',
|
||||
'retry_count' => '重试次数',
|
||||
'next_retry_at' => '下次重试时间',
|
||||
'last_notify_at' => '最后通知时间',
|
||||
'last_response' => '最后响应',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'store' => ['notify_no', 'merchant_id', 'merchant_group_id', 'biz_no', 'pay_no', 'notify_url', 'notify_data', 'status', 'retry_count', 'next_retry_at', 'last_notify_at', 'last_response'],
|
||||
];
|
||||
}
|
||||
53
app/http/api/validation/PayCallbackValidator.php
Normal file
53
app/http/api/validation/PayCallbackValidator.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 支付回调参数校验器。
|
||||
*
|
||||
* 用于校验渠道回调和主动查单回传参数。
|
||||
*/
|
||||
class PayCallbackValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'pay_no' => 'required|string|min:1|max:64|exists:ma_pay_order,pay_no',
|
||||
'success' => 'required|boolean',
|
||||
'channel_id' => 'nullable|integer|min:1|exists:ma_payment_channel,id',
|
||||
'callback_type' => 'nullable|integer|in:0,1',
|
||||
'request_data' => 'nullable|array',
|
||||
'verify_status' => 'nullable|integer|in:0,1,2',
|
||||
'process_status' => 'nullable|integer|in:0,1,2',
|
||||
'process_result' => 'nullable|array',
|
||||
'channel_trade_no' => 'nullable|string|max:64',
|
||||
'channel_order_no' => 'nullable|string|max:64',
|
||||
'fee_actual_amount' => 'nullable|integer|min:0',
|
||||
'paid_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
'channel_error_code' => 'nullable|string|max:64',
|
||||
'channel_error_msg' => 'nullable|string|max:255',
|
||||
'ext_json' => 'nullable|array',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'pay_no' => '支付单号',
|
||||
'success' => '是否成功',
|
||||
'channel_id' => '通道ID',
|
||||
'callback_type' => '回调类型',
|
||||
'request_data' => '原始回调数据',
|
||||
'verify_status' => '验签状态',
|
||||
'process_status' => '处理状态',
|
||||
'process_result' => '处理结果',
|
||||
'channel_trade_no' => '渠道交易号',
|
||||
'channel_order_no' => '渠道订单号',
|
||||
'fee_actual_amount' => '实际手续费',
|
||||
'paid_at' => '支付时间',
|
||||
'channel_error_code' => '错误码',
|
||||
'channel_error_msg' => '错误信息',
|
||||
'ext_json' => '扩展信息',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'callback' => ['pay_no', 'success', 'channel_id', 'callback_type', 'request_data', 'verify_status', 'process_status', 'process_result', 'channel_trade_no', 'channel_order_no', 'fee_actual_amount', 'paid_at', 'channel_error_code', 'channel_error_msg', 'ext_json'],
|
||||
];
|
||||
}
|
||||
31
app/http/api/validation/PayCloseValidator.php
Normal file
31
app/http/api/validation/PayCloseValidator.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 支付关闭参数校验器。
|
||||
*
|
||||
* 用于校验关闭支付单所需参数。
|
||||
*/
|
||||
class PayCloseValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'pay_no' => 'required|string|min:1|max:64|exists:ma_pay_order,pay_no',
|
||||
'reason' => 'nullable|string|max:255',
|
||||
'closed_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
'ext_json' => 'nullable|array',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'pay_no' => '支付单号',
|
||||
'reason' => '关闭原因',
|
||||
'closed_at' => '关闭时间',
|
||||
'ext_json' => '扩展信息',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'close' => ['pay_no', 'reason', 'closed_at', 'ext_json'],
|
||||
];
|
||||
}
|
||||
37
app/http/api/validation/PayPrepareValidator.php
Normal file
37
app/http/api/validation/PayPrepareValidator.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 支付预下单参数校验器。
|
||||
*
|
||||
* 用于校验支付发起时的核心入参。
|
||||
*/
|
||||
class PayPrepareValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'merchant_id' => 'required|integer|min:1|exists:ma_merchant,id',
|
||||
'merchant_order_no' => 'required|string|min:1|max:64',
|
||||
'pay_type_id' => 'required|integer|min:1|exists:ma_payment_type,id',
|
||||
'pay_amount' => 'required|integer|min:1',
|
||||
'subject' => 'sometimes|string|max:255',
|
||||
'body' => 'sometimes|string|max:500',
|
||||
'ext_json' => 'nullable|array',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'merchant_id' => '商户ID',
|
||||
'merchant_order_no' => '商户订单号',
|
||||
'pay_type_id' => '支付方式',
|
||||
'pay_amount' => '支付金额',
|
||||
'subject' => '标题',
|
||||
'body' => '描述',
|
||||
'ext_json' => '扩展信息',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'prepare' => ['merchant_id', 'merchant_order_no', 'pay_type_id', 'pay_amount', 'subject', 'body', 'ext_json'],
|
||||
];
|
||||
}
|
||||
31
app/http/api/validation/PayTimeoutValidator.php
Normal file
31
app/http/api/validation/PayTimeoutValidator.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 支付超时参数校验器。
|
||||
*
|
||||
* 用于校验超时关闭支付单所需参数。
|
||||
*/
|
||||
class PayTimeoutValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'pay_no' => 'required|string|min:1|max:64|exists:ma_pay_order,pay_no',
|
||||
'reason' => 'nullable|string|max:255',
|
||||
'timeout_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
'ext_json' => 'nullable|array',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'pay_no' => '支付单号',
|
||||
'reason' => '超时原因',
|
||||
'timeout_at' => '超时时间',
|
||||
'ext_json' => '扩展信息',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'timeout' => ['pay_no', 'reason', 'timeout_at', 'ext_json'],
|
||||
];
|
||||
}
|
||||
37
app/http/api/validation/RefundActionValidator.php
Normal file
37
app/http/api/validation/RefundActionValidator.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 退款动作参数校验器。
|
||||
*
|
||||
* 用于校验退款处理、失败和重试操作的公共参数。
|
||||
*/
|
||||
class RefundActionValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'refund_no' => 'required|string|min:1|max:64|exists:ma_refund_order,refund_no',
|
||||
'reason' => 'nullable|string|max:255',
|
||||
'last_error' => 'nullable|string|max:255',
|
||||
'processing_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
'failed_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
'ext_json' => 'nullable|array',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'refund_no' => '退款单号',
|
||||
'reason' => '原因',
|
||||
'last_error' => '最近错误信息',
|
||||
'processing_at' => '处理时间',
|
||||
'failed_at' => '失败时间',
|
||||
'ext_json' => '扩展信息',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'processing' => ['refund_no', 'reason', 'last_error', 'processing_at', 'ext_json'],
|
||||
'retry' => ['refund_no', 'reason', 'last_error', 'processing_at', 'ext_json'],
|
||||
'fail' => ['refund_no', 'reason', 'last_error', 'failed_at', 'ext_json'],
|
||||
];
|
||||
}
|
||||
33
app/http/api/validation/RefundCreateValidator.php
Normal file
33
app/http/api/validation/RefundCreateValidator.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 退款创建参数校验器。
|
||||
*
|
||||
* 用于校验退款单创建参数。
|
||||
*/
|
||||
class RefundCreateValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'pay_no' => 'required|string|min:1|max:64|exists:ma_pay_order,pay_no',
|
||||
'merchant_refund_no' => 'sometimes|string|min:1|max:64',
|
||||
'refund_amount' => 'nullable|integer|min:1',
|
||||
'reason' => 'nullable|string|max:255',
|
||||
'ext_json' => 'nullable|array',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'pay_no' => '支付单号',
|
||||
'merchant_refund_no' => '商户退款单号',
|
||||
'refund_amount' => '退款金额',
|
||||
'reason' => '退款原因',
|
||||
'ext_json' => '扩展信息',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'store' => ['pay_no', 'merchant_refund_no', 'refund_amount', 'reason', 'ext_json'],
|
||||
];
|
||||
}
|
||||
31
app/http/api/validation/RouteResolveValidator.php
Normal file
31
app/http/api/validation/RouteResolveValidator.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 路由解析参数校验器。
|
||||
*
|
||||
* 用于校验路由预览所需参数。
|
||||
*/
|
||||
class RouteResolveValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'merchant_group_id' => 'required|integer|min:1|exists:ma_merchant_group,id',
|
||||
'pay_type_id' => 'required|integer|min:1|exists:ma_payment_type,id',
|
||||
'pay_amount' => 'required|integer|min:1',
|
||||
'stat_date' => 'nullable|date_format:Y-m-d',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'merchant_group_id' => '商户分组ID',
|
||||
'pay_type_id' => '支付方式',
|
||||
'pay_amount' => '支付金额',
|
||||
'stat_date' => '统计日期',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'resolve' => ['merchant_group_id', 'pay_type_id', 'pay_amount', 'stat_date'],
|
||||
];
|
||||
}
|
||||
30
app/http/api/validation/SettlementActionValidator.php
Normal file
30
app/http/api/validation/SettlementActionValidator.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 清算动作参数校验器。
|
||||
*
|
||||
* 用于校验清算成功和失败动作的公共参数。
|
||||
*/
|
||||
class SettlementActionValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'settle_no' => 'required|string|min:1|max:64|exists:ma_settlement_order,settle_no',
|
||||
'reason' => 'nullable|string|max:255',
|
||||
'ext_json' => 'nullable|array',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'settle_no' => '清算单号',
|
||||
'reason' => '原因',
|
||||
'ext_json' => '扩展信息',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'complete' => ['settle_no'],
|
||||
'fail' => ['settle_no', 'reason', 'ext_json'],
|
||||
];
|
||||
}
|
||||
63
app/http/api/validation/SettlementCreateValidator.php
Normal file
63
app/http/api/validation/SettlementCreateValidator.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 清算创建参数校验器。
|
||||
*
|
||||
* 用于校验清算单和清算明细的创建参数。
|
||||
*/
|
||||
class SettlementCreateValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'settle_no' => 'sometimes|string|min:1|max:64',
|
||||
'merchant_id' => 'required|integer|min:1|exists:ma_merchant,id',
|
||||
'merchant_group_id' => 'required|integer|min:1|exists:ma_merchant_group,id',
|
||||
'channel_id' => 'required|integer|min:1|exists:ma_payment_channel,id',
|
||||
'cycle_type' => 'required|integer|min:0',
|
||||
'cycle_key' => 'required|string|min:1|max:64',
|
||||
'status' => 'sometimes|integer|min:0',
|
||||
'generated_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
'accounted_amount' => 'nullable|integer|min:0',
|
||||
'gross_amount' => 'nullable|integer|min:0',
|
||||
'fee_amount' => 'nullable|integer|min:0',
|
||||
'refund_amount' => 'nullable|integer|min:0',
|
||||
'fee_reverse_amount' => 'nullable|integer|min:0',
|
||||
'net_amount' => 'nullable|integer|min:0',
|
||||
'ext_json' => 'nullable|array',
|
||||
'items' => 'nullable|array',
|
||||
'items.*.pay_no' => 'sometimes|string|min:1|max:64',
|
||||
'items.*.refund_no' => 'sometimes|string|min:1|max:64',
|
||||
'items.*.pay_amount' => 'sometimes|integer|min:0',
|
||||
'items.*.fee_amount' => 'sometimes|integer|min:0',
|
||||
'items.*.refund_amount' => 'sometimes|integer|min:0',
|
||||
'items.*.fee_reverse_amount' => 'sometimes|integer|min:0',
|
||||
'items.*.net_amount' => 'sometimes|integer|min:0',
|
||||
'items.*.item_status' => 'sometimes|integer|min:0',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'settle_no' => '清算单号',
|
||||
'merchant_id' => '商户ID',
|
||||
'merchant_group_id' => '商户分组ID',
|
||||
'channel_id' => '通道ID',
|
||||
'cycle_type' => '结算周期类型',
|
||||
'cycle_key' => '结算周期键',
|
||||
'status' => '状态',
|
||||
'generated_at' => '生成时间',
|
||||
'accounted_amount' => '入账金额',
|
||||
'gross_amount' => '交易总额',
|
||||
'fee_amount' => '手续费',
|
||||
'refund_amount' => '退款金额',
|
||||
'fee_reverse_amount' => '手续费冲回',
|
||||
'net_amount' => '净额',
|
||||
'ext_json' => '扩展信息',
|
||||
'items' => '清算明细',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'store' => ['settle_no', 'merchant_id', 'merchant_group_id', 'channel_id', 'cycle_type', 'cycle_key', 'status', 'generated_at', 'accounted_amount', 'gross_amount', 'fee_amount', 'refund_amount', 'fee_reverse_amount', 'net_amount', 'ext_json', 'items', 'items.*.pay_no', 'items.*.refund_no', 'items.*.pay_amount', 'items.*.fee_amount', 'items.*.refund_amount', 'items.*.fee_reverse_amount', 'items.*.net_amount', 'items.*.item_status'],
|
||||
];
|
||||
}
|
||||
23
app/http/api/validation/TraceQueryValidator.php
Normal file
23
app/http/api/validation/TraceQueryValidator.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\api\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 统一追踪查询参数校验器。
|
||||
*/
|
||||
class TraceQueryValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'trace_no' => 'required|string|min:1|max:64',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'trace_no' => '追踪号',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'show' => ['trace_no'],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user