|
@@ -19,10 +19,11 @@ var (
|
|
|
fields = []string{"_id", "title", "publishtime", "dataweight", "detail", "site", "spidercode", "toptype", "subtype", "type", "area", "city", "district", "s_topscopeclass", "s_subscopeclass", "bidamount", "budget", "buyerclass", "buyer", "winner", "bidopentime", "buyertel", "buyerperson", "agency", "agencytel", "agencyperson", "s_winner", "winnertel", "winnerperson", "signendtime", "bidendtime", "projectinfo", "entidlist"}
|
|
|
)
|
|
|
|
|
|
-func GetMonitorList(req *types.PrMonitorListReq) (resultList []map[string]interface{}, total int64) {
|
|
|
+func GetMonitorList(req *types.PrMonitorListReq) (resultList []map[string]interface{}, total int64, hasMonitor bool) {
|
|
|
|
|
|
- bList, b := T.Mgo.Find("follow_customer", map[string]string{"userId": req.MgoUserId}, `{_id: 1}`, nil, false, -1, -1)
|
|
|
+ bList, b := T.Mgo.Find("follow_customer", map[string]interface{}{"userId": req.MgoUserId}, `{_id: 1}`, nil, false, -1, -1)
|
|
|
if b && len(*bList) > 0 {
|
|
|
+ hasMonitor = true
|
|
|
var bName []string
|
|
|
for _, v := range *bList {
|
|
|
if name := common.ObjToString(v["name"]); name != "" {
|
|
@@ -37,37 +38,37 @@ func GetMonitorList(req *types.PrMonitorListReq) (resultList []map[string]interf
|
|
|
for _, v := range strings.Split(scopeClass, ",") {
|
|
|
should = append(should, fmt.Sprintf(shouldMul, v))
|
|
|
}
|
|
|
- esQuery1 = fmt.Sprintf(esQ1, strings.ReplaceAll(strings.Join(bName, ","), ",", `","`), should, strings.ReplaceAll(strings.Join(fields, ","), ",", `","`), pageStart, req.PageSize)
|
|
|
+ esQuery1 = fmt.Sprintf(esQ1, strings.ReplaceAll(strings.Join(bName, ","), ",", `","`), strings.Join(should, ","), strings.ReplaceAll(strings.Join(fields, ","), ",", `","`), pageStart, req.PageSize)
|
|
|
} else {
|
|
|
esQuery1 = fmt.Sprintf(esQ2, strings.ReplaceAll(strings.Join(bName, ","), ",", `","`), strings.ReplaceAll(strings.Join(fields, ","), ",", `","`), pageStart, req.PageSize)
|
|
|
}
|
|
|
+ logx.Info("esQuery1---", esQuery1)
|
|
|
total, result := elastic.GetWithCount("bidding", "bidding", "", esQuery1)
|
|
|
if total == 0 {
|
|
|
- return nil, 0
|
|
|
+ return nil, 0, hasMonitor
|
|
|
}
|
|
|
for _, m := range *result {
|
|
|
resultList = append(resultList, GetInfoData(m))
|
|
|
}
|
|
|
- return resultList, total
|
|
|
+ return resultList, total, hasMonitor
|
|
|
} else {
|
|
|
- return nil, 0
|
|
|
+ return nil, 0, false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func GetCollectList(req *types.PrCollectListReq) (resultList []map[string]interface{}, total int64) {
|
|
|
+func GetCollectList(req *types.PrCollectListReq) (resultList []map[string]interface{}, total int64, has bool) {
|
|
|
scopeClass := FindBusiness(req.EntId, req.MgoUserId)
|
|
|
info := T.JianyuMysql.Find("bdcollection", map[string]interface{}{"userid": req.UserId}, "", "id desc", -1, -1)
|
|
|
var ids []interface{}
|
|
|
if info == nil || len(*info) == 0 {
|
|
|
- return make([]map[string]interface{}, 0), 0
|
|
|
+ return make([]map[string]interface{}, 0), 0, false
|
|
|
}
|
|
|
+ has = true
|
|
|
for _, m := range *info {
|
|
|
if bid := common.ObjToString(m["bid"]); bid != "" {
|
|
|
ids = append(ids, mongodb.StringTOBsonId(bid))
|
|
|
}
|
|
|
}
|
|
|
- logx.Info("scopeClass---", scopeClass)
|
|
|
- logx.Info("ids---", ids)
|
|
|
if len(ids) > 200 {
|
|
|
ids = ids[:200]
|
|
|
}
|
|
@@ -81,6 +82,7 @@ func GetCollectList(req *types.PrCollectListReq) (resultList []map[string]interf
|
|
|
if tp := common.ObjToString(m["toptype"]); tp == "采购意向" || tp == "预告" || tp == "招标" {
|
|
|
for _, s := range strings.Split(scopeClass, ",") {
|
|
|
if top := common.ObjToString(m["s_topscopeclass"]); strings.Contains(top, s) {
|
|
|
+ m["_id"] = mongodb.BsonIdToSId(m["_id"])
|
|
|
resultList = append(resultList, GetInfoData(m))
|
|
|
break
|
|
|
}
|
|
@@ -88,20 +90,18 @@ func GetCollectList(req *types.PrCollectListReq) (resultList []map[string]interf
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- logx.Info("binfo---", len(*binfo))
|
|
|
- logx.Info("resultList---", len(resultList))
|
|
|
total = int64(len(resultList))
|
|
|
start := (req.PageNum - 1) * req.PageSize
|
|
|
end := start + req.PageSize
|
|
|
|
|
|
// 处理边界情况
|
|
|
if start >= len(resultList) {
|
|
|
- return make([]map[string]interface{}, 0), total
|
|
|
+ return make([]map[string]interface{}, 0), total, has
|
|
|
}
|
|
|
if end > len(resultList) {
|
|
|
end = len(resultList)
|
|
|
}
|
|
|
- return resultList[start:end], total
|
|
|
+ return resultList[start:end], total, has
|
|
|
}
|
|
|
|
|
|
func GetInfoData(m map[string]interface{}) (result map[string]interface{}) {
|