Răsfoiți Sursa

wip:提交微信关注标签

wkyuer 4 luni în urmă
părinte
comite
968a854bd1

+ 3 - 0
userSign/config.yaml

@@ -6,6 +6,9 @@ database:
   jianyu:
   jianyu:
     link: "mysql:root:=PDT49#80Z!RVv52_z@tcp(192.168.3.14:4000)/jianyu"
     link: "mysql:root:=PDT49#80Z!RVv52_z@tcp(192.168.3.14:4000)/jianyu"
     debug: true
     debug: true
+  ckLogs:
+    link: "clickhouse:jytop:pwdTopJy123@tcp(172.20.45.129:19000)/data_analysis?dial_timeout=2000ms&max_execution_time=60"
+    debug: false
 
 
 
 
 
 

+ 19 - 10
userSign/main.go

@@ -6,7 +6,6 @@ import (
 	_ "github.com/gogf/gf/contrib/drivers/clickhouse/v2"
 	_ "github.com/gogf/gf/contrib/drivers/clickhouse/v2"
 	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
 	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/frame/g"
-	"github.com/gogf/gf/v2/os/gcron"
 	"github.com/gogf/gf/v2/os/gctx"
 	"github.com/gogf/gf/v2/os/gctx"
 	"time"
 	"time"
 	"workTasks/userSign/userAnalysis"
 	"workTasks/userSign/userAnalysis"
@@ -20,16 +19,16 @@ func main() {
 	//	g.Log().Errorf(ctx, "BaseUserTag 异常", e)
 	//	g.Log().Errorf(ctx, "BaseUserTag 异常", e)
 	//}
 	//}
 
 
-	_, err := gcron.Add(gctx.New(), g.Cfg().MustGet(ctx, "runCron", "# 0 2 * * *").String(), func(ctx context.Context) {
-		runOnce(context.TODO())
-		if e := userTag.BaseUserTag(); e != nil {
-			g.Log().Errorf(ctx, "BaseUserTag 异常", e)
-		}
-	}, "userSign")
-	if err != nil {
-		panic(err)
+	//_, err := gcron.Add(gctx.New(), g.Cfg().MustGet(ctx, "runCron", "# 0 2 * * *").String(), func(ctx context.Context) {
+	runOnce(context.TODO())
+	if e := userTag.BaseUserTag(); e != nil {
+		g.Log().Errorf(ctx, "BaseUserTag 异常", e)
 	}
 	}
-	select {}
+	//}, "userSign")
+	//if err != nil {
+	//	panic(err)
+	//}
+	//select {}
 }
 }
 
 
 func runOnce(ctx context.Context) {
 func runOnce(ctx context.Context) {
@@ -85,6 +84,16 @@ func runOnce(ctx context.Context) {
 	if res, err := manager.Visited(ctx, nowTime.AddDate(0, 0, -7)); err == nil && len(res) > 0 {
 	if res, err := manager.Visited(ctx, nowTime.AddDate(0, 0, -7)); err == nil && len(res) > 0 {
 		allRes = append(allRes, &userAnalysis.AnalysisRes{Name: "访问过剑鱼产品", Code: "visited", Data: res, SaveOldData: true})
 		allRes = append(allRes, &userAnalysis.AnalysisRes{Name: "访问过剑鱼产品", Code: "visited", Data: res, SaveOldData: true})
 	}
 	}
+	// 访问过指定页面
+	res, err := manager.GetVisitUserAnalysis(ctx, nowTime.AddDate(0, 0, -45))
+	if err != nil {
+		g.Log().Panicf(ctx, err.Error())
+	}
+	if err == nil && len(res) > 0 {
+		for _, t := range res {
+			allRes = append(allRes, t)
+		}
+	}
 
 
 	for _, re := range allRes {
 	for _, re := range allRes {
 		re.UpdateTag(ctx)
 		re.UpdateTag(ctx)

+ 6 - 4
userSign/new.sql

@@ -24,7 +24,9 @@ INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, cre
 INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2018, 'newUser_1', '近第1天注册用户',bitmapBuild([toUInt64(0)]) , 2, '2024-12-17 00:00:00', 'wky', 2018);
 INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2018, 'newUser_1', '近第1天注册用户',bitmapBuild([toUInt64(0)]) , 2, '2024-12-17 00:00:00', 'wky', 2018);
 INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2019, 'newUser_2', '近第2天注册用户',bitmapBuild([toUInt64(0)]) , 2, '2024-12-17 00:00:00', 'wky', 2019);
 INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2019, 'newUser_2', '近第2天注册用户',bitmapBuild([toUInt64(0)]) , 2, '2024-12-17 00:00:00', 'wky', 2019);
 INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2020, 'newUser_3', '近第3天注册用户',bitmapBuild([toUInt64(0)]) , 2, '2024-12-17 00:00:00', 'wky', 2020);
 INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2020, 'newUser_3', '近第3天注册用户',bitmapBuild([toUInt64(0)]) , 2, '2024-12-17 00:00:00', 'wky', 2020);
-INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2021, 'newUser_4', '近第4天注册用户',bitmapBuild([toUInt64(0)]) , 2, '2024-12-17 00:00:00', 'wky', 2021);
-INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2022, 'newUser_5', '近第5天注册用户',bitmapBuild([toUInt64(0)]) , 2, '2024-12-17 00:00:00', 'wky', 2022);
-INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2023, 'newUser_6', '近第6天注册用户',bitmapBuild([toUInt64(0)]) , 2, '2024-12-17 00:00:00', 'wky', 2023);
-INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2024, 'newUser_7', '近第7天注册用户',bitmapBuild([toUInt64(0)]) , 2, '2024-12-17 00:00:00', 'wky', 2024);
+
+
+INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2027, 'vipExpired_30', '超级订阅已经到期30天',bitmapBuild([toUInt64(0)]) , 2, '2025-03-25 00:00:00', 'wky', 2027);
+INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2028, 'vipGift7DayExpired', '超级订阅赠送7天到期',bitmapBuild([toUInt64(0)]) , 2, '2025-03-25 00:00:00', 'wky', 2028);
+INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2029, 'unBuyVip45Day', '45天加购未购超级订阅',bitmapBuild([toUInt64(0)]) , 2, '2025-03-25 00:00:00', 'wky', 2029);
+INSERT INTO pub_tags.dwd_d_tag (id, code, name, bitobj, groupid, created_at, created_by, bit_num) VALUES(2030, 'visitedVipBuyPage', '近45天浏览超级订阅购买页',bitmapBuild([toUInt64(0)]) , 2, '2025-03-25 00:00:00', 'wky', 2030);

+ 17 - 13
userSign/userAnalysis/analysisManager.go

