|
@@ -21,7 +21,7 @@ import (
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
- query = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","subtype","s_winner","buyertel","winnertel"],"from":0,"size":%d}`
|
|
|
+ query = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","subtype","s_winner","buyertel","winnertel","buyerclass"],"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}}`
|
|
|
)
|
|
@@ -42,17 +42,31 @@ func IsCollByBids(bids, userid string) map[string]interface{} {
|
|
|
|
|
|
//获取用户标签
|
|
|
type LabelByUser struct {
|
|
|
- Lid string `json:"lid"`
|
|
|
- Lname string `json:"lanme"`
|
|
|
+ Lid string `json:"lid"`
|
|
|
+ Lname string `json:"lanme"`
|
|
|
+ LCount int `json:"count"`
|
|
|
}
|
|
|
|
|
|
func GetLabelByUser(userid string) (data []LabelByUser) {
|
|
|
+ //获取标签数量
|
|
|
+ labcount := map[string]int{}
|
|
|
+ selectsql := fmt.Sprintf(`SELECT a.labelname,COUNT(1) count,a.id
|
|
|
+ FROM %s a INNER JOIN %s b ON
|
|
|
+ FIND_IN_SET(a.id,b.labelid)
|
|
|
+ WHERE b.userid =?
|
|
|
+ GROUP BY a.labelname,a.id`, db.DbConf.Bdlabel, db.DbConf.Bdcollection)
|
|
|
+ if data := *db.Mysql.SelectBySql(selectsql, userid); len(data) > 0 {
|
|
|
+ for _, v := range data {
|
|
|
+ labcount[strconv.FormatInt(v["id"].(int64), 10)] = qu.IntAll(v["count"])
|
|
|
+ }
|
|
|
+ }
|
|
|
if labArr := *db.Mysql.SelectBySql(fmt.Sprintf("select * from %s where userid = ?", db.DbConf.Bdlabel), userid); len(labArr) > 0 {
|
|
|
for _, v := range labArr {
|
|
|
l := new(LabelByUser)
|
|
|
lid := strconv.FormatInt(v["id"].(int64), 10)
|
|
|
l.Lid = qu.SE.EncodeString(lid)
|
|
|
l.Lname = qu.ObjToString(v["labelname"])
|
|
|
+ l.LCount = labcount[lid]
|
|
|
data = append(data, *l)
|
|
|
}
|
|
|
}
|
|
@@ -142,21 +156,40 @@ type LabelInfo struct {
|
|
|
Laction string `json:"laction"` //用户行为:S添加或绑定标签;D删除标签
|
|
|
}
|
|
|
|
|
|
-//新增标签(并使用)|删除标签
|
|
|
+//新增标签(并使用)|删除标签 RV0=
|
|
|
func LabelAction(labInfo *LabelInfo, userid string) (ibool bool) {
|
|
|
if labInfo.Laction == "D" && labInfo.Lids != "" {
|
|
|
labInfo.Lids = strings.Split(labInfo.Lids, ",")[0]
|
|
|
- updateMap := map[string]interface{}{
|
|
|
- "userid": userid,
|
|
|
- "labelid": qu.SE.DecodeString(labInfo.Lids),
|
|
|
- }
|
|
|
+ labid := qu.SE.DecodeString(labInfo.Lids)
|
|
|
//收藏信息解绑标签成功
|
|
|
- if db.Mysql.Update(db.DbConf.Bdcollection, updateMap, map[string]interface{}{"labelid": ""}) {
|
|
|
- deleteMap := map[string]interface{}{
|
|
|
- "userid": userid,
|
|
|
- "id": qu.SE.DecodeString(labInfo.Lids),
|
|
|
+ deleteMap := map[string]interface{}{
|
|
|
+ "userid": userid,
|
|
|
+ "id": qu.SE.DecodeString(labInfo.Lids),
|
|
|
+ }
|
|
|
+ labBid := map[string]interface{}{}
|
|
|
+ //查询出该标签下的三级页
|
|
|
+ rdata := db.Mysql.SelectBySql(fmt.Sprintf(`select labelid,bid from %s where
|
|
|
+ FIND_IN_SET(?,labelid) and userid = ?`, db.DbConf.Bdcollection), labid, userid)
|
|
|
+ if rdata != nil && len(*rdata) > 0 {
|
|
|
+ for _, v := range *rdata {
|
|
|
+ bid_id := qu.ObjToString(v["bid"])
|
|
|
+ label_id := labid
|
|
|
+ labBid[bid_id] = label_id
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //解绑标签
|
|
|
+ index := 0
|
|
|
+ for k, v := range labBid {
|
|
|
+ if db.Mysql.UpdateOrDeleteBySql(`update bdcollection set labelid =
|
|
|
+ (select new.lab from
|
|
|
+ (SELECT TRIM(BOTH ',' FROM REPLACE(CONCAT(',',labelid,','),CONCAT(',',?,','),',')) lab
|
|
|
+ FROM bdcollection WHERE bid = ? ) new
|
|
|
+ )
|
|
|
+ WHERE bid = ?`, v, k, k) > -1 {
|
|
|
+ index++
|
|
|
}
|
|
|
- //删除标签
|
|
|
+ }
|
|
|
+ if index == len(labBid) {
|
|
|
ibool = db.Mysql.Delete(db.DbConf.Bdlabel, deleteMap)
|
|
|
}
|
|
|
} else {
|
|
@@ -329,6 +362,8 @@ func GetCollList(c *CollList, userid string) map[string]interface{} {
|
|
|
sql += ` and winnerinfo = 0`
|
|
|
}
|
|
|
limit = config.BidCollConfig.PayUserCollLimit
|
|
|
+ } else {
|
|
|
+ pagesize_max = config.BidCollConfig.FreeUserCollLimit
|
|
|
}
|
|
|
sql += fmt.Sprintf(` order by createdate desc limit %v`, limit)
|
|
|
log.Println(sql)
|
|
@@ -352,7 +387,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, userid, result)
|
|
|
+ rdata["res"] = GetInfoById(db.Mgo_Bidding, db.DbConf.Mongodb.Bidding.Collection, db.DbConf.Mongodb.Bidding.Collection_change, result)
|
|
|
return rdata
|
|
|
}
|
|
|
|
|
@@ -399,7 +434,7 @@ type InfoList struct {
|
|
|
}
|
|
|
|
|
|
//根据id取内容
|
|
|
-func GetInfoById(Mgo_bidding mg.MongodbSim, bidding, bidding_back, userid string, idlist []map[string]interface{}) []*InfoList {
|
|
|
+func GetInfoById(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, idlist []map[string]interface{}) []*InfoList {
|
|
|
array := make([]*InfoList, len(idlist))
|
|
|
if len(idlist) == 0 {
|
|
|
return array
|
|
@@ -558,16 +593,15 @@ func FormatColl(bidinfo []BidInfo) []BidInfo {
|
|
|
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
|
|
|
-
|
|
|
+ }
|
|
|
+ if qu.ObjToString(infoMap["buyerclass"]) != "" {
|
|
|
+ bidinfo[k].Buyerclass = qu.ObjToString(infoMap["buyerclass"])
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
return bidinfo
|