删除数据上报逻辑
移除 pub/dataReport、reportser、srv_report、上报定时任务及 eventmod 事件表, 以及注册/登录/点赞/收藏/评论/解锁/订单/上下架等处的上报调用和 reportSdkConfig 配置下发。 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,13 +21,12 @@ import (
|
|||||||
func Info(ctx *gin.Context) {
|
func Info(ctx *gin.Context) {
|
||||||
configInfo := configser.GetConfigInfo()
|
configInfo := configser.GetConfigInfo()
|
||||||
resp := &proto.ConfigInfoResp{
|
resp := &proto.ConfigInfoResp{
|
||||||
NewAddressInfo: configser.GetNewAddress(),
|
NewAddressInfo: configser.GetNewAddress(),
|
||||||
Config: configInfo,
|
Config: configInfo,
|
||||||
Advitise: configser.GetAdvitise(),
|
Advitise: configser.GetAdvitise(),
|
||||||
SeoInfo: configser.GetSiteSeoInfo(),
|
SeoInfo: configser.GetSiteSeoInfo(),
|
||||||
SeoNavInfo: configser.GetNavSeoInfo(),
|
SeoNavInfo: configser.GetNavSeoInfo(),
|
||||||
NavPageList: configser.GetNavPageList(),
|
NavPageList: configser.GetNavPageList(),
|
||||||
ReportSDKConfig: configInfo.ReportSDKConfig,
|
|
||||||
}
|
}
|
||||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ type ConfigInfo struct {
|
|||||||
DHDescription string `json:"dhDescription" bson:"dhDescription"` // 导航SEO描述
|
DHDescription string `json:"dhDescription" bson:"dhDescription"` // 导航SEO描述
|
||||||
DHSiteName string `json:"dhSiteName" bson:"dhSiteName"` // 导航SEO网站名称
|
DHSiteName string `json:"dhSiteName" bson:"dhSiteName"` // 导航SEO网站名称
|
||||||
ActressBackGround string `json:"actressBackGround" bson:"actressBackGround"` // 女优通用背景图
|
ActressBackGround string `json:"actressBackGround" bson:"actressBackGround"` // 女优通用背景图
|
||||||
ReportSDKConfig string `json:"reportSdkConfig"` // 数据上报SDK域名配置
|
|
||||||
WatermarkImage string `json:"watermarkImage"` // 图片水印文件
|
WatermarkImage string `json:"watermarkImage"` // 图片水印文件
|
||||||
CustomerServiceHost string `json:"customerServiceHost"` // 在线客服
|
CustomerServiceHost string `json:"customerServiceHost"` // 在线客服
|
||||||
ChannelCode string `json:"channelCode"` // 渠道码
|
ChannelCode string `json:"channelCode"` // 渠道码
|
||||||
@@ -66,8 +65,6 @@ type ConfigInfoResp struct {
|
|||||||
SeoNavInfo SeoNavInfo `json:"seoNavInfo"`
|
SeoNavInfo SeoNavInfo `json:"seoNavInfo"`
|
||||||
// 导航页线路集合
|
// 导航页线路集合
|
||||||
NavPageList []NavPageItem `json:"navPageList"`
|
NavPageList []NavPageItem `json:"navPageList"`
|
||||||
// 数据上报SDK域名配置
|
|
||||||
ReportSDKConfig string `json:"reportSdkConfig"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SeoNavInfo 导航SEO信息
|
// SeoNavInfo 导航SEO信息
|
||||||
|
|||||||
@@ -107,9 +107,6 @@ type GlobalCfgEx struct {
|
|||||||
AppCode string `yaml:"appCode"` // 应用 code
|
AppCode string `yaml:"appCode"` // 应用 code
|
||||||
AesKey string `yaml:"aesKey"` // 数据解密KEY
|
AesKey string `yaml:"aesKey"` // 数据解密KEY
|
||||||
} `yaml:"adCenter"`
|
} `yaml:"adCenter"`
|
||||||
DataReport struct {
|
|
||||||
Url string `yaml:"url"`
|
|
||||||
} `yaml:"dataReport"`
|
|
||||||
LsjMediaConf struct {
|
LsjMediaConf struct {
|
||||||
AppId string `yaml:"appId"`
|
AppId string `yaml:"appId"`
|
||||||
ApiKey string `yaml:"apiKey"`
|
ApiKey string `yaml:"apiKey"`
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ adCenter:
|
|||||||
merchantCode: "1991129808640122880"
|
merchantCode: "1991129808640122880"
|
||||||
appCode: "JHA-1009"
|
appCode: "JHA-1009"
|
||||||
aesKey: "gD4+rmbX5TS5cLbb3wAN5uEAYp/1j4hkQrS9SzuSjc8"
|
aesKey: "gD4+rmbX5TS5cLbb3wAN5uEAYp/1j4hkQrS9SzuSjc8"
|
||||||
dataReport:
|
|
||||||
url: "https://api.shuifeng.cc"
|
|
||||||
lsjMediaConf:
|
lsjMediaConf:
|
||||||
appId: "430696"
|
appId: "430696"
|
||||||
apiKey: "ed48e96ce490bc94bd5eb5133dd542d0"
|
apiKey: "ed48e96ce490bc94bd5eb5133dd542d0"
|
||||||
|
|||||||
@@ -3353,10 +3353,6 @@ const docTemplate = `{
|
|||||||
"description": "qq群",
|
"description": "qq群",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"reportSdkConfig": {
|
|
||||||
"description": "数据上报SDK域名配置",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"telegram": {
|
"telegram": {
|
||||||
"description": "商务tg",
|
"description": "商务tg",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@@ -3455,10 +3451,6 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"reportSdkConfig": {
|
|
||||||
"description": "数据上报SDK域名配置",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"seoInfo": {
|
"seoInfo": {
|
||||||
"description": "全站SEO信息",
|
"description": "全站SEO信息",
|
||||||
"allOf": [
|
"allOf": [
|
||||||
|
|||||||
@@ -3351,10 +3351,6 @@
|
|||||||
"description": "qq群",
|
"description": "qq群",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"reportSdkConfig": {
|
|
||||||
"description": "数据上报SDK域名配置",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"telegram": {
|
"telegram": {
|
||||||
"description": "商务tg",
|
"description": "商务tg",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@@ -3453,10 +3449,6 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"reportSdkConfig": {
|
|
||||||
"description": "数据上报SDK域名配置",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"seoInfo": {
|
"seoInfo": {
|
||||||
"description": "全站SEO信息",
|
"description": "全站SEO信息",
|
||||||
"allOf": [
|
"allOf": [
|
||||||
|
|||||||
@@ -753,9 +753,6 @@ definitions:
|
|||||||
qq:
|
qq:
|
||||||
description: qq群
|
description: qq群
|
||||||
type: string
|
type: string
|
||||||
reportSdkConfig:
|
|
||||||
description: 数据上报SDK域名配置
|
|
||||||
type: string
|
|
||||||
telegram:
|
telegram:
|
||||||
description: 商务tg
|
description: 商务tg
|
||||||
type: string
|
type: string
|
||||||
@@ -822,9 +819,6 @@ definitions:
|
|||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/proto.NewAddressInfo'
|
- $ref: '#/definitions/proto.NewAddressInfo'
|
||||||
description: 最新地址信息
|
description: 最新地址信息
|
||||||
reportSdkConfig:
|
|
||||||
description: 数据上报SDK域名配置
|
|
||||||
type: string
|
|
||||||
seoInfo:
|
seoInfo:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/proto.SeoInfo'
|
- $ref: '#/definitions/proto.SeoInfo'
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/srvversion"
|
"videoweb/pub/common/srvversion"
|
||||||
"videoweb/pub/common/tgbot"
|
"videoweb/pub/common/tgbot"
|
||||||
"videoweb/pub/dataReport"
|
|
||||||
"videoweb/pub/esmanager"
|
"videoweb/pub/esmanager"
|
||||||
"videoweb/pub/models"
|
"videoweb/pub/models"
|
||||||
"videoweb/pub/mongos"
|
"videoweb/pub/mongos"
|
||||||
@@ -72,10 +71,6 @@ func Run(args []string) {
|
|||||||
}
|
}
|
||||||
initData()
|
initData()
|
||||||
ipstatsync.StartSync()
|
ipstatsync.StartSync()
|
||||||
dataReport.Init(dataReport.Config{
|
|
||||||
ApiUrl: appg.Conf.DataReport.Url,
|
|
||||||
RunMod: appg.Conf.RunMod,
|
|
||||||
})
|
|
||||||
|
|
||||||
initHttpServer()
|
initHttpServer()
|
||||||
//tgbot.SendToProgram("启动", "app启动完毕")
|
//tgbot.SendToProgram("启动", "app启动完毕")
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"videoweb/app/appg"
|
"videoweb/app/appg"
|
||||||
"videoweb/app/service/reportser"
|
|
||||||
"videoweb/pub/common/enum/consts"
|
"videoweb/pub/common/enum/consts"
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/srvdef"
|
"videoweb/pub/common/srvdef"
|
||||||
@@ -210,8 +209,6 @@ func Register(ctx context.Context, guestUserId int64, accountNo, email, password
|
|||||||
if serr != nil {
|
if serr != nil {
|
||||||
return nil, serr
|
return nil, serr
|
||||||
}
|
}
|
||||||
reportser.ReportUserRegister(guest, ua, ip, "username")
|
|
||||||
reportser.ReportUserLogin(guest, ua, ip, pubdef.LoginTypeAccount)
|
|
||||||
return toLoginResp(ctx, guest, token, true), nil
|
return toLoginResp(ctx, guest, token, true), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,8 +265,6 @@ func Register(ctx context.Context, guestUserId int64, accountNo, email, password
|
|||||||
if serr != nil {
|
if serr != nil {
|
||||||
return nil, serr
|
return nil, serr
|
||||||
}
|
}
|
||||||
reportser.ReportUserRegister(user, ua, ip, "username")
|
|
||||||
reportser.ReportUserLogin(user, ua, ip, pubdef.LoginTypeAccount)
|
|
||||||
return toLoginResp(ctx, user, token, false), nil
|
return toLoginResp(ctx, user, token, false), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +327,6 @@ func Login(ctx context.Context, account, password string, ua useragent.UA, ip, c
|
|||||||
bson.M{usermod.FN.User.Id: user.Id},
|
bson.M{usermod.FN.User.Id: user.Id},
|
||||||
bson.M{"$set": setDoc},
|
bson.M{"$set": setDoc},
|
||||||
)
|
)
|
||||||
reportser.ReportUserLogin(user, ua, ip, pubdef.LoginTypeAccount)
|
|
||||||
return toLoginResp(ctx, user, token, true), nil
|
return toLoginResp(ctx, user, token, true), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"videoweb/app/middleware/reptilerecord"
|
"videoweb/app/middleware/reptilerecord"
|
||||||
"videoweb/app/middleware/visit"
|
"videoweb/app/middleware/visit"
|
||||||
"videoweb/app/service/configser"
|
"videoweb/app/service/configser"
|
||||||
"videoweb/app/service/reportser"
|
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/netutil"
|
"videoweb/pub/common/netutil"
|
||||||
"videoweb/pub/common/srvdef"
|
"videoweb/pub/common/srvdef"
|
||||||
@@ -138,9 +137,7 @@ func GuestLogin(ctx context.Context, userId int64, ip string, req *GuestLoginReq
|
|||||||
resp.IsNewUser = isNewUser
|
resp.IsNewUser = isNewUser
|
||||||
if isNewUser {
|
if isNewUser {
|
||||||
visit.RecordDailyVisit(ctx, user.Id, ua, ip)
|
visit.RecordDailyVisit(ctx, user.Id, ua, ip)
|
||||||
reportser.ReportUserRegister(user, ua, ip, "deviceid")
|
|
||||||
}
|
}
|
||||||
reportser.ReportUserLogin(user, ua, ip, pubdef.LoginTypeDevice)
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
"videoweb/app/api/proto"
|
"videoweb/app/api/proto"
|
||||||
"videoweb/app/service/configser"
|
"videoweb/app/service/configser"
|
||||||
"videoweb/app/service/reportser"
|
|
||||||
"videoweb/pub/common/enum/redisconst"
|
"videoweb/pub/common/enum/redisconst"
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/netutil"
|
"videoweb/pub/common/netutil"
|
||||||
@@ -123,11 +122,6 @@ func SendComment(ctx context.Context, userId int64, ip string, req *proto.Commen
|
|||||||
log.Error("评论发布后更新短剧热度失败", log.Any("短剧ID", playletId), log.Any("评论信息", info), log.E(err))
|
log.Error("评论发布后更新短剧热度失败", log.Any("短剧ID", playletId), log.Any("评论信息", info), log.E(err))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
chapterId := int64(0)
|
|
||||||
if req.ObjectType == ObjectTypePlayletChapter {
|
|
||||||
chapterId = req.ObjectId
|
|
||||||
}
|
|
||||||
reportser.ReportPlayletComment(ctx, user, playletId, chapterId, text)
|
|
||||||
// app端发布评论先进入待审核状态,不立即增加短剧/剧集评论数;后台审核通过时再统一同步 countComment。
|
// app端发布评论先进入待审核状态,不立即增加短剧/剧集评论数;后台审核通过时再统一同步 countComment。
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import (
|
|||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/netutil"
|
"videoweb/pub/common/netutil"
|
||||||
"videoweb/pub/common/srvdef"
|
"videoweb/pub/common/srvdef"
|
||||||
"videoweb/pub/dataReport"
|
|
||||||
"videoweb/pub/models/announcementmod"
|
"videoweb/pub/models/announcementmod"
|
||||||
"videoweb/pub/models/cfg"
|
"videoweb/pub/models/cfg"
|
||||||
"videoweb/pub/models/ipblackmod"
|
"videoweb/pub/models/ipblackmod"
|
||||||
@@ -61,7 +60,6 @@ func init() {
|
|||||||
|
|
||||||
func Start() {
|
func Start() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
dataReport.StartSDKConfigCron()
|
|
||||||
UpdateConfigInfo(ctx)
|
UpdateConfigInfo(ctx)
|
||||||
UpdateAdvitiseDataFromJt()
|
UpdateAdvitiseDataFromJt()
|
||||||
updateIpBlack()
|
updateIpBlack()
|
||||||
@@ -154,7 +152,6 @@ func UpdateConfigInfo(ctx context.Context) {
|
|||||||
config.DHSiteName = sysCfg.DHSiteName
|
config.DHSiteName = sysCfg.DHSiteName
|
||||||
config.DHTitle = sysCfg.DHTitle
|
config.DHTitle = sysCfg.DHTitle
|
||||||
config.ActressBackGround = netutil.MergeURL(sysCfg.ImgAppCdn, sysCfg.ActressBackGround)
|
config.ActressBackGround = netutil.MergeURL(sysCfg.ImgAppCdn, sysCfg.ActressBackGround)
|
||||||
config.ReportSDKConfig = dataReport.GetSDKDomainConfig()
|
|
||||||
config.WatermarkImage = sysCfg.WatermarkImage
|
config.WatermarkImage = sysCfg.WatermarkImage
|
||||||
config.CustomerServiceHost = sysCfg.CustomerServiceHost
|
config.CustomerServiceHost = sysCfg.CustomerServiceHost
|
||||||
config.ChannelCode = sysCfg.ChannelCode
|
config.ChannelCode = sysCfg.ChannelCode
|
||||||
@@ -561,7 +558,6 @@ func GetVideoTagCategoryDataList() []proto.VideoTagCategoryData {
|
|||||||
return rsl
|
return rsl
|
||||||
}
|
}
|
||||||
func Stop() {
|
func Stop() {
|
||||||
dataReport.StopSDKConfigCron()
|
|
||||||
skdCron.Stop()
|
skdCron.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import (
|
|||||||
"videoweb/app/api/proto"
|
"videoweb/app/api/proto"
|
||||||
"videoweb/app/service/configser"
|
"videoweb/app/service/configser"
|
||||||
"videoweb/app/service/playletcache"
|
"videoweb/app/service/playletcache"
|
||||||
"videoweb/app/service/reportser"
|
|
||||||
"videoweb/app/service/videoser"
|
"videoweb/app/service/videoser"
|
||||||
"videoweb/pub/common/enum/redisconst"
|
"videoweb/pub/common/enum/redisconst"
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
@@ -654,9 +653,6 @@ func SetLike(ctx context.Context, userId int64, req *proto.PlayletLikeSetReq) (*
|
|||||||
IsLike: operateStatusByFlag(*req.IsLike),
|
IsLike: operateStatusByFlag(*req.IsLike),
|
||||||
CountLike: countLike,
|
CountLike: countLike,
|
||||||
}
|
}
|
||||||
if changed {
|
|
||||||
reportser.ReportPlayletLike(ctx, userId, req.Id, resp.IsLike)
|
|
||||||
}
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -676,9 +672,6 @@ func SetCollect(ctx context.Context, userId int64, req *proto.PlayletCollectSetR
|
|||||||
IsCollect: operateStatusByFlag(*req.IsCollect),
|
IsCollect: operateStatusByFlag(*req.IsCollect),
|
||||||
CountCollect: countCollect,
|
CountCollect: countCollect,
|
||||||
}
|
}
|
||||||
if changed {
|
|
||||||
reportser.ReportPlayletCollect(ctx, userId, req.Id, resp.IsCollect)
|
|
||||||
}
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,9 +721,6 @@ func SetChapterLike(ctx context.Context, userId int64, req *proto.PlayletChapter
|
|||||||
IsLike: operateStatusByFlag(*req.IsLike),
|
IsLike: operateStatusByFlag(*req.IsLike),
|
||||||
CountLike: countLike,
|
CountLike: countLike,
|
||||||
}
|
}
|
||||||
if changed {
|
|
||||||
reportser.ReportPlayletChapterLike(ctx, userId, chapter.PlayletId, req.ChapterId, resp.IsLike)
|
|
||||||
}
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,9 +740,6 @@ func SetChapterCollect(ctx context.Context, userId int64, req *proto.PlayletChap
|
|||||||
IsCollect: operateStatusByFlag(*req.IsCollect),
|
IsCollect: operateStatusByFlag(*req.IsCollect),
|
||||||
CountCollect: countCollect,
|
CountCollect: countCollect,
|
||||||
}
|
}
|
||||||
if changed {
|
|
||||||
reportser.ReportPlayletChapterCollect(ctx, userId, chapter.PlayletId, req.ChapterId, resp.IsCollect)
|
|
||||||
}
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1014,7 +1001,6 @@ func UnlockChapter(ctx context.Context, userId int64, req *proto.PlayletChapterU
|
|||||||
return nil, srvdef.New(srvdef.DBTransaction, "解锁失败,请稍后重试", "解锁失败,请稍后重试")
|
return nil, srvdef.New(srvdef.DBTransaction, "解锁失败,请稍后重试", "解锁失败,请稍后重试")
|
||||||
}
|
}
|
||||||
updatePlayletChapterUnlockStatsAsync(chapter.PlayletId, chapter.Id)
|
updatePlayletChapterUnlockStatsAsync(chapter.PlayletId, chapter.Id)
|
||||||
reportser.ReportPlayletUnlock(ctx, user, playlet, chapter, chapter.SingleCoins, user.Recharge, balanceAfter, orderNo)
|
|
||||||
return playletChapterUnlockResp(chapter, balanceAfter, -chapter.SingleCoins), nil
|
return playletChapterUnlockResp(chapter, balanceAfter, -chapter.SingleCoins), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,19 +2,11 @@ package rechargeser
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/md5"
|
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"videoweb/app/service/rechargeser/jiahua"
|
"videoweb/app/service/rechargeser/jiahua"
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/srvdef"
|
"videoweb/pub/common/srvdef"
|
||||||
"videoweb/pub/common/useragent"
|
|
||||||
"videoweb/pub/dataReport"
|
|
||||||
"videoweb/pub/models/eventmod"
|
|
||||||
"videoweb/pub/models/rechargepackagemod"
|
"videoweb/pub/models/rechargepackagemod"
|
||||||
"videoweb/pub/models/usermod"
|
"videoweb/pub/models/usermod"
|
||||||
"videoweb/pub/models/vipordermod"
|
"videoweb/pub/models/vipordermod"
|
||||||
@@ -104,8 +96,6 @@ func CreateOrder(ctx context.Context,
|
|||||||
return nil, serr
|
return nil, serr
|
||||||
}
|
}
|
||||||
|
|
||||||
go reportOrderCreated(ctx, order, pkg, userId, ip)
|
|
||||||
|
|
||||||
return &SubmitOrderResp{
|
return &SubmitOrderResp{
|
||||||
TradeNo: tradeNo,
|
TradeNo: tradeNo,
|
||||||
PayUrl: payInfo.PayUrl,
|
PayUrl: payInfo.PayUrl,
|
||||||
@@ -138,45 +128,3 @@ func GetOrderHistory(ctx context.Context, userId int64, page, pageSize int64) (v
|
|||||||
func GetUserInfo(ctx context.Context, userId int64) (*usermod.User, *srvdef.SrvErr) {
|
func GetUserInfo(ctx context.Context, userId int64) (*usermod.User, *srvdef.SrvErr) {
|
||||||
return usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: userId})
|
return usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: userId})
|
||||||
}
|
}
|
||||||
|
|
||||||
func reportOrderCreated(ctx context.Context, order *vipordermod.VipOrder, pkg *rechargepackagemod.RechargePackage, userId int64, ip string) {
|
|
||||||
user, _ := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: userId})
|
|
||||||
districtCode := ""
|
|
||||||
if user != nil {
|
|
||||||
districtCode = user.DistrictCode
|
|
||||||
}
|
|
||||||
|
|
||||||
ua := useragent.UA{SysType: order.SysType}
|
|
||||||
eventId := newEventId(pubdef.TrackerAppId(), user.Id, order.TradeNo, order.CreatedAt.Unix())
|
|
||||||
commonField := dataReport.NewCommonField(eventId, dataReport.EventTypeOrderCreated, districtCode, ua, strconv.FormatInt(user.Id, 10), ip)
|
|
||||||
|
|
||||||
commonField.Payload = dataReport.JsonRawMessage(&dataReport.OrderCreatedEvent{
|
|
||||||
OrderID: order.TradeNo,
|
|
||||||
OrderType: "vip_subscription",
|
|
||||||
ProductID: strconv.FormatInt(pkg.Id, 10),
|
|
||||||
ProductName: pkg.Name,
|
|
||||||
Amount: dataReport.JsonNumber(order.Amount),
|
|
||||||
Currency: "CNY",
|
|
||||||
CreateTime: dataReport.JsonNumber(order.CreatedAt.Unix()),
|
|
||||||
})
|
|
||||||
|
|
||||||
eventData, _ := json.Marshal(commonField)
|
|
||||||
if err := eventmod.InsertOneEvent(ctx, &eventmod.Event{
|
|
||||||
EventId: commonField.EventID,
|
|
||||||
EventType: commonField.Event,
|
|
||||||
Data: string(eventData),
|
|
||||||
Status: eventmod.Default,
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
}); err != nil {
|
|
||||||
log.Error("reportOrderCreated InsertOneEvent failed",
|
|
||||||
log.Any("tradeNo", order.TradeNo), log.E(err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newEventId(appId string, uid int64, orderId interface{}, createTime int64) string {
|
|
||||||
input := fmt.Sprintf("%v%v%v%v", appId, uid, orderId, createTime)
|
|
||||||
h := md5.New()
|
|
||||||
h.Write([]byte(input))
|
|
||||||
return hex.EncodeToString(h.Sum(nil))
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,386 +0,0 @@
|
|||||||
package reportser
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"crypto/md5"
|
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
"videoweb/pub/common"
|
|
||||||
"videoweb/pub/common/enum/consts"
|
|
||||||
"videoweb/pub/common/ipaddr"
|
|
||||||
"videoweb/pub/common/log"
|
|
||||||
"videoweb/pub/common/useragent"
|
|
||||||
"videoweb/pub/dataReport"
|
|
||||||
"videoweb/pub/models/eventmod"
|
|
||||||
"videoweb/pub/models/playletcategorymod"
|
|
||||||
"videoweb/pub/models/playletchaptermod"
|
|
||||||
"videoweb/pub/models/playletmod"
|
|
||||||
"videoweb/pub/models/usermod"
|
|
||||||
"videoweb/pub/pubdef"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
|
||||||
)
|
|
||||||
|
|
||||||
const videoContentTypePlaylet = "short_video"
|
|
||||||
|
|
||||||
// ReportUserRegister 用户注册事件
|
|
||||||
func ReportUserRegister(user *usermod.User, ua useragent.UA, ip, registerType string) {
|
|
||||||
if user == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if registerType == "" {
|
|
||||||
registerType = "deviceid"
|
|
||||||
}
|
|
||||||
ua = fillUserUA(user, ua)
|
|
||||||
createAt := user.CreatedAt
|
|
||||||
if !user.RegisterTime.IsZero() {
|
|
||||||
createAt = user.RegisterTime
|
|
||||||
}
|
|
||||||
eventId := newEventId(pubdef.TrackerAppId(), user.Id, "", createAt.Unix())
|
|
||||||
event := dataReport.NewCommonField(eventId, dataReport.EventTypeUserRegister, user.DistrictCode, ua, strconv.FormatInt(user.Id, 10), ip)
|
|
||||||
event.Payload = dataReport.JsonRawMessage(&dataReport.UserRegisterEvent{
|
|
||||||
Type: registerType,
|
|
||||||
CreateTime: dataReport.JsonNumber(createAt.Unix()),
|
|
||||||
})
|
|
||||||
insertEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReportUserLogin 用户登录事件
|
|
||||||
func ReportUserLogin(user *usermod.User, ua useragent.UA, ip string, loginType pubdef.LoginType) {
|
|
||||||
if user == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ua = fillUserUA(user, ua)
|
|
||||||
createTime := time.Now().Unix()
|
|
||||||
eventId := newEventId(pubdef.TrackerAppId(), user.Id, "", createTime)
|
|
||||||
event := dataReport.NewCommonField(eventId, dataReport.EventTypeUserLogin, user.DistrictCode, ua, strconv.FormatInt(user.Id, 10), ip)
|
|
||||||
event.Payload = dataReport.JsonRawMessage(&dataReport.UserLoginEvent{
|
|
||||||
Type: loginTypeEventValue(loginType),
|
|
||||||
})
|
|
||||||
insertEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReportPlayletLike 短剧点赞,复用 video_like
|
|
||||||
func ReportPlayletLike(ctx context.Context, userId, playletId, flag int64) {
|
|
||||||
reportPlayletVideoEvent(ctx, userId, playletId, 0, dataReport.EventTypeVideoLike, flag, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReportPlayletCollect 短剧收藏,复用 video_collect
|
|
||||||
func ReportPlayletCollect(ctx context.Context, userId, playletId, flag int64) {
|
|
||||||
reportPlayletVideoEvent(ctx, userId, playletId, 0, dataReport.EventTypeVideoCollect, flag, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReportPlayletChapterLike 短剧剧集点赞,复用 video_like
|
|
||||||
func ReportPlayletChapterLike(ctx context.Context, userId, playletId, chapterId, flag int64) {
|
|
||||||
reportPlayletVideoEvent(ctx, userId, playletId, chapterId, dataReport.EventTypeVideoLike, flag, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReportPlayletChapterCollect 短剧剧集收藏,复用 video_collect
|
|
||||||
func ReportPlayletChapterCollect(ctx context.Context, userId, playletId, chapterId, flag int64) {
|
|
||||||
reportPlayletVideoEvent(ctx, userId, playletId, chapterId, dataReport.EventTypeVideoCollect, flag, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReportPlayletComment 短剧/剧集评论,复用 video_comment
|
|
||||||
func ReportPlayletComment(ctx context.Context, user *usermod.User, playletId, chapterId int64, content string) {
|
|
||||||
if user == nil || playletId <= 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pub := buildPlayletVideoPub(ctx, playletId, chapterId)
|
|
||||||
if pub.VideoID == "" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ua, ip := uaAndIPFromCtx(ctx)
|
|
||||||
ua = fillUserUA(user, ua)
|
|
||||||
event := dataReport.NewCommonField(dataReport.GenerateGlobalEventID(), dataReport.EventTypeVideoComment, user.DistrictCode, ua, strconv.FormatInt(user.Id, 10), ip)
|
|
||||||
event.Payload = dataReport.JsonRawMessage(&dataReport.VideoCommentEvent{
|
|
||||||
VideoEventPub: pub,
|
|
||||||
CommentContent: content,
|
|
||||||
})
|
|
||||||
insertEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReportPlayletUnlock 短剧剧集金币解锁:同时上报金币消耗和购买
|
|
||||||
func ReportPlayletUnlock(ctx context.Context, user *usermod.User, playlet *playletmod.Playlet, chapter *playletchaptermod.PlayletChapter, amount, balanceBefore, balanceAfter int64, orderNo string) {
|
|
||||||
if user == nil || playlet == nil || chapter == nil || amount <= 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if full, err := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: user.Id}); err == nil && full != nil {
|
|
||||||
user = full
|
|
||||||
}
|
|
||||||
ua, ip := uaAndIPFromCtx(ctx)
|
|
||||||
ua = fillUserUA(user, ua)
|
|
||||||
productId := strconv.FormatInt(chapter.Id, 10)
|
|
||||||
productName := playletUnlockProductName(playlet, chapter)
|
|
||||||
reportCoinConsume(user, ua, ip, productId, productName, amount, balanceBefore, balanceAfter, KeyPlayletUnlock, orderNo)
|
|
||||||
reportPlayletPurchase(user, ua, ip, playlet, chapter, amount, orderNo)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReportPlayletStatusChange 短剧上下架,复用 video_status_change
|
|
||||||
func ReportPlayletStatusChange(playlet *playletmod.Playlet, flag int64) {
|
|
||||||
if playlet == nil || playlet.Id == 0 || flag == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
typeID, typeName := resolvePlayletType(context.Background(), playlet)
|
|
||||||
event := dataReport.NewCommonField("", dataReport.EventTypeVideoStatusChange, "", useragent.UA{}, "", "")
|
|
||||||
event.Payload = dataReport.JsonRawMessage(&dataReport.VideoStatusChangeEvent{
|
|
||||||
MediaId: playletMediaId(playlet),
|
|
||||||
VideoID: strconv.FormatInt(playlet.Id, 10),
|
|
||||||
VideoTitle: playlet.Title,
|
|
||||||
VideoTypeID: typeID,
|
|
||||||
VideoTypeName: typeName,
|
|
||||||
Flag: dataReport.JsonNumber(flag),
|
|
||||||
})
|
|
||||||
insertEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PlayletStatusFlag 短剧上下架映射上报 flag:1上架 2下架
|
|
||||||
func PlayletStatusFlag(status playletmod.Status) int64 {
|
|
||||||
switch status {
|
|
||||||
case playletmod.StatusUp:
|
|
||||||
return 1
|
|
||||||
case playletmod.StatusDown:
|
|
||||||
return 2
|
|
||||||
default:
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func reportPlayletVideoEvent(ctx context.Context, userId, playletId, chapterId int64, eventType string, flag int64, content string) {
|
|
||||||
if userId <= 0 || playletId <= 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
user, err := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: userId})
|
|
||||||
if err != nil || user == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pub := buildPlayletVideoPub(ctx, playletId, chapterId)
|
|
||||||
if pub.VideoID == "" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ua, ip := uaAndIPFromCtx(ctx)
|
|
||||||
ua = fillUserUA(user, ua)
|
|
||||||
event := dataReport.NewCommonField(dataReport.GenerateGlobalEventID(), eventType, user.DistrictCode, ua, strconv.FormatInt(user.Id, 10), ip)
|
|
||||||
switch eventType {
|
|
||||||
case dataReport.EventTypeVideoLike:
|
|
||||||
event.Payload = dataReport.JsonRawMessage(&dataReport.VideoLikeEvent{
|
|
||||||
VideoEventPub: pub,
|
|
||||||
Flag: dataReport.JsonNumber(flag),
|
|
||||||
})
|
|
||||||
case dataReport.EventTypeVideoCollect:
|
|
||||||
event.Payload = dataReport.JsonRawMessage(&dataReport.VideoCollectEvent{
|
|
||||||
VideoEventPub: pub,
|
|
||||||
Flag: dataReport.JsonNumber(flag),
|
|
||||||
})
|
|
||||||
case dataReport.EventTypeVideoComment:
|
|
||||||
event.Payload = dataReport.JsonRawMessage(&dataReport.VideoCommentEvent{
|
|
||||||
VideoEventPub: pub,
|
|
||||||
CommentContent: content,
|
|
||||||
})
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
insertEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
func reportCoinConsume(user *usermod.User, ua useragent.UA, ip, productId, productName string, amount, balanceBefore, balanceAfter int64, reason Key, orderId string) {
|
|
||||||
if user == nil || amount == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if productId == "" {
|
|
||||||
if productName == "" {
|
|
||||||
productName = "金币消耗"
|
|
||||||
}
|
|
||||||
productId = md5String(productName)
|
|
||||||
}
|
|
||||||
createTime := time.Now().Unix()
|
|
||||||
eventId := newEventId(pubdef.TrackerAppId(), user.Id, orderId, createTime)
|
|
||||||
event := dataReport.NewCommonField(eventId, dataReport.EventTypeCoinConsume, user.DistrictCode, ua, strconv.FormatInt(user.Id, 10), ip)
|
|
||||||
event.Payload = dataReport.JsonRawMessage(&dataReport.CoinConsumeEvent{
|
|
||||||
ProductID: productId,
|
|
||||||
ProductName: productName,
|
|
||||||
CoinConsumeAmount: dataReport.JsonNumber(amount),
|
|
||||||
CoinBalanceBefore: dataReport.JsonNumber(balanceBefore),
|
|
||||||
CoinBalanceAfter: dataReport.JsonNumber(balanceAfter),
|
|
||||||
ConsumeReasonKey: reason.Key(),
|
|
||||||
ConsumeReasonName: reason.Name(),
|
|
||||||
CreateTime: dataReport.JsonNumber(createTime),
|
|
||||||
OrderId: orderId,
|
|
||||||
})
|
|
||||||
insertEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
func reportPlayletPurchase(user *usermod.User, ua useragent.UA, ip string, playlet *playletmod.Playlet, chapter *playletchaptermod.PlayletChapter, amount int64, orderId string) {
|
|
||||||
pub := playletToVideoPub(playlet, chapter)
|
|
||||||
event := dataReport.NewCommonField(dataReport.GenerateGlobalEventID(), dataReport.EventTypeVideoPurchase, user.DistrictCode, ua, strconv.FormatInt(user.Id, 10), ip)
|
|
||||||
event.Payload = dataReport.JsonRawMessage(&dataReport.VideoPurchaseEvent{
|
|
||||||
MediaId: pub.MediaId,
|
|
||||||
VideoID: pub.VideoID,
|
|
||||||
VideoTitle: pub.VideoTitle,
|
|
||||||
VideoTypeID: pub.VideoTypeID,
|
|
||||||
VideoTypeName: pub.VideoTypeName,
|
|
||||||
VideoContentType: pub.VideoContentType,
|
|
||||||
RecommendTraceId: pub.RecommendTraceId,
|
|
||||||
CoinQuantity: dataReport.JsonNumber(amount),
|
|
||||||
OrderID: orderId,
|
|
||||||
})
|
|
||||||
insertEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
func buildPlayletVideoPub(ctx context.Context, playletId, chapterId int64) dataReport.VideoEventPub {
|
|
||||||
playlet, err := playletmod.FindOnePlaylet(ctx, bson.M{playletmod.FN.Playlet.Id: playletId}, options.FindOne().SetProjection(bson.D{
|
|
||||||
{Key: playletmod.FN.Playlet.Id, Value: 1},
|
|
||||||
{Key: playletmod.FN.Playlet.Title, Value: 1},
|
|
||||||
{Key: playletmod.FN.Playlet.CategoryIds, Value: 1},
|
|
||||||
{Key: playletmod.FN.Playlet.MediaCenterId, Value: 1},
|
|
||||||
}))
|
|
||||||
if err != nil || playlet == nil {
|
|
||||||
return dataReport.VideoEventPub{}
|
|
||||||
}
|
|
||||||
var chapter *playletchaptermod.PlayletChapter
|
|
||||||
if chapterId > 0 {
|
|
||||||
chapter, _ = playletchaptermod.FindOnePlayletChapter(ctx, bson.M{playletchaptermod.FN.PlayletChapter.Id: chapterId}, options.FindOne().SetProjection(bson.D{
|
|
||||||
{Key: playletchaptermod.FN.PlayletChapter.Id, Value: 1},
|
|
||||||
{Key: playletchaptermod.FN.PlayletChapter.PlayletId, Value: 1},
|
|
||||||
{Key: playletchaptermod.FN.PlayletChapter.Title, Value: 1},
|
|
||||||
{Key: playletchaptermod.FN.PlayletChapter.CurrentEpisode, Value: 1},
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
return playletToVideoPub(playlet, chapter)
|
|
||||||
}
|
|
||||||
|
|
||||||
func playletToVideoPub(playlet *playletmod.Playlet, chapter *playletchaptermod.PlayletChapter) dataReport.VideoEventPub {
|
|
||||||
if playlet == nil {
|
|
||||||
return dataReport.VideoEventPub{}
|
|
||||||
}
|
|
||||||
typeID, typeName := resolvePlayletType(context.Background(), playlet)
|
|
||||||
videoID := strconv.FormatInt(playlet.Id, 10)
|
|
||||||
title := playlet.Title
|
|
||||||
if chapter != nil && chapter.Id > 0 {
|
|
||||||
videoID = strconv.FormatInt(chapter.Id, 10)
|
|
||||||
title = playletUnlockProductName(playlet, chapter)
|
|
||||||
}
|
|
||||||
return dataReport.VideoEventPub{
|
|
||||||
MediaId: playletMediaId(playlet),
|
|
||||||
VideoID: videoID,
|
|
||||||
VideoTitle: title,
|
|
||||||
VideoTypeID: typeID,
|
|
||||||
VideoTypeName: typeName,
|
|
||||||
VideoContentType: videoContentTypePlaylet,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func playletUnlockProductName(playlet *playletmod.Playlet, chapter *playletchaptermod.PlayletChapter) string {
|
|
||||||
title := ""
|
|
||||||
if playlet != nil {
|
|
||||||
title = playlet.Title
|
|
||||||
}
|
|
||||||
if chapter == nil {
|
|
||||||
return title
|
|
||||||
}
|
|
||||||
if chapter.Title != "" {
|
|
||||||
if title == "" {
|
|
||||||
return chapter.Title
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s %s", title, chapter.Title)
|
|
||||||
}
|
|
||||||
if chapter.CurrentEpisode > 0 {
|
|
||||||
if title == "" {
|
|
||||||
return fmt.Sprintf("第%d集", chapter.CurrentEpisode)
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s 第%d集", title, chapter.CurrentEpisode)
|
|
||||||
}
|
|
||||||
return title
|
|
||||||
}
|
|
||||||
|
|
||||||
func playletMediaId(playlet *playletmod.Playlet) string {
|
|
||||||
if playlet == nil || playlet.MediaCenterId == 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return strconv.FormatUint(uint64(playlet.MediaCenterId), 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
func resolvePlayletType(ctx context.Context, playlet *playletmod.Playlet) (string, string) {
|
|
||||||
if playlet == nil || len(playlet.CategoryIds) == 0 {
|
|
||||||
return "default", "默认分类"
|
|
||||||
}
|
|
||||||
queryCtx, cancel := context.WithTimeout(ctx, 3*time.Second)
|
|
||||||
defer cancel()
|
|
||||||
category, err := playletcategorymod.FindOnePlayletCategory(queryCtx, bson.M{
|
|
||||||
playletcategorymod.FN.PlayletCategory.Id: playlet.CategoryIds[0],
|
|
||||||
})
|
|
||||||
if err != nil || category == nil {
|
|
||||||
return "default", "默认分类"
|
|
||||||
}
|
|
||||||
return strconv.FormatInt(category.Id, 10), category.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
func uaAndIPFromCtx(ctx context.Context) (useragent.UA, string) {
|
|
||||||
gc, ok := ctx.(*gin.Context)
|
|
||||||
if !ok {
|
|
||||||
if v := ctx.Value(consts.CtxUA); v != nil {
|
|
||||||
if ua, ok := v.(useragent.UA); ok {
|
|
||||||
return ua, ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return useragent.UA{}, ""
|
|
||||||
}
|
|
||||||
ua, _ := common.GetUA(gc)
|
|
||||||
return ua, ipaddr.ResolveClientIP(gc)
|
|
||||||
}
|
|
||||||
|
|
||||||
func fillUserUA(user *usermod.User, ua useragent.UA) useragent.UA {
|
|
||||||
if user == nil {
|
|
||||||
return ua
|
|
||||||
}
|
|
||||||
if ua.DevID == "" {
|
|
||||||
ua.DevID = user.DevID
|
|
||||||
}
|
|
||||||
if ua.DevType == "" {
|
|
||||||
ua.DevType = user.Device
|
|
||||||
}
|
|
||||||
if ua.SysType == "" {
|
|
||||||
ua.SysType = user.SysType
|
|
||||||
}
|
|
||||||
return ua
|
|
||||||
}
|
|
||||||
|
|
||||||
func loginTypeEventValue(loginType pubdef.LoginType) string {
|
|
||||||
switch loginType {
|
|
||||||
case pubdef.LoginTypeAccount:
|
|
||||||
return "username"
|
|
||||||
case pubdef.LoginTypeEmail:
|
|
||||||
return "email"
|
|
||||||
default:
|
|
||||||
return "deviceid"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newEventId(appId string, uid int64, orderId interface{}, createTime int64) string {
|
|
||||||
input := fmt.Sprintf("%v%v%v%v", appId, uid, orderId, createTime)
|
|
||||||
return md5String(input)
|
|
||||||
}
|
|
||||||
|
|
||||||
func md5String(input string) string {
|
|
||||||
h := md5.New()
|
|
||||||
h.Write([]byte(input))
|
|
||||||
return hex.EncodeToString(h.Sum(nil))
|
|
||||||
}
|
|
||||||
|
|
||||||
func insertEvent(event dataReport.CommonField) {
|
|
||||||
b, _ := json.Marshal(event)
|
|
||||||
if err := eventmod.InsertOneEvent(context.Background(), &eventmod.Event{
|
|
||||||
EventId: event.EventID,
|
|
||||||
EventType: event.Event,
|
|
||||||
Data: string(b),
|
|
||||||
Status: eventmod.Default,
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
}); err != nil {
|
|
||||||
log.Error("reportser insertEvent failed", log.Any("eventType", event.Event), log.Any("eventId", event.EventID), log.E(err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package reportser
|
|
||||||
|
|
||||||
type Key string
|
|
||||||
|
|
||||||
const (
|
|
||||||
KeyPlayletUnlock Key = "playlet_unlock" // 短剧剧集解锁
|
|
||||||
KeyCoinConsume Key = "coin_consume" // 金币消耗
|
|
||||||
)
|
|
||||||
|
|
||||||
var keyMap = map[Key]string{
|
|
||||||
KeyPlayletUnlock: "短剧解锁",
|
|
||||||
KeyCoinConsume: "金币消耗",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Key) Name() string {
|
|
||||||
return keyMap[p]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Key) Key() string {
|
|
||||||
return string(p)
|
|
||||||
}
|
|
||||||
@@ -1,246 +0,0 @@
|
|||||||
package dataReport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
|
||||||
"math/rand"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
"videoweb/pub/common/enum/redisconst"
|
|
||||||
"videoweb/pub/common/godef"
|
|
||||||
"videoweb/pub/common/log"
|
|
||||||
"videoweb/pub/common/useragent"
|
|
||||||
"videoweb/pub/pubdef"
|
|
||||||
"videoweb/pub/redis"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/moul/http2curl"
|
|
||||||
)
|
|
||||||
|
|
||||||
var config = Config{}
|
|
||||||
|
|
||||||
func Init(c Config) {
|
|
||||||
config = c
|
|
||||||
// 根据运行模式设置SDK配置API地址
|
|
||||||
switch c.RunMod {
|
|
||||||
case "prod", "release":
|
|
||||||
sdkConfigAPIURL = sdkConfigAPIProd
|
|
||||||
default:
|
|
||||||
sdkConfigAPIURL = sdkConfigAPIDev
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GenerateGlobalEventID 生成全局唯一的 event_id
|
|
||||||
func GenerateGlobalEventID() string {
|
|
||||||
// 生成一个新的 UUID
|
|
||||||
return strings.ReplaceAll(uuid.New().String(), "-", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
func AsyncReport(eventData interface{}, retryCount int) {
|
|
||||||
// TODO 后续可改成kafka异步处理
|
|
||||||
godef.Go(func() {
|
|
||||||
// 自动重试
|
|
||||||
baseDelay := 1 * time.Second
|
|
||||||
for i := 0; i < retryCount; i++ {
|
|
||||||
err := report(eventData)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Event.report failed", log.Any("retryCount", retryCount), log.Any("eventData", eventData), log.E(err))
|
|
||||||
// 指数退避 + 随机抖动
|
|
||||||
sleepTime := time.Duration(math.Pow(2, float64(i)))*baseDelay + time.Duration(rand.Intn(1000))*time.Millisecond
|
|
||||||
time.Sleep(sleepTime)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 上报事件
|
|
||||||
func report(eventData interface{}) error {
|
|
||||||
// 将结构体转换为表单数据
|
|
||||||
formData, err := structToFormData(eventData)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
apiUrl := config.ApiUrl + "/api/eventTracking/report.json"
|
|
||||||
req, err := http.NewRequest("POST", apiUrl, bytes.NewBufferString(formData))
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Event report NewRequest fail", log.E(err))
|
|
||||||
return fmt.Errorf("failed to create request: %v", err)
|
|
||||||
}
|
|
||||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
|
||||||
|
|
||||||
client := &http.Client{
|
|
||||||
Timeout: 5 * time.Second, // 设置超时时间为 5 秒
|
|
||||||
}
|
|
||||||
command, _ := http2curl.GetCurlCommand(req)
|
|
||||||
fmt.Println(command)
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Event report fail", log.E(err))
|
|
||||||
return fmt.Errorf("failed to send request: %v", err)
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
log.Error("Event report fail", log.Any("http.code", resp.StatusCode))
|
|
||||||
return fmt.Errorf("failed to report event, http.code: %d", resp.StatusCode)
|
|
||||||
}
|
|
||||||
// 读取返回的 body
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Event report fail", log.E(err))
|
|
||||||
return fmt.Errorf("failed to read response body: %v", err)
|
|
||||||
}
|
|
||||||
res := &Response{}
|
|
||||||
err = json.Unmarshal(body, res)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Event report json.Unmarshal(body, res) fail", log.Any("body", string(body)), log.E(err))
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
log.Error("Event report fail", log.Any("code", res.Code), log.Any("msg", res.Msg), log.Any("data", res.Data))
|
|
||||||
return fmt.Errorf("failed to report event, res.code: %d", res.Code)
|
|
||||||
}
|
|
||||||
// 输出响应状态和返回的 body
|
|
||||||
log.Info("Event report Response", log.Any("eventData", eventData), log.Any("body", string(body)))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func structToFormData(data interface{}) (string, error) {
|
|
||||||
// 序列化结构体为 JSON 字符串
|
|
||||||
jsonData, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
// 反序列化为 map
|
|
||||||
var dataMap map[string]interface{}
|
|
||||||
err = json.Unmarshal(jsonData, &dataMap)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
var formData []string
|
|
||||||
|
|
||||||
// 遍历 map,将其转换为 form 数据
|
|
||||||
for key, value := range dataMap {
|
|
||||||
if value == nil {
|
|
||||||
continue // 如果值为 nil,跳过
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将值转换为字符串
|
|
||||||
valueStr := fmt.Sprintf("%v", value)
|
|
||||||
|
|
||||||
// 使用 URL 编码
|
|
||||||
formData = append(formData, fmt.Sprintf(
|
|
||||||
"%s=%s",
|
|
||||||
url.QueryEscape(key),
|
|
||||||
url.QueryEscape(valueStr),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.Join(formData, "&"), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCommonField(eventId, event string, districtCode string, ua useragent.UA, uid, ip string) CommonField {
|
|
||||||
userSidKey := redisconst.UserSidKey(pubdef.AppId)
|
|
||||||
sid, _ := redis.Get(userSidKey)
|
|
||||||
if sid == nil {
|
|
||||||
id := GenerateGlobalEventID()
|
|
||||||
sid = &id
|
|
||||||
redis.Set(userSidKey, sid, redisconst.UserSidKeyExpire)
|
|
||||||
}
|
|
||||||
if eventId == "" {
|
|
||||||
eventId = GenerateGlobalEventID()
|
|
||||||
}
|
|
||||||
device := ua.SysType
|
|
||||||
if device == "" {
|
|
||||||
device = "PC"
|
|
||||||
}
|
|
||||||
deviceID := ua.DevID
|
|
||||||
if deviceID == "" {
|
|
||||||
deviceID = ip
|
|
||||||
}
|
|
||||||
deviceModel := ua.DeviceModel
|
|
||||||
if deviceModel == "" {
|
|
||||||
deviceModel = ua.DevType
|
|
||||||
}
|
|
||||||
sidVal := ua.SessionID
|
|
||||||
if sidVal == "" {
|
|
||||||
sidVal = *sid
|
|
||||||
}
|
|
||||||
return CommonField{
|
|
||||||
UID: uid,
|
|
||||||
EventID: eventId,
|
|
||||||
Event: event,
|
|
||||||
Channel: strings.TrimSpace(districtCode),
|
|
||||||
AppID: pubdef.TrackerAppId(),
|
|
||||||
ClientTS: fmt.Sprintf("%v", time.Now().Unix()),
|
|
||||||
Device: device,
|
|
||||||
DeviceID: deviceID,
|
|
||||||
UserAgent: ua.UserAgent,
|
|
||||||
DeviceBrand: ua.DeviceBrand,
|
|
||||||
DeviceModel: deviceModel,
|
|
||||||
SystemName: ua.SystemName,
|
|
||||||
SystemVersion: ua.SystemVersion,
|
|
||||||
IP: ip,
|
|
||||||
SID: sidVal,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func JsonNumber(v int64) json.Number {
|
|
||||||
return json.Number(strconv.FormatInt(v, 10))
|
|
||||||
}
|
|
||||||
func JsonRawMessage(v interface{}) json.RawMessage {
|
|
||||||
b, _ := json.Marshal(v)
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
// 批量上报事件
|
|
||||||
func BatchReport(ctx context.Context, data interface{}) error {
|
|
||||||
apiUrl := config.ApiUrl + "/api/eventTracking/batchReport.json"
|
|
||||||
reqBody, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Event report json.Marshal fail", log.E(err))
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
req, err := http.NewRequest("POST", apiUrl, bytes.NewReader(reqBody))
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Event report NewRequest fail", log.E(err))
|
|
||||||
return fmt.Errorf("failed to create request: %v", err)
|
|
||||||
}
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
|
||||||
curl, _ := http2curl.GetCurlCommand(req)
|
|
||||||
client := &http.Client{
|
|
||||||
Timeout: 5 * time.Second, // 设置超时时间为 5 秒
|
|
||||||
}
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Event report fail", log.Any("curl", curl), log.E(err))
|
|
||||||
return fmt.Errorf("failed to send request: %v", err)
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
log.Error("Event report fail", log.Any("curl", curl), log.Any("http.code", resp.StatusCode))
|
|
||||||
return fmt.Errorf("failed to report event, status code: %d", resp.StatusCode)
|
|
||||||
}
|
|
||||||
// 读取返回的 body
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Event report fail", log.Any("curl", curl), log.E(err))
|
|
||||||
return fmt.Errorf("failed to read response body: %v", err)
|
|
||||||
}
|
|
||||||
// 输出响应状态和返回的 body
|
|
||||||
log.Info("Event report Response", log.Any("body", string(body)))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
package dataReport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
"videoweb/pub/common/log"
|
|
||||||
"videoweb/pub/redis"
|
|
||||||
|
|
||||||
"github.com/robfig/cron/v3"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
sdkConfigAPIProd = "https://api.dc-server.cc/sdk/getAvailableDomainList"
|
|
||||||
sdkConfigAPIDev = "https://dcapi.dc-dev.cc/sdk/getAvailableDomainList"
|
|
||||||
sdkConfigCacheKey = "report:sdk:domain_config"
|
|
||||||
sdkConfigCacheTTL = 30 * time.Minute
|
|
||||||
sdkConfigFetchInterval = "0 */10 * * * *"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
sdkConfigAPIURL = sdkConfigAPIProd // 默认正式环境,Init时会根据RunMod覆盖
|
|
||||||
sdkConfigCron *cron.Cron
|
|
||||||
sdkConfigOnce sync.Once
|
|
||||||
|
|
||||||
sdkConfigMu sync.RWMutex
|
|
||||||
sdkDomainConfig string
|
|
||||||
sdkConfigUpdatedAt time.Time
|
|
||||||
)
|
|
||||||
|
|
||||||
type sdkConfigResponse struct {
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data string `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// StartSDKConfigCron 定时拉取 SDK 域名配置串,服务端只缓存并原样透传。
|
|
||||||
func StartSDKConfigCron() {
|
|
||||||
sdkConfigOnce.Do(func() {
|
|
||||||
if err := RefreshSDKDomainConfig(); err != nil {
|
|
||||||
log.Error("RefreshSDKDomainConfig first run fail", log.E(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
sdkConfigCron = cron.New(cron.WithSeconds())
|
|
||||||
if _, err := sdkConfigCron.AddFunc(sdkConfigFetchInterval, func() {
|
|
||||||
if err := RefreshSDKDomainConfig(); err != nil {
|
|
||||||
log.Error("RefreshSDKDomainConfig cron fail", log.E(err))
|
|
||||||
}
|
|
||||||
}); err != nil {
|
|
||||||
log.Error("StartSDKConfigCron AddFunc fail", log.E(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sdkConfigCron.Start()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func StopSDKConfigCron() {
|
|
||||||
if sdkConfigCron == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx := sdkConfigCron.Stop()
|
|
||||||
<-ctx.Done()
|
|
||||||
}
|
|
||||||
|
|
||||||
func RefreshSDKDomainConfig() error {
|
|
||||||
data, err := fetchSDKDomainConfig(sdkConfigAPIURL, &http.Client{Timeout: 5 * time.Second})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
setSDKDomainConfig(data)
|
|
||||||
if redis.Client() == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return redis.Set(sdkConfigCacheKey, data, sdkConfigCacheTTL)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetSDKDomainConfig() string {
|
|
||||||
if redis.Client() != nil {
|
|
||||||
data, err := redis.Get(sdkConfigCacheKey)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("GetSDKDomainConfig redis get fail", log.E(err))
|
|
||||||
} else if data != nil && *data != "" {
|
|
||||||
setSDKDomainConfig(*data)
|
|
||||||
return *data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sdkConfigMu.RLock()
|
|
||||||
defer sdkConfigMu.RUnlock()
|
|
||||||
return sdkDomainConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
func setSDKDomainConfig(data string) {
|
|
||||||
sdkConfigMu.Lock()
|
|
||||||
defer sdkConfigMu.Unlock()
|
|
||||||
sdkDomainConfig = data
|
|
||||||
sdkConfigUpdatedAt = time.Now()
|
|
||||||
}
|
|
||||||
|
|
||||||
func fetchSDKDomainConfig(apiURL string, client *http.Client) (string, error) {
|
|
||||||
req, err := http.NewRequest(http.MethodGet, apiURL, nil)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
req.Header.Set("Accept", "application/json")
|
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
return "", fmt.Errorf("sdk config http status: %d", resp.StatusCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
var result sdkConfigResponse
|
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if result.Code != 0 {
|
|
||||||
return "", fmt.Errorf("sdk config code: %d, msg: %s", result.Code, result.Msg)
|
|
||||||
}
|
|
||||||
if strings.TrimSpace(result.Data) == "" {
|
|
||||||
return "", fmt.Errorf("sdk config data is empty")
|
|
||||||
}
|
|
||||||
return result.Data, nil
|
|
||||||
}
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
package dataReport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Response struct {
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data interface{} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Config struct {
|
|
||||||
ApiUrl string `json:"apiUrl"`
|
|
||||||
RunMod string `json:"runMod"` // 运行模式: dev/test/prod/release
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
EventTypeAdClick = "ad_click"
|
|
||||||
EventTypeUserLogin = "user_login"
|
|
||||||
EventTypeUserRegister = "user_register"
|
|
||||||
EventTypeOrderCreated = "order_created"
|
|
||||||
EventTypeOrderPaid = "order_paid"
|
|
||||||
EventTypeCoinConsume = "coin_consume"
|
|
||||||
EventTypeVideoPurchase = "video_purchase"
|
|
||||||
EventTypeVideoLike = "video_like"
|
|
||||||
EventTypeVideoCollect = "video_collect"
|
|
||||||
EventTypeVideoComment = "video_comment"
|
|
||||||
EventTypeVideoStatusChange = "video_status_change" // 视频状态变更
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
// Event 定义事件的接口
|
|
||||||
type Event interface {
|
|
||||||
Generate(ctx context.Context, retryCount int)
|
|
||||||
AsyncReport(ctx context.Context, retryCount int) error // 执行事件上报
|
|
||||||
}
|
|
||||||
|
|
||||||
// 定义公共字段和事件数据结构
|
|
||||||
type CommonField struct {
|
|
||||||
Event string `json:"event"` // 事件类型
|
|
||||||
Channel string `json:"channel"` // 渠道码
|
|
||||||
EventID string `json:"event_id"` // 事件唯一标识符
|
|
||||||
AppID string `json:"app_id"` // 应用ID
|
|
||||||
UID string `json:"uid"` // 用户ID
|
|
||||||
SID string `json:"sid"` // 会话ID
|
|
||||||
ClientTS string `json:"client_ts"` // 客户端时间戳
|
|
||||||
Device string `json:"device"` // 设备类型(如:Android, iOS, PC)
|
|
||||||
DeviceID string `json:"device_id"` // 设备ID
|
|
||||||
UserAgent string `json:"user_agent"` // 用户代理信息
|
|
||||||
DeviceBrand string `json:"device_brand"` // 设备品牌(如:HUAWEI)
|
|
||||||
DeviceModel string `json:"device_model"` // 设备型号
|
|
||||||
SystemName string `json:"system_name"` // 系统名称
|
|
||||||
SystemVersion string `json:"system_version"` // 系统版本
|
|
||||||
IP string `json:"ip"` // 用户IP地址
|
|
||||||
Payload json.RawMessage `json:"payload"` // 事件数据
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserRegisterEvent 注册事件
|
|
||||||
type UserRegisterEvent struct {
|
|
||||||
Type string `json:"type"` // 注册方式:phone, deviceid, email, username
|
|
||||||
TraceID string `json:"trace_id"` // 唯一标识,落地页点击生成
|
|
||||||
CreateTime json.Number `json:"create_time"` // 注册时间,10位时间戳
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserLoginEvent struct {
|
|
||||||
Type string `json:"type"` // 登录方式
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrderCreatedEvent 订单创建
|
|
||||||
type OrderCreatedEvent struct {
|
|
||||||
OrderID string `json:"order_id"` // 订单号(唯一标识)
|
|
||||||
OrderType string `json:"order_type"` // 订单类型
|
|
||||||
ProductID string `json:"product_id"` // 商品ID
|
|
||||||
ProductName string `json:"product_name"` // 商品名称
|
|
||||||
VIPDurationID string `json:"vip_duration_type"`
|
|
||||||
VIPDurationName string `json:"vip_duration_name"`
|
|
||||||
Amount json.Number `json:"amount"` // 订单金额(分)
|
|
||||||
Currency string `json:"currency"` // 货币类型
|
|
||||||
CoinQuantity json.Number `json:"coin_quantity"` // 金币数量
|
|
||||||
SourcePageKey string `json:"source_page_key"` // 来源页面标识
|
|
||||||
SourcePageName string `json:"source_page_name"` // 来源页面名称
|
|
||||||
CreateTime json.Number `json:"create_time"` // 订单创建时间
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrderPaidEvent 订单支付成功
|
|
||||||
type OrderPaidEvent struct {
|
|
||||||
OrderID string `json:"order_id"` // 订单号(关联创建事件)
|
|
||||||
OrderType string `json:"order_type"` // 订单类型:coin_purchase, vip_subscription
|
|
||||||
ProductID string `json:"product_id"` // 商品ID
|
|
||||||
Amount json.Number `json:"amount"` // 实际支付金额(分)
|
|
||||||
Currency string `json:"currency"` // 货币类型:CNY, USD
|
|
||||||
CoinQuantity json.Number `json:"coin_quantity"` // 金币数量(仅金币订单)
|
|
||||||
VIPExpirationTime json.Number `json:"vip_expiration_time"` // VIP过期时间(10位时间戳)
|
|
||||||
PayType string `json:"pay_type"` // 支付方式:wechat, alipay, bank_card
|
|
||||||
PayChannel string `json:"pay_channel"` // 支付渠道:银行名称
|
|
||||||
TransactionID string `json:"transaction_id"` // 第三方支付交易号
|
|
||||||
CreateTime json.Number `json:"create_time"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CoinConsumeEvent 金币消耗
|
|
||||||
type CoinConsumeEvent struct {
|
|
||||||
ProductID string `json:"product_id"` // 商品ID
|
|
||||||
ProductName string `json:"product_name"` // 商品名称
|
|
||||||
CoinConsumeAmount json.Number `json:"coin_consume_amount"` // 金币消耗数量
|
|
||||||
CoinBalanceBefore json.Number `json:"coin_balance_before"` // 消耗前金币余额
|
|
||||||
CoinBalanceAfter json.Number `json:"coin_balance_after"` // 消耗后金币余额
|
|
||||||
ConsumeReasonKey string `json:"consume_reason_key"` // 消耗原因
|
|
||||||
ConsumeReasonName string `json:"consume_reason_name"` // 消耗原因名称
|
|
||||||
CreateTime json.Number `json:"create_time"` // 订单创建时间
|
|
||||||
OrderId string `json:"order_id"` // 订单id
|
|
||||||
}
|
|
||||||
|
|
||||||
// VideoPurchaseEvent 视频购买事件
|
|
||||||
type VideoPurchaseEvent struct {
|
|
||||||
MediaId string `json:"media_id"` // 老司机媒体资源ID(老司机接口返回的id字段)
|
|
||||||
VideoID string `json:"video_id"` // 视频ID
|
|
||||||
VideoTitle string `json:"video_title"` // 视频标题
|
|
||||||
VideoTypeID string `json:"video_type_id"` // 视频分类ID
|
|
||||||
VideoTypeName string `json:"video_type_name"` // 视频分类名称
|
|
||||||
VideoContentType string `json:"video_content_type"` // 视频类型: video(长视频)、short_video(短视频)
|
|
||||||
RecommendTraceId string `json:"recommend_trace_id"` // 推荐引擎的trace_id。没有对接搜索推荐引擎的上报空字符串。
|
|
||||||
CoinQuantity json.Number `json:"coin_quantity"` // 金币数量
|
|
||||||
OrderID string `json:"order_id"` // 订单号
|
|
||||||
}
|
|
||||||
|
|
||||||
type (
|
|
||||||
VideoEventPub struct {
|
|
||||||
MediaId string `json:"media_id"` // 老司机媒体资源ID(老司机接口返回的id字段)
|
|
||||||
VideoID string `json:"video_id"` // 视频ID
|
|
||||||
VideoTitle string `json:"video_title"` // 视频标题
|
|
||||||
VideoTypeID string `json:"video_type_id"` // 视频分类ID
|
|
||||||
VideoTypeName string `json:"video_type_name"` // 视频分类名称
|
|
||||||
VideoContentType string `json:"video_content_type"` // 视频类型: video(长视频)、short_video(短视频)
|
|
||||||
RecommendTraceId string `json:"recommend_trace_id"` // 推荐引擎的trace_id。没有对接搜索推荐引擎的上报空字符串。
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoLikeEvent struct {
|
|
||||||
VideoEventPub
|
|
||||||
Flag json.Number `json:"flag"` // 点赞状态:1(点赞), 2(取消点赞)
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoCollectEvent struct {
|
|
||||||
VideoEventPub
|
|
||||||
Flag json.Number `json:"flag"` // 收藏状态:1(收藏), 2(取消收藏)
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoCommentEvent struct {
|
|
||||||
VideoEventPub
|
|
||||||
CommentContent string `json:"comment_content"` // 评论内容
|
|
||||||
}
|
|
||||||
|
|
||||||
// VideoStatusChangeEvent 视频状态变更事件
|
|
||||||
VideoStatusChangeEvent struct {
|
|
||||||
MediaId string `json:"media_id"` // 老司机媒体资源ID
|
|
||||||
VideoID string `json:"video_id"` // 视频ID
|
|
||||||
VideoTitle string `json:"video_title"` // 视频标题
|
|
||||||
VideoTypeID string `json:"video_type_id"` // 视频分类ID
|
|
||||||
VideoTypeName string `json:"video_type_name"` // 视频分类名称
|
|
||||||
Flag json.Number `json:"flag"` // 状态标识
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
type AdClickEvent struct {
|
|
||||||
CommonField
|
|
||||||
PageKey string `json:"page_key"` // 页面标识
|
|
||||||
PageName string `json:"page_name"` // 页面名称
|
|
||||||
AdSlotKey string `json:"ad_slot_key"` // 广告位标识
|
|
||||||
AdSlotName string `json:"ad_slot_name"` // 广告位名称
|
|
||||||
AdID string `json:"ad_id"` // 广告ID
|
|
||||||
CreativeID string `json:"creative_id"` // 素材ID(可选)
|
|
||||||
AdType string `json:"ad_type"` // 广告类型
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package eventmod
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"videoweb/pub/mongos"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
|
||||||
)
|
|
||||||
|
|
||||||
var db *mongos.Collection
|
|
||||||
|
|
||||||
func Init(ctx context.Context) {
|
|
||||||
db = mongos.Shop.Coll(TN.Event)
|
|
||||||
indexes := []mongo.IndexModel{
|
|
||||||
{
|
|
||||||
Keys: bson.D{
|
|
||||||
{Key: FN.Event.Status, Value: 1},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Keys: bson.D{
|
|
||||||
{Key: FN.Event.EventType, Value: 1},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Keys: bson.D{
|
|
||||||
{Key: FN.Event.EventId, Value: 1},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Keys: bson.D{
|
|
||||||
{Key: FN.Event.Status, Value: 1},
|
|
||||||
{Key: FN.Event.RetryCount, Value: 1},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Keys: bson.D{
|
|
||||||
{Key: FN.Event.CreatedAt, Value: -1},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if _, err := db.CreateIndex(ctx, indexes); err != nil {
|
|
||||||
panic(fmt.Sprintf("(eventmod:Init) Create Event Index failed! err:%+v:", err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
package eventmod
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"videoweb/pub/common/log"
|
|
||||||
"videoweb/pub/common/srvdef"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
|
||||||
)
|
|
||||||
|
|
||||||
// InsertOneEvent 插入一个事件
|
|
||||||
func InsertOneEvent(ctx context.Context, event *Event) *srvdef.SrvErr {
|
|
||||||
if _, err := db.InsertOne(ctx, event); err != nil {
|
|
||||||
log.Warn("eventmod:InsertOneEvent db.InsertOne failed", log.E(err))
|
|
||||||
return srvdef.New(srvdef.ErrDbInsertError, "", "")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// InsertManyEvent 批量插入事件
|
|
||||||
func InsertManyEvent(ctx context.Context, events *EventList) *srvdef.SrvErr {
|
|
||||||
if _, err := db.InsertMany(ctx, events); err != nil {
|
|
||||||
log.Warn("eventmod:InsertManyEvent db.InsertMany failed", log.E(err))
|
|
||||||
return srvdef.New(srvdef.ErrDbInsertError, "", "")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DelOneEvent 删除一个事件
|
|
||||||
func DelOneEvent(ctx context.Context, filter bson.M) (int64, *srvdef.SrvErr) {
|
|
||||||
count, err := db.DeleteOne(ctx, filter)
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("eventmod:DelOneEvent db.DeleteOne failed",
|
|
||||||
log.E(err), log.Any("filter", filter))
|
|
||||||
return 0, srvdef.New(srvdef.ErrDbDeleteError, "", "")
|
|
||||||
}
|
|
||||||
return count, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DelManyEvent 批量删除事件
|
|
||||||
func DelManyEvent(ctx context.Context, filter bson.M) (int64, *srvdef.SrvErr) {
|
|
||||||
count, err := db.DeleteMany(ctx, filter)
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("eventmod:DelManyEvent db.DeleteMany failed",
|
|
||||||
log.E(err), log.Any("filter", filter))
|
|
||||||
return 0, srvdef.New(srvdef.ErrDbDeleteError, "", "")
|
|
||||||
}
|
|
||||||
return count, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindOneEvent 查找一个事件
|
|
||||||
func FindOneEvent(ctx context.Context, filter bson.M, opts ...*options.FindOneOptions) (*Event, *srvdef.SrvErr) {
|
|
||||||
var event Event
|
|
||||||
if err := db.FindOneEx(ctx, &event, filter, opts...); err != nil {
|
|
||||||
if err != mongo.ErrNoDocuments {
|
|
||||||
log.Warn("eventmod:FindOneEvent db.FindOne failed",
|
|
||||||
log.E(err), log.Any("filter", filter))
|
|
||||||
return nil, srvdef.New(srvdef.ErrDbQueryError, "", "")
|
|
||||||
}
|
|
||||||
return nil, srvdef.New(srvdef.ErrNoData, "", "")
|
|
||||||
}
|
|
||||||
return &event, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindManyEvent 查找多个事件
|
|
||||||
func FindManyEvent(ctx context.Context, filter bson.M, opts ...*options.FindOptions) (EventList, *srvdef.SrvErr) {
|
|
||||||
data := make(EventList, 0)
|
|
||||||
if err := db.Find(ctx, &data, filter, opts...); err != nil {
|
|
||||||
log.Warn("eventmod:FindManyEvent db.Find failed",
|
|
||||||
log.E(err), log.Any("filter", filter))
|
|
||||||
return nil, srvdef.New(srvdef.ErrDbQueryError, "", "")
|
|
||||||
}
|
|
||||||
return data, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CountEvent 统计事件数量
|
|
||||||
func CountEvent(ctx context.Context, filter bson.M) (int64, *srvdef.SrvErr) {
|
|
||||||
count, err := db.Count(ctx, filter)
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("eventmod:CountEvent db.Count failed",
|
|
||||||
log.E(err), log.Any("filter", filter))
|
|
||||||
return 0, srvdef.New(srvdef.ErrDbQueryError, "", "")
|
|
||||||
}
|
|
||||||
return count, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateOneEvent 更新一个事件
|
|
||||||
func UpdateOneEvent(ctx context.Context, filter bson.M, update bson.M) *srvdef.SrvErr {
|
|
||||||
result, err := db.UpdateOne(ctx, filter, update)
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("eventmod:UpdateOneEvent db.UpdateOne failed",
|
|
||||||
log.E(err), log.Any("filter", filter))
|
|
||||||
return srvdef.New(srvdef.ErrDbUpdateError, "", "")
|
|
||||||
}
|
|
||||||
if result.MatchedCount != 1 {
|
|
||||||
log.Warn("eventmod:UpdateOneEvent db.UpdateOne not matched",
|
|
||||||
log.Any("filter", filter))
|
|
||||||
return srvdef.New(srvdef.ErrNoData, "", "")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateManyEvent 批量更新事件
|
|
||||||
func UpdateManyEvent(ctx context.Context, filter bson.M, update bson.M) *srvdef.SrvErr {
|
|
||||||
result, err := db.UpdateMany(ctx, filter, update)
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("eventmod:UpdateManyEvent db.UpdateMany failed",
|
|
||||||
log.E(err), log.Any("filter", filter))
|
|
||||||
return srvdef.New(srvdef.ErrDbUpdateError, "", "")
|
|
||||||
}
|
|
||||||
if result.MatchedCount < 1 {
|
|
||||||
log.Warn("eventmod:UpdateManyEvent db.UpdateMany not matched",
|
|
||||||
log.Any("filter", filter))
|
|
||||||
return srvdef.New(srvdef.ErrNoData, "", "")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpsertOneEvent 插入或更新一个事件
|
|
||||||
func UpsertOneEvent(ctx context.Context, filter bson.M, update bson.M) *srvdef.SrvErr {
|
|
||||||
opts := options.Update().SetUpsert(true)
|
|
||||||
if _, err := db.UpdateOne(ctx, filter, update, opts); err != nil {
|
|
||||||
log.Warn("eventmod:UpsertOneEvent db.UpdateOne failed",
|
|
||||||
log.E(err), log.Any("filter", filter))
|
|
||||||
return srvdef.New(srvdef.ErrDbUpdateError, "", "")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package eventmod
|
|
||||||
|
|
||||||
type TagEvent struct {
|
|
||||||
ID string //
|
|
||||||
CreatedAt string // 创建事件
|
|
||||||
RetryCount string // 重试次数
|
|
||||||
Status string //
|
|
||||||
Data string //
|
|
||||||
EventType string //
|
|
||||||
EventId string //
|
|
||||||
UpdatedAt string // 修改时间
|
|
||||||
}
|
|
||||||
|
|
||||||
var FN struct {
|
|
||||||
Event TagEvent
|
|
||||||
}
|
|
||||||
var TN struct {
|
|
||||||
Event string
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
FN.Event.ID = "_id"
|
|
||||||
FN.Event.CreatedAt = "createdAt"
|
|
||||||
FN.Event.RetryCount = "retryCount"
|
|
||||||
FN.Event.Status = "status"
|
|
||||||
FN.Event.Data = "data"
|
|
||||||
FN.Event.EventType = "eventType"
|
|
||||||
FN.Event.EventId = "eventId"
|
|
||||||
FN.Event.UpdatedAt = "updatedAt"
|
|
||||||
TN.Event = "event"
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package eventmod
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
||||||
)
|
|
||||||
|
|
||||||
type EventStatus int
|
|
||||||
|
|
||||||
const (
|
|
||||||
Default EventStatus = 0 // 默认状态,等待上报
|
|
||||||
Success EventStatus = 1 // 成功
|
|
||||||
Failure EventStatus = 2 // 失败
|
|
||||||
)
|
|
||||||
|
|
||||||
//go:generate fox mongo --model
|
|
||||||
//go:generate fox mongo --tag
|
|
||||||
//go:generate fox mongo --update
|
|
||||||
|
|
||||||
// @table:event
|
|
||||||
// @title:事件表
|
|
||||||
type Event struct {
|
|
||||||
ID primitive.ObjectID `bson:"_id,omitempty"`
|
|
||||||
EventId string `json:"eventId" bson:"eventId"`
|
|
||||||
EventType string `json:"eventType" bson:"eventType"`
|
|
||||||
Data string `json:"data" bson:"data"`
|
|
||||||
Status EventStatus `json:"status" bson:"status"` //
|
|
||||||
RetryCount int `json:"retryCount" bson:"retryCount"` // 重试次数
|
|
||||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` // 创建事件
|
|
||||||
UpdatedAt time.Time `bson:"updatedAt"` // 修改时间
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package eventmod
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
||||||
)
|
|
||||||
|
|
||||||
type EventList []*Event
|
|
||||||
type EventUpdate struct {
|
|
||||||
RetryCount *int `json:"retryCount" bson:"retryCount,omitempty"` // 重试次数
|
|
||||||
Status *EventStatus `json:"status" bson:"status,omitempty"` //
|
|
||||||
Data *string `json:"data" bson:"data,omitempty"` //
|
|
||||||
EventType *string `json:"eventType" bson:"eventType,omitempty"` //
|
|
||||||
EventId *string `json:"eventId" bson:"eventId,omitempty"` //
|
|
||||||
UpdatedAt *time.Time `json:"" bson:"updatedAt,omitempty"` // 修改时间
|
|
||||||
}
|
|
||||||
type EventQuery struct {
|
|
||||||
ID *primitive.ObjectID `json:"" bson:"_id,omitempty"` //
|
|
||||||
RetryCount *int `json:"retryCount" bson:"retryCount,omitempty"` // 重试次数
|
|
||||||
Status *EventStatus `json:"status" bson:"status,omitempty"` //
|
|
||||||
Data *string `json:"data" bson:"data,omitempty"` //
|
|
||||||
EventType *string `json:"eventType" bson:"eventType,omitempty"` //
|
|
||||||
EventId *string `json:"eventId" bson:"eventId,omitempty"` //
|
|
||||||
UpdatedAt *time.Time `json:"" bson:"updatedAt,omitempty"` // 修改时间
|
|
||||||
}
|
|
||||||
|
|
||||||
func (query *EventQuery) GetQueryFilter() bson.M {
|
|
||||||
filter := bson.M{}
|
|
||||||
if query.ID != nil {
|
|
||||||
filter[FN.Event.ID] = *query.ID
|
|
||||||
}
|
|
||||||
if query.RetryCount != nil {
|
|
||||||
filter[FN.Event.RetryCount] = *query.RetryCount
|
|
||||||
}
|
|
||||||
if query.Status != nil {
|
|
||||||
filter[FN.Event.Status] = *query.Status
|
|
||||||
}
|
|
||||||
if query.Data != nil {
|
|
||||||
filter[FN.Event.Data] = bson.M{"$regex": primitive.Regex{Pattern: *query.Data, Options: "i"}}
|
|
||||||
}
|
|
||||||
if query.EventType != nil {
|
|
||||||
filter[FN.Event.EventType] = bson.M{"$regex": primitive.Regex{Pattern: *query.EventType, Options: "i"}}
|
|
||||||
}
|
|
||||||
if query.EventId != nil {
|
|
||||||
filter[FN.Event.EventId] = bson.M{"$regex": primitive.Regex{Pattern: *query.EventId, Options: "i"}}
|
|
||||||
}
|
|
||||||
if query.UpdatedAt != nil {
|
|
||||||
filter[FN.Event.UpdatedAt] = *query.UpdatedAt
|
|
||||||
}
|
|
||||||
return filter
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"videoweb/pub/models/contactusmod"
|
"videoweb/pub/models/contactusmod"
|
||||||
"videoweb/pub/models/detailnavmod"
|
"videoweb/pub/models/detailnavmod"
|
||||||
"videoweb/pub/models/esmod"
|
"videoweb/pub/models/esmod"
|
||||||
"videoweb/pub/models/eventmod"
|
|
||||||
"videoweb/pub/models/feedbackmod"
|
"videoweb/pub/models/feedbackmod"
|
||||||
"videoweb/pub/models/homebannermod"
|
"videoweb/pub/models/homebannermod"
|
||||||
"videoweb/pub/models/hotsearchmod"
|
"videoweb/pub/models/hotsearchmod"
|
||||||
@@ -67,7 +66,6 @@ func Init() {
|
|||||||
ipdailystatmod.Init(ctx)
|
ipdailystatmod.Init(ctx)
|
||||||
esmod.Init(ctx)
|
esmod.Init(ctx)
|
||||||
detailnavmod.Init(ctx)
|
detailnavmod.Init(ctx)
|
||||||
eventmod.Init(ctx)
|
|
||||||
translationcategorymod.Init(ctx)
|
translationcategorymod.Init(ctx)
|
||||||
translationmod.Init(ctx)
|
translationmod.Init(ctx)
|
||||||
playletcategorymod.Init(ctx)
|
playletcategorymod.Init(ctx)
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package pubdef
|
package pubdef
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
type Page struct {
|
type Page struct {
|
||||||
PageNum int64 `form:"pageNum" json:"pageNum,omitempty"`
|
PageNum int64 `form:"pageNum" json:"pageNum,omitempty"`
|
||||||
PageSize int64 `form:"pageSize" json:"pageSize,omitempty"`
|
PageSize int64 `form:"pageSize" json:"pageSize,omitempty"`
|
||||||
@@ -18,11 +16,6 @@ const (
|
|||||||
DefaultChannelCode = "HGDL"
|
DefaultChannelCode = "HGDL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TrackerAppId 数据上报 SDK / 服务端埋点共用的应用 ID
|
|
||||||
func TrackerAppId() string {
|
|
||||||
return fmt.Sprintf("JHA-%d", AppId)
|
|
||||||
}
|
|
||||||
|
|
||||||
const PageSize int64 = 36
|
const PageSize int64 = 36
|
||||||
|
|
||||||
func GetTotalPage(total int64, page int64) int64 {
|
func GetTotalPage(total int64, page int64) int64 {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import (
|
|||||||
"videoweb/pub/common/laosiji"
|
"videoweb/pub/common/laosiji"
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/srvversion"
|
"videoweb/pub/common/srvversion"
|
||||||
"videoweb/pub/dataReport"
|
|
||||||
"videoweb/pub/esmanager"
|
"videoweb/pub/esmanager"
|
||||||
"videoweb/pub/models"
|
"videoweb/pub/models"
|
||||||
"videoweb/pub/mongos"
|
"videoweb/pub/mongos"
|
||||||
@@ -77,10 +76,6 @@ func Run(args []string) {
|
|||||||
initLaosiji()
|
initLaosiji()
|
||||||
mongos.StartLid()
|
mongos.StartLid()
|
||||||
initData()
|
initData()
|
||||||
dataReport.Init(dataReport.Config{
|
|
||||||
ApiUrl: webg.Conf.DataReport.Url,
|
|
||||||
RunMod: webg.Conf.RunMod,
|
|
||||||
})
|
|
||||||
|
|
||||||
initHttpServer()
|
initHttpServer()
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"videoweb/app/service/reportser"
|
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/response"
|
"videoweb/pub/common/response"
|
||||||
"videoweb/pub/common/srvdef"
|
"videoweb/pub/common/srvdef"
|
||||||
@@ -407,31 +406,9 @@ func SetPlayletStatus(ctx context.Context, req *proto.PlayletStatusSetReq) *srvd
|
|||||||
log.Error("短剧状态同步ES失败", log.Any("短剧ID", syncIds), log.Any("状态", syncStatus), log.E(err))
|
log.Error("短剧状态同步ES失败", log.Any("短剧ID", syncIds), log.Any("状态", syncStatus), log.E(err))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if flag := reportser.PlayletStatusFlag(req.Status); flag != 0 {
|
|
||||||
reportPlayletStatusEvents(ctx, ids, flag)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func reportPlayletStatusEvents(ctx context.Context, ids []int64, flag int64) {
|
|
||||||
if len(ids) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
list, err := playletmod.FindManyPlaylet(ctx, bson.M{playletmod.FN.Playlet.Id: bson.M{"$in": ids}}, options.Find().SetProjection(bson.D{
|
|
||||||
{Key: playletmod.FN.Playlet.Id, Value: 1},
|
|
||||||
{Key: playletmod.FN.Playlet.Title, Value: 1},
|
|
||||||
{Key: playletmod.FN.Playlet.CategoryIds, Value: 1},
|
|
||||||
{Key: playletmod.FN.Playlet.MediaCenterId, Value: 1},
|
|
||||||
}))
|
|
||||||
if err != nil {
|
|
||||||
log.Error("短剧状态变更上报查询失败", log.Any("短剧ID", ids), log.E(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, item := range list {
|
|
||||||
reportser.ReportPlayletStatusChange(item, flag)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetPlayletRecommend 单/批量设置短剧是否推荐
|
// SetPlayletRecommend 单/批量设置短剧是否推荐
|
||||||
func SetPlayletRecommend(ctx context.Context, req *proto.PlayletRecommendSetReq) *srvdef.SrvErr {
|
func SetPlayletRecommend(ctx context.Context, req *proto.PlayletRecommendSetReq) *srvdef.SrvErr {
|
||||||
if req == nil {
|
if req == nil {
|
||||||
|
|||||||
@@ -2,18 +2,11 @@ package srv_recharge
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/md5"
|
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/srvdef"
|
"videoweb/pub/common/srvdef"
|
||||||
"videoweb/pub/common/useragent"
|
|
||||||
"videoweb/pub/dataReport"
|
|
||||||
"videoweb/pub/models/cointransmod"
|
"videoweb/pub/models/cointransmod"
|
||||||
"videoweb/pub/models/eventmod"
|
|
||||||
"videoweb/pub/models/rechargepackagemod"
|
"videoweb/pub/models/rechargepackagemod"
|
||||||
"videoweb/pub/models/usermod"
|
"videoweb/pub/models/usermod"
|
||||||
"videoweb/pub/models/vipordermod"
|
"videoweb/pub/models/vipordermod"
|
||||||
@@ -120,7 +113,6 @@ func handleVipOrderSuccess(order vipordermod.VipOrder, oid string, realAmount in
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
reportVipOrderPaid(ctx, &order, oid, realAmount, expire)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleCoinOrderSuccess(order vipordermod.VipOrder, oid string, realAmount int64) {
|
func handleCoinOrderSuccess(order vipordermod.VipOrder, oid string, realAmount int64) {
|
||||||
@@ -146,7 +138,6 @@ func handleCoinOrderSuccess(order vipordermod.VipOrder, oid string, realAmount i
|
|||||||
Remark: payment.CoinTransRemark(cointransmod.TranTypeCoinRecharge, ""),
|
Remark: payment.CoinTransRemark(cointransmod.TranTypeCoinRecharge, ""),
|
||||||
})
|
})
|
||||||
|
|
||||||
reportCoinOrderPaid(ctx, &order, oid, realAmount)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolvePaymentAt(param *BillCallbackParam) time.Time {
|
func resolvePaymentAt(param *BillCallbackParam) time.Time {
|
||||||
@@ -179,80 +170,3 @@ func addUserCoins(ctx context.Context, userId int64, coin int64) *srvdef.SrvErr
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reportVipOrderPaid(ctx context.Context, order *vipordermod.VipOrder, oid string, realAmount int64, vipExpire time.Time) {
|
|
||||||
user, _ := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: order.UserId})
|
|
||||||
districtCode, ip := "", order.IPAddr
|
|
||||||
if user != nil {
|
|
||||||
districtCode = user.DistrictCode
|
|
||||||
}
|
|
||||||
|
|
||||||
ua := useragent.UA{SysType: order.SysType}
|
|
||||||
eventId := newEventId(pubdef.TrackerAppId(), order.UserId, order.TradeNo, order.CreatedAt.Unix())
|
|
||||||
cf := dataReport.NewCommonField(eventId, dataReport.EventTypeOrderPaid, districtCode, ua, strconv.FormatInt(user.Id, 10), ip)
|
|
||||||
|
|
||||||
var expireTS int64
|
|
||||||
if !vipExpire.IsZero() {
|
|
||||||
expireTS = vipExpire.Unix()
|
|
||||||
}
|
|
||||||
cf.Payload = dataReport.JsonRawMessage(&dataReport.OrderPaidEvent{
|
|
||||||
OrderID: order.TradeNo,
|
|
||||||
OrderType: "vip_subscription",
|
|
||||||
ProductID: strconv.FormatInt(order.CardId, 10),
|
|
||||||
Amount: dataReport.JsonNumber(realAmount),
|
|
||||||
Currency: "CNY",
|
|
||||||
VIPExpirationTime: dataReport.JsonNumber(expireTS),
|
|
||||||
PayType: order.PayMode,
|
|
||||||
PayChannel: order.PayChannel,
|
|
||||||
TransactionID: oid,
|
|
||||||
CreateTime: dataReport.JsonNumber(order.CreatedAt.Unix()),
|
|
||||||
})
|
|
||||||
insertEvent(ctx, cf, order.TradeNo)
|
|
||||||
}
|
|
||||||
|
|
||||||
func reportCoinOrderPaid(ctx context.Context, order *vipordermod.VipOrder, oid string, realAmount int64) {
|
|
||||||
user, _ := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: order.UserId})
|
|
||||||
districtCode, ip := "", order.IPAddr
|
|
||||||
if user != nil {
|
|
||||||
districtCode = user.DistrictCode
|
|
||||||
}
|
|
||||||
|
|
||||||
ua := useragent.UA{SysType: order.SysType}
|
|
||||||
eventId := newEventId(pubdef.TrackerAppId(), order.UserId, order.TradeNo, order.CreatedAt.Unix())
|
|
||||||
cf := dataReport.NewCommonField(eventId, dataReport.EventTypeOrderPaid, districtCode, ua, strconv.FormatInt(user.Id, 10), ip)
|
|
||||||
|
|
||||||
cf.Payload = dataReport.JsonRawMessage(&dataReport.OrderPaidEvent{
|
|
||||||
OrderID: order.TradeNo,
|
|
||||||
OrderType: "coin_purchase",
|
|
||||||
ProductID: strconv.FormatInt(order.CoinCfgId, 10),
|
|
||||||
Amount: dataReport.JsonNumber(realAmount),
|
|
||||||
Currency: "CNY",
|
|
||||||
CoinQuantity: dataReport.JsonNumber(order.Coin),
|
|
||||||
PayType: order.PayMode,
|
|
||||||
PayChannel: order.PayChannel,
|
|
||||||
TransactionID: oid,
|
|
||||||
CreateTime: dataReport.JsonNumber(order.CreatedAt.Unix()),
|
|
||||||
})
|
|
||||||
insertEvent(ctx, cf, order.TradeNo)
|
|
||||||
}
|
|
||||||
|
|
||||||
func insertEvent(ctx context.Context, cf dataReport.CommonField, tradeNo string) {
|
|
||||||
data, _ := json.Marshal(cf)
|
|
||||||
if err := eventmod.InsertOneEvent(ctx, &eventmod.Event{
|
|
||||||
EventId: cf.EventID,
|
|
||||||
EventType: cf.Event,
|
|
||||||
Data: string(data),
|
|
||||||
Status: eventmod.Default,
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
}); err != nil {
|
|
||||||
log.Error("insertEvent failed", log.Any("tradeNo", tradeNo), log.E(err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newEventId(appId string, uid int64, orderId interface{}, createTime int64) string {
|
|
||||||
input := fmt.Sprintf("%v%v%v%v", appId, uid, orderId, createTime)
|
|
||||||
h := md5.New()
|
|
||||||
h.Write([]byte(input))
|
|
||||||
return hex.EncodeToString(h.Sum(nil))
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
package srv_report
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
"videoweb/pub/common/log"
|
|
||||||
"videoweb/pub/common/useragent"
|
|
||||||
"videoweb/pub/dataReport"
|
|
||||||
"videoweb/pub/models/eventmod"
|
|
||||||
"videoweb/pub/models/videocategorymod"
|
|
||||||
"videoweb/pub/models/videoinformationmod"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ReportVideoStatusChangeEvent 视频状态变更事件上报
|
|
||||||
func ReportVideoStatusChangeEvent(media *videoinformationmod.VideoInformation, flag, userId int64, ua useragent.UA) {
|
|
||||||
if media == nil || media.Id == 0 || flag == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var lsjId string
|
|
||||||
|
|
||||||
var videoTypeID = "default"
|
|
||||||
var videoTypeName = "默认分类"
|
|
||||||
if len(media.CategoryIds) > 0 {
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
|
|
||||||
defer cancel()
|
|
||||||
category, _ := videocategorymod.FindOneVideoCategory(ctx, bson.M{
|
|
||||||
videocategorymod.FN.VideoCategory.Id: media.CategoryIds[0],
|
|
||||||
})
|
|
||||||
if category != nil {
|
|
||||||
videoTypeID = fmt.Sprintf("%v", category.Id)
|
|
||||||
videoTypeName = category.Name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
event := dataReport.NewCommonField("", dataReport.EventTypeVideoStatusChange, "", ua, strconv.FormatInt(userId, 10), "")
|
|
||||||
|
|
||||||
event.Payload = dataReport.JsonRawMessage(&dataReport.VideoStatusChangeEvent{
|
|
||||||
MediaId: lsjId,
|
|
||||||
VideoID: fmt.Sprintf("%v", media.Id),
|
|
||||||
VideoTitle: media.Title,
|
|
||||||
VideoTypeID: videoTypeID,
|
|
||||||
VideoTypeName: videoTypeName,
|
|
||||||
Flag: dataReport.JsonNumber(flag),
|
|
||||||
})
|
|
||||||
b, _ := json.Marshal(event)
|
|
||||||
if err := eventmod.InsertOneEvent(context.Background(), &eventmod.Event{
|
|
||||||
EventId: event.EventID,
|
|
||||||
EventType: event.Event,
|
|
||||||
Data: string(b),
|
|
||||||
Status: eventmod.Default,
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
}); err != nil {
|
|
||||||
log.Error("ReportVideoStatusChangeEvent fail", log.Any("mediaId", media.Id), log.E(err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// VideoStatusFlag 将媒体状态映射为上报flag
|
|
||||||
func VideoStatusFlag(status videoinformationmod.InformationSatus) int64 {
|
|
||||||
switch status {
|
|
||||||
case videoinformationmod.InformationSatusVerifyOK:
|
|
||||||
return 1 // 上架
|
|
||||||
case videoinformationmod.InformationSatusVerifyCancel:
|
|
||||||
return 2 // 未通过
|
|
||||||
default:
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
"videoweb/pub/common/godef"
|
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/srvdef"
|
"videoweb/pub/common/srvdef"
|
||||||
"videoweb/pub/common/useragent"
|
"videoweb/pub/common/useragent"
|
||||||
@@ -15,7 +14,6 @@ import (
|
|||||||
"videoweb/pub/mongos"
|
"videoweb/pub/mongos"
|
||||||
"videoweb/pub/storage"
|
"videoweb/pub/storage"
|
||||||
"videoweb/pub/storage/proxy"
|
"videoweb/pub/storage/proxy"
|
||||||
"videoweb/web/service/srv_report"
|
|
||||||
"videoweb/web/service/srv_search"
|
"videoweb/web/service/srv_search"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
@@ -324,15 +322,6 @@ func UpdateVideoInfo(ctx context.Context, id, userId int64, param VideoInfoUpdat
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
if param.Status != nil && info.Status != *param.Status {
|
|
||||||
if flag := srv_report.VideoStatusFlag(*param.Status); flag != 0 {
|
|
||||||
mediaCopy := *info
|
|
||||||
mediaCopy.Status = *param.Status
|
|
||||||
godef.Go(func() {
|
|
||||||
srv_report.ReportVideoStatusChangeEvent(&mediaCopy, flag, userId, ua)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
package job
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"videoweb/pub/common/log"
|
|
||||||
"videoweb/pub/dataReport"
|
|
||||||
"videoweb/pub/models/eventmod"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
|
||||||
)
|
|
||||||
|
|
||||||
var isRuining = false
|
|
||||||
|
|
||||||
const (
|
|
||||||
maxRetryCount = 10 // 最大重试次数
|
|
||||||
maxReportNum = 100 // 最大上报数
|
|
||||||
)
|
|
||||||
|
|
||||||
func Report() {
|
|
||||||
//防止重入
|
|
||||||
if isRuining {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
isRuining = true
|
|
||||||
defer func() {
|
|
||||||
isRuining = false
|
|
||||||
}()
|
|
||||||
ctx := context.Background()
|
|
||||||
opts := options.Find()
|
|
||||||
opts = opts.SetSort(bson.D{{Key: "_id", Value: 1}}).SetLimit(1000)
|
|
||||||
// 查询出一千条记录批量上传
|
|
||||||
list, stdErr := eventmod.FindManyEvent(ctx, bson.M{
|
|
||||||
"$or": []bson.M{
|
|
||||||
bson.M{
|
|
||||||
"status": eventmod.Default,
|
|
||||||
},
|
|
||||||
bson.M{
|
|
||||||
"status": eventmod.Failure,
|
|
||||||
"retryCount": bson.M{"$lte": maxRetryCount},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}, opts)
|
|
||||||
if stdErr != nil {
|
|
||||||
log.Error("Get event list error", log.E(stdErr))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(list) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var eventList []*dataReport.CommonField
|
|
||||||
for _, v := range list {
|
|
||||||
event := &dataReport.CommonField{}
|
|
||||||
err := json.Unmarshal([]byte(v.Data), &event)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("event report json.Unmarshal fail", log.Any("eventData", v.Data), log.E(err))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
eventList = append(eventList, event)
|
|
||||||
if len(eventList) < maxReportNum {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// 批量上报
|
|
||||||
err = dataReport.BatchReport(ctx, eventList)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Batch report error", log.E(err))
|
|
||||||
// 将这些设置为失败
|
|
||||||
onReportEventFail(ctx, eventList)
|
|
||||||
} else {
|
|
||||||
onReportEventSuccess(ctx, eventList)
|
|
||||||
}
|
|
||||||
eventList = []*dataReport.CommonField{} // 重新变成0个
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将剩余的批量上报
|
|
||||||
err := dataReport.BatchReport(ctx, eventList)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Batch report error", log.E(err))
|
|
||||||
// 将这些设置为失败
|
|
||||||
onReportEventFail(ctx, eventList)
|
|
||||||
} else {
|
|
||||||
onReportEventSuccess(ctx, eventList)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func onReportEventSuccess(ctx context.Context, eventList []*dataReport.CommonField) {
|
|
||||||
eventIds := []string{}
|
|
||||||
for _, v := range eventList {
|
|
||||||
eventIds = append(eventIds, v.EventID)
|
|
||||||
}
|
|
||||||
if len(eventIds) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err := eventmod.UpdateManyEvent(ctx, bson.M{
|
|
||||||
"eventId": bson.M{"$in": eventIds},
|
|
||||||
}, bson.M{
|
|
||||||
"$set": bson.M{"status": eventmod.Success},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Update event fail", log.E(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func onReportEventFail(ctx context.Context, eventList []*dataReport.CommonField) {
|
|
||||||
eventIds := []string{}
|
|
||||||
for _, v := range eventList {
|
|
||||||
eventIds = append(eventIds, v.EventID)
|
|
||||||
}
|
|
||||||
if len(eventIds) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err := eventmod.UpdateManyEvent(ctx, bson.M{
|
|
||||||
"eventId": bson.M{"$in": eventIds},
|
|
||||||
}, bson.M{
|
|
||||||
"$set": bson.M{"status": eventmod.Failure},
|
|
||||||
"$inc": bson.M{"retryCount": 1},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Update event fail", log.E(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/web/service/srv_mediaresource"
|
"videoweb/web/service/srv_mediaresource"
|
||||||
job "videoweb/web/skd/job/reportdata"
|
|
||||||
"videoweb/web/skd/job/vipexpiry"
|
"videoweb/web/skd/job/vipexpiry"
|
||||||
"videoweb/web/skd/playletwatermark"
|
"videoweb/web/skd/playletwatermark"
|
||||||
|
|
||||||
@@ -41,10 +40,6 @@ func Start() {
|
|||||||
srv_mediaresource.EnqueuePlayletCoverCompressJobs()
|
srv_mediaresource.EnqueuePlayletCoverCompressJobs()
|
||||||
})
|
})
|
||||||
|
|
||||||
_, _ = skdCron.AddFunc("0/1 * * * * ?", func() { // 每秒执行一次批量上报
|
|
||||||
job.Report()
|
|
||||||
})
|
|
||||||
|
|
||||||
// 每天凌晨 02:00 重置 VIP 已过期用户的 VipType
|
// 每天凌晨 02:00 重置 VIP 已过期用户的 VipType
|
||||||
_, _ = skdCron.AddFunc("0 0 2 * * ?", func() {
|
_, _ = skdCron.AddFunc("0 0 2 * * ?", func() {
|
||||||
vipexpiry.ResetExpiredVip()
|
vipexpiry.ResetExpiredVip()
|
||||||
|
|||||||
@@ -55,9 +55,6 @@ type GlobalCfgEx struct {
|
|||||||
Secret string `yaml:"secret"` // 商户密钥
|
Secret string `yaml:"secret"` // 商户密钥
|
||||||
} `yaml:"playletMediaResourceDBCfg"`
|
} `yaml:"playletMediaResourceDBCfg"`
|
||||||
NewInnerStatUrl string `yaml:"newInnerStatUrl"`
|
NewInnerStatUrl string `yaml:"newInnerStatUrl"`
|
||||||
DataReport struct {
|
|
||||||
Url string `yaml:"url"`
|
|
||||||
} `yaml:"dataReport"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsDev() bool {
|
func IsDev() bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user