Browse Source

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

xuzhiheng 5 years ago
parent
commit
1c0ac6c635

+ 51 - 36
src/jfw/front/swordfish.go

@@ -2373,44 +2373,54 @@ func (f *Front) HasPushHistory() {
 	isExpire := -1
 	isExpire := -1
 	tedayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
 	tedayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
 	isOnTail := 0
 	isOnTail := 0
-	if util.IntAll((*user)["i_vip_status"]) == 1 || util.IntAll((*user)["i_vip_status"]) == 2 {
-		//
-		var threeRemind = int64(3 * 24 * 60 * 60)
-		var twoRemind = int64(2 * 24 * 60 * 60)
-		var oneRemind = int64(1 * 24 * 60 * 60)
-		var o_vipjy map[string]interface{}
-		o_vipjy, _ = (*user)["o_vipjy"].(map[string]interface{})
-		if o_vipjy["a_items"] != nil {
-			a_itmes := util.ObjArrToMapArr(o_vipjy["a_items"].([]interface{}))
-			hasKeyFlag = len(a_itmes) > 0
-		}
-		isVipFlag = true
-		isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) >= 2000
-		isOnTail = util.IntAll((*user)["i_vip_status"])
-		_endtime := (*user)["l_vip_endtime"]
-		//是否到期
-		if util.Int64All(_endtime)-time.Now().Unix() < threeRemind && util.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
-			isExpire = 3 //即将到期
-		} else if util.Int64All(_endtime)-time.Now().Unix() < twoRemind && util.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
-			isExpire = 2 //即将到期
-		} else if util.Int64All(_endtime)-time.Now().Unix() < oneRemind && util.Int64All(_endtime)-time.Now().Unix() >= 0 {
-			isExpire = 1 //即将到期
-		}
-	} else {
-		if (*user)["i_vip_status"] == nil {
-			isExpire = 0
-		} else {
-			isOnTail = util.IntAll((*user)["i_vip_status"])
-		}
-		var o_jy map[string]interface{}
-		if user != nil {
-			o_jy, _ = (*user)["o_jy"].(map[string]interface{})
-		}
+	var o_jy map[string]interface{}
+	var keys []string
+	if user != nil {
+		o_jy, _ = (*user)["o_jy"].(map[string]interface{})
 		if o_jy != nil || len(o_jy) == 0 {
 		if o_jy != nil || len(o_jy) == 0 {
 			a_key, _ := o_jy["a_key"].([]interface{})
 			a_key, _ := o_jy["a_key"].([]interface{})
-			hasKeyFlag = len(a_key) > 0
+			if a_key != nil {
+				for _, v := range a_key {
+					kv := util.ObjToMap(v)
+					keys = append(keys, util.ObjArrToStringArr((*kv)["key"].([]interface{}))...)
+				}
+			}
+		}
+		if util.IntAll((*user)["i_vip_status"]) == 1 || util.IntAll((*user)["i_vip_status"]) == 2 {
+			//
+			var threeRemind = int64(3 * 24 * 60 * 60)
+			var twoRemind = int64(2 * 24 * 60 * 60)
+			var oneRemind = int64(1 * 24 * 60 * 60)
+			var o_vipjy map[string]interface{}
+			o_vipjy, _ = (*user)["o_vipjy"].(map[string]interface{})
+			if o_vipjy["a_items"] != nil {
+				a_itmes := util.ObjArrToMapArr(o_vipjy["a_items"].([]interface{}))
+				hasKeyFlag = len(a_itmes) > 0
+			}
+			isVipFlag = true
+			isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) >= 2000
+			isOnTail = util.IntAll((*user)["i_vip_status"])
+			_endtime := (*user)["l_vip_endtime"]
+			//是否到期
+			if util.Int64All(_endtime)-time.Now().Unix() < threeRemind && util.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
+				isExpire = 3 //即将到期
+			} else if util.Int64All(_endtime)-time.Now().Unix() < twoRemind && util.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
+				isExpire = 2 //即将到期
+			} else if util.Int64All(_endtime)-time.Now().Unix() < oneRemind && util.Int64All(_endtime)-time.Now().Unix() >= 0 {
+				isExpire = 1 //即将到期
+			}
+		} else {
+			if (*user)["i_vip_status"] == nil {
+				isExpire = 0
+			} else {
+				isOnTail = util.IntAll((*user)["i_vip_status"])
+			}
+			if o_jy != nil || len(o_jy) == 0 {
+				a_key, _ := o_jy["a_key"].([]interface{})
+				hasKeyFlag = len(a_key) > 0
+			}
+			isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) >= 50
 		}
 		}
