mirror of
https://gitee.com/technical-laohu/mpay_v2_webman.git
synced 2026-05-10 10:54:27 +08:00
1. 维护代码健壮
2. 更新项目结构文档
This commit is contained in:
@@ -100,6 +100,138 @@ class MerchantPortalController extends BaseController
|
||||
return $this->success($this->merchantPortalService->myChannels($payload, $merchantId, $page, $pageSize));
|
||||
}
|
||||
|
||||
public function channelCreateMeta(Request $request): Response
|
||||
{
|
||||
return $this->success($this->merchantPortalService->channelCreateMeta());
|
||||
}
|
||||
|
||||
public function createChannel(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated($this->payload($request), MerchantPortalValidator::class, 'channelStore');
|
||||
|
||||
return $this->success($this->merchantPortalService->createChannel($merchantId, $data));
|
||||
}
|
||||
|
||||
public function updateChannel(Request $request, string $id): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated(
|
||||
array_merge($this->payload($request), ['id' => (int) $id]),
|
||||
MerchantPortalValidator::class,
|
||||
'channelUpdate'
|
||||
);
|
||||
|
||||
$channel = $this->merchantPortalService->updateChannel($merchantId, (int) $data['id'], $data);
|
||||
if (!$channel) {
|
||||
return $this->fail('通道不存在', 404);
|
||||
}
|
||||
|
||||
return $this->success($channel);
|
||||
}
|
||||
|
||||
public function deleteChannel(Request $request, string $id): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated(['id' => (int) $id], MerchantPortalValidator::class, 'channelDestroy');
|
||||
if (!$this->merchantPortalService->deleteChannel($merchantId, (int) $data['id'])) {
|
||||
return $this->fail('通道不存在', 404);
|
||||
}
|
||||
|
||||
return $this->success(true);
|
||||
}
|
||||
|
||||
public function pluginConfigs(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$payload = $this->validated($this->payload($request), MerchantPortalValidator::class, 'pluginConfigIndex');
|
||||
$page = max(1, (int) ($payload['page'] ?? 1));
|
||||
$pageSize = max(1, (int) ($payload['page_size'] ?? 10));
|
||||
|
||||
return $this->success($this->merchantPortalService->pluginConfigs($payload, $merchantId, $page, $pageSize));
|
||||
}
|
||||
|
||||
public function createPluginConfig(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated($this->payload($request), MerchantPortalValidator::class, 'pluginConfigStore');
|
||||
|
||||
return $this->success($this->merchantPortalService->createPluginConfig($merchantId, $data));
|
||||
}
|
||||
|
||||
public function updatePluginConfig(Request $request, string $id): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated(
|
||||
array_merge($this->payload($request), ['id' => (int) $id]),
|
||||
MerchantPortalValidator::class,
|
||||
'pluginConfigUpdate'
|
||||
);
|
||||
|
||||
$config = $this->merchantPortalService->updatePluginConfig($merchantId, (int) $data['id'], $data);
|
||||
if (!$config) {
|
||||
return $this->fail('插件配置不存在', 404);
|
||||
}
|
||||
|
||||
return $this->success($config);
|
||||
}
|
||||
|
||||
public function deletePluginConfig(Request $request, string $id): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$data = $this->validated(['id' => (int) $id], MerchantPortalValidator::class, 'pluginConfigDestroy');
|
||||
if (!$this->merchantPortalService->deletePluginConfig($merchantId, (int) $data['id'])) {
|
||||
return $this->fail('插件配置不存在', 404);
|
||||
}
|
||||
|
||||
return $this->success(true);
|
||||
}
|
||||
|
||||
public function pluginConfigOptions(Request $request): Response
|
||||
{
|
||||
$merchantId = $this->currentMerchantId($request);
|
||||
if ($merchantId <= 0) {
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
return $this->success([
|
||||
'configs' => $this->merchantPortalService->pluginConfigOptions($merchantId, (string) $request->get('plugin_code', '')),
|
||||
]);
|
||||
}
|
||||
|
||||
public function pluginSchema(Request $request, string $code): Response
|
||||
{
|
||||
return $this->success($this->merchantPortalService->pluginSchema($code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由解析结果。
|
||||
*
|
||||
@@ -113,7 +245,12 @@ class MerchantPortalController extends BaseController
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
$payload = $this->validated($this->payload($request), MerchantPortalValidator::class, 'routePreview');
|
||||
$rawPayload = $this->payload($request);
|
||||
if (empty($rawPayload['pay_type_id']) || empty($rawPayload['pay_amount'])) {
|
||||
return $this->success($this->merchantPortalService->routePreview($merchantId, 0, 0));
|
||||
}
|
||||
|
||||
$payload = $this->validated($rawPayload, MerchantPortalValidator::class, 'routePreview');
|
||||
$payTypeId = (int) ($payload['pay_type_id'] ?? 0);
|
||||
$payAmount = (int) ($payload['pay_amount'] ?? 0);
|
||||
$statDate = trim((string) ($payload['stat_date'] ?? ''));
|
||||
@@ -150,7 +287,9 @@ class MerchantPortalController extends BaseController
|
||||
return $this->fail('未获取到当前商户信息', 401);
|
||||
}
|
||||
|
||||
return $this->success($this->merchantPortalService->issueCredential($merchantId));
|
||||
$data = $this->validated($this->payload($request), MerchantPortalValidator::class, 'issueCredential');
|
||||
|
||||
return $this->success($this->merchantPortalService->issueCredential($merchantId, $data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user