Merge pull request 'by Robin at 20240518' (#454) from feat-IRONFANS-120-Robin into main

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/454
This commit is contained in:
chenhao 2024-05-18 00:13:38 +08:00
commit 73be110ca6
5 changed files with 108 additions and 2 deletions

View File

@ -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
}
}
}

View File

@ -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
}

View File

@ -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)

View File

@ -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,
})

View File

@ -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)
}
}