同步 web_hga 的五项改造
- 移除 买点 (user acquisition tracking) 子系统:dataReport SDK、eventmod 事件模型、reportdata 定时上报 job、reportser/srv_report 包装层,以及业务 侧的 ~20 处 Report* 调用点;去掉 proto.ConfigInfo 的 ReportSDKConfig 字段、DataReport yaml 配置块和 pubdef.TrackerAppId。 - 广告获取改走 versionUrl /api/stat/advitise/v2/get(appId=12),移除 adcenter(Jt) 调用;新增 POST /api/app/ads/click 异步上报; proto.AdvitiseData 别名 proxy.AdvitiseData,AList/BList 改名 AppInfoAList/AppInfoBList。 - web 后台登录取消谷歌验证码(srv_mwacc.AccLogin 去掉 code 参数),密码 正确即发放 token。 - app 端取消注册/登录/找回密码/游客登录接口及密码、token 相关代码;鉴权 中间件按 X-User-Agent 中的 devID 识别用户,首次访问自动建号,Redis 缓存 10 分钟;修改资料不再支持改密码。 - app m3u8 ticket 校验失败不再降级到 fallback 路径,仍按原 m3u8Name 返回。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,7 @@ func AccLogin(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
accInfo, err := srv_mwacc.AccLogin(c, req.Acc, req.Pwd, req.Code)
|
||||
accInfo, err := srv_mwacc.AccLogin(c, req.Acc, req.Pwd)
|
||||
if err != nil || accInfo == nil {
|
||||
common.ServerJSON(c, err.Code, err.Msg)
|
||||
return
|
||||
|
||||
+8
-25
@@ -1,28 +1,11 @@
|
||||
#!/bin/bash
|
||||
FILE_NAME="web_mdcom_web"
|
||||
REMOTE_FILE_PATH="/home/server2/web_mdcom/web/"
|
||||
TAG_NAME="web_mdcom_web.tar.gz"
|
||||
echo "开始"
|
||||
rm -rf ./web_hgc_web ./web_hgc_web.tar.gz
|
||||
GOOS=linux GOARCH=amd64 go build -o web_hgc_web
|
||||
tar zvcf web_hgc_web.tar.gz web_hgc_web
|
||||
|
||||
set -e
|
||||
set -o
|
||||
function send_msg() {
|
||||
msg="@jscdsndj @xiuyuan_Lee @steven0yu %0A服务:SERVER2 站点-91spz.com管理服务(WEB)%0A更新内容:$content%0A创建时间: $(date +%F_%X)%0A操作人:$(git config user.name)"
|
||||
curl -X POST "https://api.telegram.org/bot6357085965:AAEmXfjZnZwnDTicL7Wjbd7cXvYv_G98w8A/sendMessage" -d "chat_id=$1&text=$msg" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
read -p "输入yes, 开始上传: " word
|
||||
if [[ ! "yes" =~ $word ]]; then
|
||||
echo "终止"
|
||||
else
|
||||
read -e -p "本次更新内容(输入q退出编辑): " -r content
|
||||
echo "开始"
|
||||
rm -rf ./$FILE_NAME ./$TAG_NAME ./yinsemd5.txt
|
||||
GOOS=linux GOARCH=amd64 go build -o $FILE_NAME
|
||||
md5sum $FILE_NAME | cut -d ' ' -f1 >yinsemd5.txt
|
||||
tar zvcf $TAG_NAME ./$FILE_NAME yinsemd5.txt
|
||||
md5sum $TAG_NAME | cut -d ' ' -f1 >yinsemd5.txt
|
||||
scp -i ~/.ssh/id_rsa -P 22889 ./yinsemd5.txt server2@116.212.120.2:$REMOTE_FILE_PATH
|
||||
scp -i ~/.ssh/id_rsa -P 22889 ./$TAG_NAME server2@116.212.120.2:$REMOTE_FILE_PATH
|
||||
send_msg -4791758991 #服务器小组
|
||||
fi
|
||||
rm -rf ./$FILE_NAME ./$TAG_NAME ./yinsemd5.txt
|
||||
scp web_hgc_web.tar.gz root@172.104.166.87:/data/uzip
|
||||
ssh root@172.104.166.87 "/server/web_hgc/web/up_app.sh"
|
||||
|
||||
rm -rf ./web_hgc_web ./web_hgc_web.tar.gz
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
sudo make test
|
||||
|
||||
scp -P 22889 web_91av_web.tar.gz root@172.104.181.99:/server/web_91av/web/
|
||||
ssh root@172.104.181.99 -p 22889 "cd /server/web_91av/web/ && /bin/tar -xf /server/web_91av/web/web_91av_web.tar.gz && /usr/bin/supervisorctl restart web_91av_web"
|
||||
if [ $? -eq 0 ];then
|
||||
echo -e "\033[32m 91spz.com web更新成功 \033[0m"
|
||||
else
|
||||
echo -e "\033[31m 91spz.com web更新失败 \033[0m"
|
||||
fi
|
||||
rm -f web_91av_web.tar.gz
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"videoweb/pub/common/laosiji"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/srvversion"
|
||||
"videoweb/pub/dataReport"
|
||||
"videoweb/pub/esmanager"
|
||||
"videoweb/pub/models"
|
||||
"videoweb/pub/mongos"
|
||||
@@ -80,10 +79,6 @@ func Run(args []string) {
|
||||
mongos.StartLid()
|
||||
initData()
|
||||
initSeoPush()
|
||||
dataReport.Init(dataReport.Config{
|
||||
ApiUrl: webg.Conf.DataReport.Url,
|
||||
RunMod: webg.Conf.RunMod,
|
||||
})
|
||||
|
||||
initHttpServer()
|
||||
|
||||
|
||||
@@ -9,11 +9,9 @@ import (
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/common/utils"
|
||||
"videoweb/pub/google"
|
||||
"videoweb/pub/models/mwacc"
|
||||
"videoweb/web/webg"
|
||||
|
||||
"github.com/skip2/go-qrcode"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
@@ -78,8 +76,8 @@ func isCustomerServiceRole(ctx context.Context, acc *mwacc.MwAcc) bool {
|
||||
return strings.Contains(roleName, "客服")
|
||||
}
|
||||
|
||||
// 账号登录
|
||||
func AccLogin(ctx context.Context, acc string, pwd string, code string) (*mwacc.MwAcc, *srvdef.SrvErr) {
|
||||
// 账号登录(已取消谷歌验证,密码正确即登录)
|
||||
func AccLogin(ctx context.Context, acc string, pwd string) (*mwacc.MwAcc, *srvdef.SrvErr) {
|
||||
var data *mwacc.MwAcc
|
||||
res, dataErr := mwacc.FindOneAccByFilter(ctx, bson.M{
|
||||
mwacc.FN.MwAcc.Acc: acc,
|
||||
@@ -99,43 +97,18 @@ func AccLogin(ctx context.Context, acc string, pwd string, code string) (*mwacc.
|
||||
return data, srvdef.New(srvdef.AccountErrPasswordError, srvdef.AccountErrPasswordError.Msg(), "")
|
||||
}
|
||||
|
||||
if !res.IsBase32 {
|
||||
// 谷歌绑定二维码
|
||||
googleUrl := google.NewGoogleAuth().GetQrcode(acc, res.Base32)
|
||||
qrCodePNG, _ := qrcode.Encode(googleUrl, qrcode.Medium, 256)
|
||||
|
||||
bq := &mwacc.MwAcc{}
|
||||
bq.Qurl = qrCodePNG
|
||||
data = bq
|
||||
} else {
|
||||
// hf屏蔽
|
||||
if webg.Conf.RunMod == "prod" && (res.RoleId != 46761 && res.RoleId != 29601) {
|
||||
if code == "" {
|
||||
return data, srvdef.New(srvdef.ErrCaptcha, srvdef.ErrCaptcha.Msg(), "")
|
||||
}
|
||||
result, Verr := google.NewGoogleAuth().VerifyCode(res.Base32, code)
|
||||
if Verr != nil || !result {
|
||||
return data, srvdef.New(srvdef.ErrCaptchaInvalid, srvdef.ErrCaptchaInvalid.Msg(), "")
|
||||
}
|
||||
}
|
||||
// 通过验证,再次验证密码是否正确
|
||||
pwd := crypt.StrToMd5(pwd)
|
||||
if res.Pwd != pwd {
|
||||
return data, srvdef.New(srvdef.AccountErrPasswordError, srvdef.AccountErrPasswordError.Msg(), "")
|
||||
}
|
||||
getToken, err := generateToken(res.Id)
|
||||
if err != nil {
|
||||
return data, srvdef.New(srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg(), "")
|
||||
}
|
||||
_ = mwacc.UpOneAccByFilter(ctx, bson.M{
|
||||
mwacc.FN.MwAcc.Id: res.Id,
|
||||
}, bson.M{
|
||||
mwacc.FN.MwAcc.LastTime: time.Now(),
|
||||
})
|
||||
// 更新最近登录时间
|
||||
data = res
|
||||
data.Token = getToken
|
||||
getToken, err := generateToken(res.Id)
|
||||
if err != nil {
|
||||
return data, srvdef.New(srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg(), "")
|
||||
}
|
||||
// 更新最近登录时间
|
||||
_ = mwacc.UpOneAccByFilter(ctx, bson.M{
|
||||
mwacc.FN.MwAcc.Id: res.Id,
|
||||
}, bson.M{
|
||||
mwacc.FN.MwAcc.LastTime: time.Now(),
|
||||
})
|
||||
data = res
|
||||
data.Token = getToken
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"videoweb/app/service/reportser"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/response"
|
||||
"videoweb/pub/common/srvdef"
|
||||
@@ -520,9 +519,6 @@ func SetPlayletStatus(ctx context.Context, req *proto.PlayletStatusSetReq) *srvd
|
||||
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)
|
||||
}
|
||||
if req.Status == playletmod.StatusUp {
|
||||
submitPlayletAiComments(ids...)
|
||||
}
|
||||
@@ -541,24 +537,6 @@ func submitPlayletAiComments(ids ...int64) {
|
||||
}()
|
||||
}
|
||||
|
||||
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.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 单/批量设置短剧是否推荐
|
||||
func SetPlayletRecommend(ctx context.Context, req *proto.PlayletRecommendSetReq) *srvdef.SrvErr {
|
||||
if req == nil {
|
||||
|
||||
@@ -2,17 +2,11 @@ package srv_recharge
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/dataReport"
|
||||
"videoweb/pub/models/cointransmod"
|
||||
"videoweb/pub/models/eventmod"
|
||||
"videoweb/pub/models/rechargepackagemod"
|
||||
"videoweb/pub/models/usermod"
|
||||
"videoweb/pub/models/vipordermod"
|
||||
@@ -73,19 +67,18 @@ func OnPayCenterCallback(ctx *gin.Context, param *BillCallbackParam) *srvdef.Srv
|
||||
|
||||
orderSnap := *order
|
||||
realAmount := param.RealAmount
|
||||
oid := param.Oid
|
||||
|
||||
switch order.OrderType {
|
||||
case vipordermod.OrderTypeCoin:
|
||||
go handleCoinOrderSuccess(orderSnap, oid, realAmount)
|
||||
go handleCoinOrderSuccess(orderSnap, realAmount)
|
||||
default:
|
||||
go handleVipOrderSuccess(orderSnap, oid, realAmount)
|
||||
go handleVipOrderSuccess(orderSnap, realAmount)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleVipOrderSuccess(order vipordermod.VipOrder, oid string, realAmount int64) {
|
||||
func handleVipOrderSuccess(order vipordermod.VipOrder, realAmount int64) {
|
||||
ctx := context.Background()
|
||||
|
||||
pkg, err := findVipPackage(ctx, order.CardId)
|
||||
@@ -118,11 +111,9 @@ func handleVipOrderSuccess(order vipordermod.VipOrder, oid string, realAmount in
|
||||
Remark: payment.CoinTransRemark(cointransmod.TranTypeVipGiftCoin, pkg.Name),
|
||||
})
|
||||
}
|
||||
|
||||
reportVipOrderPaid(ctx, &order, oid, realAmount, expire)
|
||||
}
|
||||
|
||||
func handleCoinOrderSuccess(order vipordermod.VipOrder, oid string, realAmount int64) {
|
||||
func handleCoinOrderSuccess(order vipordermod.VipOrder, realAmount int64) {
|
||||
ctx := context.Background()
|
||||
|
||||
if err := addUserCoins(ctx, order.UserId, order.Coin); err != nil {
|
||||
@@ -137,8 +128,6 @@ func handleCoinOrderSuccess(order vipordermod.VipOrder, oid string, realAmount i
|
||||
log.Info("handleCoinOrderSuccess done", log.Any("userId", order.UserId), log.Any("coin", order.Coin))
|
||||
|
||||
writeCoinOrderTrans(ctx, order)
|
||||
|
||||
reportCoinOrderPaid(ctx, &order, oid, realAmount)
|
||||
}
|
||||
|
||||
func writeCoinOrderTrans(ctx context.Context, order vipordermod.VipOrder) {
|
||||
@@ -229,79 +218,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 := order.Client.UA(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 := order.Client.UA(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"
|
||||
"net/http"
|
||||
"time"
|
||||
"videoweb/pub/common/godef"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/playletcache"
|
||||
"videoweb/pub/common/srvdef"
|
||||
@@ -17,7 +16,6 @@ import (
|
||||
"videoweb/pub/seo/sitemapdirty"
|
||||
"videoweb/pub/storage"
|
||||
"videoweb/pub/storage/proxy"
|
||||
"videoweb/web/service/srv_report"
|
||||
"videoweb/web/service/srv_search"
|
||||
"videoweb/web/service/srv_seopush"
|
||||
"videoweb/web/service/srv_videoslug"
|
||||
@@ -353,15 +351,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)
|
||||
})
|
||||
}
|
||||
}
|
||||
sitemapdirty.Mark(ctx)
|
||||
if param.Status != nil {
|
||||
if *param.Status == videoinformationmod.InformationSatusVerifyOK &&
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/web/service/srv_aicomment"
|
||||
"videoweb/web/service/srv_mediaresource"
|
||||
job "videoweb/web/skd/job/reportdata"
|
||||
seopushjob "videoweb/web/skd/job/seopush"
|
||||
"videoweb/web/skd/job/vipexpiry"
|
||||
"videoweb/web/skd/playletwatermark"
|
||||
@@ -64,10 +63,6 @@ func Start() {
|
||||
srv_mediaresource.StartCGDJOriginalBackfillOnce(context.Background())
|
||||
go srv_mediaresource.RefreshAIContentBackflowTodayStats()
|
||||
|
||||
_, _ = skdCron.AddFunc("0/1 * * * * ?", func() { // 每秒执行一次批量上报
|
||||
job.Report()
|
||||
})
|
||||
|
||||
// 每天凌晨 02:00 重置 VIP 已过期用户的 VipType
|
||||
_, _ = skdCron.AddFunc("0 0 2 * * ?", func() {
|
||||
vipexpiry.ResetExpiredVip()
|
||||
|
||||
+1
-4
@@ -57,10 +57,7 @@ type GlobalCfgEx struct {
|
||||
Secret string `yaml:"secret"` // 商户密钥
|
||||
} `yaml:"playletMediaResourceDBCfg"`
|
||||
NewInnerStatUrl string `yaml:"newInnerStatUrl"`
|
||||
DataReport struct {
|
||||
Url string `yaml:"url"`
|
||||
} `yaml:"dataReport"`
|
||||
AiComment struct {
|
||||
AiComment struct {
|
||||
Url string `yaml:"url"`
|
||||
AppId string `yaml:"appId"`
|
||||
Secret string `yaml:"secret"`
|
||||
|
||||
Reference in New Issue
Block a user