|
@@ -15,6 +15,7 @@ import (
|
|
"math/rand"
|
|
"math/rand"
|
|
"sort"
|
|
"sort"
|
|
"strings"
|
|
"strings"
|
|
|
|
+ "sync"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -471,3 +472,70 @@ func NewHotEnt(isWinner bool) (data []map[string]interface{}) {
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// 中标喜报
|
|
|
|
+func WinnerGladTidings() (entBidArr []map[string]interface{}) {
|
|
|
|
+ redisKey := "winnerGladTidings"
|
|
|
|
+ data, _ := redis.Get(RedisNameNew, redisKey).([]interface{})
|
|
|
|
+ if len(data) > 0 {
|
|
|
|
+ entBidArr = common.ObjArrToMapArr(data)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ entName := public.Mysql.SelectBySql(fmt.Sprintf(`SELECT a.name,b.min_vip_starttime,b.max_vip_endtime
|
|
|
|
+FROM
|
|
|
|
+ entniche_info a
|
|
|
|
+ INNER JOIN ( SELECT ent_id, MIN(vip_starttime) AS min_vip_starttime, MAX(vip_endtime) AS max_vip_endtime
|
|
|
|
+FROM dataexport_order
|
|
|
|
+WHERE order_status = 1 AND product_type = '大会员' AND vip_endtime > '%s' AND ent_id > 0
|
|
|
|
+GROUP BY ent_id) b on a.id = b.ent_id
|
|
|
|
+WHERE
|
|
|
|
+ a.NAME NOT LIKE %s `, time.Now().Format("2006-01-02 15:04:05"), "'%测试%'"))
|
|
|
|
+ if entName != nil && len(*entName) > 0 {
|
|
|
|
+ pool := make(chan bool, 10)
|
|
|
|
+ wait := &sync.WaitGroup{}
|
|
|
|
+ var lock sync.Mutex
|
|
|
|
+ for _, v := range *entName {
|
|
|
|
+ eName := common.InterfaceToStr(v["name"])
|
|
|
|
+ vipStarttime := common.InterfaceToStr(v["min_vip_starttime"])
|
|
|
|
+ vipEndtime := common.InterfaceToStr(v["max_vip_endtime"])
|
|
|
|
+ pool <- true
|
|
|
|
+ wait.Add(1)
|
|
|
|
+ go func(name, sta, end string) {
|
|
|
|
+ defer func() {
|
|
|
|
+ wait.Done()
|
|
|
|
+ <-pool
|
|
|
|
+ }()
|
|
|
|
+ //es查询
|
|
|
|
+ list := getEsEntBid(name, sta, end)
|
|
|
|
+ if list != nil {
|
|
|
|
+ lock.Lock()
|
|
|
|
+ entBidArr = append(entBidArr, list)
|
|
|
|
+ lock.Unlock()
|
|
|
|
+ }
|
|
|
|
+ }(eName, vipStarttime, vipEndtime)
|
|
|
|
+ }
|
|
|
|
+ wait.Wait()
|
|
|
|
+ if len(entBidArr) > 0 {
|
|
|
|
+ redis.Put(RedisNameNew, redisKey, entBidArr, 24*3600*7)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return entBidArr
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func getEsEntBid(names, sta, end string) map[string]interface{} {
|
|
|
|
+ sTime, err := time.Parse("2006-01-02 15:04:05", sta)
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("日期时间解析错误:", err)
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ eTime, err := time.Parse("2006-01-02 15:04:05", end)
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("日期时间解析错误:", err)
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ list := elastic.Get("bidding", "bidding", fmt.Sprintf(`{"query": {"bool": {"must": [{"range":{"publishtime":{"gte":%d,"lte":%d}}},{"terms": {"s_winner": ["%s"]}},{"terms": {"subtype": ["中标","成交"]}}],"minimum_should_match": 0}},"_source": ["_id"], "sort": [{"publishtime": "desc"}],"size": 1}`, sTime.Unix(), eTime.Unix(), names))
|
|
|
|
+ if list != nil && len(*list) > 0 {
|
|
|
|
+ return map[string]interface{}{names: encrypt.EncodeArticleId2ByCheck(common.InterfaceToStr((*list)[0]["_id"]))}
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
|
|
+}
|