|
@@ -21,9 +21,9 @@ import (
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
- query = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget"],"from":0,"size":%d}`
|
|
|
- mongodb_fields = `{"_id":1,"area":1,"publishtime":1,"s_subscopeclass":1,"subtype":1,"title":1,"toptype":1,"type":1, "buyerclass":1,"budget":1,"bidamount":1}`
|
|
|
- querys = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","title","detail","area","city","publishtime","projectname","buyer","buyerclass","s_winner","bidamount","subtype","toptype","href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel"]}`
|
|
|
+ query = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","subtype","s_winner","buyertel","winnertel"],"from":0,"size":%d}`
|
|
|
+ mongodb_fields = `{"_id":1,"area":1,"publishtime":1,"s_subscopeclass":1,"subtype":1,"title":1,"toptype":1,"type":1, "buyerclass":1,"budget":1,"bidamount":1,"winnertel":1,"s_winner":1,"buyertel":1}`
|
|
|
+ querys = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","title","detail","area","city","publishtime","projectname","buyer","buyerclass","s_winner","bidamount","subtype","toptype","projectcode","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel"],"from":0,"size":%d}}`
|
|
|
)
|
|
|
|
|
|
//招标信息是否被收藏
|
|
@@ -79,6 +79,15 @@ type BidInfo struct {
|
|
|
func BidCollOrRemByIds(bidAction BidAction, userid string) bool {
|
|
|
var i = 0
|
|
|
var wg sync.WaitGroup
|
|
|
+ maxCount := config.BidCollConfig.FreeUserCollLimit
|
|
|
+ isPay := Power(userid)
|
|
|
+ if isPay {
|
|
|
+ maxCount = config.BidCollConfig.PayUserCollLimit
|
|
|
+ }
|
|
|
+ //已收藏的次数
|
|
|
+ collCount := db.Mysql.Count(db.DbConf.Bdcollection, map[string]interface{}{"userid": userid})
|
|
|
+ //格式化数据
|
|
|
+ bidAction.Binfo = FormatColl(bidAction.Binfo)
|
|
|
for _, v := range bidAction.Binfo {
|
|
|
wg.Add(1)
|
|
|
go func(bd BidInfo) {
|
|
@@ -95,19 +104,24 @@ func BidCollOrRemByIds(bidAction BidAction, userid string) bool {
|
|
|
}
|
|
|
} else {
|
|
|
if db.Mysql.Count(db.DbConf.Bdcollection, queryMap) == 0 {
|
|
|
- now := time.Now().Unix()
|
|
|
- inserMap := map[string]interface{}{
|
|
|
- "bid": util.DecodeId(bd.Bid),
|
|
|
- "buyerclass": jy.PushMapping.Buyerclass[bd.Buyerclass],
|
|
|
- "buyerinfo": bd.Buyerinfo,
|
|
|
- "winnerinfo": bd.Winnerinfo,
|
|
|
- "userid": userid,
|
|
|
- "createdate": qu.FormatDateByInt64(&now, qu.Date_Full_Layout),
|
|
|
- }
|
|
|
- if it := db.Mysql.Insert(db.DbConf.Bdcollection, inserMap); it > 0 {
|
|
|
- i++
|
|
|
+ if int(collCount) >= maxCount {
|
|
|
+ log.Printf("userid :%s,收藏失败 id : %s ,已收藏数量:%v ,上限数量:%v", userid, util.DecodeId(bd.Bid), collCount, maxCount)
|
|
|
} else {
|
|
|
- log.Printf("userid :%s,收藏失败 id : %s", userid, util.DecodeId(bd.Bid))
|
|
|
+ now := time.Now().Unix()
|
|
|
+ inserMap := map[string]interface{}{
|
|
|
+ "bid": util.DecodeId(bd.Bid),
|
|
|
+ "buyerclass": jy.PushMapping.Buyerclass[bd.Buyerclass],
|
|
|
+ "buyerinfo": bd.Buyerinfo,
|
|
|
+ "winnerinfo": bd.Winnerinfo,
|
|
|
+ "userid": userid,
|
|
|
+ "createdate": qu.FormatDateByInt64(&now, qu.Date_Full_Layout),
|
|
|
+ }
|
|
|
+ if it := db.Mysql.Insert(db.DbConf.Bdcollection, inserMap); it > 0 {
|
|
|
+ i++
|
|
|
+ collCount++
|
|
|
+ } else {
|
|
|
+ log.Printf("userid :%s,收藏失败 id : %s", userid, util.DecodeId(bd.Bid))
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
log.Printf("userid :%s,已收藏 id : %s", userid, util.DecodeId(bd.Bid))
|
|
@@ -170,8 +184,16 @@ func LabelAction(labInfo *LabelInfo, userid string) (ibool bool) {
|
|
|
}
|
|
|
//收藏招标信息
|
|
|
if labInfo.Lids != "" && len(labInfo.Binfo) > 0 {
|
|
|
+ maxCount := config.BidCollConfig.FreeUserCollLimit
|
|
|
+ isPay := Power(userid)
|
|
|
+ if isPay {
|
|
|
+ maxCount = config.BidCollConfig.PayUserCollLimit
|
|
|
+ }
|
|
|
+ //已收藏的次数
|
|
|
+ collCount := db.Mysql.Count(db.DbConf.Bdcollection, map[string]interface{}{"userid": userid})
|
|
|
var i = 0
|
|
|
var wg sync.WaitGroup
|
|
|
+ labInfo.Binfo = FormatColl(labInfo.Binfo)
|
|
|
for _, v := range labInfo.Binfo {
|
|
|
wg.Add(1)
|
|
|
go func(bd BidInfo) {
|
|
@@ -189,19 +211,24 @@ func LabelAction(labInfo *LabelInfo, userid string) (ibool bool) {
|
|
|
lids += qu.SE.DecodeString(lv)
|
|
|
}
|
|
|
if db.Mysql.Count(db.DbConf.Bdcollection, queryMap) == 0 {
|
|
|
- inserMap := map[string]interface{}{
|
|
|
- "labelid": lids,
|
|
|
- "bid": util.DecodeId(bd.Bid),
|
|
|
- "buyerclass": jy.PushMapping.Buyerclass[bd.Buyerclass],
|
|
|
- "buyerinfo": bd.Buyerinfo,
|
|
|
- "winnerinfo": bd.Winnerinfo,
|
|
|
- "userid": userid,
|
|
|
- "createdate": qu.FormatDateByInt64(&now, qu.Date_Full_Layout),
|
|
|
- }
|
|
|
- if it := db.Mysql.Insert(db.DbConf.Bdcollection, inserMap); it > 0 {
|
|
|
- i++
|
|
|
+ if int(collCount) >= maxCount {
|
|
|
+ log.Printf("userid :%s,收藏失败 id : %s ,已收藏数量:%v ,上限数量:%v", userid, util.DecodeId(bd.Bid), collCount, maxCount)
|
|
|
} else {
|
|
|
- log.Printf("userid :%s,收藏失败 id : %s", userid, util.DecodeId(bd.Bid))
|
|
|
+ inserMap := map[string]interface{}{
|
|
|
+ "labelid": lids,
|
|
|
+ "bid": util.DecodeId(bd.Bid),
|
|
|
+ "buyerclass": jy.PushMapping.Buyerclass[bd.Buyerclass],
|
|
|
+ "buyerinfo": bd.Buyerinfo,
|
|
|
+ "winnerinfo": bd.Winnerinfo,
|
|
|
+ "userid": userid,
|
|
|
+ "createdate": qu.FormatDateByInt64(&now, qu.Date_Full_Layout),
|
|
|
+ }
|
|
|
+ if it := db.Mysql.Insert(db.DbConf.Bdcollection, inserMap); it > 0 {
|
|
|
+ i++
|
|
|
+ collCount++
|
|
|
+ } else {
|
|
|
+ log.Printf("userid :%s,收藏失败 id : %s", userid, util.DecodeId(bd.Bid))
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
if db.Mysql.Update(db.DbConf.Bdcollection, queryMap, map[string]interface{}{"labelid": lids}) {
|
|
@@ -325,7 +352,7 @@ func GetCollList(c *CollList, userid string) map[string]interface{} {
|
|
|
// rdata["res"] = result
|
|
|
rdata["count"] = count
|
|
|
rdata["haveNextPage"] = haveNextPage
|
|
|
- rdata["res"] = GetInfoById(db.Mgo_Bidding, db.DbConf.Mongodb.Bidding.Collection, db.DbConf.Mongodb.Bidding.Collection_change, result)
|
|
|
+ rdata["res"] = GetInfoById(db.Mgo_Bidding, db.DbConf.Mongodb.Bidding.Collection, db.DbConf.Mongodb.Bidding.Collection_change, userid, result)
|
|
|
return rdata
|
|
|
}
|
|
|
|
|
@@ -353,7 +380,6 @@ func Power(userid string) bool {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- log.Println(isVip, isEnt, isMember)
|
|
|
return isVip || isEnt || isMember
|
|
|
}
|
|
|
|
|
@@ -367,10 +393,13 @@ type InfoList struct {
|
|
|
Publishtime int64 `json:"publishtime"`
|
|
|
Budget interface{} `json:"budget"`
|
|
|
Bidamount interface{} `json:"bidamount"`
|
|
|
+ Buyer string `json:"buyer"`
|
|
|
+ S_winner string `json:"s_winner"`
|
|
|
+ Bidopentime int64 `json:"bidopentime"`
|
|
|
}
|
|
|
|
|
|
//根据id取内容
|
|
|
-func GetInfoById(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, idlist []map[string]interface{}) []*InfoList {
|
|
|
+func GetInfoById(Mgo_bidding mg.MongodbSim, bidding, bidding_back, userid string, idlist []map[string]interface{}) []*InfoList {
|
|
|
array := make([]*InfoList, len(idlist))
|
|
|
if len(idlist) == 0 {
|
|
|
return array
|
|
@@ -400,7 +429,7 @@ func GetInfoById(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, idlist
|
|
|
// log.Println(es_ids)
|
|
|
//elasticsearch
|
|
|
if len(es_ids) > 0 {
|
|
|
- list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
|
|
|
+ list := elastic.Get("bidding", "bidding", fmt.Sprintf(querys, strings.Join(es_ids, `","`), len(es_ids)))
|
|
|
if list != nil {
|
|
|
for _, v := range *list {
|
|
|
_id := qu.ObjToString(v["_id"])
|
|
@@ -454,7 +483,7 @@ func GetInfoById(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, idlist
|
|
|
return array
|
|
|
}
|
|
|
|
|
|
-//历史推送记录中单条信息格式化
|
|
|
+//列表单条信息格式化
|
|
|
func InfoFormat(p string, info *map[string]interface{}) *InfoList {
|
|
|
area := qu.ObjToString((*info)["area"])
|
|
|
if area == "A" {
|
|
@@ -497,5 +526,71 @@ func InfoFormat(p string, info *map[string]interface{}) *InfoList {
|
|
|
Publishtime: qu.Int64All((*info)["publishtime"]),
|
|
|
Budget: (*info)["budget"],
|
|
|
Bidamount: (*info)["bidamount"],
|
|
|
+ Buyer: qu.ObjToString((*info)["buyer"]),
|
|
|
+ S_winner: qu.ObjToString((*info)["s_winner"]),
|
|
|
+ Bidopentime: qu.Int64All((*info)["bidopentime"]),
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func FormatColl(bidinfo []BidInfo) []BidInfo {
|
|
|
+ es_ids := []string{}
|
|
|
+ infos := map[string]interface{}{}
|
|
|
+ for _, v := range bidinfo {
|
|
|
+ es_ids = append(es_ids, util.DecodeId(v.Bid))
|
|
|
+ }
|
|
|
+ if len(es_ids) > 0 {
|
|
|
+ list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
|
|
|
+ if list != nil {
|
|
|
+ for _, v := range *list {
|
|
|
+ _id := qu.ObjToString(v["_id"])
|
|
|
+ //中标电话 需要查企业库 和三级页保持一致
|
|
|
+ winnertel := qu.ObjToString(v["winnertel"])
|
|
|
+ if winnertel == "" && isbid(v["subtype"]) {
|
|
|
+ v["winnertel"] = getwinnertel(v["s_winner"])
|
|
|
+ }
|
|
|
+ infos[_id] = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(infos) > 0 {
|
|
|
+ for k, v := range bidinfo {
|
|
|
+ id := util.DecodeId(v.Bid)
|
|
|
+ if infos[id] != nil {
|
|
|
+ infoMap, _ := (infos[id]).(map[string]interface{})
|
|
|
+ if qu.ObjToString(infoMap["winnertel"]) != "" {
|
|
|
+ v.Winnerinfo = true
|
|
|
+ bidinfo[k].Winnerinfo = true
|
|
|
+ }
|
|
|
+ if qu.ObjToString(infoMap["buyertel"]) != "" {
|
|
|
+ v.Buyerinfo = true
|
|
|
+ bidinfo[k].Buyerinfo = true
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bidinfo
|
|
|
+}
|
|
|
+
|
|
|
+func isbid(typ interface{}) bool {
|
|
|
+ if typ != nil {
|
|
|
+ subtype := qu.ObjToString(typ)
|
|
|
+ if subtype == "中标" || subtype == "合同" || subtype == "成交" {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+func getwinnertel(company interface{}) string {
|
|
|
+ if company != nil {
|
|
|
+ data, _ := db.Mgo_Ent.FindOneByField("winner_enterprise", map[string]interface{}{
|
|
|
+ "company_name": qu.ObjToString(company),
|
|
|
+ }, map[string]interface{}{"company_phone": 1})
|
|
|
+ if (*data)["company_phone"] != nil {
|
|
|
+ return qu.ObjToString((*data)["company_phone"])
|
|
|
+ }
|
|
|
}
|
|
|
+ return ""
|
|
|
}
|