赠送套餐逻辑
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s

This commit is contained in:
2026-04-28 17:40:06 +08:00
parent 516a7f5bdf
commit 37b4483183
34 changed files with 1172 additions and 60 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/break/junhong_cmp_fiber/internal/model"
packagepkg "github.com/break/junhong_cmp_fiber/internal/service/package"
"github.com/break/junhong_cmp_fiber/internal/service/packageprice"
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
"github.com/break/junhong_cmp_fiber/pkg/constants"
)
@@ -337,7 +338,10 @@ func (h *AutoPurchaseHandler) loadPackages(ctx context.Context, packageIDs []uin
totalAmount := int64(0)
for _, pkg := range packages {
totalAmount += pkg.SuggestedRetailPrice
if pkg.IsGift {
return nil, 0, errors.New("赠送套餐不能进入自动购包链路")
}
totalAmount += packageprice.PackageEffectiveRetailPrice(pkg)
}
if err := validatePackageTypeMix(packages); err != nil {
@@ -399,16 +403,19 @@ func (h *AutoPurchaseHandler) buildOrderAndItems(
items := make([]*model.OrderItem, 0, len(packages))
for _, pkg := range packages {
unitPrice := packageprice.PackageEffectiveRetailPrice(pkg)
items = append(items, &model.OrderItem{
BaseModel: model.BaseModel{
Creator: rechargeOrder.UserID,
Updater: rechargeOrder.UserID,
},
PackageID: pkg.ID,
PackageName: pkg.PackageName,
Quantity: 1,
UnitPrice: pkg.SuggestedRetailPrice,
Amount: pkg.SuggestedRetailPrice,
PackageID: pkg.ID,
PackageName: pkg.PackageName,
Quantity: 1,
UnitPrice: unitPrice,
Amount: unitPrice,
PackagePriceConfigStatus: pkg.PriceConfigStatus,
PackageIsGift: pkg.IsGift,
})
}
@@ -525,6 +532,8 @@ func (h *AutoPurchaseHandler) activateMainPackage(
PendingRealnameActivation: pendingRealnameActivation,
Generation: order.Generation,
PaidAmount: order.ActualPaidAmount,
PackagePriceConfigStatus: pkg.PriceConfigStatus,
PackageIsGift: pkg.IsGift,
}
if carrierType == constants.AssetWalletResourceTypeIotCard {
@@ -604,6 +613,8 @@ func (h *AutoPurchaseHandler) activateAddonPackage(
DataResetCycle: pkg.DataResetCycle,
Generation: order.Generation,
PaidAmount: order.ActualPaidAmount,
PackagePriceConfigStatus: pkg.PriceConfigStatus,
PackageIsGift: pkg.IsGift,
}
if carrierType == constants.AssetWalletResourceTypeIotCard {