-		isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) >= 50
 	}
 	}
 	pageNum, _ := f.GetInteger("pageNum")
 	pageNum, _ := f.GetInteger("pageNum")
 	if pageNum == 0 {
 	if pageNum == 0 {
@@ -2421,7 +2431,11 @@ func (f *Front) HasPushHistory() {
 	if hasKeyFlag && len(list) == 0 && formatTime == "" && !isVipFlag {
 	if hasKeyFlag && len(list) == 0 && formatTime == "" && !isVipFlag {
 		flag, data := public.HistoryPush.MakeHistoryDatas(userId, bidSearch_field_1)
 		flag, data := public.HistoryPush.MakeHistoryDatas(userId, bidSearch_field_1)
 		if flag && data != nil {
 		if flag && data != nil {
-			list = data
+			jsonBytes, err := json.Marshal(data)
+			err = json.Unmarshal(jsonBytes, &list)
+			if err != nil {
+				log.Println("err:", err)
+			}
 		}
 		}
 	}
 	}
 	//
 	//
@@ -2435,6 +2449,7 @@ func (f *Front) HasPushHistory() {
 		"isExpire":    isExpire,
 		"isExpire":    isExpire,
 		"isOnTail":    isOnTail,
 		"isOnTail":    isOnTail,
 		"userId":      util.EncodeArticleId(userId),
 		"userId":      util.EncodeArticleId(userId),
+		"keys":        keys,
 	})
 	})
 }
 }
 
 

+ 38 - 46
src/jfw/modules/pushsubscribe/src/push/util/util.go

