|
@@ -11,6 +11,75 @@ import (
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
|
|
+type SemJsChatRecord struct {
|
|
|
|
+ ChatID int64 `gorm:"column:CHAT_ID"`
|
|
|
|
+ CreateTime time.Time `gorm:"column:CREATE_TIME"`
|
|
|
|
+ ReferPage string `gorm:"type:text;column:REFER_PAGE"`
|
|
|
|
+ ChatURL string `gorm:"type:text;column:CHAT_URL"`
|
|
|
|
+ ChannleID int `gorm:"column:CHANNLE_ID"`
|
|
|
|
+ CategoryID int `gorm:"column:CATEGORY_ID"`
|
|
|
|
+ GrUserID string `gorm:"column:gr_user_id"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 会话渠道归因处理
|
|
|
|
+func getChatChannel(chat SemJsChatRecord) ChannelCategory {
|
|
|
|
+ channel := 7
|
|
|
|
+ category := 126
|
|
|
|
+ if strings.Contains(chat.ChatURL, "pages") && strings.Split(strings.Split(chat.ChatURL, "?")[1], "=")[0] == "miniapp" {
|
|
|
|
+ appType := strings.Split(strings.Split(strings.Split(chat.ChatURL, "?")[1], "=")[1], "_")[1]
|
|
|
|
+ if appType == "baidu" {
|
|
|
|
+ channel = 1
|
|
|
|
+ category = 30
|
|
|
|
+ } else if appType == "wechat" {
|
|
|
|
+ channel = 8
|
|
|
|
+ category = 32
|
|
|
|
+ }
|
|
|
|
+ } else if !strings.Contains(chat.ReferPage, "utm") && !strings.Contains(chat.ChatURL, "utm") && (strings.Contains(chat.ReferPage, "daomeng") || strings.Contains(chat.ChatURL, "daomeng")) {
|
|
|
|
+ channel = 38
|
|
|
|
+ category = 201
|
|
|
|
+ } else if chat.ChannleID == 5 || chat.ChannleID == 7 && !strings.Contains(chat.ReferPage, "utm") && !strings.Contains(chat.ChatURL, "utm") {
|
|
|
|
+ layout := "2006-01-02 15:04:05"
|
|
|
|
+ startTime := chat.CreateTime.Add(-1 * time.Hour)
|
|
|
|
+ start := startTime.Format(layout)
|
|
|
|
+ end := chat.CreateTime.Format(layout)
|
|
|
|
+ sql := "select $url from events where distinct_id = '" + chat.GrUserID + "'and event = '$pageview' and time between '" + start + "' and '" + end + "' order by time limit 1"
|
|
|
|
+ url := getSensorsData(sql)
|
|
|
|
+ if strings.Contains(url, "utm") && strings.Contains(strings.ToLower(url), "link") {
|
|
|
|
+ channelIDString := strings.Split(strings.Split(strings.Split(url, "link")[1], "_")[0], "=")[1]
|
|
|
|
+ categoryIDString := strings.Split(strings.Split(strings.Split(url, "link")[1], "_")[0], "=")[2]
|
|
|
|
+ channel, _ = strconv.Atoi(channelIDString)
|
|
|
|
+ category, _ = strconv.Atoi(categoryIDString)
|
|
|
|
+ } else if url == "https://www.jjl.cn/" || url == "https://m.jjl.cn/" {
|
|
|
|
+ channel = 7
|
|
|
|
+ category = 126
|
|
|
|
+ } else {
|
|
|
|
+ channel = 5
|
|
|
|
+ category = 11
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if strings.Contains(strings.ToLower(chat.ChatURL), "link") {
|
|
|
|
+ channelIDString := strings.Split(strings.Split(strings.Split(chat.ChatURL, "link")[1], "_")[0], "=")[1]
|
|
|
|
+ categoryIDString := strings.Split(strings.Split(strings.Split(chat.ChatURL, "link")[1], "_")[0], "=")[2]
|
|
|
|
+ channel, _ = strconv.Atoi(channelIDString)
|
|
|
|
+ category, _ = strconv.Atoi(categoryIDString)
|
|
|
|
+ } else if strings.Contains(strings.ToLower(chat.ReferPage), "link") {
|
|
|
|
+ channelIDString := strings.Split(strings.Split(strings.Split(chat.ReferPage, "link")[1], "_")[0], "=")[1]
|
|
|
|
+ categoryIDString := strings.Split(strings.Split(strings.Split(chat.ReferPage, "link")[1], "_")[0], "=")[2]
|
|
|
|
+ channel, _ = strconv.Atoi(channelIDString)
|
|
|
|
+ category, _ = strconv.Atoi(categoryIDString)
|
|
|
|
+ } else if !strings.Contains(strings.ToLower(chat.ReferPage), "link") {
|
|
|
|
+ channel = 7
|
|
|
|
+ category = 126
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var channelCategory ChannelCategory
|
|
|
|
+ channelCategory.Channel = channel
|
|
|
|
+ channelCategory.Category = category
|
|
|
|
+ return channelCategory
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
type ResourceAssessment struct {
|
|
type ResourceAssessment struct {
|
|
ID uint `gorm:"primaryKey" json:"id"` // 留学评估表
|
|
ID uint `gorm:"primaryKey" json:"id"` // 留学评估表
|
|
DataType uint8 `json:"data_type"` // 1.网课 2.api资源 3.专题页 4.工作台录入 5.后台录入 6 小程序
|
|
DataType uint8 `json:"data_type"` // 1.网课 2.api资源 3.专题页 4.工作台录入 5.后台录入 6 小程序
|