diff --git a/api/proto/daily_statement_zone_info/proto/daily_statement_zone_info_op.go b/api/proto/daily_statement_zone_info/proto/daily_statement_zone_info_op.go index 287111ad..f3af8768 100644 --- a/api/proto/daily_statement_zone_info/proto/daily_statement_zone_info_op.go +++ b/api/proto/daily_statement_zone_info/proto/daily_statement_zone_info_op.go @@ -57,9 +57,9 @@ type OpListReq struct { } type OpListData struct { - List []*dbstruct.DailyStatementZoneInfo `json:"list"` - Offset int `json:"offset"` - More int `json:"more"` + List []*OpDailyStatementZoneInfoVO `json:"list"` + Offset int `json:"offset"` + More int `json:"more"` } type OpListResp struct { diff --git a/api/proto/daily_statement_zone_info/proto/daily_statement_zone_info_vo_op.go b/api/proto/daily_statement_zone_info/proto/daily_statement_zone_info_vo_op.go new file mode 100644 index 00000000..288cdd85 --- /dev/null +++ b/api/proto/daily_statement_zone_info/proto/daily_statement_zone_info_vo_op.go @@ -0,0 +1,19 @@ +package proto + +import ( + streamerproto "service/api/proto/streamer/proto" + "service/dbstruct" +) + +type OpDailyStatementZoneInfoVO struct { + *dbstruct.DailyStatementZoneInfo + StreamerExt *streamerproto.OpListExtVO `json:"streamer_ext"` +} + +func (vo *OpDailyStatementZoneInfoVO) CopyStreamerExt(streamerExt streamerproto.StreamerExtVO) { + if streamerExt != nil { + if apiStreamerExt, ok := streamerExt.(*streamerproto.OpListExtVO); ok { + vo.StreamerExt = apiStreamerExt + } + } +} diff --git a/app/mix/controller/config_op.go b/app/mix/controller/config_op.go index 01daf725..6ca3a051 100644 --- a/app/mix/controller/config_op.go +++ b/app/mix/controller/config_op.go @@ -45,7 +45,7 @@ func OpGetSupportWxIdList(ctx *gin.Context) { func OpIsThereANewVersionAvailable(ctx *gin.Context) { req := ctx.MustGet("client_req").(*base.BaseRequest) - result, version, ec := service.DefaultConfigService.OpIsThereANewVersionAvailable(ctx, req) + result, version, ec := service.DefaultConfigService.OpIsThereANewVersionAvailableV2(ctx, req) if ec != errcode.ErrCodeOk { logger.Error("OpIsThereANewVersionAvailable fail, ec: %v", ec) ReplyErrCodeMsg(ctx, ec) diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index c5b365d1..748c41e3 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -226,7 +226,7 @@ func Init(r *gin.Engine) { // 是否有新版本 apiVersion := r.Group("/api/version", PrepareToC()) - apiVersion.POST("is_there_a_new_version_available", middleware.JSONParamValidator(base.BaseRequest{}), middleware.JwtAuthenticator(), OpIsThereANewVersionAvailable) + apiVersion.POST("is_there_a_new_version_available", middleware.JSONParamValidator(base.BaseRequest{}), OpIsThereANewVersionAvailable) // 上传媒体失败配置 apiUploadMediaFailConfig := r.Group("/api/upload_media_fail_config", PrepareToC()) diff --git a/app/mix/dao/mysql_zone.go b/app/mix/dao/mysql_zone.go index ad7b945a..46c73318 100644 --- a/app/mix/dao/mysql_zone.go +++ b/app/mix/dao/mysql_zone.go @@ -542,7 +542,7 @@ func (m *Mysql) GetLastHourZoneProfit(ctx *gin.Context, tx *sqlx.Tx, st, et int6 func (m *Mysql) GetLastHourZoneRefund(ctx *gin.Context, tx *sqlx.Tx, st, et int64) (list []*dbstruct.ZoneProfit, err error) { var sql strings.Builder - sql.WriteString(fmt.Sprintf("t1.uid as mid, t1.oid1 as zid, count(1) as num, sum(t1.pay_amount) as amount from %s t1 join %s t2 on t1.id = t2.order_id", TableOrder, TableVasZoneRefundHis)) + sql.WriteString(fmt.Sprintf("select t1.uid as mid, t1.oid1 as zid, count(1) as num, sum(t1.pay_amount) as amount from %s t1 join %s t2 on t1.id = t2.order_id", TableOrder, TableVasZoneRefundHis)) sql.WriteString(fmt.Sprintf(" where t2.ct >=%d and t2.ct<=%d and t1.ct <%d group by t1.uid, t1.oid1", st, et, st)) list = make([]*dbstruct.ZoneProfit, 0) if tx != nil { diff --git a/app/mix/service/configservice.go b/app/mix/service/configservice.go index c2f7974d..415a5a62 100644 --- a/app/mix/service/configservice.go +++ b/app/mix/service/configservice.go @@ -6,8 +6,10 @@ import ( "service/api/consts" "service/api/errcode" "service/apollostruct" + "service/bizcommon/util" "service/library/apollo" "service/library/logger" + "service/library/sutil" "strconv" "strings" @@ -149,6 +151,33 @@ func (s *ConfigService) OpIsThereANewVersionAvailable(ctx *gin.Context, baseRequ return } +func (s *ConfigService) OpIsThereANewVersionAvailableV2(ctx *gin.Context, baseRequest *base.BaseRequest) (result bool, version *apollostruct.Version, ec errcode.ErrCode) { + ec = errcode.ErrCodeOk + result = false + + var key string + if baseRequest.DevType == consts.DevType_Android { + key = consts.AndroidKey + } else if baseRequest.DevType == consts.DevType_Ios { + key = consts.IosKey + } + ver := &apollostruct.Version{} + err := apollo.GetJson(key, ver, apollo.ApolloOpts().SetNamespace("version")) + if err != nil { + logger.Error("Apollo read failed : %v", err) + ec = errcode.ErrCodeApolloReadFail + return + } + logger.Info("apollo_ver, %v", util.ToJson(ver)) + + verCmp := sutil.NewVersionCmp(baseRequest.Version) + if verCmp.Lt(ver.Version) { + result = true + version = ver + } + return +} + func (s *ConfigService) OpGetUploadMediaFailConfigList(ctx *gin.Context) (uploadMediaFailConfigMap map[string]int64, ec errcode.ErrCode) { ec = errcode.ErrCodeOk diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index 2f97fb2d..be1b7d49 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -2986,6 +2986,9 @@ func (v *Vas) refundZoneMoment(ctx *gin.Context, order *dbstruct.Order, req *vas return err } + // 减购买人数 + _ = v.store.DecZoneMomentBuyerCnt(ctx, zid, momentId) + return nil } diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 9d33d570..d5df969d 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3994,13 +3994,40 @@ func (s *Service) OpZoneUnlockCollaborators(ctx *gin.Context, req *zoneproto.OpZ } // DailyStatementZoneInfo -func (s *Service) OpGetDailyStatementZoneInfoList(ctx *gin.Context, req *daily_statement_zone_info_proto.OpListReq) (list []*dbstruct.DailyStatementZoneInfo, ec errcode.ErrCode) { +func (s *Service) OpGetDailyStatementZoneInfoList(ctx *gin.Context, req *daily_statement_zone_info_proto.OpListReq) (volist []*daily_statement_zone_info_proto.OpDailyStatementZoneInfoVO, ec errcode.ErrCode) { ec = errcode.ErrCodeDailyStatementZoneInfoSrvOk + + volist = make([]*daily_statement_zone_info_proto.OpDailyStatementZoneInfoVO, 0) + list, err := _DefaultDailyStatementZoneInfo.OpList(ctx, req) if err != nil { logger.Error("OpGetDailyStatementZoneInfoList fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeDailyStatementZoneInfoSrvFail return } + + midSet := make(map[int64]*dbstruct.Moment) + mids := make([]int64, 0) + for _, dailyStatementZoneInfo := range list { + mid := dailyStatementZoneInfo.GetMid() + if midSet[mid] == nil { + midSet[mid] = &dbstruct.Moment{} + mids = append(mids, mid) + } + volist = append(volist, &daily_statement_zone_info_proto.OpDailyStatementZoneInfoVO{ + DailyStatementZoneInfo: dailyStatementZoneInfo, + }) + } + + mp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Op) + if err != nil { + logger.Error("utilGetStreamerExtMapByMids fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeStreamerSrvFail + return + } + for _, vo := range volist { + vo.CopyStreamerExt(mp[vo.DailyStatementZoneInfo.GetMid()]) + } + return } diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 6cdfa407..c2d7e351 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -931,6 +931,10 @@ func (s *Service) utilUnThumbsZoneMoment(ctx *gin.Context, req *zonemomentproto. // 加密未解锁身份的动态 func (s *Service) utilEncryptInaccessibleZoneMoment(vo *zonemomentproto.ApiZoneMomentVO) { + if vo.GetIsCreatingPaidText() == consts.IsCreatingPaidText_Yes { + vo.Text = goproto.String(vo.GetText()[:len(vo.GetText())-len(vo.GetPaidText())]) + vo.PaidText = nil + } if vo.GetMType() == consts.MediaTypeImg { imageIds := vo.MediaComp.GetImageIds() mediaVisibleRange := vo.GetMediaVisibleRange() @@ -944,9 +948,6 @@ func (s *Service) utilEncryptInaccessibleZoneMoment(vo *zonemomentproto.ApiZoneM imageIds = imageIds[:mediaVisibleRange] vo.MediaComp.ImageIds = util.Int64Slice(imageIds) } - if vo.GetIsCreatingPaidText() == consts.IsCreatingPaidText_Yes { - vo.Text = goproto.String(vo.GetText()[:len(vo.GetText())-len(vo.GetPaidText())]) - } } // 填充动态是否解锁 @@ -1976,8 +1977,11 @@ func (s *Service) utilAssembleDailyStatementZoneInfo(zoneprofits, zonerefunds [] zidZrMp[zonerefund.GetZid()] = zonerefund dlystmt := &dbstruct.DailyStatementZoneInfo{ Zid: zonerefund.Zid, + Mid: zonerefund.Mid, RefundAmount: zonerefund.Amount, RefunderAmount: zonerefund.Num, + StartTime: goproto.Int64(st), + EndTime: goproto.Int64(et), } zidDlystmtMp[zonerefund.GetZid()] = dlystmt list = append(list, dlystmt) @@ -1989,7 +1993,10 @@ func (s *Service) utilAssembleDailyStatementZoneInfo(zoneprofits, zonerefunds [] if !ok { //没有相关信息,写入一个 dlystmt = &dbstruct.DailyStatementZoneInfo{ - Zid: zoneprofit.Zid, + Zid: zoneprofit.Zid, + Mid: zoneprofit.Mid, + StartTime: goproto.Int64(st), + EndTime: goproto.Int64(et), } zidDlystmtMp[zoneprofit.GetZid()] = dlystmt list = append(list, dlystmt) diff --git a/app/mix/service/xxljob_tasks.go b/app/mix/service/xxljob_tasks.go index 6f939e70..7f49f8d0 100644 --- a/app/mix/service/xxljob_tasks.go +++ b/app/mix/service/xxljob_tasks.go @@ -169,6 +169,9 @@ func (s *CronService) CreateDailyStatement(ctx context.Context, param *xxl.RunRe return fmt.Sprintf("_DefaultDailyStatementZoneInfo OpCreateBatch fail : %v", err) } dailyStatementZoneInfos := DefaultService.utilAssembleDailyStatementZoneInfo(zoneprofits, zonerefunds, startTimeStamp, endTimeStamp) + for _, dailyStatementZoneInfo := range dailyStatementZoneInfos { + dailyStatementZoneInfo.Fill() + } err = _DefaultDailyStatementZoneInfo.OpCreateBatch(&gin.Context{}, &daily_statement_zone_infoproto.OpCreateBatchReq{ DailyStatementZoneInfos: dailyStatementZoneInfos, }) diff --git a/dbstruct/daily_statement_zone_info.go b/dbstruct/daily_statement_zone_info.go index fabae2e8..d285accd 100644 --- a/dbstruct/daily_statement_zone_info.go +++ b/dbstruct/daily_statement_zone_info.go @@ -1,7 +1,12 @@ package dbstruct +import ( + goproto "google.golang.org/protobuf/proto" +) + type DailyStatementZoneInfo struct { Id *int64 `json:"id" bson:"_id"` // 每日报表id + Mid *int64 `json:"mid" bson:"mid"` // mid Zid *int64 `json:"zid" bson:"zid"` // 空间id EntrantNum *int64 `json:"entrant_num" bson:"entrant_num"` // 上小时新增空间进入人数(不含退款) TotalAmount *int64 `json:"total_amount" bson:"total_amount"` // 上小时总入账 @@ -17,6 +22,13 @@ type DailyStatementZoneInfo struct { DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记 } +func (p *DailyStatementZoneInfo) GetMid() int64 { + if p != nil && p.Mid != nil { + return *p.Mid + } + return 0 +} + func (p *DailyStatementZoneInfo) GetTotalAmount() int64 { if p != nil && p.TotalAmount != nil { return *p.TotalAmount @@ -30,3 +42,42 @@ func (p *DailyStatementZoneInfo) GetEntrantNum() int64 { } return 0 } + +func (p *DailyStatementZoneInfo) Fill() { + if p == nil { + return + } + if p.Mid == nil { + p.Mid = goproto.Int64(0) + } + if p.Zid == nil { + p.Zid = goproto.Int64(0) + } + if p.EntrantNum == nil { + p.EntrantNum = goproto.Int64(0) + } + if p.TotalAmount == nil { + p.TotalAmount = goproto.Int64(0) + } + if p.AdmissionAmount == nil { + p.AdmissionAmount = goproto.Int64(0) + } + if p.ZoneMomentAmount == nil { + p.ZoneMomentAmount = goproto.Int64(0) + } + if p.SuperfanshipAmount == nil { + p.SuperfanshipAmount = goproto.Int64(0) + } + if p.RefundAmount == nil { + p.RefundAmount = goproto.Int64(0) + } + if p.RefunderAmount == nil { + p.RefunderAmount = goproto.Int64(0) + } + if p.StartTime == nil { + p.StartTime = goproto.Int64(0) + } + if p.EndTime == nil { + p.EndTime = goproto.Int64(0) + } +} diff --git a/dbstruct/media.go b/dbstruct/media.go index e278a9b0..6b4f5e71 100644 --- a/dbstruct/media.go +++ b/dbstruct/media.go @@ -141,10 +141,10 @@ func NewVideoFromJson(item any) (vid *Video, err error) { err = errors.New("invalid video object with null md5") return } - if vid.Dur == 0 { - err = errors.New("invalid video object with zero dur") - return - } + //if vid.Dur == 0 { + // err = errors.New("invalid video object with zero dur") + // return + //} if vid.Fmt == "" { err = errors.New("invalid video object with null fmt") return diff --git a/library/middleware/logger.go b/library/middleware/logger.go index 76ec9a1b..347b355e 100644 --- a/library/middleware/logger.go +++ b/library/middleware/logger.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/gin-gonic/gin" "service/library/logger" + "strings" "time" ) @@ -91,7 +92,9 @@ func LoggerMiddleware(conf gin.LoggerConfig) gin.HandlerFunc { bodyStr = string(body.([]byte)) } logger.Info("%s params: %s", formatter(param), bodyStr) - //logger.Info("%s response: %s", formatter(param), blw.body.String()) + if strings.Contains(param.Path, "is_there_a_new_version_available") { + logger.Info("%s response: %s", formatter(param), blw.body.String()) + } //logger.WithCtx(c.Request.Context()).Info("%s params: %s", formatter(param), bodyStr) //if accessConf.LogResponseEnabled { diff --git a/library/sutil/sutil.go b/library/sutil/sutil.go new file mode 100644 index 00000000..d919d841 --- /dev/null +++ b/library/sutil/sutil.go @@ -0,0 +1,70 @@ +// Copyright 2014 The sutil Author. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sutil + +import ( + "fmt" + "strings" + //"crypto/sha1" +) + +type VersionCmp struct { + ver string +} + +func NewVersionCmp(ver string) *VersionCmp { + v := &VersionCmp{} + + v.ver = v.fmtver(ver) + return v +} + +func (m *VersionCmp) fmtver(ver string) string { + pvs := strings.Split(ver, ".") + + rv := "" + for _, pv := range pvs { + rv += fmt.Sprintf("%020s", pv) + } + + return rv + +} + +func (m *VersionCmp) Min() string { + return m.fmtver("0") +} + +func (m *VersionCmp) Max() string { + return m.fmtver("99999999999999999999") +} + +func (m *VersionCmp) Lt(ver string) bool { + return m.ver < m.fmtver(ver) +} + +func (m *VersionCmp) Lte(ver string) bool { + return m.ver <= m.fmtver(ver) +} + +func (m *VersionCmp) Gt(ver string) bool { + return m.ver > m.fmtver(ver) +} + +func (m *VersionCmp) Gte(ver string) bool { + return m.ver >= m.fmtver(ver) +} + +func (m *VersionCmp) Eq(ver string) bool { + return m.ver == m.fmtver(ver) +} + +func (m *VersionCmp) Ne(ver string) bool { + return m.ver != m.fmtver(ver) +} + +func (m *VersionCmp) GetFormatVersion() string { + return m.ver +}