修复错误购买报错的问题,修复接口返回虚流量启动错误的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m48s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m48s
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
asset "github.com/break/junhong_cmp_fiber/internal/service/asset"
|
||||
packagepkg "github.com/break/junhong_cmp_fiber/internal/service/package"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/purchase_validation"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/alipay"
|
||||
@@ -1248,10 +1247,6 @@ func (s *Service) PayOrder(ctx context.Context, customerID uint, orderID uint, r
|
||||
return &dto.ClientPayOrderResponse{PaymentMethod: model.PaymentMethodWallet}, nil
|
||||
|
||||
case model.PaymentMethodWechat:
|
||||
if err := s.ensureOrderFormalPackagePayable(skipCtx, order); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
activeConfig, appID, err := s.resolveWechatConfig(skipCtx, req.AppType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -1308,10 +1303,6 @@ func (s *Service) PayOrder(ctx context.Context, customerID uint, orderID uint, r
|
||||
}, nil
|
||||
|
||||
case model.PaymentMethodAlipay:
|
||||
if err := s.ensureOrderFormalPackagePayable(skipCtx, order); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 支付宝支付:不需要 app_type / OpenID
|
||||
activeConfig, err := s.wechatConfigService.GetActiveConfig(skipCtx)
|
||||
if err != nil {
|
||||
@@ -1346,58 +1337,6 @@ func (s *Service) PayOrder(ctx context.Context, customerID uint, orderID uint, r
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) ensureOrderFormalPackagePayable(ctx context.Context, order *model.Order) error {
|
||||
if order == nil {
|
||||
return errors.New(errors.CodeInvalidParam)
|
||||
}
|
||||
|
||||
var items []*model.OrderItem
|
||||
if err := s.db.WithContext(ctx).Where("order_id = ?", order.ID).Find(&items).Error; err != nil {
|
||||
return errors.Wrap(errors.CodeDatabaseError, err, "查询订单明细失败")
|
||||
}
|
||||
|
||||
hasFormal := false
|
||||
for _, item := range items {
|
||||
if item == nil || item.PackageType == nil {
|
||||
continue
|
||||
}
|
||||
if *item.PackageType == constants.PackageTypeFormal {
|
||||
hasFormal = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasFormal {
|
||||
return nil
|
||||
}
|
||||
|
||||
carrierType := ""
|
||||
carrierID := uint(0)
|
||||
if order.OrderType == model.OrderTypeSingleCard && order.IotCardID != nil {
|
||||
carrierType = constants.AssetWalletResourceTypeIotCard
|
||||
carrierID = *order.IotCardID
|
||||
} else if order.OrderType == model.OrderTypeDevice && order.DeviceID != nil {
|
||||
carrierType = constants.AssetWalletResourceTypeDevice
|
||||
carrierID = *order.DeviceID
|
||||
}
|
||||
if carrierID == 0 {
|
||||
return errors.New(errors.CodeInvalidParam, "订单缺少套餐载体")
|
||||
}
|
||||
|
||||
hasBlockingMain, err := packagepkg.HasBlockingMainPackageForFormal(
|
||||
s.db.WithContext(ctx),
|
||||
carrierType,
|
||||
carrierID,
|
||||
time.Now(),
|
||||
)
|
||||
if err != nil {
|
||||
return errors.Wrap(errors.CodeDatabaseError, err, "查询主套餐失败")
|
||||
}
|
||||
if hasBlockingMain {
|
||||
return errors.New(errors.CodeMainPackageExists)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) getAssetGeneration(ctx context.Context, assetType string, assetID uint) (int, error) {
|
||||
switch assetType {
|
||||
case "card":
|
||||
|
||||
Reference in New Issue
Block a user