|
|
@@ -69,6 +69,20 @@ func handleUserVisitIpAddress(msg []byte) error { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
if msgStruct.MasterId == "" { |
|
|
|
cacheKeyForUrl := fmt.Sprintf(md.ZhiOsMasterIdForUrlHashMapCacheKey) |
|
|
|
get, _ := cache.HGetString(cacheKeyForUrl, msgStruct.Url) |
|
|
|
if get == "" { |
|
|
|
var domainType string |
|
|
|
if msgStruct.Pvd == "app" || msgStruct.Pvd == "applet" { |
|
|
|
domainType = "api" |
|
|
|
} else { |
|
|
|
domainType = "wap" |
|
|
|
} |
|
|
|
msgStruct.MasterId = GetWebSiteDomainMasterId(domainType, msgStruct.Url) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//1、判断ip是否已统计 |
|
|
|
cacheKey := fmt.Sprintf(md.ZhiOsUserVisitIpAddressHashMapCacheKey, msgStruct.MasterId, today) |
|
|
|
//get, _ := cache.HGetString(cacheKey, msgStruct.Ip) |
|
|
@@ -84,6 +98,7 @@ func handleUserVisitIpAddress(msg []byte) error { |
|
|
|
if cityName == "" { |
|
|
|
cityName = msgStruct.City |
|
|
|
} |
|
|
|
|
|
|
|
data = append(data, &model.MasterAreaVisitsFlows{ |
|
|
|
Ip: msgStruct.Ip, |
|
|
|
MasterId: utils.StrToInt(msgStruct.MasterId), |
|
|
@@ -93,6 +108,7 @@ func handleUserVisitIpAddress(msg []byte) error { |
|
|
|
ProvinceId: provinceId, |
|
|
|
CityName: cityName, |
|
|
|
CityId: cityId, |
|
|
|
Pvd: msgStruct.Pvd, |
|
|
|
CreateAt: now, |
|
|
|
UpdateAt: now, |
|
|
|
}) |
|
|
@@ -129,3 +145,13 @@ func getIpAddress(Db *xorm.Engine, message md.ZhiOsUserVisitIpAddressMessage) (c |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 获取指定类型的域名对应的masterId:admin、wap、api |
|
|
|
func GetWebSiteDomainMasterId(domainType string, host string) string { |
|
|
|
obj := new(model.UserAppDomain) |
|
|
|
has, err := db.Db.Where("domain=? and type=?", host, domainType).Get(obj) |
|
|
|
if err != nil || !has { |
|
|
|
return "" |
|
|
|
} |
|
|
|
return utils.AnyToString(obj.Uuid) |
|
|
|
} |