wangshan 5 жил өмнө
parent
commit
3f2d2049e9

+ 30 - 20
src/jfw/modules/subscribepay/src/service/afterPay.go

@@ -268,6 +268,7 @@ func (a *AfterPay) SetUserInfo() error {
 			actionType := a.GetString("actionType")
 			addtion_kws := a.GetSlice("addition_kws")
 			not_kws := a.GetSlice("not_kws")
+			kwscount := a.GetString("kwscount")
 			if len([]rune(kws_name)) > 20 {
 				kws_name = qutil.SubString(kws_name, 0, 20)
 			}
@@ -294,27 +295,36 @@ func (a *AfterPay) SetUserInfo() error {
 							}
 						}
 					}
-					var _key = make(map[string]interface{})
-					var a_key = make([]map[string]interface{}, 1)
-					if classify_name == "" {
-						classify_name = "未分类"
-					}
-					_key["key"] = _kws
-					_key["appendkey"] = addtion_kws
-					_key["notkey"] = not_kws
-					a_key[0] = _key
-					if len(a_key) > 0 {
-						flag = util.MQFW.UpdateById("user", userId, bson.M{
-							"$push": bson.M{
-								"o_vipjy.a_items." + classify_index + ".a_key": bson.M{
-									"$each": a_key,
+					if kwscount != "0" {
+						//修改关键词
+						saveData["o_vipjy.a_items."+classify_index+".s_item"] = classify_name
+						saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".key"] = _kws
+						saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".appendkey"] = addtion_kws
+						saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".notkey"] = not_kws
+					} else {
+						//首次添加分类和关键词
+						var _key = make(map[string]interface{})
+						var a_key = make([]map[string]interface{}, 1)
+						if classify_name == "" {
+							classify_name = "未分类"
+						}
+						_key["key"] = _kws
+						_key["appendkey"] = addtion_kws
+						_key["notkey"] = not_kws
+						a_key[0] = _key
+						if len(a_key) > 0 {
+							flag = util.MQFW.UpdateById("user", userId, bson.M{
+								"$push": bson.M{
+									"o_vipjy.a_items." + classify_index + ".a_key": bson.M{
+										"$each": a_key,
+									},
 								},
-							},
-							"$set": bson.M{
-								"o_vipjy.l_modifydate":                          time.Now().Unix(),
-								"o_vipjy.a_items." + classify_index + ".s_item": classify_name,
-							},
-						})
+								"$set": bson.M{
+									"o_vipjy.l_modifydate":                          time.Now().Unix(),
+									"o_vipjy.a_items." + classify_index + ".s_item": classify_name,
+								},
+							})
+						}
 					}
 					//					}
 				} else if actionType == "DK" { //删除关键词

+ 1 - 0
src/web/templates/weixin/vipsubscribe/keyWord.html

@@ -634,6 +634,7 @@
             param.actionType = actionType;
             param.addition_kws = addition_kws;
             param.not_kws = not_kws;
+			 param.kwscount = $(".content .showKeyWord li").length;
             $.ajax({
                 type: "POST",
                 url: "/subscribepay/afterPay/setUserInfo",