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/service/service.go b/app/mix/service/service.go index 80cac263..433f0157 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3937,13 +3937,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 0c458c1b..c2d7e351 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -1977,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) @@ -1990,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 f5d5c017..2dc30724 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) + } +}