Merge pull request 'feat-IRONFANS-192-Robin' (#685) from feat-IRONFANS-192-Robin into main

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/685
This commit is contained in:
chenhao 2024-08-06 18:38:43 +08:00
commit f0fe54bc0e
2 changed files with 39 additions and 4 deletions

View File

@ -1402,13 +1402,18 @@ func (s *Service) OpHeadZoneMomentBusinessValidate(ctx *gin.Context, req *zonemo
func (s *Service) OpUpdateZoneThirdPartnerBusinessValidate(ctx *gin.Context, req *zone_third_partner_proto.OpUpdateReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeZoneThirdPartnerSrvOk
// 1.业务校验
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
EnsureZoneThirdPartnerSharingRatioIsNotTooLarge(req.ZoneThirdPartner.GetSharingRatio()).
EnsureZoneThirdPartnerSharingRatioIsEnough(func(ctx *gin.Context, zid int64) ([]*dbstruct.ZoneCollaborator, error) {
validator := businessvalidator.NewAuthBusinessValidator(ctx, req).
EnsureZoneThirdPartnerIsNotZoneCreater(_DefaultZone.GetById, req.ZoneThirdPartner.GetZid(), req.ZoneThirdPartner.GetThirdPartnerMid()).
EnsureZoneThirdPartnerSharingRatioIsNotTooLarge(req.ZoneThirdPartner.GetSharingRatio())
// 若不更新代运营,则确保代运营分成比例足够
if req.ZoneThirdPartner.ThirdPartnerMid == nil {
validator.EnsureZoneThirdPartnerSharingRatioIsEnough(func(ctx *gin.Context, zid int64) ([]*dbstruct.ZoneCollaborator, error) {
return _DefaultZoneCollaborator.OpList(ctx, &zone_collaborator_proto.OpListReq{
Zid: goproto.Int64(zid),
})
}, req.ZoneThirdPartner.GetZid(), req.ZoneThirdPartner.GetSharingRatio()).
}, req.ZoneThirdPartner.GetZid(), req.ZoneThirdPartner.GetSharingRatio())
}
result := validator.
Validate().
Collect()
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {

View File

@ -4442,6 +4442,28 @@ func (s *Service) OpUpdateZoneThirdPartner(ctx *gin.Context, req *zone_third_par
return
}
zid := req.ZoneThirdPartner.GetZid()
// 如果更新代运营,则移除协作者团队
if req.ZoneThirdPartner.ThirdPartnerMid != nil {
zclist, err := _DefaultZoneCollaborator.OpList(ctx, &zone_collaborator_proto.OpListReq{
Zid: goproto.Int64(zid),
})
if err != nil {
logger.Error("OpList fail, id: %v, err: %v", zid, err)
ec = errcode.ErrCodeZoneCollaboratorSrvFail
return
}
for _, zc := range zclist {
err := _DefaultZoneCollaborator.OpDelete(ctx, zc.GetId())
if err != nil {
logger.Error("OpDelete fail, id: %v, err: %v", zid, err)
ec = errcode.ErrCodeZoneCollaboratorSrvFail
return
}
}
}
err := _DefaultZoneThirdPartner.OpUpdateByZid(ctx, req)
if err == qmgo.ErrNoSuchDocuments {
ec = errcode.ErrCodeZoneThirdPartnerNotExist
@ -4454,6 +4476,14 @@ func (s *Service) OpUpdateZoneThirdPartner(ctx *gin.Context, req *zone_third_par
return
}
// 若更新代运营,则新代运营加入空间
if req.ZoneThirdPartner.ThirdPartnerMid != nil {
_err := _DefaultVas.ZoneFreeJoinThirdPartner(ctx, req.ZoneThirdPartner.GetThirdPartnerMid(), req.ZoneThirdPartner.GetZid())
if _err != nil {
logger.Error("ZoneFreeJoinThirdPartner fail, mid: %v, zid: %v, err: %v", req.ZoneThirdPartner.GetThirdPartnerMid(), req.ZoneThirdPartner.GetZid(), _err)
}
}
return
}