Pārlūkot izejas kodu

Merge branch 'dev2.8.5' of http://192.168.3.207:10080/qmx/jy into dev2.8.5

xuzhiheng 5 gadi atpakaļ
vecāks
revīzija
3a9bc6a897

+ 41 - 27
src/jfw/modules/subscribepay/src/service/afterPay.go

@@ -164,7 +164,6 @@ func (a *AfterPay) DirectSubKWS() error {
 			} else if kwsCount >= 300 {
 				flag = "m"
 			} else {
-				//首次添加分类和关键词
 				var _key = make(map[string]interface{})
 				var a_key = make([]map[string]interface{}, 1)
 				classify_name := "未分类"
@@ -269,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)
 			}
@@ -295,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" { //删除关键词
@@ -376,12 +385,17 @@ func (a *AfterPay) GetUserInfo() error {
 			}
 			delete((*userData), "o_jy")
 			//区域
-			_buyset := qutil.ObjToMap((*data)["o_buyset"].(interface{}))
-			var area_i = qutil.IntAll((*_buyset)["areacount"])
-			var citys = qutil.ObjToMap((*_buyset)["citys"].(interface{}))
+			var area_i = -1
+			var buyerclasscount = -1
 			var city_i = 0
-			for _, cv := range *citys {
-				city_i += qutil.IntAll(cv.(int))
+			_buyset := qutil.ObjToMap((*data)["o_buyset"].(interface{}))
+			if (*_buyset)["citys"] != nil {
+				area_i = qutil.IntAll((*_buyset)["areacount"])
+				citys := qutil.ObjToMap((*_buyset)["citys"].(interface{}))
+				buyerclasscount = qutil.IntAll((*_buyset)["buyerclasscount"])
+				for _, cv := range *citys {
+					city_i += qutil.IntAll(cv.(int))
+				}
 			}
 			if area_i != -1 && city_i != 0 {
 				(*data)["o_area"] = strconv.Itoa(area_i) + "个省级区域、" + strconv.Itoa(city_i) + "个地市"
@@ -393,7 +407,7 @@ func (a *AfterPay) GetUserInfo() error {
 				(*data)["o_area"] = "全国"
 			}
 			//采购行业
-			(*data)["a_buyerclass"] = qutil.IntAll((*_buyset)["buyerclasscount"])
+			(*data)["a_buyerclass"] = buyerclasscount
 			//有效日期
 			var _starttime = (*userData)["l_vip_starttime"]
 			(*userData)["l_vip_starttime"] = strings.Replace(qutil.FormatDateWithObj(&_starttime, qutil.Date_Short_Layout), "-", ".", -1)

+ 1 - 1
src/jfw/modules/subscribepay/src/timetask/timetask.go

@@ -72,7 +72,7 @@ func syncVipUpgrade() {
 
 //每天0点 检查试用、vip服务是否到期
 func checkIsExpire() {
-	crontab(false, TimeTaskConfig.CheckIsExpire, func() {
+	crontab(true, TimeTaskConfig.CheckIsExpire, func() {
 		log.Println("定时任务,开始更新vip状态")
 		now_unix := time.Now().Unix()
 		sess := util.MQFW.GetMgoConn()

+ 17 - 25
src/jfw/modules/weixin/src/wx/wx.go

@@ -1559,9 +1559,7 @@ func vipFastSubscribe(user *map[string]interface{}, keyWord, openId string) (ret
 	}
 	o_vipjy, _ := (*user)["o_vipjy"].(map[string]interface{})
 	var classify_index = 0 //未分类索引
-	//var keys_index = 0     未分类关键词组数量
-	var keysHas = ""    //已订阅关键词
-	var itemHas = false //是否有未分类
+	var keysHas = ""       //已订阅关键词
 	flag := false
 	//有分类
 	var keysFilter = strings.Split(strings.Replace(keyWord, "+", " ", -1), " ")
@@ -1574,7 +1572,6 @@ func vipFastSubscribe(user *map[string]interface{}, keyWord, openId string) (ret
 			keysMap := util.ObjArrToMapArr(v["a_key"].([]interface{}))
 			if v["s_item"].(string) == "未分类" {
 				classify_index = i
-				itemHas = true
 			}
 			keysCount += len(keysMap)
 			for _, k := range keysMap {
@@ -1607,29 +1604,23 @@ func vipFastSubscribe(user *map[string]interface{}, keyWord, openId string) (ret
 			return -3, strings.Replace(keyWord, "+", " ", -1), hasOldKey
 		}
 	}
-	var _key []map[string]interface{}
-	if itemHas {
-		for _, v := range keysFilter {
-			tmp := map[string]interface{}{"key": strings.Split(v, " ")}
-			_key = append(_key, tmp)
-		}
+	var _key = make(map[string]interface{})
+	var a_key = make([]map[string]interface{}, 1)
+	classify_name := "未分类"
+	_key["key"] = keysFilter
+	a_key[0] = _key
+	if len(a_key) > 0 {
 		flag = tools.MQFW.Update("user", `{"s_m_openid":"`+openId+`"}`, bson.M{
-			"$push": bson.M{"o_vipjy.a_items." + strconv.Itoa(classify_index) + ".a_key": bson.M{"$each": _key}},
+			"$push": bson.M{
+				"o_vipjy.a_items." + strconv.Itoa(classify_index) + ".a_key": bson.M{
+					"$each": a_key,
+				},
+			},
+			"$set": bson.M{
+				"o_vipjy.l_modifydate":                                        time.Now().Unix(),
+				"o_vipjy.a_items." + strconv.Itoa(classify_index) + ".s_item": classify_name,
+			},
 		}, false, false)
-	} else {
-		var o_kws = make(map[string]interface{})
-		o_kws["s_item"] = "未分类"
-		for _, v := range keysFilter {
-			tmp := map[string]interface{}{"key": strings.Split(v, " ")}
-			_key = append(_key, tmp)
-		}
-		o_kws["a_key"] = _key
-		o_kws["i_tips"] = 0
-		if o_kws != nil && len(o_kws) > 0 {
-			flag = tools.MQFW.Update("user", `{"s_m_openid":"`+openId+`"}`, bson.M{
-				"$push": bson.M{"o_vipjy.a_items": o_kws},
-			}, false, false)
-		}
 	}
 	if flag {
 		return 1, strings.Replace(strings.Join(keysFilter, " "), "+", " ", -1), hasOldKey
@@ -1646,6 +1637,7 @@ func fastSubscribe(content, openId string) (int, string, bool) {
 		//content = strings.TrimSpace(content)
 		content = regexp.MustCompile("\\s+").ReplaceAllString(content, " ")
 		keyWord := strings.Replace(content, " ", "+", -1)
+		log.Println(keyWord, ":kwssssssss")
 		o_jy, _ := (*user)["o_jy"].(map[string]interface{})
 		i_vip_status := util.IntAll((*user)["i_vip_status"])
 		if (*user)["i_vip_status"] != nil && i_vip_status > 0 && keyWord != "" {

+ 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",