|
|
package fissionaction
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"joybuywork/internal/consts"
|
|
|
"joybuywork/internal/plugins/hashid"
|
|
|
"joybuywork/internal/plugins/jsonm"
|
|
|
"joybuywork/internal/repository/cache"
|
|
|
"joybuywork/internal/repository/dao"
|
|
|
"joybuywork/internal/repository/model"
|
|
|
"joybuywork/internal/repository/mtype"
|
|
|
"joybuywork/internal/service/queue/producer"
|
|
|
"joybuywork/internal/service/queue/types"
|
|
|
"joybuywork/internal/utils"
|
|
|
"fmt"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
type identify struct {
|
|
|
campaignId int64
|
|
|
userMark string
|
|
|
userMarkSource int8
|
|
|
isView bool // 是否一个预览用户
|
|
|
}
|
|
|
|
|
|
type pointOnce struct {
|
|
|
t int32 // 埋点类型
|
|
|
at int64 // 行为时间
|
|
|
|
|
|
otherData *types.FissionActionOtherData
|
|
|
opts []Option
|
|
|
}
|
|
|
|
|
|
type MarkPoint struct {
|
|
|
ctx context.Context
|
|
|
|
|
|
p producer.FissionBiReceiver
|
|
|
|
|
|
dimension mtype.Dimension
|
|
|
identify identify
|
|
|
|
|
|
batch bool
|
|
|
|
|
|
points []*pointOnce
|
|
|
actions []*model.FissionAction
|
|
|
afterDo []func()
|
|
|
|
|
|
timezone []int32
|
|
|
}
|
|
|
|
|
|
func NewMarkPoint(ctx context.Context, opts ...BPOption) *MarkPoint {
|
|
|
markPoint := &MarkPoint{
|
|
|
ctx: ctx,
|
|
|
p: producer.NewFissionBiReceiver(ctx),
|
|
|
}
|
|
|
|
|
|
for _, opt := range opts {
|
|
|
opt(markPoint)
|
|
|
}
|
|
|
|
|
|
return markPoint
|
|
|
}
|
|
|
|
|
|
func (s *MarkPoint) append(t int32, at int64, otherData *types.FissionActionOtherData, opts ...Option) {
|
|
|
if s.batch {
|
|
|
s.points = append(s.points, &pointOnce{
|
|
|
t: t,
|
|
|
at: at,
|
|
|
otherData: otherData,
|
|
|
opts: opts,
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
s.pub(t, at, otherData, opts...)
|
|
|
}
|
|
|
|
|
|
func (s *MarkPoint) appendDo(fc func()) {
|
|
|
s.afterDo = append(s.afterDo, fc)
|
|
|
}
|
|
|
|
|
|
// Push 推送
|
|
|
func (s *MarkPoint) Push() {
|
|
|
for _, point := range s.points {
|
|
|
s.pub(point.t, point.at, point.otherData, point.opts...)
|
|
|
}
|
|
|
|
|
|
s.after()
|
|
|
|
|
|
// 推送之后要重制一下值
|
|
|
s.points, s.actions, s.afterDo = nil, nil, nil
|
|
|
}
|
|
|
|
|
|
func (s *MarkPoint) pub(t int32, at int64, otherData *types.FissionActionOtherData, opts ...Option) {
|
|
|
if s.identify.isView {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
dms := s.dimension
|
|
|
|
|
|
for _, opt := range opts {
|
|
|
opt(&dms.DimensionOption)
|
|
|
}
|
|
|
|
|
|
otherStr, _ := jsonm.MarshalToString(otherData)
|
|
|
tz := s.timezones()
|
|
|
|
|
|
data := types.FissionAction{
|
|
|
ID: hashid.IdBigint(),
|
|
|
CampaignID: s.identify.campaignId,
|
|
|
UserMark: s.identify.userMark,
|
|
|
UserMarkSource: s.identify.userMarkSource,
|
|
|
Type: t,
|
|
|
ActionTime: at,
|
|
|
Dimension: dms,
|
|
|
OtherData: otherStr,
|
|
|
Timezone: tz,
|
|
|
}
|
|
|
|
|
|
s.p.FissionAction(data)
|
|
|
|
|
|
if s.batch {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
s.after()
|
|
|
}
|
|
|
|
|
|
func (s *MarkPoint) after() {
|
|
|
for _, do := range s.afterDo {
|
|
|
do()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (s *MarkPoint) platform(platform string) string {
|
|
|
platform = strings.ToLower(platform)
|
|
|
switch platform {
|
|
|
case consts.PlatformAndroid, consts.PlatformIOS, consts.PlatformWeb, consts.PlatformIPad:
|
|
|
default:
|
|
|
platform = consts.PlatformOther
|
|
|
}
|
|
|
|
|
|
return platform
|
|
|
}
|
|
|
|
|
|
func (s *MarkPoint) timezones() []int32 {
|
|
|
if len(s.timezone) > 0 {
|
|
|
return s.timezone
|
|
|
}
|
|
|
|
|
|
cpn, _ := cache.NewCampaign(s.ctx).FindById(s.identify.campaignId)
|
|
|
s.timezone = append(s.timezone, cpn.TOffset)
|
|
|
|
|
|
if len(cpn.GetLangTypes()) == 1 {
|
|
|
return s.timezone
|
|
|
}
|
|
|
|
|
|
m := dao.FissionCampaignLang
|
|
|
var tz []int32
|
|
|
_ = m.WithContext(s.ctx).Where(m.CampaignID.Eq(cpn.ID), m.TOffset.Neq(cpn.TOffset), m.IsDel.Eq(0)).Group(m.TOffset).Pluck(m.TOffset, &tz)
|
|
|
for _, t := range tz {
|
|
|
s.timezone = append(s.timezone, t)
|
|
|
}
|
|
|
|
|
|
return s.timezone
|
|
|
}
|
|
|
|
|
|
// InApp 站内行为
|
|
|
type InApp struct {
|
|
|
*MarkPoint
|
|
|
user *model.FissionUser
|
|
|
}
|
|
|
|
|
|
func (s *MarkPoint) InApp(user *model.FissionUser, dems ...CusDem) InApp {
|
|
|
|
|
|
s.identify = identify{
|
|
|
campaignId: user.CampaignID,
|
|
|
userMark: fmt.Sprint(user.ID),
|
|
|
userMarkSource: mtype.FissionActionUserMarkSourceFissionUser,
|
|
|
isView: user.IsView == mtype.Yes,
|
|
|
}
|
|
|
|
|
|
var platform string
|
|
|
pAttr, _ := cache.NewFissionUserAttr(s.ctx).FindByUniqIdx(user.ID, mtype.FissionUserAttrMarkPlatform)
|
|
|
if pAttr != nil {
|
|
|
platform = pAttr.Value
|
|
|
}
|
|
|
|
|
|
s.dimension = mtype.Dimension{
|
|
|
Platform: platform,
|
|
|
ChannelId: user.ChannelID,
|
|
|
ParentId: user.ParentID,
|
|
|
Lang: utils.STernary[string](user.UserLang, "", user.LangMark),
|
|
|
LevelMark: user.LevelMark,
|
|
|
UserLv: user.UserLevel,
|
|
|
Country: user.UserCountry,
|
|
|
DimensionOption: mtype.DimensionOption{},
|
|
|
}
|
|
|
|
|
|
for _, dem := range dems {
|
|
|
dem(&s.dimension)
|
|
|
}
|
|
|
|
|
|
return InApp{
|
|
|
MarkPoint: s,
|
|
|
user: user,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// View 访问活动行为
|
|
|
func (s InApp) View(at int64, ip, os, ver, device string) {
|
|
|
s.appendDo(func() {
|
|
|
if s.user.JoinAt > 0 {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
m, sm := dao.FissionUser, dao.FissionUser.SubTable(s.user.CampaignID)
|
|
|
_, _ = m.WithContext(s.ctx).Where(m.ID.Eq(s.user.ID)).UpdateSimple(m.JoinAt.Value(at))
|
|
|
_, _ = sm.WithContext(s.ctx).Where(sm.ID.Eq(s.user.ID)).UpdateSimple(sm.JoinAt.Value(at))
|
|
|
|
|
|
_ = cache.NewFissionUser(s.ctx, s.user.CampaignID).Clear(s.user)
|
|
|
})
|
|
|
|
|
|
s.append(mtype.FissionActionTypeView, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
Os: os,
|
|
|
OsVersion: ver,
|
|
|
DeviceModel: device,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// AppOpen 用户打开app行为
|
|
|
func (s InApp) AppOpen(at int64, ip, os, ver, device string, cpnFirst bool) {
|
|
|
s.append(mtype.FissionActionTypeAppOpen, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
Os: os,
|
|
|
OsVersion: ver,
|
|
|
DeviceModel: device,
|
|
|
}, SetCpnFirst(cpnFirst))
|
|
|
}
|
|
|
|
|
|
// AppInstall 用户安装app行为
|
|
|
func (s InApp) AppInstall(at int64, ip, os, ver, device string, cpnFirst bool) {
|
|
|
s.appendDo(func() {
|
|
|
if s.user.InstallAt > 0 {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
m, sm := dao.FissionUser, dao.FissionUser.SubTable(s.user.CampaignID)
|
|
|
_, _ = m.WithContext(s.ctx).Where(m.ID.Eq(s.user.ID)).UpdateSimple(m.InstallAt.Value(at))
|
|
|
_, _ = sm.WithContext(s.ctx).Where(sm.ID.Eq(s.user.ID)).UpdateSimple(sm.InstallAt.Value(at))
|
|
|
|
|
|
_ = cache.NewFissionUser(s.ctx, s.user.CampaignID).Clear(s.user)
|
|
|
})
|
|
|
|
|
|
s.append(mtype.FissionActionTypeAppInstall, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
Os: os,
|
|
|
OsVersion: ver,
|
|
|
DeviceModel: device,
|
|
|
}, SetCpnFirst(cpnFirst))
|
|
|
}
|
|
|
|
|
|
// WebFirstOpen 用户首次打开行为
|
|
|
func (s InApp) WebFirstOpen(at int64, ip, os, ver, device string, cpnFirst bool) {
|
|
|
s.appendDo(func() {
|
|
|
if s.user.InstallAt > 0 {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
m, sm := dao.FissionUser, dao.FissionUser.SubTable(s.user.CampaignID)
|
|
|
_, _ = m.WithContext(s.ctx).Where(m.ID.Eq(s.user.ID)).UpdateSimple(m.InstallAt.Value(at))
|
|
|
_, _ = sm.WithContext(s.ctx).Where(sm.ID.Eq(s.user.ID)).UpdateSimple(sm.InstallAt.Value(at))
|
|
|
|
|
|
_ = cache.NewFissionUser(s.ctx, s.user.CampaignID).Clear(s.user)
|
|
|
})
|
|
|
|
|
|
s.append(mtype.FissionActionTypeWebFirstOpen, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
Os: os,
|
|
|
OsVersion: ver,
|
|
|
DeviceModel: device,
|
|
|
}, SetCpnFirst(cpnFirst))
|
|
|
}
|
|
|
|
|
|
// AppRegister 用户注册app行为
|
|
|
func (s InApp) AppRegister(at int64, ip, os, ver, device string, cpnFirst bool) {
|
|
|
s.appendDo(func() {
|
|
|
if s.user.RegisterAt > 0 {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
m, sm := dao.FissionUser, dao.FissionUser.SubTable(s.user.CampaignID)
|
|
|
_, _ = m.WithContext(s.ctx).Where(m.ID.Eq(s.user.ID)).UpdateSimple(m.RegisterAt.Value(at))
|
|
|
_, _ = sm.WithContext(s.ctx).Where(sm.ID.Eq(s.user.ID)).UpdateSimple(sm.RegisterAt.Value(at))
|
|
|
|
|
|
_ = cache.NewFissionUser(s.ctx, s.user.CampaignID).Clear(s.user)
|
|
|
})
|
|
|
|
|
|
s.append(mtype.FissionActionTypeAppRegister, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
Os: os,
|
|
|
OsVersion: ver,
|
|
|
DeviceModel: device,
|
|
|
}, SetCpnFirst(cpnFirst))
|
|
|
}
|
|
|
|
|
|
// ClickPlay 活动按钮点击行为
|
|
|
// from: play_btn=点击活动玩的按钮 again=点击再玩一次触发玩的按钮
|
|
|
func (s InApp) ClickPlay(at int64, ip, from string) {
|
|
|
s.append(mtype.FissionActionTypeClickPlay, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
}, SetFrom(from))
|
|
|
}
|
|
|
|
|
|
// ClickShare 点击分享
|
|
|
func (s InApp) ClickShare(at, mediaId int64, ip string) {
|
|
|
s.append(mtype.FissionActionTypeClickShare, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
}, SetMediaId(mediaId))
|
|
|
}
|
|
|
|
|
|
// ClickCond 点击去完成条件
|
|
|
// from: my_task=点击我的任务弹窗中的去完成按钮 home=点击首页中展示的任务的去完成按钮
|
|
|
func (s InApp) ClickCond(at, condId int64, ip, from string) {
|
|
|
s.append(mtype.FissionActionTypeClickCond, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
}, SetCondId(condId), SetFrom(from))
|
|
|
}
|
|
|
|
|
|
// FinishCond 完成条件
|
|
|
func (s InApp) FinishCond(at, condId int64, total float64, event string, eventData []types.EventData) {
|
|
|
s.append(mtype.FissionActionTypeFinishCond, at, &types.FissionActionOtherData{
|
|
|
Event: event,
|
|
|
EventData: eventData,
|
|
|
Total: total,
|
|
|
}, SetCondId(condId))
|
|
|
}
|
|
|
|
|
|
// Sign 签到 signDate 格式为 20250712
|
|
|
func (s InApp) Sign(at int64, utm int32, signDate string) {
|
|
|
s.append(mtype.FissionActionTypeSign, at, nil, SetSignDate(utm, signDate))
|
|
|
}
|
|
|
|
|
|
// UseProp 使用道具
|
|
|
// prop_name: sign_card = 补签卡 fixed_dice = 幸运骰子(固定点数)
|
|
|
//
|
|
|
// uno_three = uno+3道具 uno_five = uno+5道具 uno_fix = uno指定颜色道具
|
|
|
func (s InApp) UseProp(at int64, propName string) {
|
|
|
s.append(mtype.FissionActionTypeUseProp, at, nil, SetPropName(propName))
|
|
|
}
|
|
|
|
|
|
// GetProp 领取道具
|
|
|
// prop_name: sign_card = 补签卡 fixed_dice = 幸运骰子(固定点数)
|
|
|
//
|
|
|
// uno_three = uno+3道具 uno_five = uno+5道具 uno_fix = uno指定颜色道具
|
|
|
func (s InApp) GetProp(at int64, propName string, propNum int32) {
|
|
|
s.append(mtype.FissionActionTypeGetProp, at, nil,
|
|
|
SetPropName(propName),
|
|
|
SetPropNum(propNum),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// Grow 领养生命体
|
|
|
func (s InApp) Grow(at int64, rewardId int64) {
|
|
|
s.append(mtype.FissionActionTypeGrow, at, nil, SetRewardId(rewardId))
|
|
|
}
|
|
|
|
|
|
// GrowOk 养成生命体
|
|
|
func (s InApp) GrowOk(at int64, rewardId, rewardRecordId int64) {
|
|
|
s.append(mtype.FissionActionTypeGrowOk, at, nil,
|
|
|
SetRewardId(rewardId),
|
|
|
SetRewardRecordId(rewardRecordId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// WebToApp web用户转行成app用户
|
|
|
func (s InApp) WebToApp(at, rewardId, rewardRecordId int64, webId string) {
|
|
|
s.append(mtype.FissionActionTypeWebToApp, at, nil,
|
|
|
SetRewardId(rewardId),
|
|
|
SetRewardRecordId(rewardRecordId),
|
|
|
SetFromWebId(webId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// ToUse 点击去使用按钮
|
|
|
// from: my_reward=点击奖励记录去使用 window=点击领奖弹窗去使用按钮
|
|
|
func (s InApp) ToUse(at, rewardId int64, ip, from string) {
|
|
|
s.append(mtype.FissionActionTypeToUse, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
}, SetRewardId(rewardId), SetFrom(from))
|
|
|
}
|
|
|
|
|
|
// ClickLongImg 点击长图
|
|
|
func (s InApp) ClickLongImg(at int64, imgUrl string, imgId, zoneId int64, ip string) {
|
|
|
s.append(mtype.FissionActionTypeClickLongImg, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
}, SetImgUrl(imgUrl), SetImgId(imgId), SetZoneId(zoneId))
|
|
|
}
|
|
|
|
|
|
// FinishTask 完成任务
|
|
|
func (s InApp) FinishTask(at int64, taskId int64) {
|
|
|
s.append(mtype.FissionActionTypeFinishTask, at, nil, SetTaskId(taskId))
|
|
|
}
|
|
|
|
|
|
// ClickMyTask 点击我的任务icon
|
|
|
func (s InApp) ClickMyTask(at int64, ip string) {
|
|
|
s.append(mtype.FissionActionTypeClickMyTask, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// ClickMyReward 点击奖励记录
|
|
|
func (s InApp) ClickMyReward(at int64, ip string) {
|
|
|
s.append(mtype.FissionActionTypeClickMyReward, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// ClickRule 点击活动规则
|
|
|
func (s InApp) ClickRule(at int64, ip string) {
|
|
|
s.append(mtype.FissionActionTypeClickRule, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// FormShow 打开表单
|
|
|
// from: my_reward = 奖品记录 window = 弹窗
|
|
|
// form_status: blank = 空白表单 fill = 已经填写过的
|
|
|
func (s InApp) FormShow(at int64, status, from string, rewardId, rewardRecordId int64) {
|
|
|
s.append(mtype.FissionActionTypeFormShow, at, nil,
|
|
|
SetFromStatus(status),
|
|
|
SetFrom(from),
|
|
|
SetRewardId(rewardId),
|
|
|
SetRewardRecordId(rewardRecordId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// FormSubmit 点击活动规则
|
|
|
func (s InApp) FormSubmit(at int64, rewardId, rewardRecordId int64) {
|
|
|
s.append(mtype.FissionActionTypeFormSubmit, at, nil,
|
|
|
SetRewardId(rewardId),
|
|
|
SetRewardRecordId(rewardRecordId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// CopyContact 复制客服联系方式
|
|
|
// from: my_reward = 奖品记录 window = 弹窗
|
|
|
func (s InApp) CopyContact(at int64, from string, rewardId int64) {
|
|
|
s.append(mtype.FissionActionTypeCopyContact, at, nil,
|
|
|
SetFrom(from),
|
|
|
SetRewardId(rewardId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// Reward 获得一个奖品
|
|
|
func (s InApp) Reward(at, rewardId, rewardRecordId, childId int64, rewardType int8, rewardNum int32) {
|
|
|
s.append(mtype.FissionActionTypeReward, at, nil,
|
|
|
SetRewardId(rewardId),
|
|
|
SetRewardRecordId(rewardRecordId),
|
|
|
SetChildId(childId),
|
|
|
SetRewardType(int32(rewardType)),
|
|
|
SetRewardNum(rewardNum),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// ShowWindow 展示弹窗
|
|
|
// from: reward = 获得奖品弹窗 chance = 获得抽奖机会弹窗 chance_lack = 抽奖机会不足弹窗
|
|
|
func (s InApp) ShowWindow(at int64, from string) {
|
|
|
s.append(mtype.FissionActionTypeShowWindow, at, nil,
|
|
|
SetFrom(from),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// AnswerQa 回答问题
|
|
|
func (s InApp) AnswerQa(at int64, qaId, qaOptionId int64, isRight int32) {
|
|
|
s.append(mtype.FissionActionTypeAnswerQa, at, nil,
|
|
|
SetQaId(qaId),
|
|
|
SetQaOptionId(qaOptionId),
|
|
|
SetQaOptionRight(isRight),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// SubmitQa 提交答卷
|
|
|
func (s InApp) SubmitQa(at int64, qaGroupId int64, qaNum int32, point string) {
|
|
|
s.append(mtype.FissionActionTypeSubmitQa, at, nil,
|
|
|
SetQaGroupId(qaGroupId),
|
|
|
SetQaNum(qaNum),
|
|
|
SetQaPoint(point),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// SelectReward 选择奖品
|
|
|
func (s InApp) SelectReward(at int64, rewardId int64) {
|
|
|
s.append(mtype.FissionActionTypeSelectReward, at, nil,
|
|
|
SetRewardId(rewardId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// Help 获得助力
|
|
|
// from: help_install = 安装助力 help_register = 注册助力 help_open = 拉日活助力
|
|
|
func (s InApp) Help(at int64, from string, rewardId int64) {
|
|
|
s.append(mtype.FissionActionTypeHelp, at, nil,
|
|
|
SetFrom(from),
|
|
|
SetRewardId(rewardId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// Newcomer 完成新人任务
|
|
|
func (s InApp) Newcomer(at int64, rewardId, rewardRecordId int64) {
|
|
|
s.append(mtype.FissionActionTypeNewcomer, at, nil,
|
|
|
SetRewardId(rewardId),
|
|
|
SetRewardRecordId(rewardRecordId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// ClickFlip 点击立即翻牌
|
|
|
func (s InApp) ClickFlip(at int64, fromStatus string) {
|
|
|
s.append(mtype.FissionActionTypeClickFlip, at, nil,
|
|
|
SetFromStatus(fromStatus),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// UseCoin 投放金币
|
|
|
func (s InApp) UseCoin(at int64, sceneId, times int64) {
|
|
|
s.append(mtype.FissionActionTypeUseCoin, at, nil,
|
|
|
SetSceneId(sceneId),
|
|
|
SetUseTimes(times),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// GetCoin 领取金币
|
|
|
func (s InApp) GetCoin(at int64, sceneId int64) {
|
|
|
s.append(mtype.FissionActionTypeGetCoin, at, nil,
|
|
|
SetSceneId(sceneId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// ClickCustomBtn 点击自定义按钮
|
|
|
func (s InApp) ClickCustomBtn(at int64, customBtnId int64) {
|
|
|
s.append(mtype.FissionActionTypeClickCustomBtn, at, nil,
|
|
|
SetCustomBtnId(customBtnId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// ClickChild 点击子活动入口
|
|
|
func (s InApp) ClickChild(at int64, childId int64, childType int8) {
|
|
|
s.append(mtype.FissionActionTypeClickChild, at, nil,
|
|
|
SetChildId(childId),
|
|
|
SetChildType(int32(childType)),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// JoinChild 参与子活动(玩子活动)
|
|
|
func (s InApp) JoinChild(at int64, childId int64, childType int8) {
|
|
|
s.append(mtype.FissionActionTypeJoinChild, at, nil,
|
|
|
SetChildId(childId),
|
|
|
SetChildType(int32(childType)),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// Pay 支付事件
|
|
|
func (s InApp) Pay(at int64, info *types.PurchaseData) {
|
|
|
s.append(mtype.FissionActionTypePay, at,
|
|
|
&types.FissionActionOtherData{PurchaseData: info},
|
|
|
SetPay(info.Amount, info.Currency),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// PointsUse 使用积分事件
|
|
|
func (s InApp) PointsUse(at int64, pointUse int32) {
|
|
|
s.append(mtype.FissionActionTypePointsUse, at, nil,
|
|
|
SetPointsUse(pointUse),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// ManualTask 手动领取任务奖励
|
|
|
func (s InApp) ManualTask(at int64, taskId, rewardId int64) {
|
|
|
s.append(mtype.FissionActionTypeManualTask, at, nil,
|
|
|
SetRewardId(rewardId),
|
|
|
SetTaskId(taskId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// CenterDrainage 任务中心引流
|
|
|
func (s InApp) CenterDrainage(at int64, centerHashId, centerModuleId string) {
|
|
|
s.append(mtype.FissionActionTypeCenterDrainage, at, nil,
|
|
|
SetCenterHashId(centerHashId),
|
|
|
SetCenterModuleId(centerModuleId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// ClickChat 进入AI对话
|
|
|
// chat_from: icon = 图标,tip = 宠物文案
|
|
|
func (s InApp) ClickChat(at int64, chatFrom, chatTipMsg string) {
|
|
|
s.append(mtype.FissionActionTypeClickChat, at, nil,
|
|
|
SetChatFrom(chatFrom),
|
|
|
SetChatTipMsg(chatTipMsg),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// VsVote 赛事竞猜投票
|
|
|
func (s InApp) VsVote(at int64, scheduleId int64, winType int32, winTeamId int64) {
|
|
|
s.append(mtype.FissionActionTypeVsVote, at, nil,
|
|
|
SetScheduleId(scheduleId),
|
|
|
SetWinType(winType, winTeamId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// VsWin 赛事竞猜获胜
|
|
|
func (s InApp) VsWin(at int64, scheduleId int64, voteNum int32) {
|
|
|
s.append(mtype.FissionActionTypeVsWin, at, nil,
|
|
|
SetScheduleId(scheduleId),
|
|
|
SetVoteNum(voteNum),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// VsAcceptReward 赛事竞猜领取奖品
|
|
|
func (s InApp) VsAcceptReward(at int64, scheduleId, rewardId, rewardRecordId int64) {
|
|
|
s.append(mtype.FissionActionTypeVsAcceptReward, at, nil,
|
|
|
SetScheduleId(scheduleId),
|
|
|
SetRewardId(rewardId),
|
|
|
SetRewardRecordId(rewardRecordId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// MallRedeem 兑换商城商品
|
|
|
func (s InApp) MallRedeem(at int64, mallId, mallItemId int64, pointUse int32) {
|
|
|
s.append(mtype.FissionActionTypeMallRedeem, at, nil,
|
|
|
SetMallId(mallId),
|
|
|
SetMallItemId(mallItemId),
|
|
|
SetPointsUse(pointUse),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// ClickUnoCard 点击UNO自定卡
|
|
|
func (s InApp) ClickUnoCard(at int64, colorMark, cardNo string, cardId int64) {
|
|
|
s.append(mtype.FissionActionTypeClickUnoCard, at, nil,
|
|
|
SetCardNo(colorMark, cardNo),
|
|
|
SetUnoCardId(cardId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// CollectUnoCard 集齐uno卡牌
|
|
|
func (s InApp) CollectUnoCard(at int64, cardColor string) {
|
|
|
s.append(mtype.FissionActionTypeCollectUnoCard, at, nil,
|
|
|
SetCardColor(cardColor),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// UnlockReward 解锁奖品
|
|
|
func (s InApp) UnlockReward(at, rewardId, taskId int64) {
|
|
|
s.append(mtype.FissionActionTypeUnlockReward, at, nil,
|
|
|
SetRewardId(rewardId),
|
|
|
SetTaskId(taskId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// OutApp 站外行为
|
|
|
type OutApp struct {
|
|
|
*MarkPoint
|
|
|
}
|
|
|
|
|
|
func (s *MarkPoint) OutApp(cpnId, channelId, parentId int64, webId, platform, lang string) OutApp {
|
|
|
s.identify = identify{
|
|
|
campaignId: cpnId,
|
|
|
userMark: webId,
|
|
|
userMarkSource: mtype.FissionActionUserMarkSourceUaWebId,
|
|
|
}
|
|
|
|
|
|
s.dimension = mtype.Dimension{
|
|
|
Platform: s.platform(platform),
|
|
|
ChannelId: channelId,
|
|
|
ParentId: parentId,
|
|
|
Lang: lang,
|
|
|
DimensionOption: mtype.DimensionOption{},
|
|
|
}
|
|
|
|
|
|
return OutApp{
|
|
|
MarkPoint: s,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// View 访问活动行为,这个是web2app用的访问活动
|
|
|
func (s OutApp) View(at int64, ip, os, ver, device string) {
|
|
|
s.append(mtype.FissionActionTypeView, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
Os: os,
|
|
|
OsVersion: ver,
|
|
|
DeviceModel: device,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// ViewDownload 浏览下载页行为
|
|
|
// from: base=正常下载页 wechat=从微信跳转过来的下载页 web=站外过来的下载页
|
|
|
func (s OutApp) ViewDownload(at int64, downloadFrom, ip, os, ver, device string) {
|
|
|
s.append(mtype.FissionActionTypeViewDownload, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
Os: os,
|
|
|
OsVersion: ver,
|
|
|
DeviceModel: device,
|
|
|
}, SetDownloadFrom(downloadFrom))
|
|
|
}
|
|
|
|
|
|
// ClickDownload 点击下载按钮行为 base=正常下载页点击下载 wechat=从微信跳转过来的下载页点击下载 web=站外过来的下载页点击下载
|
|
|
func (s OutApp) ClickDownload(at int64, downloadFrom string) {
|
|
|
s.append(mtype.FissionActionTypeClickDownload, at, nil, SetDownloadFrom(downloadFrom))
|
|
|
}
|
|
|
|
|
|
// ViewWechat 浏览微信页行为
|
|
|
func (s OutApp) ViewWechat(at int64, ip string) {
|
|
|
s.append(mtype.FissionActionTypeViewWechat, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// ViewWeb 访问站外链接行为
|
|
|
func (s OutApp) ViewWeb(at int64, ip, os, ver, device string) {
|
|
|
s.append(mtype.FissionActionTypeViewWeb, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
Os: os,
|
|
|
OsVersion: ver,
|
|
|
DeviceModel: device,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// ClickPlayWeb 活动站外按钮点击行为
|
|
|
func (s OutApp) ClickPlayWeb(at int64, rewardId int64) {
|
|
|
s.append(mtype.FissionActionTypeClickPlayWeb, at, nil,
|
|
|
SetRewardId(rewardId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// InAppOpenLink 站内打开链接行为
|
|
|
func (s OutApp) InAppOpenLink(at int64, blackBox, uid string) {
|
|
|
s.append(mtype.FissionActionTypeInAppOpenLink, at, nil,
|
|
|
SetBlackbox(blackBox),
|
|
|
SetUid(uid),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// Help 获得助力
|
|
|
// from: help_click = 点击助力
|
|
|
func (s OutApp) Help(at int64, from string, rewardId int64, ip, os, ver, device string) {
|
|
|
s.append(mtype.FissionActionTypeHelp, at,
|
|
|
&types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
Os: os,
|
|
|
OsVersion: ver,
|
|
|
DeviceModel: device,
|
|
|
},
|
|
|
SetFrom(from),
|
|
|
SetRewardId(rewardId),
|
|
|
)
|
|
|
}
|
|
|
|
|
|
// ClickShareLink 点击分享连接行为
|
|
|
func (s OutApp) ClickShareLink(at int64, ip, os, ver, device string) {
|
|
|
s.append(mtype.FissionActionTypeClickShareLink, at, &types.FissionActionOtherData{
|
|
|
Ip: ip,
|
|
|
Os: os,
|
|
|
OsVersion: ver,
|
|
|
DeviceModel: device,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// Child 子活动行为
|
|
|
type Child struct {
|
|
|
*MarkPoint
|
|
|
}
|
|
|
|
|
|
func (s *MarkPoint) Child(child *model.FissionChildUser, user *model.FissionUser, dems ...CusDem) Child {
|
|
|
s.identify = identify{
|
|
|
campaignId: child.CampaignID,
|
|
|
userMark: fmt.Sprint(child.ID),
|
|
|
userMarkSource: mtype.FissionActionUserMarkSourceChild,
|
|
|
}
|
|
|
|
|
|
var platform string
|
|
|
pAttr, _ := cache.NewFissionUserAttr(s.ctx).FindByUniqIdx(user.ID, mtype.FissionUserAttrMarkPlatform)
|
|
|
if pAttr != nil {
|
|
|
platform = pAttr.Value
|
|
|
}
|
|
|
|
|
|
s.dimension = mtype.Dimension{
|
|
|
Platform: platform,
|
|
|
ChannelId: user.ChannelID,
|
|
|
ParentId: user.ParentID,
|
|
|
Lang: utils.STernary[string](user.UserLang, "", user.LangMark),
|
|
|
LevelMark: user.LevelMark,
|
|
|
UserLv: user.UserLevel,
|
|
|
Country: user.UserCountry,
|
|
|
DimensionOption: mtype.DimensionOption{
|
|
|
PCpnId: child.PCpnID,
|
|
|
},
|
|
|
}
|
|
|
|
|
|
for _, dem := range dems {
|
|
|
dem(&s.dimension)
|
|
|
}
|
|
|
|
|
|
return Child{
|
|
|
MarkPoint: s,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// ChildShow 子活动入口打开
|
|
|
func (s Child) ChildShow(at int64) {
|
|
|
s.append(mtype.FissionActionTypeChildShow, at, nil)
|
|
|
}
|
|
|
|
|
|
// ChildSign 子活动签到
|
|
|
func (s Child) ChildSign(at int64) {
|
|
|
s.append(mtype.FissionActionTypeChildSign, at, nil)
|
|
|
}
|
|
|
|
|
|
// ChildLottery 子活动抽奖
|
|
|
func (s Child) ChildLottery(at int64) {
|
|
|
s.append(mtype.FissionActionTypeChildLottery, at, nil)
|
|
|
}
|
|
|
|
|
|
// ChildInvite 子活动邀请成功
|
|
|
func (s Child) ChildInvite(at int64, invitedId int64) {
|
|
|
s.append(mtype.FissionActionTypeChildInvite, at, &types.FissionActionOtherData{
|
|
|
InvitedId: invitedId,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// ChildGetReward 子活动获得奖品
|
|
|
func (s Child) ChildGetReward(at int64, rewardId, rewardRecordId int64, rewardType int8) {
|
|
|
s.append(mtype.FissionActionTypeChildGetReward, at, nil,
|
|
|
SetRewardId(rewardId),
|
|
|
SetRewardRecordId(rewardRecordId),
|
|
|
SetRewardType(int32(rewardType)),
|
|
|
)
|
|
|
}
|