|
@@ -160,47 +160,55 @@ func getIyProList(iy string, positionId int64) (array []string) {
|
|
|
}
|
|
|
|
|
|
func getQuerySql(req *types.ProjectListReq, plist []string, businessStr string) (countSql, findSql string, allArgs []interface{}) {
|
|
|
- countSql = "select count(1) from information.transaction_info_all a "
|
|
|
- findSql = "select b.project_id as project_id,b.project_name as project_name,b.business_type as business_type,b.buyer as buyer,b.buyer_id as buyer_id,b.area as area,b.city as city,b.district as district,b.zbtime as zbtime,b.endtime as endtime,b.project_money as project_money,b.info_id as info_id,b.information_id as information_id,b.info_ids as info_ids from information.transaction_info_all a "
|
|
|
+ countSql = "select count(1) from information.transaction_info_all"
|
|
|
+ findSql = "select project_id,project_name,business_type,buyer,buyer_id,area,city,district,zbtime,endtime,project_money,info_id,information_id,info_ids from information.transaction_info_all"
|
|
|
allArgs = []interface{}{}
|
|
|
- ors := []string{}
|
|
|
- // 左侧选中的业主id
|
|
|
+ ors1 := []string{}
|
|
|
if len(plist) > 0 {
|
|
|
wh, args := common.WhArgs(plist)
|
|
|
- ors = append(ors, "a.buyer_id in ("+wh+") and a.project_id=b.project_id")
|
|
|
+ ors1 = append(ors1, `buyer_id in (`+wh+`)`)
|
|
|
allArgs = append(allArgs, args...)
|
|
|
}
|
|
|
- ors2 := []string{}
|
|
|
+ wm := map[string]bool{}
|
|
|
winner_ids := []string{}
|
|
|
- if req.Supplier != "" {
|
|
|
- winner_ids = append(winner_ids, strings.Split(req.Supplier, ",")...)
|
|
|
+ for _, v := range strings.Split(req.Supplier, ",") {
|
|
|
+ if wm[v] {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ winner_ids = append(winner_ids, v)
|
|
|
+ wm[v] = true
|
|
|
}
|
|
|
- if req.Heterotophy != "" {
|
|
|
- winner_ids = append(winner_ids, strings.Split(req.Heterotophy, ",")...)
|
|
|
+ for _, v := range strings.Split(req.Heterotophy, ",") {
|
|
|
+ if wm[v] {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ winner_ids = append(winner_ids, v)
|
|
|
+ wm[v] = true
|
|
|
}
|
|
|
+ ors2 := []string{}
|
|
|
if len(winner_ids) > 0 {
|
|
|
wh, args := common.WhArgs(winner_ids)
|
|
|
- ors2 = append(ors2, "hasAny(a.winner_id,["+wh+"])")
|
|
|
+ ors2 = append(ors2, `hasAny(winner_id,[`+wh+`])`)
|
|
|
allArgs = append(allArgs, args...)
|
|
|
}
|
|
|
if req.Agency != "" {
|
|
|
wh, args := common.WhArgs(strings.Split(req.Agency, ","))
|
|
|
- ors2 = append(ors2, "a.agency_id in ("+wh+")")
|
|
|
+ ors2 = append(ors2, `agency_id in (`+wh+`)`)
|
|
|
allArgs = append(allArgs, args...)
|
|
|
}
|
|
|
if len(ors2) > 0 {
|
|
|
- ors = append(ors, "("+strings.Join(ors2, " or ")+") and a.buyer_id<>'' and a.buyer_id=b.buyer_id")
|
|
|
+ ors1 = append(ors1, `(buyer_id in (select buyer_id from transaction_info_all where `+strings.Join(ors2, " or ")+`))`)
|
|
|
}
|
|
|
- querys := []string{}
|
|
|
+ ands := []string{}
|
|
|
//业务类型
|
|
|
if businessStr != "" {
|
|
|
wh, args := common.WhArgs(strings.Split(businessStr, ","))
|
|
|
- querys = append(querys, `hasAny(b.topscopeclass,[`+wh+`])`)
|
|
|
+ ands = append(ands, `hasAny(topscopeclass,[`+wh+`])`)
|
|
|
allArgs = append(allArgs, args...)
|
|
|
}
|
|
|
//区域
|
|
|
if req.Area != "" {
|
|
|
- querys = append(querys, "b.area=?")
|
|
|
+ ands = append(ands, "area=?")
|
|
|
allArgs = append(allArgs, req.Area)
|
|
|
}
|
|
|
// 项目金额 0: 全部,1: 50万以下,2: 50-100万, 3: 100-200万, 4: 200-500万, 5:500万以上
|
|
@@ -209,31 +217,31 @@ func getQuerySql(req *types.ProjectListReq, plist []string, businessStr string)
|
|
|
var tempArr []string
|
|
|
for _, s := range strings.Split(req.Amount, ",") {
|
|
|
if s == "1" {
|
|
|
- tempArr = append(tempArr, "b.project_money<=?")
|
|
|
+ tempArr = append(tempArr, "project_money<=?")
|
|
|
allArgs = append(allArgs, 500000)
|
|
|
} else if s == "2" {
|
|
|
- tempArr = append(tempArr, "(b.project_money>=? and b.project_money<=?)")
|
|
|
+ tempArr = append(tempArr, "(project_money>=? and project_money<=?)")
|
|
|
allArgs = append(allArgs, 500000, 1000000)
|
|
|
} else if s == "3" {
|
|
|
- tempArr = append(tempArr, "(b.project_money>=? and b.project_money<=?)")
|
|
|
+ tempArr = append(tempArr, "(project_money>=? and project_money<=?)")
|
|
|
allArgs = append(allArgs, 1000000, 2000000)
|
|
|
} else if s == "4" {
|
|
|
- tempArr = append(tempArr, "(b.project_money>=? and b.project_money<=?)")
|
|
|
+ tempArr = append(tempArr, "(project_money>=? and project_money<=?)")
|
|
|
allArgs = append(allArgs, 2000000, 5000000)
|
|
|
} else if s == "5" {
|
|
|
- tempArr = append(tempArr, "b.project_money>=?")
|
|
|
+ tempArr = append(tempArr, "project_money>=?")
|
|
|
allArgs = append(allArgs, 5000000)
|
|
|
}
|
|
|
}
|
|
|
if len(tempArr) > 0 {
|
|
|
- querys = append(querys, fmt.Sprintf("(%s)", strings.Join(tempArr, " or ")))
|
|
|
+ ands = append(ands, fmt.Sprintf("(%s)", strings.Join(tempArr, " or ")))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//过滤掉已中标的招标项目数据
|
|
|
- sqlAppend := "inner join information.transaction_info_all b on(" + strings.Join(ors, " or ") + ") where b.project_bidstatus>1 and " + strings.Join(querys, " and ")
|
|
|
+ sqlAppend := " where (" + strings.Join(ors1, " or ") + ") and " + strings.Join(ands, " and ") + "and project_bidstatus>1"
|
|
|
countSql += sqlAppend
|
|
|
- findSql += fmt.Sprintf(sqlAppend+" order by b.zbtime desc limit %d,%d", (req.PageNum-1)*req.PageSize, req.PageSize)
|
|
|
+ findSql += fmt.Sprintf(sqlAppend+" order by zbtime desc limit %d,%d", (req.PageNum-1)*req.PageSize, req.PageSize)
|
|
|
return
|
|
|
}
|
|
|
|