by Robin at 20240515

This commit is contained in:
Leufolium 2024-05-15 09:58:45 +08:00
parent 5ffd2d6085
commit 7107bb0393
13 changed files with 309 additions and 6 deletions

View File

@ -205,6 +205,9 @@ var ErrCodeMsgMap = map[ErrCode]string{
ErrCodeZoneMomentCreateTimesSrvFail: "空间动态创建频次表服务错误", ErrCodeZoneMomentCreateTimesSrvFail: "空间动态创建频次表服务错误",
ErrCodeZoneMomentCreateTimesNotExist: "空间动态创建频次表不存在", ErrCodeZoneMomentCreateTimesNotExist: "空间动态创建频次表不存在",
ErrCodeZoneMomentCreateTimesReachedDailyUpperbound: "每天仅可发布十条空间动态", ErrCodeZoneMomentCreateTimesReachedDailyUpperbound: "每天仅可发布十条空间动态",
ErrCodeDailyStatementZoneInfoSrvFail: "空间相关每日报表服务错误",
ErrCodeDailyStatementZoneInfoNotExist: "空间相关每日报表不存在",
} }
const ( const (
@ -490,6 +493,11 @@ const (
ErrCodeZoneMomentCreateTimesNotExist ErrCode = -39002 // 动态创建频次表不存在 ErrCodeZoneMomentCreateTimesNotExist ErrCode = -39002 // 动态创建频次表不存在
ErrCodeZoneMomentCreateTimesReachedDailyUpperbound ErrCode = -39003 // 动态创建次数已达每日上限 ErrCodeZoneMomentCreateTimesReachedDailyUpperbound ErrCode = -39003 // 动态创建次数已达每日上限
// DailyStatementZoneInfo: 40xxx
ErrCodeDailyStatementZoneInfoSrvOk ErrCode = ErrCodeOk
ErrCodeDailyStatementZoneInfoSrvFail ErrCode = -40001 // 空间相关每日报表服务错误
ErrCodeDailyStatementZoneInfoNotExist ErrCode = -40002 // 空间相关每日报表不存在
// Media: 60xxx // Media: 60xxx
ErrCodeMediaSrvOk ErrCode = ErrCodeOk ErrCodeMediaSrvOk ErrCode = ErrCodeOk
ErrCodeMediaSrvFail ErrCode = -60001 // 媒体服务错误 ErrCodeMediaSrvFail ErrCode = -60001 // 媒体服务错误

View File

@ -0,0 +1,68 @@
package proto
import (
"service/api/base"
"service/dbstruct"
)
// op 创建
type OpCreateReq struct {
base.BaseRequest
*dbstruct.DailyStatementZoneInfo
}
type OpCreateData struct {
}
type OpCreateResp struct {
base.BaseResponse
Data *OpCreateData `json:"data"`
}
// op 删除
type OpDeleteReq struct {
base.BaseRequest
Id int64 `json:"id"`
}
type OpDeleteData struct {
}
type OpDeleteResp struct {
base.BaseResponse
Data *OpDeleteData `json:"data"`
}
// op 更新
type OpUpdateReq struct {
base.BaseRequest
*dbstruct.DailyStatementZoneInfo
}
type OpUpdateData struct {
}
type OpUpdateResp struct {
base.BaseResponse
Data *OpUpdateData `json:"data"`
}
// op 列表
type OpListReq struct {
base.BaseRequest
CtUpperBound *int64 `json:"ct_upper_bound"`
CtLowerBound *int64 `json:"ct_lower_bound"`
Offset int `json:"offset"`
Limit int `json:"limit"`
}
type OpListData struct {
List []*dbstruct.DailyStatementZoneInfo `json:"list"`
Offset int `json:"offset"`
More int `json:"more"`
}
type OpListResp struct {
base.BaseResponse
Data *OpListData `json:"data"`
}

View File

@ -0,0 +1,37 @@
package controller
import (
"service/api/consts"
"service/api/errcode"
daily_statement_zone_info_proto "service/api/proto/daily_statement_zone_info/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"github.com/gin-gonic/gin"
)
func OpGetDailyStatementZoneInfoList(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*daily_statement_zone_info_proto.OpListReq)
//设置默认页长
if req.Limit == 0 {
req.Limit = consts.DefaultPageSize
}
list, ec := service.DefaultService.OpGetDailyStatementZoneInfoList(ctx, req)
if ec != errcode.ErrCodeDailyStatementZoneInfoSrvOk {
logger.Error("OpGetDailyStatementZoneInfoList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &daily_statement_zone_info_proto.OpListData{
List: list,
Offset: req.Offset + len(list),
}
if len(list) >= req.Limit {
data.More = 1
}
ReplyOk(ctx, data)
}

View File

@ -29,6 +29,7 @@ import (
contact_customer_serviceproto "service/api/proto/contact_customer_service/proto" contact_customer_serviceproto "service/api/proto/contact_customer_service/proto"
contact_customer_service_sessionproto "service/api/proto/contact_customer_service_session/proto" contact_customer_service_sessionproto "service/api/proto/contact_customer_service_session/proto"
daily_statementproto "service/api/proto/daily_statement/proto" daily_statementproto "service/api/proto/daily_statement/proto"
daily_statement_zone_info_proto "service/api/proto/daily_statement_zone_info/proto"
feedbackproto "service/api/proto/feedback/proto" feedbackproto "service/api/proto/feedback/proto"
footprintproto "service/api/proto/footprint/proto" footprintproto "service/api/proto/footprint/proto"
loginproto "service/api/proto/login/proto" loginproto "service/api/proto/login/proto"
@ -513,6 +514,10 @@ func Init(r *gin.Engine) {
opZoneMomentGroup.POST("head", middleware.JSONParamValidator(zonemomentproto.OpHeadReq{}), middleware.JwtAuthenticator(), OpHeadZoneMoment) opZoneMomentGroup.POST("head", middleware.JSONParamValidator(zonemomentproto.OpHeadReq{}), middleware.JwtAuthenticator(), OpHeadZoneMoment)
opZoneMomentGroup.POST("set_private", middleware.JSONParamValidator(zonemomentproto.OpSetPrivateReq{}), middleware.JwtAuthenticator(), OpSetPrivateZoneMoment) opZoneMomentGroup.POST("set_private", middleware.JSONParamValidator(zonemomentproto.OpSetPrivateReq{}), middleware.JwtAuthenticator(), OpSetPrivateZoneMoment)
// 空间相关每日报表
opDailyStatementZoneInfoGroup := r.Group("/op/daily_statement_zone_info", PrepareOp())
opDailyStatementZoneInfoGroup.POST("list", middleware.JSONParamValidator(daily_statement_zone_info_proto.OpListReq{}), middleware.JwtAuthenticator(), OpGetDailyStatementZoneInfoList)
// 视频审核callback // 视频审核callback
extVideoModerationGroup := r.Group("/ext/video_moderation") extVideoModerationGroup := r.Group("/ext/video_moderation")
extVideoModerationGroup.POST("callback", middleware.FORMParamValidator(video_moderation_proto.ExtVideoModerationReq{}), VideoModerationCallback) extVideoModerationGroup.POST("callback", middleware.FORMParamValidator(video_moderation_proto.ExtVideoModerationReq{}), VideoModerationCallback)

View File

@ -24,6 +24,7 @@ import (
contact_customer_service_proto "service/api/proto/contact_customer_service/proto" contact_customer_service_proto "service/api/proto/contact_customer_service/proto"
contact_customer_service_sessionproto "service/api/proto/contact_customer_service_session/proto" contact_customer_service_sessionproto "service/api/proto/contact_customer_service_session/proto"
daily_statementproto "service/api/proto/daily_statement/proto" daily_statementproto "service/api/proto/daily_statement/proto"
daily_statement_zone_info_proto "service/api/proto/daily_statement_zone_info/proto"
feedbackproto "service/api/proto/feedback/proto" feedbackproto "service/api/proto/feedback/proto"
footprintproto "service/api/proto/footprint/proto" footprintproto "service/api/proto/footprint/proto"
imageaudittaskproto "service/api/proto/imageaudittask/proto" imageaudittaskproto "service/api/proto/imageaudittask/proto"
@ -162,8 +163,9 @@ const (
DBContactCustomerServiceSession = "contact_customer_service_session" DBContactCustomerServiceSession = "contact_customer_service_session"
COLContactCustomerServiceSession = "contact_customer_service_session" COLContactCustomerServiceSession = "contact_customer_service_session"
DBDailyStatement = "daily_statement" DBDailyStatement = "daily_statement"
COLDailyStatement = "daily_statement" COLDailyStatement = "daily_statement"
COLDailyStatementZoneInfo = "daily_statement_zone_info"
DBAppConfig = "app_config" DBAppConfig = "app_config"
COLAppConfig = "app_config" COLAppConfig = "app_config"
@ -524,6 +526,11 @@ func (m *Mongo) getColVideoModerationTask() *qmgo.Collection {
return m.clientMix.Database(DBVideoModeration).Collection(COLVideoModerationTask) return m.clientMix.Database(DBVideoModeration).Collection(COLVideoModerationTask)
} }
// 空间相关每日报表表
func (m *Mongo) getColDailyStatementZoneInfo() *qmgo.Collection {
return m.clientMix.Database(DBDailyStatement).Collection(COLDailyStatementZoneInfo)
}
// 商品相关 // 商品相关
func (m *Mongo) CreateProduct(ctx *gin.Context, product *dbstruct.Product) error { func (m *Mongo) CreateProduct(ctx *gin.Context, product *dbstruct.Product) error {
col := m.getColProduct() col := m.getColProduct()
@ -5071,3 +5078,67 @@ func (m *Mongo) UpdateOverdueVideoModerationTasksStatus(ctx *gin.Context, videoM
result, err := col.UpdateAll(ctx, filter, up) result, err := col.UpdateAll(ctx, filter, up)
return result, err return result, err
} }
// 空间相关每日报表相关
func (m *Mongo) CreateDailyStatementZoneInfo(ctx *gin.Context, dlyStmtZoneInfo *dbstruct.DailyStatementZoneInfo) error {
col := m.getColDailyStatementZoneInfo()
_, err := col.InsertOne(ctx, dlyStmtZoneInfo)
return err
}
func (m *Mongo) UpdateDailyStatementZoneInfo(ctx *gin.Context, dlyStmtZoneInfo *dbstruct.DailyStatementZoneInfo) error {
col := m.getColDailyStatementZoneInfo()
set := util.EntityToM(dlyStmtZoneInfo)
set["ut"] = time.Now().Unix()
up := qmgo.M{
"$set": set,
}
err := col.UpdateId(ctx, dlyStmtZoneInfo.Id, up)
return err
}
func (m *Mongo) DeleteDailyStatementZoneInfo(ctx *gin.Context, id int64) error {
col := m.getColDailyStatementZoneInfo()
update := qmgo.M{
"$set": qmgo.M{
"del_flag": 1,
},
}
err := col.UpdateId(ctx, id, update)
return err
}
func (m *Mongo) GetDailyStatementZoneInfoList(ctx *gin.Context, req *daily_statement_zone_info_proto.OpListReq) ([]*dbstruct.DailyStatementZoneInfo, error) {
list := make([]*dbstruct.DailyStatementZoneInfo, 0)
col := m.getColDailyStatementZoneInfo()
query := qmgo.M{
"del_flag": 0,
}
filterInClause := []qmgo.M{}
if req.CtLowerBound != nil {
filterInClause = append(filterInClause, qmgo.M{
"start_time": qmgo.M{
"$gte": util.DerefInt64(req.CtLowerBound),
},
})
}
if req.CtUpperBound != nil {
filterInClause = append(filterInClause, qmgo.M{
"end_time": qmgo.M{
"$lte": util.DerefInt64(req.CtUpperBound),
},
})
}
if len(filterInClause) > 0 {
query["$and"] = filterInClause
}
err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
if err == qmgo.ErrNoSuchDocuments {
err = nil
return list, err
}
return list, err
}

View File

@ -499,3 +499,8 @@ func (m *Mysql) GetZoneRefundHisList(ctx *gin.Context, tx *sqlx.Tx, mid, zid int
} }
return return
} }
// 获取时段内空间进入人数、总入账金额、各业务分入账金额、退款金额、退款人数
func (m *MySql) GetDailyStatementZoneInfoFromVasOrder(ctx *gin.Context, tx *sqlx.Tx, st, et int64, offset, limit int) {
}

View File

@ -0,0 +1,65 @@
package logic
import (
"service/api/consts"
daily_statement_zone_infoproto "service/api/proto/daily_statement_zone_info/proto"
"service/app/mix/dao"
"service/dbstruct"
"service/library/idgenerator"
"service/library/logger"
"time"
"github.com/gin-gonic/gin"
goproto "google.golang.org/protobuf/proto"
)
type DailyStatementZoneInfo struct {
store *dao.Store
}
func NewDailyStatementZoneInfo(store *dao.Store) (a *DailyStatementZoneInfo) {
a = &DailyStatementZoneInfo{
store: store,
}
return
}
func (p *DailyStatementZoneInfo) OpCreate(ctx *gin.Context, req *daily_statement_zone_infoproto.OpCreateReq) error {
req.DailyStatementZoneInfo.Id = goproto.Int64(idgenerator.GenDailyStatementZoneInfoId())
req.DailyStatementZoneInfo.Ct = goproto.Int64(time.Now().Unix())
req.DailyStatementZoneInfo.Ut = goproto.Int64(time.Now().Unix())
req.DailyStatementZoneInfo.DelFlag = goproto.Int64(consts.Exist)
err := p.store.CreateDailyStatementZoneInfo(ctx, req.DailyStatementZoneInfo)
if err != nil {
logger.Error("CreateDailyStatementZoneInfo fail, err: %v", err)
return err
}
return nil
}
func (p *DailyStatementZoneInfo) OpUpdate(ctx *gin.Context, req *daily_statement_zone_infoproto.OpUpdateReq) error {
err := p.store.UpdateDailyStatementZoneInfo(ctx, req.DailyStatementZoneInfo)
if err != nil {
logger.Error("UpdateDailyStatementZoneInfo fail, err: %v", err)
return err
}
return nil
}
func (p *DailyStatementZoneInfo) OpDelete(ctx *gin.Context, id int64) error {
err := p.store.DeleteDailyStatementZoneInfo(ctx, id)
if err != nil {
logger.Error("DeleteDailyStatementZoneInfo fail, err: %v", err)
return err
}
return nil
}
func (p *DailyStatementZoneInfo) OpList(ctx *gin.Context, req *daily_statement_zone_infoproto.OpListReq) ([]*dbstruct.DailyStatementZoneInfo, error) {
list, err := p.store.GetDailyStatementZoneInfoList(ctx, req)
if err != nil {
logger.Error("GetDailyStatementZoneInfoList fail, err: %v", err)
return make([]*dbstruct.DailyStatementZoneInfo, 0), err
}
return list, nil
}

View File

@ -18,6 +18,7 @@ import (
contact_customer_service_proto "service/api/proto/contact_customer_service/proto" contact_customer_service_proto "service/api/proto/contact_customer_service/proto"
contact_customer_service_sessionproto "service/api/proto/contact_customer_service_session/proto" contact_customer_service_sessionproto "service/api/proto/contact_customer_service_session/proto"
daily_statementproto "service/api/proto/daily_statement/proto" daily_statementproto "service/api/proto/daily_statement/proto"
daily_statement_zone_info_proto "service/api/proto/daily_statement_zone_info/proto"
feedbackproto "service/api/proto/feedback/proto" feedbackproto "service/api/proto/feedback/proto"
footprintproto "service/api/proto/footprint/proto" footprintproto "service/api/proto/footprint/proto"
imageaudittaskproto "service/api/proto/imageaudittask/proto" imageaudittaskproto "service/api/proto/imageaudittask/proto"
@ -123,6 +124,7 @@ var (
_DefaultZoneMomentCreateTimes *logic.ZoneMomentCreateTimes _DefaultZoneMomentCreateTimes *logic.ZoneMomentCreateTimes
_DefaultVideoModeration *logic.VideoModeration _DefaultVideoModeration *logic.VideoModeration
_DefaultVideoModerationTask *logic.VideoModerationTask _DefaultVideoModerationTask *logic.VideoModerationTask
_DefaultDailyStatementZoneInfo *logic.DailyStatementZoneInfo
) )
type Service struct { type Service struct {
@ -211,6 +213,7 @@ func (s *Service) Init(c any) (err error) {
_DefaultZoneMomentCreateTimes = logic.NewZoneMomentCreateTimes(store) _DefaultZoneMomentCreateTimes = logic.NewZoneMomentCreateTimes(store)
_DefaultVideoModeration = logic.NewVideoModeration(store) _DefaultVideoModeration = logic.NewVideoModeration(store)
_DefaultVideoModerationTask = logic.NewVideoModerationTask(store) _DefaultVideoModerationTask = logic.NewVideoModerationTask(store)
_DefaultDailyStatementZoneInfo = logic.NewDailyStatementZoneInfo(store)
_DefaultVas = logic.NewVas(store, _DefaultStreamer, _DefaultAccount, _DefaultZone, _DefaultZoneThirdPartner, _DefaultZoneCollaborator) _DefaultVas = logic.NewVas(store, _DefaultStreamer, _DefaultAccount, _DefaultZone, _DefaultZoneThirdPartner, _DefaultZoneCollaborator)
return return
@ -3876,3 +3879,15 @@ func (s *Service) OpZoneUnlockCollaborators(ctx *gin.Context, req *zoneproto.OpZ
} }
return nil return nil
} }
// DailyStatementZoneInfo
func (s *Service) OpGetDailyStatementZoneInfoList(ctx *gin.Context, req *daily_statement_zone_info_proto.OpListReq) (list []*dbstruct.DailyStatementZoneInfo, ec errcode.ErrCode) {
ec = errcode.ErrCodeDailyStatementZoneInfoSrvOk
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
}
return
}

View File

@ -131,6 +131,7 @@ func (s *CronService) CreateDailyStatement(ctx context.Context, param *xxl.RunRe
return fmt.Sprintf("_DefaultAccount OpCountLastHourNewUserSource fail : %v", err) return fmt.Sprintf("_DefaultAccount OpCountLastHourNewUserSource fail : %v", err)
} }
//获取订单完成量
finishedOrderCount := int32(0) finishedOrderCount := int32(0)
allOrderCount := int32(0) allOrderCount := int32(0)
for _, orderCount := range orderCounts { for _, orderCount := range orderCounts {
@ -140,6 +141,8 @@ func (s *CronService) CreateDailyStatement(ctx context.Context, param *xxl.RunRe
allOrderCount += util.DerefInt32(orderCount.Count) allOrderCount += util.DerefInt32(orderCount.Count)
} }
//获取空间相关信息
dailyStatement := &dbstruct.DailyStatement{ dailyStatement := &dbstruct.DailyStatement{
H5CallCount: goproto.Int64(int64(count)), H5CallCount: goproto.Int64(int64(count)),
RegisteredUserCount: goproto.Int64(accountCount), RegisteredUserCount: goproto.Int64(accountCount),

View File

@ -9,10 +9,10 @@ import (
func main() { func main() {
genSource := &generator.GenSource{ genSource := &generator.GenSource{
EntityName: "ZoneCollaborator", EntityName: "DailyStatementZoneInfo",
ModuleName: "zone_collaborator", ModuleName: "daily_statement_zone_info",
EntityCNName: "空间协作者表", EntityCNName: "空间相关每日报表",
ErrCodeSeq: "38", ErrCodeSeq: "40",
} }
generator.CreateFileDirectory(genSource) generator.CreateFileDirectory(genSource)

View File

@ -0,0 +1,19 @@
package dbstruct
type DailyStatementZoneInfo struct {
Id *int64 `json:"id" bson:"_id"` // 每日报表id
Zid *int64 `json:"zid" bson:"zid"` // 空间id
EntrantNum *int64 `json:"entrant_num" bson:"entrant_num"` // 上小时新增空间进入人数(不含退款)
TotalAmount *int64 `json:"total_amount" bson:"total_amount"` // 上小时总入账
AdmissionAmount *int64 `json:"admission_amount" bson:"admission_amount"` // 成员入账
ZoneMomentAmount *int64 `json:"zone_moment_amount" bson:"zone_moment_amount"` // 帖子入账
SuperfanshipAmount *int64 `json:"superfanship_amount" bson:"superfanship_amount"` // 超粉入账
RefundAmount *int64 `json:"refund_amount" bson:"refund_amount"` // 退款金额
RefunderAmount *int64 `json:"refunder_amount" bson:"refunder_amount"` // 退款人数
StartTime *int64 `json:"start_time" bson:"start_time"` // 起始时间
EndTime *int64 `json:"end_time" bson:"end_time"` // 结束时间
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记
}

View File

@ -52,6 +52,7 @@ const (
NodeZoneMomentThumbsUp // node 私密圈动态点赞 NodeZoneMomentThumbsUp // node 私密圈动态点赞
NodeZoneSession // node 空间对话表 NodeZoneSession // node 空间对话表
NodeZoneThirdPartner // node 空间代运营表 NodeZoneThirdPartner // node 空间代运营表
NodeDailyStatementZoneInfo // node 空间相关每日报表
) )
func GenIdInt64(node int64) (int64, error) { func GenIdInt64(node int64) (int64, error) {
@ -245,3 +246,9 @@ func GenZoneThirdPartnerId() int64 {
id, _ := GenIdInt64(NodeZoneThirdPartner) id, _ := GenIdInt64(NodeZoneThirdPartner)
return id return id
} }
// daily_statement_zone_info
func GenDailyStatementZoneInfoId() int64 {
id, _ := GenIdInt64(NodeDailyStatementZoneInfo)
return id
}