diff --git a/internal/service/order/service.go b/internal/service/order/service.go index 02a3a7f..a4b9aee 100644 --- a/internal/service/order/service.go +++ b/internal/service/order/service.go @@ -1869,11 +1869,34 @@ func (s *Service) activateMainPackage(ctx context.Context, tx *gorm.DB, order *m nextResetAt = packagepkg.CalculateNextResetTime(pkg.DataResetCycle, pkg.CalendarType, now, activatedAt) } - // 任务 8.9: 后台囤货场景 - if pkg.EnableRealnameActivation { - // 需要实名后才能激活 - status = constants.PackageUsageStatusPending - pendingRealnameActivation = true + // REALNAME-02: 后台囤货场景三维决策(卡类型 + 购买路径 + expiry_base) + // 注意:仅在 else 分支(立即激活)时才需要判断是否切换为等实名 + if !hasActiveMain { + // 查询卡类型(行业卡永远直接激活,不等实名) + var cardCategory string + if carrierType == "iot_card" { + var card model.IotCard + if err := tx.Select("card_category").First(&card, carrierID).Error; err == nil { + cardCategory = card.CardCategory + } + } + + // 判断是否 C 端购买(C 端购买前已做实名前置检查,直接激活) + isCEndPurchase := order.BuyerType == model.BuyerTypePersonal + + if cardCategory != "industry" && !isCEndPurchase { + // 后台囤货路径:按 expiry_base 决定是否等实名 + if pkg.ExpiryBase != "from_purchase" { + // from_activation(默认):等实名后激活 + status = constants.PackageUsageStatusPending + pendingRealnameActivation = true + activatedAt = time.Time{} + expiresAt = time.Time{} + nextResetAt = nil + } + // from_purchase:立即激活,status 已为 Active,保持不变 + } + // 行业卡或 C 端购买:直接激活,status 已为 Active,保持不变 } // 创建套餐使用记录