feat(quality-owner): 增加优质号主、极品专区与无忧租号保险
- 支持保证金余额支付、在线支付开通及后台手动设置审计 - 新增极品专区发布权限、赔付方案与保险结算费率快照 - 优化首页、商品卡和个人中心的优质号主身份展示
This commit is contained in:
@@ -3,6 +3,8 @@ package listing
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"hfb_sys/backend/internal/modules/qualityowner"
|
||||
)
|
||||
|
||||
func (s *Service) Create(ctx context.Context, ownerID uint64, req CreateRequest, siteCode ...string) (*ListingDTO, error) {
|
||||
@@ -30,6 +32,9 @@ func (s *Service) Create(ctx context.Context, ownerID uint64, req CreateRequest,
|
||||
if err := validateRequiredOnlineTime(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.applyPublishEntitlements(ctx, ownerID, &req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cooldown, err := s.publishCooldown(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -63,6 +68,9 @@ func (s *Service) Update(ctx context.Context, ownerID uint64, id uint64, req Upd
|
||||
if err := validateRequiredOnlineTime(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.applyPublishEntitlements(ctx, ownerID, &req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reviewRequired, err := s.reviewRequired(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -70,6 +78,45 @@ func (s *Service) Update(ctx context.Context, ownerID uint64, id uint64, req Upd
|
||||
return s.repo.Update(ctx, ownerID, id, req, reviewRequired)
|
||||
}
|
||||
|
||||
func (s *Service) applyPublishEntitlements(ctx context.Context, ownerID uint64, req *CreateRequest) error {
|
||||
req.CompensationPlan = strings.TrimSpace(req.CompensationPlan)
|
||||
if req.CompensationPlan == "" {
|
||||
req.CompensationPlan = CompensationPlanNormal
|
||||
}
|
||||
if req.CompensationPlan != CompensationPlanNormal && req.CompensationPlan != CompensationPlanInsurance {
|
||||
return ErrInvalidInput
|
||||
}
|
||||
|
||||
isQualityOwner, err := s.repo.IsQualityOwner(ctx, ownerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if req.IsPremium && !isQualityOwner {
|
||||
return ErrPremiumOwnerRequired
|
||||
}
|
||||
|
||||
req.InsuranceFeeBps = 0
|
||||
if req.CompensationPlan != CompensationPlanInsurance {
|
||||
return nil
|
||||
}
|
||||
rules := qualityowner.DefaultRules()
|
||||
if s.config != nil {
|
||||
value, err := s.config.FindValue(ctx, qualityowner.ConfigKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rules, err = qualityowner.ParseConfigValue(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
req.InsuranceFeeBps = rules.InsuranceFeeBps
|
||||
if req.IsPremium && isQualityOwner {
|
||||
req.InsuranceFeeBps = rules.PremiumInsuranceFeeBps
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) SubmitReview(ctx context.Context, ownerID uint64, id uint64) (*ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
|
||||
Reference in New Issue
Block a user