wangchuanjin vor 3 Monaten
Ursprung
Commit
bab0f39361
2 geänderte Dateien mit 15 neuen und 16 gelöschten Zeilen
  1. 7 7
      matcher/freematch.go
  2. 8 9
      matcher/paymatch.go

+ 7 - 7
matcher/freematch.go

@@ -4,7 +4,7 @@ import (
 	. "bp.jydev.jianyu360.cn/BaseService/pushpkg/p"
 )
 
-//免费用户
+// 免费用户
 type FreeUser struct {
 	Users        map[*UserInfo]bool
 	Title_KeyDfa *KeyDfa
@@ -12,7 +12,6 @@ type FreeUser struct {
 	SubtypeUsers map[string]map[*UserInfo]bool
 }
 
-//
 func NewFreeUser() *FreeUser {
 	return &FreeUser{
 		Users:        map[*UserInfo]bool{},
@@ -21,12 +20,10 @@ func NewFreeUser() *FreeUser {
 	}
 }
 
-//
 func (f *FreeUser) Match(poolSize int, datas *[]map[string]interface{}) (*map[*UserInfo]*SortList, *map[*UserInfo]*[]string) {
 	return EachFoMatch(f, poolSize, datas)
 }
 
-//
 func (f *FreeUser) ToMatch(info map[string]interface{}) (*map[*UserInfo]*MatchUser, *[]*UserInfo) {
 	area, _ := info["area"].(string)
 	if area == "全国" {
@@ -58,8 +55,8 @@ func (f *FreeUser) ToMatch(info map[string]interface{}) (*map[*UserInfo]*MatchUs
 	return &users, nil
 }
 
-//获取最终的用户,排除词、信息范围、信息类型之后的
-//返回匹配上的用户和没有匹配到的用户
+// 获取最终的用户,排除词、信息范围、信息类型之后的
+// 返回匹配上的用户和没有匹配到的用户
 func (f *FreeUser) GetFinalUser(keys, notkeys []string, keyUser *map[string]*[]*UserInfo, info map[string]interface{}) *map[*UserInfo]*MatchUser {
 	area, _ := info["area"].(string)
 	toptype, _ := info["toptype"].(string)
@@ -102,7 +99,10 @@ func (f *FreeUser) GetFinalUser(keys, notkeys []string, keyUser *map[string]*[]*
 					Keys: []string{},
 				}
 			}
-			matchUser.Keys = append(matchUser.Keys, k)
+			if !matchUser.Key[k] {
+				matchUser.Keys = append(matchUser.Keys, k)
+			}
+			matchUser.Key[k] = true
 			users[u] = matchUser
 		}
 	}

+ 8 - 9
matcher/paymatch.go

@@ -7,7 +7,7 @@ import (
 	. "bp.jydev.jianyu360.cn/BaseService/pushpkg/p"
 )
 
-//付费用户
+// 付费用户
 type PayUser struct {
 	Users                map[*UserInfo]bool
 	Title_KeyDfa         *KeyDfa
@@ -23,7 +23,6 @@ type PayUser struct {
 	SubBusinessTypeUsers map[string]map[*UserInfo]bool
 }
 
-//
 func NewPayUser() *PayUser {
 	return &PayUser{
 		Users:                map[*UserInfo]bool{},
@@ -37,12 +36,10 @@ func NewPayUser() *PayUser {
 	}
 }
 
-//
 func (p *PayUser) Match(poolSize int, datas *[]map[string]interface{}) (*map[*UserInfo]*SortList, *map[*UserInfo]*[]string) {
 	return EachFoMatch(p, poolSize, datas)
 }
 
-//
 func (p *PayUser) ToMatch(info map[string]interface{}) (*map[*UserInfo]*MatchUser, *[]*UserInfo) {
 	buyerclass, _ := info["buyerclass"].(string)
 	area, _ := info["area"].(string)
@@ -154,7 +151,7 @@ func (p *PayUser) ToMatch(info map[string]interface{}) (*map[*UserInfo]*MatchUse
 	return &users, &projectUsers
 }
 
-//返回匹配上的用户
+// 返回匹配上的用户
 func (p *PayUser) GetKeyUser(matchWay string, keys []string, keyUser *map[string]*[]*UserInfo, yesUsers map[*UserInfo]*MatchUser) {
 	keyMap := map[string]bool{}
 	for _, v := range keys {
@@ -177,7 +174,10 @@ func (p *PayUser) GetKeyUser(matchWay string, keys []string, keyUser *map[string
 					MatchWay:  map[string]bool{},
 				}
 			}
-			matchUser.Keys = append(matchUser.Keys, k)
+			if !matchUser.Key[k] {
+				matchUser.Keys = append(matchUser.Keys, k)
+			}
+			matchUser.Key[k] = true
 			item := u.SubSet.Key_item[k]
 			if item != "" {
 				if !matchUser.Item[item] {
@@ -194,8 +194,8 @@ func (p *PayUser) GetKeyUser(matchWay string, keys []string, keyUser *map[string
 	}
 }
 
-//获取最终的用户,排除词、信息范围、信息类型之后的
-//返回匹配上的用户和没有匹配到的用户
+// 获取最终的用户,排除词、信息范围、信息类型之后的
+// 返回匹配上的用户和没有匹配到的用户
 func (p *PayUser) GetFinalUser(keys, notkeys []string, keyUsers ...*KeyDfa) map[*UserInfo]bool {
 	notUsers := map[*UserInfo]bool{}
 	keyMap := map[string]bool{}
@@ -227,7 +227,6 @@ func (p *PayUser) GetFinalUser(keys, notkeys []string, keyUsers ...*KeyDfa) map[
 	return notUsers
 }
 
-//
 func (p *PayUser) MatchArray(values []interface{}, u *UserInfo, all map[string]map[*UserInfo]bool) bool {
 	if all[""][u] {
 		return true