@@ -16,6 +16,8 @@ type (
 
 
 		BinPhone, BindMail   map[BaseUserId]bool
 		BinPhone, BindMail   map[BaseUserId]bool
 		Vip, Vip15, Vip30    map[BaseUserId]bool
 		Vip, Vip15, Vip30    map[BaseUserId]bool
+		VipExpired30         map[BaseUserId]bool //已到期30天
+		VipGift7DayExpired   map[BaseUserId]bool //赠送7天到期
 		Member, MemberExpire map[BaseUserId]bool
 		Member, MemberExpire map[BaseUserId]bool
 
 
 		UnSubUser map[string]bool             //取关
 		UnSubUser map[string]bool             //取关
@@ -85,19 +87,21 @@ func (ar *AnalysisRes) UpdateTag(ctx context.Context) {
 
 
 func NewManager() *UserAnalysis {
 func NewManager() *UserAnalysis {
 	return &UserAnalysis{
 	return &UserAnalysis{
-		UserMapping:      map[string]BaseUserId{},
-		EntUserIdMapping: map[int64]BaseUserId{},
-		FullBaseUserId:   map[BaseUserId]bool{},
-		BinPhone:         map[BaseUserId]bool{},
-		BindMail:         map[BaseUserId]bool{},
-		Vip:              map[BaseUserId]bool{},
-		Vip15:            map[BaseUserId]bool{},
-		Vip30:            map[BaseUserId]bool{},
-		Member:           map[BaseUserId]bool{},
-		MemberExpire:     map[BaseUserId]bool{},
-		TestUser:         map[BaseUserId]bool{},
-		UnSubUser:        map[string]bool{},
-		NewUser:          map[int]map[BaseUserId]bool{},
+		UserMapping:        map[string]BaseUserId{},
+		EntUserIdMapping:   map[int64]BaseUserId{},
+		FullBaseUserId:     map[BaseUserId]bool{},
+		BinPhone:           map[BaseUserId]bool{},
+		BindMail:           map[BaseUserId]bool{},
+		Vip:                map[BaseUserId]bool{},
+		Vip15:              map[BaseUserId]bool{},
+		Vip30:              map[BaseUserId]bool{},
+		VipExpired30:       map[BaseUserId]bool{}, //已到期30天
+		VipGift7DayExpired: map[BaseUserId]bool{}, //赠送7天到期
+		Member:             map[BaseUserId]bool{},
+		MemberExpire:       map[BaseUserId]bool{},
+		TestUser:           map[BaseUserId]bool{},
+		UnSubUser:          map[string]bool{},
+		NewUser:            map[int]map[BaseUserId]bool{},
 	}
 	}
 }
 }
 
 

+ 29 - 0
userSign/userAnalysis/jobCklogs.go

@@ -0,0 +1,29 @@
+package userAnalysis
+
+import (
+	"context"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/util/gconv"
+	"github.com/pkg/errors"
+	"time"
+)
+
+func (ua *UserAnalysis) GetVisitUserAnalysis(ctx context.Context, t time.Time) ([]*AnalysisRes, error) {
+	var (
+		visitedVipBuyPage = map[BaseUserId]bool{}
+	)
+	res, err := g.DB().Query(ctx, "SELECT user_id,count(*) as total  FROM dwd_f_personnel_behavior WHERE `date` > ? and user_id!='' AND (url like '%jy_mobile/order/create/svip%' or url like '%/swordfish/page_big_pc/free/svip/buy%') group by user_id order BY total desc", t.Format(time.DateTime))
+	if err != nil {
+		return nil, errors.Wrap(err, "查询超级订阅购买页访问数据异常")
+	}
+
+	for _, m := range res.List() {
+		userId := gconv.String(m["user_id"])
+		baseUserId, ok := ua.UserMapping[userId]
+		if !ok {
+			continue
+		}
+		visitedVipBuyPage[baseUserId] = true
+	}
+	return []*AnalysisRes{{Name: "近45天浏览超级订阅购买页", Code: "visitedVipBuyPage", Data: visitedVipBuyPage}}, nil
+}

+ 14 - 1
userSign/userAnalysis/jobMgoUserRange.go

@@ -19,6 +19,8 @@ func (ua *UserAnalysis) GetMgoUserRes(ctx context.Context) ([]*AnalysisRes, erro
 		{Name: "超级订阅用户", Code: "vip", Data: ua.Vip},
 		{Name: "超级订阅用户", Code: "vip", Data: ua.Vip},
 		{Name: "超级订阅15天到期", Code: "vipExpire_15", Data: ua.Vip15},
 		{Name: "超级订阅15天到期", Code: "vipExpire_15", Data: ua.Vip15},
 		{Name: "超级订阅30天到期", Code: "vipExpire_30", Data: ua.Vip30},
 		{Name: "超级订阅30天到期", Code: "vipExpire_30", Data: ua.Vip30},
+		{Name: "超级订阅已经到期30天", Code: "vipExpired_30", Data: ua.VipExpired30},
+		{Name: "超级订阅赠送7天到期", Code: "vipGift7DayExpired ", Data: ua.VipExpired30},
 		{Name: "大会员用户", Code: "member", Data: ua.Member},
 		{Name: "大会员用户", Code: "member", Data: ua.Member},
 		{Name: "测试用户", Code: "testGroup", Data: ua.TestUser},
 		{Name: "测试用户", Code: "testGroup", Data: ua.TestUser},
 		{Name: "曾购大会员用户", Code: "memberExpired", Data: ua.MemberExpire}}
 		{Name: "曾购大会员用户", Code: "memberExpired", Data: ua.MemberExpire}}
@@ -90,7 +92,8 @@ func (ua *UserAnalysis) mgoUserRange(ctx context.Context) {
 			ua.BindMail[base_user_id] = true
 			ua.BindMail[base_user_id] = true
 		}
 		}
 		//超级订阅用户处理
 		//超级订阅用户处理
