同步 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:
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user