This commit is contained in:
lwl0608 2024-04-28 17:59:57 +08:00
parent 6bf1f9e472
commit 8db2ce1071
5 changed files with 135 additions and 0 deletions

View File

@ -83,3 +83,15 @@ type OpListByUserIdResp struct {
base.BaseResponse
Data *OpListByUserIdData `json:"data"`
}
// op 代运营解锁主播所有空间
type OpZoneUnlockThirdPartnersParam struct {
ThirdPartMids []int64 `json:"third_part_mids"` // 代运营的mid
StreamerMid int64 `json:"streamer_mid"` // 主播的mid
}
// op 代运营解锁主播所有空间
type OpZoneUnlockCollaboratorsParam struct {
CollaboratorMids []int64 `json:"collaborator_mids"` // 协作者的mids
StreamerMid int64 `json:"streamer_mid"` // 主播的mid
}

View File

@ -494,6 +494,8 @@ func Init(r *gin.Engine) {
opZoneGroup.POST("delete", middleware.JSONParamValidator(zoneproto.OpDeleteReq{}), middleware.JwtAuthenticator(), OpDeleteZone)
opZoneGroup.POST("list", middleware.JSONParamValidator(zoneproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetZoneList)
opZoneGroup.POST("list_by_user_id", middleware.JSONParamValidator(zoneproto.OpListByUserIdReq{}), middleware.JwtAuthenticator(), OpGetZoneListByUserId)
opZoneGroup.POST("unlock_third_partners", middleware.JSONParamValidator(zoneproto.OpZoneUnlockThirdPartnersParam{}), OpZoneUnlockThirdPartners)
opZoneGroup.POST("unlock_collaborators", middleware.JSONParamValidator(zoneproto.OpZoneUnlockCollaboratorsParam{}), OpZoneUnlockCollaborators)
// 私密圈动态
opZoneMomentGroup := r.Group("/op/zone_moment", PrepareOp())

View File

@ -96,3 +96,25 @@ func OpGetZoneListByUserId(ctx *gin.Context) {
}
ReplyOk(ctx, data)
}
func OpZoneUnlockThirdPartners(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*zoneproto.OpZoneUnlockThirdPartnersParam)
err := service.DefaultService.OpZoneUnlockThirdPartners(ctx, req)
if err != nil {
logger.Error("OpZoneUnlockThirdPartners fail, req: %v, err: %v", util.ToJson(req), err)
ReplyErrorMsg(ctx, err.Error())
return
}
ReplyOk(ctx, nil)
}
func OpZoneUnlockCollaborators(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*zoneproto.OpZoneUnlockCollaboratorsParam)
err := service.DefaultService.OpZoneUnlockCollaborators(ctx, req)
if err != nil {
logger.Error("OpZoneUnlockCollaborators fail, req: %v, err: %v", util.ToJson(req), err)
ReplyErrorMsg(ctx, err.Error())
return
}
ReplyOk(ctx, nil)
}

View File

@ -1787,6 +1787,67 @@ func (v *Vas) DealOneOrder(ctx *gin.Context, orderId string) (err error) {
switch order.GetProductId() {
case dbstruct.ProductIdMembership:
return v.dealOneMembershipOrder(ctx, tx, order)
case dbstruct.ProductIdH5ZoneAdmission, dbstruct.ProductIdH5ZoneMoment, dbstruct.ProductIdH5ZoneSuperfanship:
return v.dealOneZoneOrder(ctx, tx, order)
}
return
}
// 结算空订单
func (v *Vas) dealOneZoneOrder(ctx *gin.Context, tx *sqlx.Tx, order *dbstruct.Order) (err error) {
// 把订单对应的收入记录拿出来
chList, err := v.store.GetIncomeCHList(ctx, tx, order.GetID())
if err != nil {
logger.Error("GetIncomeCHList fail, orderId: %v, err: %v", order.GetID(), err)
return
}
// 处理
for _, ch := range chList {
if ch.GetMid() == common.OfficialMid {
continue
}
// 获取钱包
wallet, errIn := v.store.GetWalletForUpdate(ctx, tx, ch.GetMid())
if errIn != nil {
logger.Error("GetWalletForUpdate fail, mid: %v, err: %v", ch.GetMid(), errIn)
err = errIn
return
}
// 添加记录
h := &dbstruct.WithdrawDiamondsHis{
Mid: goproto.Int64(ch.GetMid()),
IncomeChId: goproto.Int64(ch.GetId()),
OrderId: goproto.String(ch.GetOrderId()),
Ct: goproto.Int64(time.Now().Unix()),
BeforeWithdrawDiamonds: goproto.Int64(wallet.GetWithdrawDiamonds()),
AfterWithdrawDiamonds: goproto.Int64(wallet.GetWithdrawDiamonds() + ch.GetChange()),
Change: goproto.Int64(ch.GetChange()),
ProductId: goproto.String(order.GetProductId()),
}
errIn = v.store.CreateWithdrawDiamondsHis(ctx, tx, h)
if errIn != nil {
logger.Error("CreateWithdrawDiamondsHis fail, mid: %v, err: %v", ch.GetMid(), errIn)
err = errIn
return
}
// 更新钱包
errIn = v.store.IncWithdrawDiamonds(ctx, tx, ch.GetMid(), ch.GetChange())
if errIn != nil {
logger.Error("IncWithdrawDiamonds fail, mid: %v, change: %v, err: %v", ch.GetMid(), ch.GetChange(), errIn)
err = errIn
return
}
}
// 更新订单状态
err = v.store.UpdateOrderStatus(ctx, tx, order.GetID(), dbstruct.VasOrderStatusPaySuccess, dbstruct.VasOrderStatusFinish)
if err != nil {
logger.Error("UpdateOrderStatus fail, orderId: %v, err: %v", order.GetID(), err)
return
}
return
}

View File

@ -3566,3 +3566,41 @@ func (s *Service) OpGetZoneCollaboratorList(ctx *gin.Context, req *zone_collabor
}
return
}
func (s *Service) OpZoneUnlockThirdPartners(ctx *gin.Context, req *zoneproto.OpZoneUnlockThirdPartnersParam) error {
zone, err := _DefaultZone.GetByMid(ctx, req.StreamerMid)
if err != nil {
return err
}
if zone == nil {
err = fmt.Errorf("GetByMid nil")
return err
}
for _, mid := range req.ThirdPartMids {
err = _DefaultVas.ZoneFreeJoinThirdPartner(ctx, mid, zone.GetId())
if err != nil {
return err
}
}
return nil
}
func (s *Service) OpZoneUnlockCollaborators(ctx *gin.Context, req *zoneproto.OpZoneUnlockCollaboratorsParam) error {
zone, err := _DefaultZone.GetByMid(ctx, req.StreamerMid)
if err != nil {
return err
}
if zone == nil {
err = fmt.Errorf("GetByMid nil")
return err
}
for _, mid := range req.CollaboratorMids {
err = _DefaultVas.ZoneFreeJoinCollaborator(ctx, mid, zone.GetId())
if err != nil {
return err
}
}
return nil
}