-		if vip_status := gconv.Int(m["i_vip_status"]); vip_status > 0 {
+		vip_status := gconv.Int(m["i_vip_status"])
+		if vip_status > 0 {
 			ua.Vip[base_user_id] = true
 			ua.Vip[base_user_id] = true
 			if timeStamp := gconv.Int64(m["l_vip_endtime"]); timeStamp > 0 {
 			if timeStamp := gconv.Int64(m["l_vip_endtime"]); timeStamp > 0 {
 				var vip_endtime = time.Unix(timeStamp, 0)
 				var vip_endtime = time.Unix(timeStamp, 0)
@@ -101,6 +104,16 @@ func (ua *UserAnalysis) mgoUserRange(ctx context.Context) {
 					ua.Vip30[base_user_id] = true
 					ua.Vip30[base_user_id] = true
 				}
 				}
 			}
 			}
+		} else if vip_status < 0 {
+			if vip_status == -2 { //赠送7天超级订阅到期
+				ua.VipGift7DayExpired[base_user_id] = true
+			}
+			if timeStamp := gconv.Int64(m["l_vip_endtime"]); timeStamp > 0 {
+				var vip_endtime = time.Unix(timeStamp, 0)
+				if vip_endtime.AddDate(0, 0, 30).Before(now) {
+					ua.VipExpired30[base_user_id] = true //超级订阅已到期30天
+				}
+			}
 		}
 		}
 		//大会员处理
 		//大会员处理
 		if member_status := gconv.Int(m["i_member_status"]); member_status > 0 {
 		if member_status := gconv.Int(m["i_member_status"]); member_status > 0 {

+ 19 - 3
userSign/userAnalysis/jobOrderRange.go

@@ -18,11 +18,12 @@ func (ua *UserAnalysis) TiDBOrderRange(ctx context.Context) ([]*AnalysisRes, err
 		return nil, err
 		return nil, err
 	}
 	}
 	var (
 	var (
-		now                             = time.Now()
-		hasPay                          = map[BaseUserId]bool{}
-		unBuyVipMonth, unBuyMemberMonth = map[BaseUserId]bool{}, map[BaseUserId]bool{}
+		now                                            = time.Now()
+		hasPay                                         = map[BaseUserId]bool{}
+		unBuyVipMonth, unBuyMemberMonth, unBuyVip45Day = map[BaseUserId]bool{}, map[BaseUserId]bool{}, map[BaseUserId]bool{}
 
 
 		vip, member = map[BaseUserId]int{}, map[BaseUserId]int{}
 		vip, member = map[BaseUserId]int{}, map[BaseUserId]int{}
+		vip45d      = map[BaseUserId]int{} //45天加购未购超级订阅
 	)
 	)
 	for index, m := range order.List() {
 	for index, m := range order.List() {
 		if index%10e4 == 0 {
 		if index%10e4 == 0 {
@@ -67,6 +68,14 @@ func (ua *UserAnalysis) TiDBOrderRange(ctx context.Context) ([]*AnalysisRes, err
 					}
 					}
 				}
 				}
 			}
 			}
+			//统计45天超级订阅加购未购
+			if now.Sub(t).Hours()/24 <= 45 {
+				if orderStatus <= 0 && pay_money == 0 && is_backstage_order == 0 {
+					vip45d[baseUserId] += 0
+				} else {
+					vip45d[baseUserId] += 1
+				}
+			}
 		}
 		}
 	}
 	}
 	for id, i := range vip {
 	for id, i := range vip {
@@ -74,14 +83,21 @@ func (ua *UserAnalysis) TiDBOrderRange(ctx context.Context) ([]*AnalysisRes, err
 			unBuyVipMonth[id] = true
 			unBuyVipMonth[id] = true
 		}
 		}
 	}
 	}
+	for id, i := range vip45d {
+		if i == 0 {
+			unBuyVip45Day[id] = true
+		}
+	}
 	for id, i := range member {
 	for id, i := range member {
 		if i == 0 {
 		if i == 0 {
 			unBuyMemberMonth[id] = true
 			unBuyMemberMonth[id] = true
 		}
 		}
 	}
 	}
+
 	return []*AnalysisRes{
 	return []*AnalysisRes{
 			{Name: "付费用户", Code: "hasPay", Data: hasPay},
 			{Name: "付费用户", Code: "hasPay", Data: hasPay},
 			{Name: "本月加购未购超级订阅", Code: "unBuyVipMonth", Data: unBuyVipMonth},
 			{Name: "本月加购未购超级订阅", Code: "unBuyVipMonth", Data: unBuyVipMonth},
+			{Name: "45天加购未购超级订阅", Code: "unBuyVip45Day", Data: unBuyVip45Day},
 			{Name: "本月加购未购大会员", Code: "unBuyMemberMonth", Data: unBuyMemberMonth}},
 			{Name: "本月加购未购大会员", Code: "unBuyMemberMonth", Data: unBuyMemberMonth}},
 		nil
 		nil
 }
 }

+ 0 - 1
wxSign/main.go

@@ -23,7 +23,6 @@ type (
 func main() {
 func main() {
 	ctx := gctx.New()
 	ctx := gctx.New()
 	_, err := gcron.Add(gctx.New(), g.Cfg().MustGet(ctx, "runCron", "# 0 2 * * *").String(), func(ctx context.Context) {
 	_, err := gcron.Add(gctx.New(), g.Cfg().MustGet(ctx, "runCron", "# 0 2 * * *").String(), func(ctx context.Context) {
-
 		for code, mConfig := range g.Cfg().MustGet(ctx, "groupConfig").Map() {
 		for code, mConfig := range g.Cfg().MustGet(ctx, "groupConfig").Map() {
 			var (
 			var (
 				mConfig = gconv.Map(mConfig)
 				mConfig = gconv.Map(mConfig)