mirror of
https://gitee.com/technical-laohu/mpay_v2_webman.git
synced 2026-04-24 19:14:27 +08:00
重构初始化
This commit is contained in:
47
app/http/mer/controller/account/AccountController.php
Normal file
47
app/http/mer/controller/account/AccountController.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\controller\account;
|
||||
|
||||
use app\common\base\BaseController;
|
||||
use app\http\mer\validation\BalanceValidator;
|
||||
use app\service\account\funds\MerchantAccountService;
|
||||
use app\service\merchant\MerchantService;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 商户账户控制器。
|
||||
*
|
||||
* 负责商户余额查询等账户类接口。
|
||||
*/
|
||||
class AccountController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数,注入商户与账户服务。
|
||||
*/
|
||||
public function __construct(
|
||||
protected MerchantService $merchantService,
|
||||
protected MerchantAccountService $merchantAccountService
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /mer/merchant/{merchantNo}/balance
|
||||
*
|
||||
* 查询商户余额。
|
||||
*/
|
||||
public function balance(Request $request, string $merchantNo): Response
|
||||
{
|
||||
$data = $this->validated(['merchant_no' => $merchantNo], BalanceValidator::class, 'show');
|
||||
|
||||
$currentMerchantNo = $this->currentMerchantNo($request);
|
||||
if ($currentMerchantNo !== '' && $currentMerchantNo !== (string) $data['merchant_no']) {
|
||||
return $this->fail('无权查看该商户余额', 403);
|
||||
}
|
||||
|
||||
$merchant = $this->merchantService->findEnabledMerchantByNo((string) $data['merchant_no']);
|
||||
|
||||
return $this->success($this->merchantAccountService->getBalanceSnapshot((int) $merchant->id));
|
||||
}
|
||||
}
|
||||
|
||||
191
app/http/mer/controller/merchant/MerchantPortalController.php
Normal file
191
app/http/mer/controller/merchant/MerchantPortalController.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\controller\merchant;
|
||||
|
||||
use app\common\base\BaseController;
|
||||
use app\http\mer\validation\MerchantPortalValidator;
|
||||
use app\service\merchant\portal\MerchantPortalService;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 商户后台基础页面控制器。
|
||||
*
|
||||
* 统一承接当前商户可见的资料、通道、路由、凭证、清算和资金页面数据。
|
||||
*/
|
||||
class MerchantPortalController extends BaseController
|
||||
{
|
||||
public function __construct(
|
||||
protected MerchantPortalService $merchantPortalService
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前商户资料。
|
||||
*/
|
||||
public function profile(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
return $this->success($this->merchantPortalService->profile($merchantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新当前商户资料。
|
||||
*/
|
||||
public function updateProfile(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated($this->payload($request), MerchantPortalValidator::class, 'profileUpdate');
|
||||
|
||||
return $this->success($this->merchantPortalService->updateProfile($merchantId, $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改当前商户登录密码。
|
||||
*/
|
||||
public function changePassword(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated($this->payload($request), MerchantPortalValidator::class, 'passwordUpdate');
|
||||
|
||||
return $this->success($this->merchantPortalService->changePassword($merchantId, $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的通道列表。
|
||||
*/
|
||||
public function myChannels(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$payload = $this->payload($request);
|
||||
$page = max(1, (int) ($payload['page'] ?? 1));
|
||||
$pageSize = max(1, (int) ($payload['page_size'] ?? 10));
|
||||
|
||||
return $this->success($this->merchantPortalService->myChannels($payload, $merchantId, $page, $pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 路由预览。
|
||||
*/
|
||||
public function routePreview(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$payload = $this->validated($this->payload($request), MerchantPortalValidator::class, 'routePreview');
|
||||
$payTypeId = (int) ($payload['pay_type_id'] ?? 0);
|
||||
$payAmount = (int) ($payload['pay_amount'] ?? 0);
|
||||
$statDate = trim((string) ($payload['stat_date'] ?? ''));
|
||||
|
||||
return $this->success($this->merchantPortalService->routePreview($merchantId, $payTypeId, $payAmount, $statDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前商户接口凭证。
|
||||
*/
|
||||
public function apiCredential(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
return $this->success($this->merchantPortalService->apiCredential($merchantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成或重置接口凭证。
|
||||
*/
|
||||
public function issueCredential(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
return $this->success($this->merchantPortalService->issueCredential($merchantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前商户的清算记录列表。
|
||||
*/
|
||||
public function settlementRecords(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$payload = $this->payload($request);
|
||||
$page = max(1, (int) ($payload['page'] ?? 1));
|
||||
$pageSize = max(1, (int) ($payload['page_size'] ?? 10));
|
||||
|
||||
return $this->success($this->merchantPortalService->settlementRecords($payload, $merchantId, $page, $pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前商户的清算记录详情。
|
||||
*/
|
||||
public function settlementRecordShow(Request $request, string $settleNo): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$detail = $this->merchantPortalService->settlementRecordDetail($settleNo, $merchantId);
|
||||
if (!$detail) {
|
||||
return $this->fail('清算记录不存在', 404);
|
||||
}
|
||||
|
||||
return $this->success($detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前商户可提现余额快照。
|
||||
*/
|
||||
public function withdrawableBalance(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
return $this->success($this->merchantPortalService->withdrawableBalance($merchantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前商户资金流水列表。
|
||||
*/
|
||||
public function balanceFlows(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$payload = $this->payload($request);
|
||||
$page = max(1, (int) ($payload['page'] ?? 1));
|
||||
$pageSize = max(1, (int) ($payload['page_size'] ?? 10));
|
||||
|
||||
return $this->success($this->merchantPortalService->balanceFlows($payload, $merchantId, $page, $pageSize));
|
||||
}
|
||||
}
|
||||
61
app/http/mer/controller/system/AuthController.php
Normal file
61
app/http/mer/controller/system/AuthController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\controller\system;
|
||||
|
||||
use app\common\base\BaseController;
|
||||
use app\http\mer\validation\AuthValidator;
|
||||
use app\service\merchant\auth\MerchantAuthService;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 商户认证控制器。
|
||||
*/
|
||||
class AuthController extends BaseController
|
||||
{
|
||||
public function __construct(
|
||||
protected MerchantAuthService $merchantAuthService
|
||||
) {
|
||||
}
|
||||
|
||||
public function login(Request $request): Response
|
||||
{
|
||||
$data = $this->validated($request->all(), AuthValidator::class, 'login');
|
||||
|
||||
return $this->success($this->merchantAuthService->authenticateCredentials(
|
||||
(string) $data['merchant_no'],
|
||||
(string) $data['password'],
|
||||
$request->getRealIp(),
|
||||
$request->header('user-agent', '')
|
||||
));
|
||||
}
|
||||
|
||||
public function logout(Request $request): Response
|
||||
{
|
||||
$token = trim((string) ($request->header('authorization', '') ?: $request->header('x-merchant-token', '')));
|
||||
$token = preg_replace('/^Bearer\s+/i', '', $token) ?: $token;
|
||||
|
||||
if ($token === '') {
|
||||
return $this->fail('未获取到登录令牌', 401);
|
||||
}
|
||||
|
||||
$this->merchantAuthService->revokeToken($token);
|
||||
|
||||
return $this->success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录商户的信息
|
||||
*/
|
||||
public function profile(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$merchantNo = $this->currentMerchantNo($request);
|
||||
return $this->success($this->merchantAuthService->profile($merchantId, $merchantNo));
|
||||
}
|
||||
}
|
||||
|
||||
30
app/http/mer/controller/system/SystemController.php
Normal file
30
app/http/mer/controller/system/SystemController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\controller\system;
|
||||
|
||||
use app\common\base\BaseController;
|
||||
use app\service\bootstrap\SystemBootstrapService;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 商户后台系统数据控制器。
|
||||
*/
|
||||
class SystemController extends BaseController
|
||||
{
|
||||
public function __construct(
|
||||
protected SystemBootstrapService $systemBootstrapService
|
||||
) {
|
||||
}
|
||||
|
||||
public function menuTree(Request $request): Response
|
||||
{
|
||||
return $this->success($this->systemBootstrapService->getMenuTree('merchant'));
|
||||
}
|
||||
|
||||
public function dictItems(Request $request): Response
|
||||
{
|
||||
return $this->success($this->systemBootstrapService->getDictItems((string) $request->get('code', '')));
|
||||
}
|
||||
}
|
||||
|
||||
44
app/http/mer/controller/trade/PayOrderController.php
Normal file
44
app/http/mer/controller/trade/PayOrderController.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\controller\trade;
|
||||
|
||||
use app\common\base\BaseController;
|
||||
use app\http\mer\validation\PayOrderValidator;
|
||||
use app\service\payment\order\PayOrderService;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 商户后台支付订单控制器。
|
||||
*
|
||||
* 商户后台只能看到当前登录商户自己的支付订单。
|
||||
*/
|
||||
class PayOrderController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数,注入支付订单服务。
|
||||
*/
|
||||
public function __construct(
|
||||
protected PayOrderService $payOrderService
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前商户的支付订单列表。
|
||||
*/
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated($request->all(), PayOrderValidator::class, 'index');
|
||||
$data['merchant_id'] = $merchantId;
|
||||
$page = max(1, (int) ($data['page'] ?? 1));
|
||||
$pageSize = max(1, (int) ($data['page_size'] ?? 10));
|
||||
|
||||
return $this->success($this->payOrderService->paginate($data, $page, $pageSize, $merchantId));
|
||||
}
|
||||
}
|
||||
|
||||
72
app/http/mer/controller/trade/RefundOrderController.php
Normal file
72
app/http/mer/controller/trade/RefundOrderController.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\controller\trade;
|
||||
|
||||
use app\common\base\BaseController;
|
||||
use app\http\mer\validation\RefundActionValidator;
|
||||
use app\http\mer\validation\RefundOrderValidator;
|
||||
use app\service\payment\order\RefundService;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 商户后台退款订单控制器。
|
||||
*/
|
||||
class RefundOrderController extends BaseController
|
||||
{
|
||||
public function __construct(
|
||||
protected RefundService $refundService
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前商户的退款订单列表。
|
||||
*/
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated($request->all(), RefundOrderValidator::class, 'index');
|
||||
$data['merchant_id'] = $merchantId;
|
||||
$page = max(1, (int) ($data['page'] ?? 1));
|
||||
$pageSize = max(1, (int) ($data['page_size'] ?? 10));
|
||||
|
||||
return $this->success($this->refundService->paginate($data, $page, $pageSize, $merchantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前商户的退款订单详情。
|
||||
*/
|
||||
public function show(Request $request, string $refundNo): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
return $this->success($this->refundService->detail($refundNo, $merchantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重试当前商户的退款单。
|
||||
*/
|
||||
public function retry(Request $request, string $refundNo): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated(
|
||||
array_merge($request->all(), ['refund_no' => $refundNo]),
|
||||
RefundActionValidator::class,
|
||||
'retry'
|
||||
);
|
||||
|
||||
return $this->success($this->refundService->retryRefund($refundNo, $data, $merchantId));
|
||||
}
|
||||
}
|
||||
|
||||
63
app/http/mer/middleware/MerchantAuthMiddleware.php
Normal file
63
app/http/mer/middleware/MerchantAuthMiddleware.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\middleware;
|
||||
|
||||
use app\service\merchant\auth\MerchantAuthService;
|
||||
use support\Context;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
use Webman\MiddlewareInterface;
|
||||
|
||||
/**
|
||||
* 商户认证中间件。
|
||||
*
|
||||
* 负责读取商户 token,并把商户身份写入请求上下文。
|
||||
*/
|
||||
class MerchantAuthMiddleware implements MiddlewareInterface
|
||||
{
|
||||
/**
|
||||
* 构造函数,注入对应依赖。
|
||||
*/
|
||||
public function __construct(
|
||||
protected MerchantAuthService $merchantAuthService
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求。
|
||||
*/
|
||||
public function process(Request $request, callable $handler): Response
|
||||
{
|
||||
$token = trim((string) ($request->header('authorization', '') ?: $request->header('x-merchant-token', '')));
|
||||
$token = preg_replace('/^Bearer\s+/i', '', $token) ?: $token;
|
||||
|
||||
if ($token === '') {
|
||||
if ((int) env('AUTH_MIDDLEWARE_STRICT', 1) === 1) {
|
||||
return json([
|
||||
'code' => 401,
|
||||
'msg' => 'merchant unauthorized',
|
||||
'data' => null,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$result = $this->merchantAuthService->authenticateToken(
|
||||
$token,
|
||||
$request->getRealIp(),
|
||||
$request->header('user-agent', '')
|
||||
);
|
||||
if (!$result) {
|
||||
return json([
|
||||
'code' => 401,
|
||||
'msg' => 'merchant unauthorized',
|
||||
'data' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
Context::set('auth.merchant_id', (int) $result['merchant']->id);
|
||||
Context::set('auth.merchant_no', (string) $result['merchant']->merchant_no);
|
||||
}
|
||||
|
||||
return $handler($request);
|
||||
}
|
||||
}
|
||||
|
||||
25
app/http/mer/validation/AuthValidator.php
Normal file
25
app/http/mer/validation/AuthValidator.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 商户登录参数校验器。
|
||||
*/
|
||||
class AuthValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'merchant_no' => 'required|string|min:1|max:32',
|
||||
'password' => 'required|string|min:6|max:32',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'merchant_no' => '商户号',
|
||||
'password' => '登录密码',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'login' => ['merchant_no', 'password'],
|
||||
];
|
||||
}
|
||||
25
app/http/mer/validation/BalanceValidator.php
Normal file
25
app/http/mer/validation/BalanceValidator.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 商户余额查询参数校验器。
|
||||
*
|
||||
* 用于校验商户余额查询入参。
|
||||
*/
|
||||
class BalanceValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'merchant_no' => 'required|string|min:1|max:64',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'merchant_no' => '商户号',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'show' => ['merchant_no'],
|
||||
];
|
||||
}
|
||||
60
app/http/mer/validation/MerchantPortalValidator.php
Normal file
60
app/http/mer/validation/MerchantPortalValidator.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 商户后台资料与安全页校验器。
|
||||
*/
|
||||
class MerchantPortalValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'merchant_short_name' => 'sometimes|string|max:64',
|
||||
'contact_name' => 'sometimes|string|max:64',
|
||||
'contact_phone' => 'sometimes|string|max:32',
|
||||
'contact_email' => 'sometimes|email|max:128',
|
||||
'settlement_account_name' => 'sometimes|string|max:128',
|
||||
'settlement_account_no' => 'sometimes|string|max:128',
|
||||
'settlement_bank_name' => 'sometimes|string|max:128',
|
||||
'settlement_bank_branch' => 'sometimes|string|max:128',
|
||||
'current_password' => 'sometimes|string|min:6|max:32',
|
||||
'password' => 'sometimes|string|min:6|max:32',
|
||||
'password_confirm' => 'sometimes|string|min:6|max:32|same:password',
|
||||
'pay_type_id' => 'required|integer|min:1',
|
||||
'pay_amount' => 'required|integer|min:1',
|
||||
'stat_date' => 'sometimes|date',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'merchant_short_name' => '商户简称',
|
||||
'contact_name' => '联系人',
|
||||
'contact_phone' => '联系电话',
|
||||
'contact_email' => '联系邮箱',
|
||||
'settlement_account_name' => '结算账户名',
|
||||
'settlement_account_no' => '结算账号',
|
||||
'settlement_bank_name' => '开户行',
|
||||
'settlement_bank_branch' => '开户支行',
|
||||
'current_password' => '当前密码',
|
||||
'password' => '新密码',
|
||||
'password_confirm' => '确认密码',
|
||||
'pay_type_id' => '支付方式',
|
||||
'pay_amount' => '支付金额',
|
||||
'stat_date' => '统计日期',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'profileUpdate' => [
|
||||
'merchant_short_name',
|
||||
'contact_name',
|
||||
'contact_phone',
|
||||
'contact_email',
|
||||
'settlement_account_name',
|
||||
'settlement_account_no',
|
||||
'settlement_bank_name',
|
||||
'settlement_bank_branch',
|
||||
],
|
||||
'passwordUpdate' => ['current_password', 'password', 'password_confirm'],
|
||||
'routePreview' => ['pay_type_id', 'pay_amount', 'stat_date'],
|
||||
];
|
||||
}
|
||||
39
app/http/mer/validation/PayOrderValidator.php
Normal file
39
app/http/mer/validation/PayOrderValidator.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 支付订单列表参数校验器。
|
||||
*
|
||||
* 仅供商户后台使用。
|
||||
*/
|
||||
class PayOrderValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'keyword' => 'sometimes|string|max:128',
|
||||
'merchant_id' => 'sometimes|integer|min:1',
|
||||
'pay_type_id' => 'sometimes|integer|min:1',
|
||||
'status' => 'sometimes|integer|in:0,1,2,3,4,5',
|
||||
'channel_mode' => 'sometimes|integer|in:0,1',
|
||||
'callback_status' => 'sometimes|integer|in:0,1,2',
|
||||
'page' => 'sometimes|integer|min:1',
|
||||
'page_size' => 'sometimes|integer|min:1|max:100',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'keyword' => '关键字',
|
||||
'merchant_id' => '商户ID',
|
||||
'pay_type_id' => '支付方式',
|
||||
'status' => '状态',
|
||||
'channel_mode' => '通道模式',
|
||||
'callback_status' => '回调状态',
|
||||
'page' => '页码',
|
||||
'page_size' => '每页条数',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'index' => ['keyword', 'merchant_id', 'pay_type_id', 'status', 'channel_mode', 'callback_status', 'page', 'page_size'],
|
||||
];
|
||||
}
|
||||
36
app/http/mer/validation/RefundActionValidator.php
Normal file
36
app/http/mer/validation/RefundActionValidator.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 退款操作参数校验器。
|
||||
*
|
||||
* 仅供商户后台的退款重试等操作使用。
|
||||
*/
|
||||
class RefundActionValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'refund_no' => 'required|string|max:64',
|
||||
'processing_at' => 'sometimes|date_format:Y-m-d H:i:s',
|
||||
'failed_at' => 'sometimes|date_format:Y-m-d H:i:s',
|
||||
'last_error' => 'sometimes|string|max:512',
|
||||
'channel_refund_no' => 'sometimes|string|max:64',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'refund_no' => '退款单号',
|
||||
'processing_at' => '处理时间',
|
||||
'failed_at' => '失败时间',
|
||||
'last_error' => '错误信息',
|
||||
'channel_refund_no' => '渠道退款单号',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'retry' => ['refund_no', 'processing_at'],
|
||||
'mark_fail' => ['refund_no', 'failed_at', 'last_error'],
|
||||
'mark_processing' => ['refund_no', 'processing_at'],
|
||||
'mark_success' => ['refund_no', 'channel_refund_no'],
|
||||
];
|
||||
}
|
||||
37
app/http/mer/validation/RefundOrderValidator.php
Normal file
37
app/http/mer/validation/RefundOrderValidator.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\validation;
|
||||
|
||||
use support\validation\Validator;
|
||||
|
||||
/**
|
||||
* 退款订单列表参数校验器。
|
||||
*
|
||||
* 仅供商户后台使用。
|
||||
*/
|
||||
class RefundOrderValidator extends Validator
|
||||
{
|
||||
protected array $rules = [
|
||||
'keyword' => 'sometimes|string|max:128',
|
||||
'merchant_id' => 'sometimes|integer|min:1',
|
||||
'pay_type_id' => 'sometimes|integer|min:1',
|
||||
'status' => 'sometimes|integer|in:0,1,2,3,4',
|
||||
'channel_mode' => 'sometimes|integer|in:0,1',
|
||||
'page' => 'sometimes|integer|min:1',
|
||||
'page_size' => 'sometimes|integer|min:1|max:100',
|
||||
];
|
||||
|
||||
protected array $attributes = [
|
||||
'keyword' => '关键字',
|
||||
'merchant_id' => '商户ID',
|
||||
'pay_type_id' => '支付方式',
|
||||
'status' => '退款状态',
|
||||
'channel_mode' => '通道模式',
|
||||
'page' => '页码',
|
||||
'page_size' => '每页条数',
|
||||
];
|
||||
|
||||
protected array $scenes = [
|
||||
'index' => ['keyword', 'merchant_id', 'pay_type_id', 'status', 'channel_mode', 'page', 'page_size'],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user