You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
434 lines
9.4 KiB
Go
434 lines
9.4 KiB
Go
package containers
|
|
|
|
import (
|
|
"context"
|
|
"joybuywork/internal/repository/dao"
|
|
"joybuywork/internal/repository/dbcheck"
|
|
"joybuywork/internal/repository/finder"
|
|
"joybuywork/internal/service/cmm"
|
|
"joybuywork/internal/service/containers/campaign"
|
|
"joybuywork/internal/service/containers/campaignuser"
|
|
"joybuywork/internal/utils/logic"
|
|
cpb "joybuywork/proto/go_proto/w_campaign"
|
|
pb "joybuywork/proto/go_proto/w_campaign_user"
|
|
lpb "joybuywork/proto/go_proto/w_library"
|
|
rpb "joybuywork/proto/go_proto/w_reward"
|
|
"testing"
|
|
|
|
"github.com/golang-module/carbon/v2"
|
|
|
|
_ "joybuywork/test"
|
|
)
|
|
|
|
func TestCampaignUserSignIn(t *testing.T) {
|
|
res := &pb.SignInRes{}
|
|
|
|
container := new(campaignuser.SignIn)
|
|
{
|
|
container.Init(context.Background())
|
|
container.Req = &pb.SignInReq{
|
|
UserId: 15706,
|
|
NowMouth: "",
|
|
PageType: 0,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(res.SignDate, container.Run())
|
|
}
|
|
|
|
func TestCampaignUserVisit(t *testing.T) {
|
|
res := &pb.VisitRes{}
|
|
|
|
container := new(campaignuser.Visit)
|
|
{
|
|
container.Init(context.Background(), logic.WithTran())
|
|
container.Req = &pb.VisitReq{
|
|
Hid: "coh2uberdj7n1v8728s0",
|
|
Uid: "",
|
|
Cid: "sS",
|
|
Wid: "",
|
|
Lang: "",
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res, carbon.NewCarbon().Parse("").Timestamp())
|
|
}
|
|
|
|
func TestRewardList(t *testing.T) {
|
|
res := &rpb.ListRes{}
|
|
|
|
container := new(RewardList)
|
|
{
|
|
container.Init(context.Background())
|
|
container.Req = &rpb.ListReq{
|
|
Page: 1,
|
|
PerPage: 10,
|
|
PageLang: "zh",
|
|
ProjectHashId: "clr8qhurdj7o3ecsbai0",
|
|
Title: "",
|
|
LangMark: "",
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestCampaignStore(t *testing.T) {
|
|
res := &cpb.StoreRes{}
|
|
|
|
container := new(campaign.Store)
|
|
{
|
|
container.Init(context.Background(), logic.WithTran())
|
|
container.Req = &cpb.StoreReq{
|
|
ProjectId: "X5c6Zz8CeUcwim82YXtsh9",
|
|
TemplateId: "6c309b2490001a4",
|
|
UserId: 0,
|
|
Title: "123123",
|
|
StartTime: 1711445937,
|
|
EndTime: 1717171200,
|
|
CoverUrl: "",
|
|
Config: &cpb.StoreReq_Config{
|
|
RuleTextColor: "#FFF",
|
|
RuleBgColor: "#FFB423",
|
|
ShareText: "邀请好友 一起赢奖励 点击链接为好友助力",
|
|
HasRank: 0,
|
|
RankBackgroundColor: "",
|
|
RankTextColor: "",
|
|
DownloadPageImage: "",
|
|
IsDefaultDownload: 0,
|
|
WechatPageImage: "",
|
|
IsDefaultWechat: 0,
|
|
ImageMain: "ftg/wheel/main.png",
|
|
IsDefaultMain: 0,
|
|
ImagePreview: "",
|
|
LinkBtnTextColor: "#FFF",
|
|
LinkBtnBgColor: "#FFB752",
|
|
LinkTextColor: "#A2A2AE",
|
|
ShowShare: 1,
|
|
Share: nil,
|
|
PlayRule: "<p>111</p>",
|
|
PageTitle: "3123",
|
|
DmShow: 0,
|
|
WebBgImg: "",
|
|
HasWarmUp: 0,
|
|
WarmUpImg: "",
|
|
WarmUpEnd: 0,
|
|
IconType: 1,
|
|
IconBgColor: "#000",
|
|
DlType: 1,
|
|
DlBannerType: 1,
|
|
DlBannerImg: "",
|
|
DlBannerAppLogo: "",
|
|
DlBannerAppName: "",
|
|
DlBannerAppBtn: "",
|
|
DlBannerPosition: 1,
|
|
TopicColor: "#FF4E77",
|
|
WindowCover: 0,
|
|
},
|
|
CampaignData: nil,
|
|
PrizeWheel: &cpb.StoreReq_LotteryConfig{
|
|
TargetNum: 1,
|
|
InitChance: 1,
|
|
Chance: 1,
|
|
},
|
|
Slot: nil,
|
|
Blind: nil,
|
|
Grid: nil,
|
|
Referral: nil,
|
|
QuestionAnswer: nil,
|
|
Quiz: nil,
|
|
Win: nil,
|
|
TOffset: 8,
|
|
Target: &cpb.StoreReq_Target{
|
|
Target: 1,
|
|
Option: 1,
|
|
AppEvent: 1,
|
|
BothType: 1,
|
|
Cond: nil,
|
|
},
|
|
Sign: nil,
|
|
Dice: nil,
|
|
Grow: nil,
|
|
Ballot: nil,
|
|
Chop: nil,
|
|
Rewards: &cpb.StoreReq_Rewards{
|
|
RewardGroup: 1,
|
|
Normal: []*cpb.StoreReq_Reward{
|
|
{
|
|
RewardId: 1,
|
|
Stock: 1,
|
|
InviteNum: 0,
|
|
RewardNum: 0,
|
|
IsThank: 1,
|
|
Score: 0,
|
|
SignDay: 0,
|
|
CollectNum: 0,
|
|
IsSuper: 0,
|
|
},
|
|
{
|
|
RewardId: 6,
|
|
Stock: 1,
|
|
InviteNum: 1,
|
|
RewardNum: 0,
|
|
IsThank: 0,
|
|
Score: 0,
|
|
SignDay: 0,
|
|
CollectNum: 0,
|
|
IsSuper: 0,
|
|
},
|
|
},
|
|
UserLevel: nil,
|
|
Langs: nil,
|
|
LangUserLevel: nil,
|
|
},
|
|
RewardsWeb: nil,
|
|
RewardsExtra: nil,
|
|
RewardsNewcomer: nil,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestCampaignUpdate(t *testing.T) {
|
|
res := &cpb.UpdateRes{}
|
|
|
|
container := new(campaign.Update)
|
|
{
|
|
container.Init(context.Background(), logic.WithTran())
|
|
container.Req = &cpb.UpdateReq{
|
|
Id: 0,
|
|
HashId: "cparbgerdj7ll37rq060",
|
|
Title: "123",
|
|
StartTime: 1717065840,
|
|
EndTime: 1717152240,
|
|
CoverUrl: "ftg/cash/cover_url.png",
|
|
Config: &cpb.UpdateReq_Config{
|
|
RuleTextColor: "#FFF",
|
|
RuleBgColor: "#FFB423",
|
|
ShareText: "邀请好友 一起赢奖励 点击链接为好友助力",
|
|
HasRank: 0,
|
|
RankBackgroundColor: "",
|
|
RankTextColor: "",
|
|
DownloadPageImage: "",
|
|
IsDefaultDownload: 0,
|
|
WechatPageImage: "",
|
|
IsDefaultWechat: 0,
|
|
ImageMain: "ftg/cash/main_zh.png",
|
|
IsDefaultMain: 0,
|
|
ImagePreview: "",
|
|
LinkBtnTextColor: "#FFF",
|
|
LinkBtnBgColor: "#FFB752",
|
|
LinkTextColor: "#A2A2AE",
|
|
ShowShare: 1,
|
|
Share: nil,
|
|
PlayRule: "<p>111</p>",
|
|
PageTitle: "3123",
|
|
DmShow: 0,
|
|
WebBgImg: "",
|
|
HasWarmUp: 0,
|
|
WarmUpImg: "",
|
|
WarmUpEnd: 0,
|
|
IconType: 1,
|
|
IconBgColor: "#000",
|
|
DlType: 1,
|
|
DlBannerType: 1,
|
|
DlBannerImg: "",
|
|
DlBannerAppLogo: "dynamic/logo.png",
|
|
DlBannerAppName: "",
|
|
DlBannerAppBtn: "",
|
|
DlBannerPosition: 1,
|
|
TopicColor: "#FF4E77",
|
|
WindowCover: 0,
|
|
},
|
|
TOffset: 8,
|
|
Rewards: &cpb.UpdateReq_Rewards{
|
|
RewardGroup: 2,
|
|
Normal: nil,
|
|
UserLevel: &cpb.UpdateReq_UserLevel{
|
|
DefaultLevelId: 7,
|
|
LevelList: []*cpb.UpdateReq_UserLevelOne{
|
|
{
|
|
LevelId: 7,
|
|
Rewards: []*cpb.UpdateReq_Reward{
|
|
{
|
|
Id: 6378,
|
|
RewardId: 109335324832083968,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
LevelId: 8,
|
|
Rewards: []*cpb.UpdateReq_Reward{
|
|
{
|
|
Id: 6379,
|
|
RewardId: 109333950685818880,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
UserId: 1,
|
|
Ip: "1",
|
|
TargetOption: &cpb.UpdateReq_TargetOption{
|
|
Target: 1,
|
|
Fixed: &cpb.UpdateReq_Fixed{
|
|
Open: 1,
|
|
AppEvent: 1,
|
|
TargetNum: 1,
|
|
Chance: 0,
|
|
ChanceLimit: 0,
|
|
Percent: 1,
|
|
},
|
|
Custom: nil,
|
|
},
|
|
Cash: &cpb.UpdateReq_Cash{
|
|
ExpiredDay: 3,
|
|
Price: 200,
|
|
PriceNum: 0,
|
|
},
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestCampaignShow(t *testing.T) {
|
|
res := &cpb.ShowRes{}
|
|
|
|
container := new(campaign.Show)
|
|
{
|
|
container.Init(context.Background())
|
|
container.Req = &cpb.ShowReq{
|
|
HashId: "d5kv96mrdj7kpgfc8h40",
|
|
NotReward: false,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res.TargetOption)
|
|
}
|
|
|
|
func TestCampaignShowReward(t *testing.T) {
|
|
res := &cpb.ShowRewardRes{}
|
|
|
|
container := new(campaign.ShowReward)
|
|
{
|
|
container.Init(context.Background())
|
|
container.Req = &cpb.ShowRewardReq{
|
|
CampaignId: 2714,
|
|
LangMark: "en",
|
|
LevelMark: "",
|
|
ShowLang: "",
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestCampaignRewardDetail(t *testing.T) {
|
|
res := &cpb.RewardDetailRes{}
|
|
|
|
container := new(campaign.RewardDetail)
|
|
{
|
|
container.Init(context.Background())
|
|
container.Req = &cpb.RewardDetailReq{
|
|
HashId: "d1uqlumrdj7iim4807h0",
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestName(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
user, err := finder.FissionUser(ctx, 1, "coeg5vurdj7ssimb4u6g")
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if user == nil {
|
|
t.Log(123123)
|
|
return
|
|
}
|
|
|
|
dmgM := dao.Q.FissionDiceMapGroup
|
|
dmg, err := dmgM.WithContext(ctx).Where(dmgM.CampaignID.Eq(user.CampaignID), dmgM.LangMark.Eq(user.UserLang), dmgM.LevelID.Eq(user.UserLevel)).Take()
|
|
if err = dbcheck.DbError(err); err != nil {
|
|
return
|
|
}
|
|
|
|
m := dao.Q.FissionDiceMap
|
|
list, err := m.WithContext(ctx).Where(m.CampaignID.Eq(user.CampaignID), m.DmgID.Eq(dmg.ID)).Find()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if len(list) == 0 {
|
|
return
|
|
}
|
|
|
|
cpn, err := finder.Campaign(ctx, user.CampaignID)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
rewardMap, err := cmm.NewCMM(ctx, dao.Q).UserAppRewardInfo(cpn, user)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
var ll []*pb.DiceMapRes_One
|
|
|
|
var add = func(i int) {
|
|
v := list[i]
|
|
one := &pb.DiceMapRes_One{
|
|
MapHashId: v.HashID,
|
|
MarkType: int32(v.MarkType),
|
|
RewardTitle: "",
|
|
ImgUrl: "",
|
|
}
|
|
|
|
if reward, ok := rewardMap[v.RewardID]; ok {
|
|
one.RewardTitle = reward.Title
|
|
one.ImgUrl = reward.ImgUrl
|
|
one.RewardId = reward.RewardId
|
|
}
|
|
|
|
ll = append(ll, one)
|
|
}
|
|
|
|
for i := 0; i < 6; i++ {
|
|
add(i)
|
|
}
|
|
|
|
t.Log(ll)
|
|
}
|
|
|
|
func TestLibraryQaRand(t *testing.T) {
|
|
res := &lpb.QaRandRes{}
|
|
|
|
container := new(LibraryQaRand)
|
|
{
|
|
container.Init(context.Background())
|
|
container.Req = &lpb.QaRandReq{
|
|
CampaignId: 5017,
|
|
GroupHashId: "ctfsrrerdj7qqih3vml0",
|
|
LangMark: "en",
|
|
UserId: 314377173277581312,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|