Remove 买点 (user acquisition tracking) subsystem
Delete the dataReport SDK, event storage model, and scheduled uploader, along with the reportser/srv_report wrapper services and all ~20 Report* call sites in business code. Also drop the ReportSDKConfig field from the APP config response, the TrackerAppId helper, and the related dataReport yaml config block. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user