diff --git a/api/proto/vas/proto/vas.go b/api/proto/vas/proto/vas.go index 0e5e9f4f..b5596383 100644 --- a/api/proto/vas/proto/vas.go +++ b/api/proto/vas/proto/vas.go @@ -247,3 +247,17 @@ type ZoneFreeJoinResp struct { base.BaseResponse Data *ZoneFreeJoinData `json:"data"` } + +// 退出空间 +type ZoneExitReq struct { + base.BaseRequest + Zid int64 `json:"zid"` // 空间id +} + +type ZoneExitData struct { +} + +type ZoneExitResp struct { + base.BaseResponse + Data *ZoneFreeJoinData `json:"data"` +} diff --git a/app/mix/controller/zone_api.go b/app/mix/controller/zone_api.go index 42b1f76b..4c9d6501 100644 --- a/app/mix/controller/zone_api.go +++ b/app/mix/controller/zone_api.go @@ -151,7 +151,7 @@ func ApiGetZoneListByUserIdFromOutside(ctx *gin.Context) { req.Limit = consts.DefaultPageSize } - list, ec := service.DefaultService.ApiGetZoneListByUserIdFromOutside(ctx, req) + refundEnable, list, ec := service.DefaultService.ApiGetZoneListByUserIdFromOutside(ctx, req) if ec != errcode.ErrCodeZoneSrvOk { logger.Error("ApiGetZoneListByUserIdFromOutside fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) @@ -169,8 +169,9 @@ func ApiGetZoneListByUserIdFromOutside(ctx *gin.Context) { mediafiller.FillList(ctx, mediaFillableList) data := &zoneproto.ApiListByMidData{ - List: list, - Offset: req.Offset + len(list), + List: list, + Offset: req.Offset + len(list), + RefundEnable: refundEnable, } if len(list) >= req.Limit { data.More = 1 diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index dfd9db92..170e949f 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2282,7 +2282,7 @@ func (s *Service) ApiGetZoneListByVisitorMid(ctx *gin.Context, req *zoneproto.Ap return } -func (s *Service) ApiGetZoneListByUserIdFromOutside(ctx *gin.Context, req *zoneproto.ApiListByUserIdFromOutsideReq) (volist []*zoneproto.ApiZoneVO, ec errcode.ErrCode) { +func (s *Service) ApiGetZoneListByUserIdFromOutside(ctx *gin.Context, req *zoneproto.ApiListByUserIdFromOutsideReq) (refundEnable int, volist []*zoneproto.ApiZoneVO, ec errcode.ErrCode) { ec = errcode.ErrCodeZoneSrvOk volist = make([]*zoneproto.ApiZoneVO, 0) @@ -2329,6 +2329,16 @@ func (s *Service) ApiGetZoneListByUserIdFromOutside(ctx *gin.Context, req *zonep volist = append(volist, vo) } + // 是否能退款 + if len(list) < 1 { + return + } + zid := list[0].GetId() + zidZuMap, _ := _DefaultVas.GetZoneUnlockMapByMidZids(ctx, mid, []int64{zid}) + if zu, ok := zidZuMap[zid]; ok && (time.Now().Unix()-zu.GetAdmissionCt() < 3600*2) { + refundEnable = 1 + } + return } diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 2383d551..f1be2d40 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -1536,7 +1536,7 @@ func (s *Service) utilFillZonesWithApiVOInfo(ctx *gin.Context, list []*dbstruct. // 填充访客身份 vo.VisitorRole = consts.Zone_Outsider - if zidZuMap[zid] != nil { // 访客已解锁空间是否有该zid + if zidZuMap[zid].IsUnlockAdmission() { // 访客已解锁空间是否有该zid vo.VisitorRole = consts.Zone_Visitor } else if zoneZidMap[zid] != nil { // 访客创建的空间是否有该zid vo.VisitorRole = consts.Zone_Creater diff --git a/dbstruct/vas.sql b/dbstruct/vas.sql index 5c8f4e89..358046d5 100644 --- a/dbstruct/vas.sql +++ b/dbstruct/vas.sql @@ -216,13 +216,11 @@ CREATE TABLE `vas_zone_ch` -- 空间成员列表 CREATE TABLE `vas_zone_member` ( - `id` bigint AUTO_INCREMENT COMMENT 'id', - `mid` bigint NOT NULL COMMENT '用户id', - `zid` bigint NOT NULL COMMENT '空间id', - `consume` bigint DEFAULT 0 COMMENT '单笔消费', - `ct` bigint DEFAULT 0 COMMENT '解锁时间', - `order_id` varchar(128) DEFAULT NULL COMMENT '绑定的订单id', - `product_id` varchar(128) DEFAULT NULL COMMENT '商品id', + `id` bigint AUTO_INCREMENT COMMENT 'id', + `mid` bigint NOT NULL COMMENT '用户id', + `zid` bigint NOT NULL COMMENT '空间id', + `member_type` int DEFAULT 0 COMMENT '空间成员类型', + `ct` bigint DEFAULT 0 COMMENT '解锁时间', PRIMARY KEY (`id`) ); diff --git a/dbstruct/vas_mysql.go b/dbstruct/vas_mysql.go index 02b5c044..5d1ee1f8 100644 --- a/dbstruct/vas_mysql.go +++ b/dbstruct/vas_mysql.go @@ -962,12 +962,6 @@ type ZoneUnlock struct { } func (p *ZoneUnlock) IsUnlockAdmission() bool { - if p == nil { - return false - } - if p.AdmissionCt == nil { - return false - } if p.GetAdmissionUntil() == -1 || p.GetAdmissionUntil() < time.Now().Unix() { return true } @@ -975,12 +969,6 @@ func (p *ZoneUnlock) IsUnlockAdmission() bool { } func (p *ZoneUnlock) IsUnlockIronfanship() bool { - if p == nil { - return false - } - if p.IronfanshipCt == nil { - return false - } if p.GetIronfanshipUntil() == -1 || p.GetIronfanshipUntil() < time.Now().Unix() { return true } @@ -988,12 +976,6 @@ func (p *ZoneUnlock) IsUnlockIronfanship() bool { } func (p *ZoneUnlock) IsUnlockSuperfanship() bool { - if p == nil { - return false - } - if p.SuperfanshipCt == nil { - return false - } if p.GetSuperfanshipUntil() == -1 || p.GetSuperfanshipUntil() < time.Now().Unix() { return true }