@@ -156,54 +156,46 @@ func SaveToPushsubscribe(isVipUser, isProjectInfo bool, userId string, matchInfo
 	length := len(*matchInfos)
 	length := len(*matchInfos)
 	fields := []string{"userid", "infoid", "date", "matchkeys", "area", "city", "buyerclass", "type", "isvip"}
 	fields := []string{"userid", "infoid", "date", "matchkeys", "area", "city", "buyerclass", "type", "isvip"}
 	var savecount int64
 	var savecount int64
-	i := length
-	for {
-		batchSize := 0
-		values := []interface{}{}
-		for i > 0 {
-			i--
-			matchInfo := (*matchInfos)[i]
-			values = append(values, userId, util.ObjToString((*matchInfo.Info)["_id"]), unix)
-			if len(matchInfo.Keys) > 0 {
-				values = append(values, strings.Join(matchInfo.Keys, " "))
-			} else {
-				values = append(values, nil)
-			}
-			if area := util.ObjToString((*matchInfo.Info)["area"]); area != "" {
-				values = append(values, area)
-			} else {
-				values = append(values, nil)
-			}
-			if city := util.ObjToString((*matchInfo.Info)["city"]); city != "" {
-				values = append(values, city)
-			} else {
-				values = append(values, nil)
-			}
-			if buyerclass := util.ObjToString((*matchInfo.Info)["buyerclass"]); buyerclass != "" {
-				values = append(values, buyerclass)
-			} else {
-				values = append(values, nil)
-			}
-			if isProjectInfo {
-				values = append(values, 1)
-			} else {
-				values = append(values, nil)
-			}
-			if isVipUser {
-				values = append(values, 1)
-			} else {
-				values = append(values, nil)
-			}
-			batchSize++
-			if batchSize == BigBulkSize {
-				break
-			}
+	batchSize := 0
+	values := []interface{}{}
+	for i := len(*matchInfos) - 1; i >= 0; i-- {
+		matchInfo := (*matchInfos)[i]
+		values = append(values, userId, util.ObjToString((*matchInfo.Info)["_id"]), unix)
+		if len(matchInfo.Keys) > 0 {
+			values = append(values, strings.Join(matchInfo.Keys, " "))
+		} else {
+			values = append(values, nil)
 		}
 		}
-		if batchSize > 0 {
-			savecount += Mysql.InsertBatch("pushsubscribe", fields, values)
+		if area := util.ObjToString((*matchInfo.Info)["area"]); area != "" {
+			values = append(values, area)
+		} else {
+			values = append(values, nil)
 		}
 		}
-		if batchSize < BigBulkSize {
-			break
+		if city := util.ObjToString((*matchInfo.Info)["city"]); city != "" {
+			values = append(values, city)
+		} else {
+			values = append(values, nil)
+		}
+		if buyerclass := util.ObjToString((*matchInfo.Info)["buyerclass"]); buyerclass != "" {
+			values = append(values, buyerclass)
+		} else {
+			values = append(values, nil)
+		}
+		if isProjectInfo {
+			values = append(values, 1)
+		} else {
+			values = append(values, nil)
+		}
+		if isVipUser {
+			values = append(values, 1)
+		} else {
+			values = append(values, nil)
+		}
+		batchSize++
+		if i == 0 || batchSize == BigBulkSize {
+			savecount += Mysql.InsertBatch("pushsubscribe", fields, values)
+			batchSize = 0
+			values = []interface{}{}
 		}
 		}
 	}
 	}
 	if int(savecount) != length {
 	if int(savecount) != length {

+ 65 - 42
src/jfw/public/historypush.go

@@ -7,6 +7,7 @@ import (
 	"qfw/util/elastic"
 	"qfw/util/elastic"
 	"qfw/util/jy"
 	"qfw/util/jy"
 	"qfw/util/redis"
 	"qfw/util/redis"
+	"sort"
 	"strings"
 	"strings"
 	"time"
 	"time"
 
 
@@ -428,11 +429,31 @@ func (h *historyPush) getInfoByIds(pushCas []*jy.PushCa) []map[string]interface{
 	return array
 	return array
 }
 }
 
 
+type resultData struct {
+	Area            string   `json:"area"`
+	Id              string   `json:"_id"`
+	Publishtime     int64    `json:"publishtime"`
+	Type            string   `json:"stype"`
+	S_subscopeclass string   `json:"s_subscopeclass"`
+	Title           string   `json:"title"`
+	Ca_isvip        int      `json:"ca_isvip"`
+	Ca_date         int64    `json:"ca_date"`
+	Ca_isvisit      int      `json:"ca_isvisit"`
+	Ca_index        int      `json:"ca_index"`
+	Matchkeys       []string `json:"matchkeys"`
+}
+
+type resultSort []*resultData
+
+func (p resultSort) Len() int           { return len(p) }
+func (p resultSort) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
+func (p resultSort) Less(i, j int) bool { return p[i].Ca_index > p[j].Ca_index }
+
 //保存最近7天的数据到历史记录
 //保存最近7天的数据到历史记录
-func (h *historyPush) MakeHistoryDatas(userId, field string) (bool, []map[string]interface{}) {
+func (h *historyPush) MakeHistoryDatas(userId, field string) (bool, []*resultData) {
 	allquery := `{"range":{"publishtime":{"gt":%s}}}`
 	allquery := `{"range":{"publishtime":{"gt":%s}}}`
 	allquery = fmt.Sprintf(allquery, fmt.Sprint(time.Now().AddDate(0, 0, -7).Unix()))
 	allquery = fmt.Sprintf(allquery, fmt.Sprint(time.Now().AddDate(0, 0, -7).Unix()))
-	//	allquery = ``
+	allquery = ``
 	keys, list := PushView(userId, allquery, field, 1, 50)
 	keys, list := PushView(userId, allquery, field, 1, 50)
 	log.Println(list)
 	log.Println(list)
 	if list == nil || len(*list) == 0 {
 	if list == nil || len(*list) == 0 {
@@ -446,13 +467,12 @@ func (h *historyPush) MakeHistoryDatas(userId, field string) (bool, []map[string
 			}
 			}
 		}
 		}
 	}
 	}
-	result := []map[string]interface{}{}
-	fields := []string{"userid", "infoid", "date", "matchkeys", "area", "city", "type", "subscopeclass"}
-	values := []interface{}{}
 	publishTitle := map[string]bool{}
 	publishTitle := map[string]bool{}
 	now := time.Now()
 	now := time.Now()
 	keystr := strings.Join(matchkeys, " ")
 	keystr := strings.Join(matchkeys, " ")
-	for k, v := range *list {
+	var resultList []*resultData
+	for _, v := range *list {
+		var myInsert = make(map[string]interface{})
 		title := strings.Replace(v["title"].(string), "\n", "", -1)
 		title := strings.Replace(v["title"].(string), "\n", "", -1)
 		area_check := util.ObjToString(v["area"])
 		area_check := util.ObjToString(v["area"])
 		city_check := util.ObjToString(v["city"])
 		city_check := util.ObjToString(v["city"])
@@ -461,38 +481,34 @@ func (h *historyPush) MakeHistoryDatas(userId, field string) (bool, []map[string
 		} else {
 		} else {
 			publishTitle[area_check+title] = true
 			publishTitle[area_check+title] = true
 		}
 		}
-		values = append(values, userId, util.ObjToString(v["_id"]), now.Unix(), keystr, area_check, city_check, 0, v["s_subscopeclass"])
+		myInsert["userid"] = userId
+		myInsert["infoid"] = util.ObjToString(v["_id"])
+		myInsert["date"] = now.Unix()
+		myInsert["matchkeys"] = keystr
+		myInsert["area"] = area_check
+		myInsert["city"] = city_check
+		myInsert["type"] = 0
+		myInsert["isvisit"] = 0
+		myInsert["isvip"] = 0
+		myInsert["buyerclass"] = v["buyerclass"]
+		id := Mysql.Insert("pushsubscribe", myInsert)
 		info := map[string]interface{}{
 		info := map[string]interface{}{
-			"area":             area_check,
-			"_id":              util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"])),
-			"publishtime":      v["publishtime"],
-			"stype":            v["type"],
-			"toptype":          v["toptype"],
-			"subtype":          v["subtype"],
-			"s_subscopeclass":  v["s_subscopeclass"],
-			"buyer":            v["buyer"],
-			"projectname":      v["projectname"],
-			"budget":           v["budget"],
-			"bidopentime":      v["bidopentime"],
-			"winner":           v["winner"],
-			"bidamount":        v["bidamount"],
-			"title":            title,
-			"ca_isvisit_index": k + 1,
-			"ca_date":          now.Unix(),
-			"ca_isvisit":       0,
-			"matchkeys":        matchkeys,
+			"area":            area_check,
+			"_id":             util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"])),
+			"publishtime":     v["publishtime"],
+			"stype":           v["type"],
+			"toptype":         v["toptype"],
+			"subtype":         v["subtype"],
+			"s_subscopeclass": v["s_subscopeclass"],
+			"title":           title,
+			"ca_isvip":        0,
+			"ca_date":         now.Unix(),
+			"ca_isvisit":      0,
+			"ca_index":        id,
 		}
 		}
 		area := util.ObjToString(info["area"])
 		area := util.ObjToString(info["area"])
 		if area == "A" {
 		if area == "A" {
-			area = "全国"
-		}
-		budget, _ := info["budget"].(float64)
-		if budget == 0 || strings.TrimSpace(fmt.Sprint(info["budget"])) == "" {
-			delete(info, "budget")
-		}
-		bidamount, _ := info["bidamount"].(float64)
-		if bidamount == 0 || strings.TrimSpace(fmt.Sprint(info["bidamount"])) == "" {
-			delete(info, "bidamount")
+			info["area"] = "全国"
 		}
 		}
 		industry := util.ObjToString(info["s_subscopeclass"])
 		industry := util.ObjToString(info["s_subscopeclass"])
 		scs := strings.Split(industry, ",")
 		scs := strings.Split(industry, ",")
@@ -522,15 +538,22 @@ func (h *historyPush) MakeHistoryDatas(userId, field string) (bool, []map[string
 		delete(info, "subtype")
 		delete(info, "subtype")
 		delete(info, "toptype")
 		delete(info, "toptype")
 
 
-		result = append(result, info)
+		resultList = append(resultList, &resultData{
+			util.ObjToString(info["area"]),
+			util.ObjToString(info["_id"]),
+			util.Int64All(info["publishtime"]),
+			util.ObjToString(info["stype"]),
+			util.ObjToString(info["s_subscopeclass"]),
+			util.ObjToString(info["title"]),
+			util.IntAll(info["ca_isvip"]),
+			util.Int64All(info["ca_date"]),
+			util.IntAll(info["ca_isvisit"]),
+			util.IntAll(info["ca_index"]),
+			matchkeys,
+		})
 	}
 	}
-	go func(fields []string, values []interface{}) {
-		count := Mysql.InsertBatch("pushsubscribe", fields, values)
-		if int(count) == len(values) {
-			log.Println("mysql insert  true")
-		}
-	}(fields, values)
-	return true, result
+	sort.Sort(resultSort(resultList))
+	return true, resultList
 }
 }
 
 
 //获取用户信息
 //获取用户信息

+ 2 - 0
src/web/staticres/js/wxSupersearch.js

@@ -1915,6 +1915,8 @@ var SuperSearch = {
 		if(SuperSearch.dropload != null){
 		if(SuperSearch.dropload != null){
 			SuperSearch.dropload.resetload();
 			SuperSearch.dropload.resetload();
 		}
 		}
+		//再html内点击都会存缓存 关闭广告后再刷新 会取缓存 
+		SuperSearch.clearSessionStorage();
 	},
 	},
 	appendInterceptWord: function(word){
 	appendInterceptWord: function(word){
 		SuperSearch.interceptWord = word;
 		SuperSearch.interceptWord = word;

+ 12 - 5
src/web/templates/weixin/historypush.html

@@ -36,6 +36,7 @@
 		var wxflag = "";
 		var wxflag = "";
 		var a_visitedindex = new Array;
 		var a_visitedindex = new Array;
 		var closeAdvert=false//是否关闭广告
 		var closeAdvert=false//是否关闭广告
+		var words = ""
 		initShare({{.T.signature}},{{.T.openid}},2,"jy_extend",{{.T.nickname}},{{.T.avatar}});
 		initShare({{.T.signature}},{{.T.openid}},2,"jy_extend",{{.T.nickname}},{{.T.avatar}});
 		$(function(){
 		$(function(){
 			var isinitpage = false;
 			var isinitpage = false;
@@ -105,6 +106,7 @@
 				userId = sessionStorage.userId;
 				userId = sessionStorage.userId;
 				firstTime = sessionStorage.getItem(userId+"_searchTime");
 				firstTime = sessionStorage.getItem(userId+"_searchTime");
 				selectCity = sessionStorage.getItem(userId+"_selectCity");
 				selectCity = sessionStorage.getItem(userId+"_selectCity");
+				words = JSON.parse(sessionStorage.keys);
 			    if(sessionStorage.closeAdvert=="true"){
 			    if(sessionStorage.closeAdvert=="true"){
 			      	closeAdvert=true
 			      	closeAdvert=true
 			    }
 			    }
@@ -155,6 +157,8 @@
 						isExpire = data.isExpire;
 						isExpire = data.isExpire;
 						sessionStorage.isExpire = isExpire;
 						sessionStorage.isExpire = isExpire;
 						sessionStorage.setItem(userId+"_searchTime",firstTime);
 						sessionStorage.setItem(userId+"_searchTime",firstTime);
+						words = data.keys;
+						sessionStorage.keys = JSON.stringify(words);
 						showPage();
 						showPage();
 					},
 					},
 					error: function(xhr, type){
 					error: function(xhr, type){
@@ -340,15 +344,18 @@
 				//标题(需要高亮)
 				//标题(需要高亮)
 				var title=obj.title;
 				var title=obj.title;
 				var mWords="";
 				var mWords="";
-				var words = obj.matchkeys;
-				if(words.length>0){
-					for(var n=0;n<words.length;n++){
-						var keysTemp = words[n].split("+");
+				var _words = words;
+				if(obj.matchkeys!=undefined&&obj.matchkeys!=null&&obj.matchkeys!=""){
+					_words = obj.matchkeys;
+				}
+				if(_words.length>0){
+					for(var n=0;n<_words.length;n++){
+						var keysTemp = _words[n].split("+");
 						for(var m=0;m<keysTemp.length;m++){
 						for(var m=0;m<keysTemp.length;m++){
 							 title = keyWordHighlight(title,keysTemp[m],'<font class="keyword">$1</font>');
 							 title = keyWordHighlight(title,keysTemp[m],'<font class="keyword">$1</font>');
 						}
 						}
 					}
 					}
-					mWords=words.join("_");
+					mWords=_words.join("_");
 				}
 				}
 				//地区
 				//地区
 				var area=obj.area;
 				var area=obj.area;

+ 1 - 1
src/web/templates/weixin/search/mainSearch.html

@@ -23,7 +23,7 @@
 <script src="{{Msg "seo" "cdn"}}/wxswordfish/share.js?v={{Msg "seo" "version"}}111"></script>
 <script src="{{Msg "seo" "cdn"}}/wxswordfish/share.js?v={{Msg "seo" "version"}}111"></script>
 <script src="{{Msg "seo" "cdn"}}/js/dropload.js?v={{Msg "seo" "version"}}"></script>
 <script src="{{Msg "seo" "cdn"}}/js/dropload.js?v={{Msg "seo" "version"}}"></script>
 <script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/wxEntsesearch.js?v={{Msg "seo" "version"}}"></script>
 <script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/wxEntsesearch.js?v={{Msg "seo" "version"}}"></script>
-<script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/wxSupersearch.js?v={{Msg "seo" "version"}}521"></script>
+<script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/wxSupersearch.js?v={{Msg "seo" "version"}}522"></script>
 <!--2.8-->
 <!--2.8-->
 <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/wx_dataExport/css/base_myorder.css?v={{Msg "seo" "version"}}1">
 <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/wx_dataExport/css/base_myorder.css?v={{Msg "seo" "version"}}1">
 <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/wx_dataExport/iconfont/iconfont.css?v={{Msg "seo" "version"}}">
 <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/wx_dataExport/iconfont/iconfont.css?v={{Msg "seo" "version"}}">