避免续费报价缺失阻断资产详情
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 1m23s

Constraint: 代理渠道缺少套餐分配记录时不存在可信的当前续费价
Rejected: 回退平台价或历史成交价 | 会与实际下单校验和当前价格口径不一致
Confidence: high
Scope-risk: narrow
Directive: renewal_price 为 null 时前端不得展示价格或发起续费
Tested: go build ./internal/handler/app
Not-tested: 按用户要求未添加或运行测试
This commit is contained in:
2026-07-30 17:14:28 +08:00
parent e2687de338
commit cf2ff0ac1c
3 changed files with 16 additions and 8 deletions

View File

@@ -307,24 +307,32 @@ func (h *ClientAssetHandler) getCurrentPackageID(ctx context.Context, usageID *u
return usage.PackageID, nil
}
func (h *ClientAssetHandler) getRenewalPrice(ctx context.Context, packageID, sellerShopID uint) (int64, error) {
func (h *ClientAssetHandler) getRenewalPrice(ctx context.Context, packageID, sellerShopID uint) (*int64, error) {
if packageID == 0 {
return 0, nil
return nil, nil
}
pkg, err := h.packageStore.GetByID(ctx, packageID)
if err != nil {
return 0, errors.Wrap(errors.CodeDatabaseError, err, "查询续费套餐失败")
if err == gorm.ErrRecordNotFound {
return nil, nil
}
return nil, errors.Wrap(errors.CodeDatabaseError, err, "查询续费套餐失败")
}
if sellerShopID == 0 {
return packageprice.PackageEffectiveRetailPrice(pkg), nil
price := packageprice.PackageEffectiveRetailPrice(pkg)
return &price, nil
}
allocation, err := h.shopPackageAllocationStore.GetByShopAndPackageForSystem(ctx, sellerShopID, packageID)
if err != nil {
return 0, errors.Wrap(errors.CodeDatabaseError, err, "查询续费套餐价格失败")
if err == gorm.ErrRecordNotFound {
return nil, nil
}
return nil, errors.Wrap(errors.CodeDatabaseError, err, "查询续费套餐价格失败")
}
return packageprice.AllocationEffectiveRetailPrice(allocation), nil
price := packageprice.AllocationEffectiveRetailPrice(allocation)
return &price, nil
}
func (h *ClientAssetHandler) dispatchAssetReadObservations(ctx context.Context, asset *dto.AssetResolveResponse) {