|
@@ -6,7 +6,6 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"log"
|
|
"log"
|
|
mg "mongodb"
|
|
mg "mongodb"
|
|
- "net/url"
|
|
|
|
qu "qfw/util"
|
|
qu "qfw/util"
|
|
"qfw/util/elastic"
|
|
"qfw/util/elastic"
|
|
"qfw/util/jy"
|
|
"qfw/util/jy"
|
|
@@ -27,14 +26,21 @@ const (
|
|
)
|
|
)
|
|
|
|
|
|
//招标信息是否被收藏
|
|
//招标信息是否被收藏
|
|
-func IsCollByBids(bids, userid string) map[string]interface{} {
|
|
|
|
- res := map[string]interface{}{}
|
|
|
|
|
|
+func IsCollByBids(bids, userid string) []string {
|
|
|
|
+ res := []string{}
|
|
|
|
+ collBidMap := map[string]bool{}
|
|
|
|
+ if labArr := *db.Mysql.SelectBySql(fmt.Sprintf("select bid from %s where userid = ?", db.DbConf.Bdcollection), userid); len(labArr) > 0 {
|
|
|
|
+ for _, v := range labArr {
|
|
|
|
+ bid_id := qu.ObjToString(v["bid"])
|
|
|
|
+ collBidMap[bid_id] = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
for _, v := range strings.Split(bids, ",") {
|
|
for _, v := range strings.Split(bids, ",") {
|
|
//招标信息解密
|
|
//招标信息解密
|
|
- res[url.QueryEscape(v)] = false
|
|
|
|
bid := util.DecodeId(v)
|
|
bid := util.DecodeId(v)
|
|
- if labArr := *db.Mysql.SelectBySql(fmt.Sprintf("select * from %s where bid = ? and userid = ?", db.DbConf.Bdcollection), bid, userid); len(labArr) == 1 {
|
|
|
|
- res[url.QueryEscape(v)] = true
|
|
|
|
|
|
+ if collBidMap[bid] {
|
|
|
|
+ // url.QueryEscape(v)
|
|
|
|
+ res = append(res, v)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return res
|
|
return res
|
|
@@ -90,8 +96,9 @@ type BidInfo struct {
|
|
}
|
|
}
|
|
|
|
|
|
//收藏招标信息(批量收藏)|取消收藏(批量取消)
|
|
//收藏招标信息(批量收藏)|取消收藏(批量取消)
|
|
-func BidCollOrRemByIds(bidAction BidAction, userid string) bool {
|
|
|
|
|
|
+func BidCollOrRemByIds(bidAction BidAction, userid string) map[string]interface{} {
|
|
var i = 0
|
|
var i = 0
|
|
|
|
+ ok, msg := true, ""
|
|
var wg sync.WaitGroup
|
|
var wg sync.WaitGroup
|
|
maxCount := config.BidCollConfig.FreeUserCollLimit
|
|
maxCount := config.BidCollConfig.FreeUserCollLimit
|
|
isPay := Power(userid)
|
|
isPay := Power(userid)
|
|
@@ -119,6 +126,8 @@ func BidCollOrRemByIds(bidAction BidAction, userid string) bool {
|
|
} else {
|
|
} else {
|
|
if db.Mysql.Count(db.DbConf.Bdcollection, queryMap) == 0 {
|
|
if db.Mysql.Count(db.DbConf.Bdcollection, queryMap) == 0 {
|
|
if int(collCount) >= maxCount {
|
|
if int(collCount) >= maxCount {
|
|
|
|
+ ok = false
|
|
|
|
+ msg = "收藏已达上限"
|
|
log.Printf("userid :%s,收藏失败 id : %s ,已收藏数量:%v ,上限数量:%v", userid, util.DecodeId(bd.Bid), collCount, maxCount)
|
|
log.Printf("userid :%s,收藏失败 id : %s ,已收藏数量:%v ,上限数量:%v", userid, util.DecodeId(bd.Bid), collCount, maxCount)
|
|
} else {
|
|
} else {
|
|
now := time.Now().Unix()
|
|
now := time.Now().Unix()
|
|
@@ -145,7 +154,11 @@ func BidCollOrRemByIds(bidAction BidAction, userid string) bool {
|
|
}(v)
|
|
}(v)
|
|
}
|
|
}
|
|
wg.Wait()
|
|
wg.Wait()
|
|
- return i <= len(bidAction.Binfo)
|
|
|
|
|
|
+ m := map[string]interface{}{
|
|
|
|
+ "status": qu.If(ok, i <= len(bidAction.Binfo), ok),
|
|
|
|
+ "msg": msg,
|
|
|
|
+ }
|
|
|
|
+ return m
|
|
}
|
|
}
|
|
|
|
|
|
//添加或绑定标签|删除标签
|
|
//添加或绑定标签|删除标签
|
|
@@ -157,7 +170,8 @@ type LabelInfo struct {
|
|
}
|
|
}
|
|
|
|
|
|
//新增标签(并使用)|删除标签 RV0=
|
|
//新增标签(并使用)|删除标签 RV0=
|
|
-func LabelAction(labInfo *LabelInfo, userid string) (ibool bool) {
|
|
|
|
|
|
+func LabelAction(labInfo *LabelInfo, userid string) map[string]interface{} {
|
|
|
|
+ ibool, ok, msg := true, true, ""
|
|
if labInfo.Laction == "D" && labInfo.Lids != "" {
|
|
if labInfo.Laction == "D" && labInfo.Lids != "" {
|
|
labInfo.Lids = strings.Split(labInfo.Lids, ",")[0]
|
|
labInfo.Lids = strings.Split(labInfo.Lids, ",")[0]
|
|
labid := qu.SE.DecodeString(labInfo.Lids)
|
|
labid := qu.SE.DecodeString(labInfo.Lids)
|
|
@@ -245,6 +259,7 @@ func LabelAction(labInfo *LabelInfo, userid string) (ibool bool) {
|
|
}
|
|
}
|
|
if db.Mysql.Count(db.DbConf.Bdcollection, queryMap) == 0 {
|
|
if db.Mysql.Count(db.DbConf.Bdcollection, queryMap) == 0 {
|
|
if int(collCount) >= maxCount {
|
|
if int(collCount) >= maxCount {
|
|
|
|
+ ok, msg = false, "收藏已达上限"
|
|
log.Printf("userid :%s,收藏失败 id : %s ,已收藏数量:%v ,上限数量:%v", userid, util.DecodeId(bd.Bid), collCount, maxCount)
|
|
log.Printf("userid :%s,收藏失败 id : %s ,已收藏数量:%v ,上限数量:%v", userid, util.DecodeId(bd.Bid), collCount, maxCount)
|
|
} else {
|
|
} else {
|
|
inserMap := map[string]interface{}{
|
|
inserMap := map[string]interface{}{
|
|
@@ -277,7 +292,10 @@ func LabelAction(labInfo *LabelInfo, userid string) (ibool bool) {
|
|
ibool = i == len(labInfo.Binfo)
|
|
ibool = i == len(labInfo.Binfo)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return ibool
|
|
|
|
|
|
+ return map[string]interface{}{
|
|
|
|
+ "status": qu.If(ok, ibool, ok),
|
|
|
|
+ "msg": msg,
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//收藏列表
|
|
//收藏列表
|
|
@@ -292,6 +310,7 @@ type CollList struct {
|
|
}
|
|
}
|
|
|
|
|
|
func GetCollList(c *CollList, userid string) map[string]interface{} {
|
|
func GetCollList(c *CollList, userid string) map[string]interface{} {
|
|
|
|
+ log.Println(c)
|
|
pagesize_max := config.BidCollConfig.Pagesize
|
|
pagesize_max := config.BidCollConfig.Pagesize
|
|
rdata := map[string]interface{}{
|
|
rdata := map[string]interface{}{
|
|
"count": 0,
|
|
"count": 0,
|
|
@@ -574,18 +593,18 @@ func FormatColl(bidinfo []BidInfo) []BidInfo {
|
|
es_ids = append(es_ids, util.DecodeId(v.Bid))
|
|
es_ids = append(es_ids, util.DecodeId(v.Bid))
|
|
}
|
|
}
|
|
if len(es_ids) > 0 {
|
|
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
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // 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 {
|
|
if len(infos) > 0 {
|
|
for k, v := range bidinfo {
|
|
for k, v := range bidinfo {
|
|
@@ -628,3 +647,40 @@ func getwinnertel(company interface{}) string {
|
|
}
|
|
}
|
|
return ""
|
|
return ""
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//新增标签
|
|
|
|
+func AddLab(name, userid string) map[string]interface{} {
|
|
|
|
+ m := map[string]interface{}{
|
|
|
|
+ "labid": "",
|
|
|
|
+ "msg": "",
|
|
|
|
+ }
|
|
|
|
+ now := time.Now().Unix()
|
|
|
|
+ if db.Mysql.CountBySql(fmt.Sprintf(`select count(1) from %s where userid =?`, db.DbConf.Bdlabel), userid) >= int64(config.BidCollConfig.LabelMaxCount) {
|
|
|
|
+ m := map[string]interface{}{
|
|
|
|
+ "labid": "",
|
|
|
|
+ "msg": "标签数量已达上限",
|
|
|
|
+ }
|
|
|
|
+ return m
|
|
|
|
+ }
|
|
|
|
+ //是否有重名
|
|
|
|
+ if labArr := *db.Mysql.SelectBySql(fmt.Sprintf("select * from %s where labelname = ? and userid = ?", db.DbConf.Bdlabel), name, userid); len(labArr) == 1 {
|
|
|
|
+ res := labArr[0]
|
|
|
|
+ m["labid"] = qu.SE.EncodeString(strconv.FormatInt(qu.Int64All(res["id"]), 10))
|
|
|
|
+ m["msg"] = "已存在"
|
|
|
|
+ return m
|
|
|
|
+ } else { //新增标签
|
|
|
|
+ insertMap := map[string]interface{}{
|
|
|
|
+ "userid": userid,
|
|
|
|
+ "labelname": name,
|
|
|
|
+ "createdate": qu.FormatDateByInt64(&now, qu.Date_Full_Layout),
|
|
|
|
+ }
|
|
|
|
+ if lid := db.Mysql.Insert(db.DbConf.Bdlabel, insertMap); lid > 0 {
|
|
|
|
+ m["labid"] = qu.SE.EncodeString(strconv.FormatInt(lid, 10))
|
|
|
|
+ } else {
|
|
|
|
+ log.Println("新增标签失败 - name:", name)
|
|
|
|
+ m["msg"] = "保存失败"
|
|
|
|
+ return m
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return m
|
|
|
|
+}
|