|
@@ -86,58 +86,145 @@ func (this *ParamInfo) SetAreaByOneProvince() (b bool) {
|
|
}
|
|
}
|
|
return b
|
|
return b
|
|
}
|
|
}
|
|
-func (this *ParamInfo) IsSub() (bool, string) {
|
|
|
|
- mData := config.Compatible.Select(this.UserId, `{"o_jy":1,"o_member_jy":1,"o_vipjy":1,"i_vip_status":1,"i_member_status":1}`)
|
|
|
|
|
|
+func (this *ParamInfo) IsSub() (bool, string, map[string][]interface{}, map[string][]interface{}) {
|
|
|
|
+ areaMap := make(map[string][]interface{})
|
|
|
|
+ districtMap := make(map[string][]interface{})
|
|
|
|
+ mData := config.Compatible.Select(this.UserId, `{"o_jy":1,"o_member_jy":1,"o_vipjy":1,"i_vip_status":1,"i_member_status":1,"last_trigger_time":1}`)
|
|
productType := "free"
|
|
productType := "free"
|
|
|
|
+ isNull := false
|
|
memberStatus := gconv.Int64((*mData)["i_member_status"])
|
|
memberStatus := gconv.Int64((*mData)["i_member_status"])
|
|
vipStatus := gconv.Int64((*mData)["i_vip_status"])
|
|
vipStatus := gconv.Int64((*mData)["i_vip_status"])
|
|
|
|
+ if memberStatus > 0 {
|
|
|
|
+ productType = "member"
|
|
|
|
+ } else if vipStatus > 0 {
|
|
|
|
+ productType = "vip"
|
|
|
|
+ }
|
|
if mData != nil && len(*mData) != 0 {
|
|
if mData != nil && len(*mData) != 0 {
|
|
positionType := gconv.Int64(this.Session.Get("positionType"))
|
|
positionType := gconv.Int64(this.Session.Get("positionType"))
|
|
if positionType == 1 {
|
|
if positionType == 1 {
|
|
//企业身份
|
|
//企业身份
|
|
- return false, productType
|
|
|
|
|
|
+ return false, productType, areaMap, districtMap
|
|
|
|
+ }
|
|
|
|
+ lastTriggerTime := gconv.Int64((*mData)["last_trigger_time"])
|
|
|
|
+ if time.Now().Unix()-lastTriggerTime < config.Config.FrequentContinuous*24*60*60 {
|
|
|
|
+ return false, productType, areaMap, districtMap
|
|
}
|
|
}
|
|
o_jy, _ := (*mData)["o_jy"].(map[string]interface{})
|
|
o_jy, _ := (*mData)["o_jy"].(map[string]interface{})
|
|
|
|
+ a_key, _ := o_jy["a_key"].([]interface{})
|
|
|
|
+ if len(a_key) > 0 {
|
|
|
|
+ return false, productType, areaMap, districtMap
|
|
|
|
+ }
|
|
if o_jy["o_area"] != nil {
|
|
if o_jy["o_area"] != nil {
|
|
oarea, _ := o_jy["o_area"].(map[string]interface{})
|
|
oarea, _ := o_jy["o_area"].(map[string]interface{})
|
|
if len(oarea) > 0 {
|
|
if len(oarea) > 0 {
|
|
- return false, productType
|
|
|
|
|
|
+ for s, i := range oarea {
|
|
|
|
+ areaMap[s] = gconv.Interfaces(i)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ isNull = false
|
|
|
|
+ } else {
|
|
|
|
+ isNull = true
|
|
}
|
|
}
|
|
- a_key, _ := o_jy["a_key"].([]interface{})
|
|
|
|
- if len(a_key) > 0 {
|
|
|
|
- return false, productType
|
|
|
|
|
|
+ if o_jy["o_district"] != nil {
|
|
|
|
+ district, _ := o_jy["o_district"].(map[string]interface{})
|
|
|
|
+ if len(district) > 0 {
|
|
|
|
+ for s, i := range district {
|
|
|
|
+ districtMap[s] = gconv.Interfaces(i)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if vipStatus > 0 {
|
|
if vipStatus > 0 {
|
|
- productType = "vip"
|
|
|
|
o_vipjy, _ := (*mData)["o_vipjy"].(map[string]interface{})
|
|
o_vipjy, _ := (*mData)["o_vipjy"].(map[string]interface{})
|
|
|
|
+ a_key, _ = o_vipjy["a_key"].([]interface{})
|
|
|
|
+ if len(a_key) > 0 {
|
|
|
|
+ return false, productType, areaMap, districtMap
|
|
|
|
+ }
|
|
if o_vipjy["o_area"] != nil {
|
|
if o_vipjy["o_area"] != nil {
|
|
oarea, _ := o_vipjy["o_area"].(map[string]interface{})
|
|
oarea, _ := o_vipjy["o_area"].(map[string]interface{})
|
|
if len(oarea) > 0 {
|
|
if len(oarea) > 0 {
|
|
- return false, productType
|
|
|
|
|
|
+ for s, i := range oarea {
|
|
|
|
+ areaMap[s] = gconv.Interfaces(i)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ isNull = false
|
|
|
|
+ } else {
|
|
|
|
+ isNull = true
|
|
|
|
+ areaMap = make(map[string][]interface{})
|
|
}
|
|
}
|
|
- a_key, _ = o_vipjy["a_key"].([]interface{})
|
|
|
|
- if len(a_key) > 0 {
|
|
|
|
- return false, productType
|
|
|
|
|
|
+ if o_vipjy["o_district"] != nil {
|
|
|
|
+ district, _ := o_vipjy["o_district"].(map[string]interface{})
|
|
|
|
+ if len(district) > 0 {
|
|
|
|
+ for s, i := range district {
|
|
|
|
+ districtMap[s] = gconv.Interfaces(i)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ districtMap = make(map[string][]interface{})
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ districtMap = make(map[string][]interface{})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if memberStatus > 0 {
|
|
if memberStatus > 0 {
|
|
- productType = "member"
|
|
|
|
o_member_jy, _ := (*mData)["o_member_jy"].(map[string]interface{})
|
|
o_member_jy, _ := (*mData)["o_member_jy"].(map[string]interface{})
|
|
|
|
+ a_key, _ = o_member_jy["a_key"].([]interface{})
|
|
|
|
+ if len(a_key) > 0 {
|
|
|
|
+ return false, productType, areaMap, districtMap
|
|
|
|
+ }
|
|
if o_member_jy["o_area"] != nil {
|
|
if o_member_jy["o_area"] != nil {
|
|
oarea, _ := o_member_jy["o_area"].(map[string]interface{})
|
|
oarea, _ := o_member_jy["o_area"].(map[string]interface{})
|
|
if len(oarea) > 0 {
|
|
if len(oarea) > 0 {
|
|
- return false, productType
|
|
|
|
|
|
+ for s, i := range oarea {
|
|
|
|
+ areaMap[s] = gconv.Interfaces(i)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ areaMap = make(map[string][]interface{})
|
|
}
|
|
}
|
|
|
|
+ isNull = false
|
|
|
|
+ } else {
|
|
|
|
+ isNull = true
|
|
|
|
+ areaMap = make(map[string][]interface{})
|
|
}
|
|
}
|
|
- a_key, _ = o_member_jy["a_key"].([]interface{})
|
|
|
|
- if len(a_key) > 0 {
|
|
|
|
- return false, productType
|
|
|
|
|
|
+ if o_member_jy["o_district"] != nil {
|
|
|
|
+ district, _ := o_member_jy["o_district"].(map[string]interface{})
|
|
|
|
+ if len(district) > 0 {
|
|
|
|
+ for s, i := range district {
|
|
|
|
+ districtMap[s] = gconv.Interfaces(i)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ districtMap = make(map[string][]interface{})
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ districtMap = make(map[string][]interface{})
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if isNull {
|
|
|
|
+ area, city, district := HistorySearch(this.UserId)
|
|
|
|
+ if area != "" {
|
|
|
|
+ if city != "" {
|
|
|
|
+ areaMap[area] = []interface{}{
|
|
|
|
+ city,
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ areaMap[area] = []interface{}{}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if productType != "free" && area != "" && district != "" {
|
|
|
|
+ districtMap[city] = []interface{}{
|
|
|
|
+ district,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return true, productType
|
|
|
|
|
|
+ config.Compatible.Update(this.UserId, map[string]interface{}{
|
|
|
|
+ "$set": map[string]interface{}{"last_trigger_time": time.Now().Unix()},
|
|
|
|
+ })
|
|
|
|
+ if len(areaMap) == 0 && areaMap != nil && len(districtMap) == 0 && districtMap != nil {
|
|
|
|
+ return true, productType, nil, nil
|
|
|
|
+ } else {
|
|
|
|
+ return true, productType, areaMap, districtMap
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
type RuleStruct struct {
|
|
type RuleStruct struct {
|
|
@@ -145,7 +232,7 @@ type RuleStruct struct {
|
|
}
|
|
}
|
|
|
|
|
|
// 浏览记录查询
|
|
// 浏览记录查询
|
|
-func (this *ParamInfo) HistorySearch(userId string) (string, string, string) {
|
|
|
|
|
|
+func HistorySearch(userId string) (string, string, string) {
|
|
ass := []RuleStruct{}
|
|
ass := []RuleStruct{}
|
|
rows, err1 := db.ClickhouseConn.Query(context.TODO(), "select browse from sub_recommend_rule where userid=?", userId)
|
|
rows, err1 := db.ClickhouseConn.Query(context.TODO(), "select browse from sub_recommend_rule where userid=?", userId)
|
|
if err1 != nil {
|
|
if err1 != nil {
|