|
@@ -496,7 +496,7 @@ func (a *AfterPay) SetUserInfo() error {
|
|
|
_key["key"] = newKws
|
|
|
_key["appendkey"] = append(addtion_kws, _kws[1:]...)
|
|
|
_key["notkey"] = not_kws
|
|
|
- _key["matchway"] = match_way
|
|
|
+ _key["matchway"] = match_way //matchway 0:精准匹配 1:模糊匹配
|
|
|
if kwscount != "0" {
|
|
|
if KeyWordsRepeat(_key, a_items) {
|
|
|
flag = false
|
|
@@ -509,7 +509,6 @@ func (a *AfterPay) SetUserInfo() error {
|
|
|
saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".notkey"] = not_kws
|
|
|
saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".matchway"] = match_way
|
|
|
saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".updatetime"] = time.Now().Unix()
|
|
|
-
|
|
|
}
|
|
|
} else {
|
|
|
//首次添加分类和关键词
|
|
@@ -547,16 +546,17 @@ func (a *AfterPay) SetUserInfo() error {
|
|
|
//没有关键词 批量删除/新增分类
|
|
|
if classify_name != "" {
|
|
|
if actionType == "SC" { //保存分类 无关键词
|
|
|
- log.Println(sitemsArr, classify_name)
|
|
|
if isRepeat(append(sitemsArr, classify_name)) {
|
|
|
msg = "分类名称重复"
|
|
|
} else {
|
|
|
- if classify_index == "" {
|
|
|
- classify_index = strconv.Itoa(len(a_items)) //索引
|
|
|
- saveData["o_vipjy.a_items."+classify_index+".a_key"] = []map[string]interface{}{}
|
|
|
+ c_lens := strconv.Itoa(len(a_items))
|
|
|
+ if ci, _ := strconv.Atoi(classify_index); ci < len(a_items)+1 {
|
|
|
+ if classify_index == "" || c_lens == classify_index { //新增
|
|
|
+ classify_index = strconv.Itoa(len(a_items)) //索引
|
|
|
+ saveData["o_vipjy.a_items."+classify_index+".a_key"] = []map[string]interface{}{}
|
|
|
+ }
|
|
|
+ saveData["o_vipjy.a_items."+classify_index+".s_item"] = classify_name
|
|
|
}
|
|
|
- log.Println("====", classify_index)
|
|
|
- saveData["o_vipjy.a_items."+classify_index+".s_item"] = classify_name
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -758,12 +758,13 @@ func (a *AfterPay) GetUserInfo() error {
|
|
|
|
|
|
//关键词判重
|
|
|
func KeyWordsRepeat(obj map[string]interface{}, aitems []interface{}) bool {
|
|
|
+ // 录入的关键词
|
|
|
key, _ := obj["key"].([]string)
|
|
|
notkey, _ := obj["notkey"].([]string)
|
|
|
- matchway, _ := obj["matchway"].(int)
|
|
|
+ matchway, _ := obj["matchway"].(int) //matchway 0:精准匹配 1:模糊匹配
|
|
|
appendkey, _ := obj["appendkey"].([]string)
|
|
|
log.Println("obj", obj)
|
|
|
- // 录入的关键词
|
|
|
+ keyM := map[string]bool{} //已有的关键词组
|
|
|
for _, v := range aitems {
|
|
|
if items, ok := v.(map[string]interface{}); ok && len(items) > 0 {
|
|
|
for kk, vv := range items {
|
|
@@ -781,12 +782,38 @@ func KeyWordsRepeat(obj map[string]interface{}, aitems []interface{}) bool {
|
|
|
if n["appendkey"] != nil {
|
|
|
db_append = qutil.ObjArrToStringArr(n["appendkey"].([]interface{}))
|
|
|
}
|
|
|
- if StringArrEqual(key, db_key) && StringArrEqual(notkey, db_not) && qutil.IntAllDef(n["matchway"], 0) == matchway && StringArrEqual(appendkey, db_append) {
|
|
|
- return true
|
|
|
+ db_matchway := qutil.IntAllDef(n["matchway"], 0)
|
|
|
+ k_m := ""
|
|
|
+ if db_matchway == 1 {
|
|
|
+ for _, x := range append(db_key, db_append...) {
|
|
|
+ k_m = fmt.Sprintf("%s_%s_%v", x, strings.Join(db_not, ""), db_matchway)
|
|
|
+ log.Println("--k_m-", k_m)
|
|
|
+ keyM[k_m] = true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ k_m = fmt.Sprintf("%s_%s_%v", strings.Join(append(db_key, db_append...), ""), strings.Join(db_not, ""), db_matchway)
|
|
|
+ keyM[k_m] = true
|
|
|
+ log.Println("--k_m-", k_m)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(keyM) > 0 {
|
|
|
+ if matchway == 1 {
|
|
|
+ for _, v := range append(key, appendkey...) {
|
|
|
+ k_m2 := fmt.Sprintf("%s_%s_%v", v, strings.Join(notkey, ""), matchway)
|
|
|
+ log.Println("--", k_m2)
|
|
|
+ if keyM[k_m2] {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ k_m2 := fmt.Sprintf("%s_%s_%v", strings.Join(append(key, appendkey...), ""), strings.Join(notkey, ""), matchway)
|
|
|
+ log.Println("--", k_m2)
|
|
|
+ if keyM[k_m2] {
|
|
|
+ return true
|
|
|
}
|
|
|
}
|
|
|
}
|