|
@@ -96,12 +96,23 @@ type SearchOptimize struct {
|
|
|
Period int `json:"period"` //合同周期
|
|
|
Changehand int `json:"changehand"` //价格区间
|
|
|
Scale int `json:"scale"` //换手率
|
|
|
+ Isfile int `json:"isfile"` //有无附件
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// NewSearchOptimize 初始化
|
|
|
func NewSearchOptimize(userId, phone, province, city, district, subtype, topType, publishTime, selectType, price, industry, buyerClass, buyerTel, winnerTel, fileExists, keyWords, additionalWords, exclusionWords, platform, territorialization, expireTime, propertyForm, subinformation string,
|
|
|
- pageNum, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand int,
|
|
|
- userInfo jy.VipState, searchTypeSwitch bool, r *http.Request) *SearchOptimize {
|
|
|
+ pageNum, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand, isfile int,
|
|
|
+ userInfo jy.VipState, searchTypeSwitch bool, r *http.Request, accountId, entAccountId, entId, entUserId int64) *SearchOptimize {
|
|
|
+ IsPay := userInfo.IsPayedUser()
|
|
|
+ if territorialization == "BIProperty" {
|
|
|
+ res := config.Middleground.ResourceCenter.Haspowers(accountId, entAccountId, entId, entUserId)
|
|
|
+ for _, pCode := range res.Powers {
|
|
|
+ if pCode == "bi_yx_wyzb" {
|
|
|
+ IsPay = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
var so = &SearchOptimize{
|
|
|
AppId: "10000",
|
|
|
UserId: userId,
|
|
@@ -127,7 +138,7 @@ func NewSearchOptimize(userId, phone, province, city, district, subtype, topType
|
|
|
AdditionalWords: additionalWords,
|
|
|
ExclusionWords: exclusionWords,
|
|
|
Platform: platform,
|
|
|
- IsPay: userInfo.IsPayedUser(),
|
|
|
+ IsPay: IsPay,
|
|
|
BidField: territorialization,
|
|
|
SearchTypeSwitch: searchTypeSwitch,
|
|
|
IsOldVip: userInfo.VipState > 0 && userInfo.RegisterData < util.Int64All(config.Sysconfig["contextOldVipLimit"]),
|
|
@@ -340,7 +351,7 @@ func (so *SearchOptimize) GetBidSearchList(isCache bool) (count, total int64, li
|
|
|
total, repl = biddingSearch.GetAllByNgramWithCount()
|
|
|
if repl != nil && *repl != nil && len(*repl) > 0 {
|
|
|
//格式化查询结果
|
|
|
- list = SearchListFormat(so.Industry, *repl, strings.Contains(so.SelectType, "detail"))
|
|
|
+ list = SearchListFormat(so.Industry, *repl, strings.Contains(so.SelectType, "detail"), so.BidField)
|
|
|
count = util.If(so.IsPay, int64(bidsearch.SearchMaxPageCount_PAYED), int64(bidsearch.SearchMaxPageCount_PC)).(int64)
|
|
|
//数据如果>最大数据结果量 total==count,否则count = 付费:5000;免费:500;
|
|
|
count = util.If(count > total, total, count).(int64)
|
|
@@ -544,6 +555,9 @@ func (so *SearchOptimize) GetSearchQuery(mustQuery string) (qstr string) {
|
|
|
if so.Changehand != 0 && isLogin {
|
|
|
musts = append(musts, fmt.Sprintf(queryBoolMustA, "tag_set.wuye.changehand", `"`+gconv.String(so.Changehand)+`"`))
|
|
|
}
|
|
|
+ if so.Isfile != 0 && isLogin {
|
|
|
+ musts = append(musts, fmt.Sprintf(queryBoolMustA, "tag_set.wuye.isfile", `"`+gconv.String(so.Isfile)+`"`))
|
|
|
+ }
|
|
|
//价格
|
|
|
if so.Price != "" && len(strings.Split(so.Price, "-")) > 1 && isLogin {
|
|
|
minPrice, maxPrice := strings.Split(so.Price, "-")[0], strings.Split(so.Price, "-")[1]
|
|
@@ -707,6 +721,51 @@ func (so *SearchOptimize) GetBidSearchQuery() string {
|
|
|
}
|
|
|
query += `}}}`
|
|
|
}
|
|
|
+ if so.ExpireTime != "" {
|
|
|
+ if len(query) > 0 {
|
|
|
+ query += ","
|
|
|
+ }
|
|
|
+ startTime, endTime := "", ""
|
|
|
+ now := time.Now()
|
|
|
+ if publishTime == "1" { //本月到期
|
|
|
+ startTime = fmt.Sprint(now.Unix())
|
|
|
+ first := time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, time.Local)
|
|
|
+ endTime = fmt.Sprint(first.AddDate(0, 0, -1).Unix())
|
|
|
+ /* endTime = fmt.Sprint(time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, time.Local).Unix())*/
|
|
|
+ } else if publishTime == "1-3" { //1-3个月到期
|
|
|
+ startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+1, now.Day(), 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+3, now.Day(), 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ } else if publishTime == "3-6" { //3-6个月到期
|
|
|
+ startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+3, now.Day(), 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+6, now.Day(), 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ } else if publishTime == "6-12" { //6-12个月到期
|
|
|
+ startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+6, now.Day(), 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+12, now.Day(), 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ } else if publishTime == "12" { //12个月以后
|
|
|
+ startTime = fmt.Sprint(now.Unix())
|
|
|
+ startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+12, now.Day(), 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ } else if len(strings.Split(publishTime, "_")) > 1 {
|
|
|
+ startTime = strings.Split(publishTime, "_")[0]
|
|
|
+ endTime = strings.Split(publishTime, "_")[1]
|
|
|
+ etTime := time.Now()
|
|
|
+ if endTime != "" {
|
|
|
+ et, _ := strconv.ParseInt(endTime, 0, 64)
|
|
|
+ etTime = time.Unix(et, 0)
|
|
|
+ }
|
|
|
+ endTime = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ }
|
|
|
+ query += `{"range":{"expiredate":{`
|
|
|
+ if startTime != "" {
|
|
|
+ query += `"gte":` + startTime
|
|
|
+ }
|
|
|
+ if startTime != "" && endTime != "" {
|
|
|
+ query += `,`
|
|
|
+ }
|
|
|
+ if endTime != "" {
|
|
|
+ query += `"lt":` + endTime
|
|
|
+ }
|
|
|
+ query += `}}}`
|
|
|
+ }
|
|
|
//信息类型-二级
|
|
|
subtype := so.Subtype
|
|
|
topType := util.If(so.TopType != "", strings.Split(so.TopType, ","), []string{}).([]string)
|
|
@@ -888,7 +947,7 @@ func (e *SearchByES) GetAllByNgramWithCount() (int64, *[]map[string]interface{})
|
|
|
}
|
|
|
|
|
|
// SearchListFormat 格式化数据
|
|
|
-func SearchListFormat(industry string, repl []map[string]interface{}, b bool) (list []*map[string]interface{}) {
|
|
|
+func SearchListFormat(industry string, repl []map[string]interface{}, b bool, bidField string) (list []*map[string]interface{}) {
|
|
|
for _, v := range repl {
|
|
|
//正文
|
|
|
if b {
|
|
@@ -966,6 +1025,29 @@ func SearchListFormat(industry string, repl []map[string]interface{}, b bool) (l
|
|
|
})
|
|
|
}
|
|
|
v["winnerInfo"] = winnerInfo
|
|
|
+
|
|
|
+ }
|
|
|
+ if bidField == "BIProperty" {
|
|
|
+ //物业数据处理
|
|
|
+ subinformationArr := gconv.SliceStr(v["tag_subinformation"])
|
|
|
+ if len(subinformationArr) > 0 {
|
|
|
+ for i, value := range subinformationArr {
|
|
|
+ subinformationArr[i] = strings.Split(value, "_")[1]
|
|
|
+ }
|
|
|
+ v["tag_subinformation"] = subinformationArr
|
|
|
+ }
|
|
|
+ //是否有附件
|
|
|
+ tag := gconv.Map(v["tag_set"])
|
|
|
+ if tag != nil {
|
|
|
+ wuye := gconv.Map(tag["wuye"])
|
|
|
+ if tag != nil {
|
|
|
+ isFile := gconv.Int64(wuye["isfile"])
|
|
|
+ if isFile == 63 {
|
|
|
+ v["fileExists"] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ delete(v, "tag_set")
|
|
|
}
|
|
|
tmp := v
|
|
|
list = append(list, &tmp)
|