feat-IRONFANS-192-Robin #685

Merged
chenhao merged 3 commits from feat-IRONFANS-192-Robin into main 2024-08-06 18:38:43 +08:00
2 changed files with 45 additions and 4 deletions
Showing only changes of commit f73d0f9a75 - Show all commits

View File

@ -1402,13 +1402,17 @@ 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).
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,35 @@ func (s *Service) OpUpdateZoneThirdPartner(ctx *gin.Context, req *zone_third_par
return
}
zid := req.ZoneThirdPartner.GetZid()
// 如果更新代运营,则删除旧代运营及协作者团队
if req.ZoneThirdPartner.ThirdPartnerMid != nil {
_, err := _DefaultZoneThirdPartner.OpDeleteByZid(ctx, zid)
if err != nil {
logger.Error("OpDelete fail, id: %v, err: %v", zid, err)
ec = errcode.ErrCodeZoneThirdPartnerSrvFail
return
}
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 +4483,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
}