package campaign import ( "context" "joybuywork/internal/config" "joybuywork/internal/consts" "joybuywork/internal/server/depend" "joybuywork/internal/utils/logic" pb "joybuywork/proto/go_proto/w_campaign" _ "joybuywork/test" "encoding/json" "os" "testing" "gits.branchcn.com/backend/microcode/micro" ) func TestTT(t *testing.T) { res := &pb.StoreRes{} req := &pb.StoreReq{} const reqJSON = `{"project_id":"X5c6Zz8CeUcwim82YXtsh9","template_id":"d9u3qmmrdj7suicsn710","user_id":133,"title":"2121","start_time":1786607700,"end_time":1788681300,"config":{"rule_text_color":"#FF6778","rule_bg_color":"#FFF","share_text":"邀请好友 一起赢奖励 点击链接为好友助力","image_main":"/resource/2026/08/13/d9ujgm6rdj7suictg1a0.png","image_preview":"/resource/2026/08/13/d9ujgsmrdj7suictg1eg.png","link_btn_text_color":"#FFF","link_btn_bg_color":"#FFB752","link_text_color":"#A2A2AE","show_share":1,"play_rule":"\u003cp\u003e12212111\u003c/p\u003e","page_title":"2121","dm_show":1,"icon_type":1,"icon_bg_color":"#000","dl_type":1,"dl_banner_type":1,"dl_banner_app_logo":"/dynamic/logo.png","dl_banner_position":1,"topic_color":"#FF4E77","icon_open":[1,2,3,4],"pc_bg":"/web/sdk/img/campBg.png","link_temp_id":"1054","rule_time_open":1,"outside_task":1,"icon_text_color":"#000","open_share":1,"show_to_use":1},"question_answer":{"init_chance":1,"question_ask_time":600,"group_hash_id":"cmia16erdj7vs0jqlbv0","qa_num":10,"day_chance":1,"open_guide":1,"guide_group_hash_id":"cmia16erdj7vs0jqlbv0"},"t_offset":8,"target":{"target":1,"option":1,"app_event":1},"rewards":{"reward_group":1,"normal":[{"reward_id":-2,"stock":1,"reward_num":1,"is_thank":1,"score":1,"collect_num":1,"odds":1000,"collect_rule":{},"open_add":{}},{"reward_id":320229033112907776,"stock":111,"reward_num":1,"score":100,"collect_num":1,"collect_rule":{},"open_add":{}}]},"target_option":{"target":1,"fixed":{"open":1,"app_event":1,"target_num":11,"chance":11},"custom":{"open":1,"both_type":2,"cond":[{"event":"subscribe","event_key":"subscribe1","event_val":"11","desc":"xx","chance":1,"trigger_type":1,"event_type":1,"view_type":2,"go_show":1,"prop_mark":"chance","sort":1,"go_text":"去完成","click_effect":5,"click_effect_unit":"min"}],"both_all":{}}},"copy_campaign_id":"d9umfamrdj7mrtlnndi0","ip":"120.229.5.148","push":{"visit":{"open":1}}}` if err := json.Unmarshal([]byte(reqJSON), req); err != nil { t.Fatalf("unmarshal StoreReq: %v", err) } t.Logf("%+v \r\n", req.GetTargetOption().GetFixed()) container := new(Store) { container.Init(context.Background(), logic.WithTran()) container.Req = req container.Res = res } t.Log(container.Run(), res) } func TestLangs(t *testing.T) { res := &pb.LangsRes{} container := new(Langs) { container.Init(context.Background()) container.Req = &pb.LangsReq{ CampaignHashId: "d7tvciurdj7hbvco20g0", } container.Res = res } t.Log(container.Run()) for _, v := range res.Langs { t.Logf("%+v", v) } t.Log("------------------") for _, v := range res.NotSupport { t.Logf("%+v", v) } } func rpc() { os.Args = []string{} depend.M = micro.Grpc(micro.GrpcConfig{ ServerName: consts.ServiceName, EtcdAddress: config.Config.Etcd.Address, }) }