1. 维护代码健壮

2. 更新项目结构文档
This commit is contained in:
技术老胡
2026-04-27 16:20:41 +08:00
parent 9a16a88640
commit 0e5de50337
198 changed files with 21038 additions and 702 deletions

View File

@@ -46,6 +46,7 @@ class PaymentPluginConfService extends BaseService
->leftJoin('ma_payment_plugin as p', 'c.plugin_code', '=', 'p.code')
->select([
'c.id',
'c.merchant_id',
'c.plugin_code',
'c.config',
'c.settlement_cycle_type',
@@ -71,6 +72,11 @@ class PaymentPluginConfService extends BaseService
$query->where('c.plugin_code', $pluginCode);
}
$merchantId = trim((string) ($filters['merchant_id'] ?? ''));
if ($merchantId !== '') {
$query->where('c.merchant_id', (int) $merchantId);
}
return $query
->orderByDesc('c.id')
->paginate(max(1, $pageSize), ['*'], 'page', max(1, $page));
@@ -249,6 +255,7 @@ class PaymentPluginConfService extends BaseService
{
return [
'plugin_code' => trim((string) ($data['plugin_code'] ?? '')),
'merchant_id' => max(0, (int) ($data['merchant_id'] ?? 0)),
// 配置内容统一按数组保存,外部传入非数组时直接回退为空数组。
'config' => is_array($data['config'] ?? null) ? $data['config'] : [],
// 默认结算周期按日配置,截止时间默认按当天 23:59:59 收口。

View File

@@ -216,6 +216,10 @@ class PaymentPluginService extends BaseService
$payload['status'] = (int) $data['status'];
}
if (array_key_exists('allow_merchant', $data)) {
$payload['allow_merchant'] = (int) $data['allow_merchant'];
}
if (array_key_exists('remark', $data)) {
$payload['remark'] = trim((string) $data['remark']);
}

View File

@@ -90,6 +90,7 @@ class PaymentPluginSyncService extends BaseService
$current = $existing[$code] ?? null;
$payload = array_merge($row, [
'status' => (int) ($current->status ?? 1),
'allow_merchant' => (int) ($current->allow_merchant ?? 0),
'remark' => (string) ($current->remark ?? ''),
]);
@@ -141,4 +142,3 @@ class PaymentPluginSyncService extends BaseService
}
}

View File

@@ -3,6 +3,7 @@
namespace app\service\payment\config;
use app\common\base\BaseService;
use app\common\constant\CommonConstant;
use app\exception\ValidationException;
use app\model\payment\PaymentType;
use app\repository\payment\config\PaymentTypeRepository;
@@ -87,7 +88,9 @@ class PaymentTypeService extends BaseService
}
/**
* 解析启用中的支付方式,优先按编码匹配,未命中则取首个启用项
* 解析启用中的支付方式。
*
* 仅在显式传入编码且命中启用项时返回,未命中直接抛错,不再提供默认回退。
*
* @param string $code 支付方式编码
* @return PaymentType 支付方式模型
@@ -98,18 +101,12 @@ class PaymentTypeService extends BaseService
$code = trim($code);
if ($code !== '') {
$paymentType = $this->paymentTypeRepository->findByCode($code);
if ($paymentType && (int) $paymentType->status === 1) {
if ($paymentType && (int) $paymentType->status === CommonConstant::STATUS_ENABLED) {
return $paymentType;
}
}
// 没有传编码或编码不可用时,直接回退到系统当前首个启用支付方式。
$paymentType = $this->paymentTypeRepository->enabledList()->first();
if (!$paymentType) {
throw new ValidationException('未配置可用支付方式');
}
return $paymentType;
throw new ValidationException('未配置可用支付方式');
}
/**
@@ -184,5 +181,3 @@ class PaymentTypeService extends BaseService
return $this->paymentTypeRepository->deleteById($id);
}
}