feat: 技术债务清理(支付配置动态化、API文档补全、轮询常量提取、废弃代码清理)
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m13s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m13s
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/break/junhong_cmp_fiber/internal/task"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/payment"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/queue"
|
||||
"github.com/hibiken/asynq"
|
||||
"go.uber.org/zap"
|
||||
@@ -28,7 +29,6 @@ type ForceRechargeRequirement struct {
|
||||
CurrentAccumulated int64 `json:"current_accumulated"` // 当前累计充值
|
||||
Threshold int64 `json:"threshold"` // 佣金触发阈值
|
||||
Message string `json:"message"` // 提示信息
|
||||
FirstCommissionPaid bool `json:"first_commission_paid"` // 一次性佣金是否已发放
|
||||
}
|
||||
|
||||
// WechatConfigServiceInterface 支付配置服务接口
|
||||
@@ -49,6 +49,7 @@ type Service struct {
|
||||
packageSeriesStore *postgres.PackageSeriesStore
|
||||
commissionRecordStore *postgres.CommissionRecordStore
|
||||
wechatConfigService WechatConfigServiceInterface
|
||||
paymentLoader payment.PaymentConfigLoader
|
||||
queueClient *queue.Client // 任务队列客户端,用于触发自动购包任务
|
||||
logger *zap.Logger
|
||||
}
|
||||
@@ -65,6 +66,7 @@ func New(
|
||||
packageSeriesStore *postgres.PackageSeriesStore,
|
||||
commissionRecordStore *postgres.CommissionRecordStore,
|
||||
wechatConfigService WechatConfigServiceInterface,
|
||||
paymentLoader payment.PaymentConfigLoader,
|
||||
logger *zap.Logger,
|
||||
queueClient *queue.Client,
|
||||
) *Service {
|
||||
@@ -79,6 +81,7 @@ func New(
|
||||
packageSeriesStore: packageSeriesStore,
|
||||
commissionRecordStore: commissionRecordStore,
|
||||
wechatConfigService: wechatConfigService,
|
||||
paymentLoader: paymentLoader,
|
||||
queueClient: queueClient,
|
||||
logger: logger,
|
||||
}
|
||||
@@ -88,10 +91,10 @@ func New(
|
||||
// 验证资源、金额范围、强充要求,生成订单号
|
||||
func (s *Service) Create(ctx context.Context, req *dto.CreateRechargeRequest, userID uint) (*dto.RechargeResponse, error) {
|
||||
// 1. 验证金额范围
|
||||
if req.Amount < constants.RechargeMinAmount {
|
||||
if req.Amount < constants.AssetRechargeMinAmount {
|
||||
return nil, errors.New(errors.CodeRechargeAmountInvalid, "充值金额不能低于1元")
|
||||
}
|
||||
if req.Amount > constants.RechargeMaxAmount {
|
||||
if req.Amount > constants.AssetRechargeMaxAmount {
|
||||
return nil, errors.New(errors.CodeRechargeAmountInvalid, "充值金额不能超过100000元")
|
||||
}
|
||||
|
||||
@@ -268,7 +271,7 @@ func (s *Service) List(ctx context.Context, req *dto.RechargeListRequest, userID
|
||||
|
||||
// HandlePaymentCallback 支付回调处理
|
||||
// 支持幂等性检查、事务处理、更新余额、触发佣金
|
||||
// TODO: 按 payment_config_id 加载配置验签(当前留桩,验签由外层处理)
|
||||
// 验签由外层 Handler 负责;如需按 payment_config_id 加载配置,可通过 s.paymentLoader 获取
|
||||
func (s *Service) HandlePaymentCallback(ctx context.Context, rechargeNo string, paymentMethod string, paymentTransactionID string) error {
|
||||
// 1. 查询充值订单
|
||||
recharge, err := s.assetRechargeStore.GetByRechargeNo(ctx, rechargeNo)
|
||||
@@ -414,8 +417,8 @@ func (s *Service) HandlePaymentCallback(ctx context.Context, rechargeNo string,
|
||||
func (s *Service) checkForceRechargeRequirement(ctx context.Context, resourceType string, resourceID uint) (*ForceRechargeRequirement, error) {
|
||||
result := &ForceRechargeRequirement{
|
||||
NeedForceRecharge: false,
|
||||
MinAmount: constants.RechargeMinAmount,
|
||||
MaxAmount: constants.RechargeMaxAmount,
|
||||
MinAmount: constants.AssetRechargeMinAmount,
|
||||
MaxAmount: constants.AssetRechargeMaxAmount,
|
||||
Message: "无强充要求,可自由充值",
|
||||
}
|
||||
|
||||
@@ -455,7 +458,6 @@ func (s *Service) checkForceRechargeRequirement(ctx context.Context, resourceTyp
|
||||
}
|
||||
|
||||
result.CurrentAccumulated = accumulatedRecharge
|
||||
result.FirstCommissionPaid = firstCommissionPaid
|
||||
|
||||
if seriesID == nil || shopID == nil {
|
||||
return result, nil
|
||||
|
||||
Reference in New Issue
Block a user