zhangxinlei1996 4 years ago
parent
commit
0a24171b5d

+ 40 - 13
src/jfw/modules/subscribepay/src/service/afterPay.go

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

+ 32 - 7
src/jfw/modules/subscribepay/src/service/vipSubscribeChange.go

@@ -22,10 +22,11 @@ import (
 //订阅修改 or 升级
 //订阅修改 or 升级
 type SubscribeChange struct {
 type SubscribeChange struct {
 	*xweb.Action
 	*xweb.Action
-	getSubBuyMsg  xweb.Mapper `xweb:"/vipsubscribe/getSubBuyMsg"`  //获取vip订阅详情
-	saveChange    xweb.Mapper `xweb:"/vipsubscribe/saveChange"`    //订阅修改
-	mergeIndustry xweb.Mapper `xweb:"/vipsubscribe/mergeIndustry"` //行业合并
-	upgrade       xweb.Mapper `xweb:"/vipsubscribe/upgrade"`       //升级超级订阅
+	getSubBuyMsg   xweb.Mapper `xweb:"/vipsubscribe/getSubBuyMsg"`   //获取vip订阅详情
+	saveChange     xweb.Mapper `xweb:"/vipsubscribe/saveChange"`     //订阅修改
+	mergeIndustry  xweb.Mapper `xweb:"/vipsubscribe/mergeIndustry"`  //行业合并
+	upgrade        xweb.Mapper `xweb:"/vipsubscribe/upgrade"`        //升级超级订阅
+	freeSaveChange xweb.Mapper `xweb:"/vipsubscribe/freeSaveChange"` //免费用户试用超级订阅
 }
 }
 
 
 func init() {
 func init() {
@@ -112,6 +113,30 @@ func (this *SubscribeChange) SaveChange() {
 	this.ServeJson(r.Format())
 	this.ServeJson(r.Format())
 }
 }
 
 
+//免费用户设置超级订阅(体验)
+func (this *SubscribeChange) FreeSaveChange() {
+	area := qutil.ObjToMap(this.GetString("area"))
+	industry := strings.Split(this.GetString("industry"), ",")
+	userId := qutil.ObjToString(this.GetSession("userId"))
+	r := func() *entity.FuncResult {
+		if len(industry) == 1 && industry[0] == "" {
+			industry = []string{}
+		}
+		updateOk := util.MQFW.UpdateById("user", userId,
+			bson.M{"$set": bson.M{
+				"o_vipjy.o_area":       area,     //设置地区
+				"o_vipjy.a_buyerclass": industry, //设置行业
+			}})
+		return &entity.FuncResult{true, nil, map[string]interface{}{
+			"doSuccess": updateOk,
+		}}
+	}()
+	if r.Err != nil {
+		log.Printf("%s SaveChange err:%v\n", userId, r.Err.Error())
+	}
+	this.ServeJson(r.Format())
+}
+
 //升级订阅
 //升级订阅
 func (this *SubscribeChange) Upgrade() {
 func (this *SubscribeChange) Upgrade() {
 	userId := qutil.ObjToString(this.GetSession("userId"))
 	userId := qutil.ObjToString(this.GetSession("userId"))
@@ -147,7 +172,7 @@ func (this *SubscribeChange) Upgrade() {
 			}
 			}
 			needRenew = true
 			needRenew = true
 		}
 		}
-		area_select := true //是否回显城市选择
+		area_select := true                     //是否回显城市选择
 		if len(*area) == 0 && area_count != 0 { //升级时为传入选择省份
 		if len(*area) == 0 && area_count != 0 { //升级时为传入选择省份
 			(*area)["areacount"] = area_count
 			(*area)["areacount"] = area_count
 			area_select = false
 			area_select = false
@@ -249,7 +274,7 @@ func (this *SubscribeChange) Upgrade() {
 			disWord = disWordStr
 			disWord = disWordStr
 		}
 		}
 		ordercode := pay.GetOrderCode(userId)
 		ordercode := pay.GetOrderCode(userId)
-		if (disWord == "") {
+		if disWord == "" {
 			start_time := TimeProcessing(time.Now().Format(DateFullLayout), -config.Config.TermValidity).Format(DateFullLayout)
 			start_time := TimeProcessing(time.Now().Format(DateFullLayout), -config.Config.TermValidity).Format(DateFullLayout)
 			stop_time := TimeProcessing(time.Now().Format(DateFullLayout), config.Config.TermValidity).Format(DateFullLayout)
 			stop_time := TimeProcessing(time.Now().Format(DateFullLayout), config.Config.TermValidity).Format(DateFullLayout)
 			infoList := util.Mysql.SelectBySql("select  * from  dis_word where userId=?  and  ?<=start_time  and stop_time<? ORDER BY id ", userId, start_time, stop_time)
 			infoList := util.Mysql.SelectBySql("select  * from  dis_word where userId=?  and  ?<=start_time  and stop_time<? ORDER BY id ", userId, start_time, stop_time)
@@ -450,7 +475,7 @@ func needUpgrade(newBuySet, oldBuySet *entity.SubvipBuySet) bool {
 						UpgradeBuyset.AreaCount = newBuySet.AreaCount
 						UpgradeBuyset.AreaCount = newBuySet.AreaCount
 					}
 					}
 					del_2_flag, del_1_flag := 0, 0 //被占用
 					del_2_flag, del_1_flag := 0, 0 //被占用
-					if c_2_diff < 0 { //有两个城市的名额未使用完
+					if c_2_diff < 0 {              //有两个城市的名额未使用完
 						if p_Diff > 0 {
 						if p_Diff > 0 {
 							//转移给一个省使用
 							//转移给一个省使用
 							if c_2_diff+p_Diff > 0 {
 							if c_2_diff+p_Diff > 0 {