common.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. package util
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/encrypt"
  5. "app.yhyue.com/moapp/jybase/esv1"
  6. "app.yhyue.com/moapp/jybase/mongodb"
  7. "app.yhyue.com/moapp/jybase/mysql"
  8. "app.yhyue.com/moapp/jybase/redis"
  9. "fmt"
  10. "go.mongodb.org/mongo-driver/bson/primitive"
  11. "jyBXBase/rpc/bxbase"
  12. IC "jyBXBase/rpc/init"
  13. "log"
  14. "strconv"
  15. "strings"
  16. "time"
  17. )
  18. const (
  19. query = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","subtype","s_winner","buyertel","winnertel","buyerclass"],"from":0,"size":%d}`
  20. 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,"attach_text":1}`
  21. 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}}`
  22. )
  23. //是否是付费用户 -bool: true:是 fasle:不是
  24. func Power(userid string) (bool, map[string]interface{}) {
  25. isVip, isMember, isEnt := false, false, false
  26. vipstatus := 0
  27. phone := ""
  28. var registedate int64
  29. data, ok := IC.Mgo.FindById("user", userid, `"i_member_status":1,"i_vip_status":1,"s_m_phone":1,"s_phone":1,"o_vipjy":1,"l_registedate":1`)
  30. if data != nil && len(*data) > 0 && ok {
  31. i_vip_status := common.IntAll((*data)["i_vip_status"])
  32. if i_vip_status > 1 {
  33. vipstatus = 1
  34. isVip = true
  35. }
  36. ovipjy, _ := (*data)["o_vipjy"].(map[string]interface{})
  37. if ovipjy["o_buyset"] != nil {
  38. o_buyset := ovipjy["o_buyset"].(map[string]interface{})
  39. if o_buyset["upgrade"] != nil && isVip {
  40. vipstatus = 2
  41. }
  42. }
  43. if i_member_status := common.IntAllDef((*data)["i_member_status"], 0); i_member_status > 0 {
  44. isMember = true
  45. }
  46. if s_phone, _ := (*data)["s_phone"].(string); s_phone != "" {
  47. phone = s_phone
  48. } else if s_m_phone, _ := (*data)["s_m_phone"].(string); s_m_phone != "" {
  49. phone = s_m_phone
  50. }
  51. if phone != "" {
  52. //已购买企业未过期
  53. if entInfo := *IC.MainMysql.SelectBySql(`SELECT status FROM entniche_info WHERE id IN (SELECT ent_id FROM entniche_user where phone = ? and power =1)`, phone); len(entInfo) > 0 {
  54. for _, v := range entInfo {
  55. if common.IntAll(v["status"]) == 1 {
  56. isEnt = true
  57. break
  58. }
  59. }
  60. }
  61. }
  62. registedate, _ = (*data)["l_registedate"].(int64)
  63. }
  64. return isVip || isEnt || isMember, map[string]interface{}{
  65. "vip": vipstatus,
  66. "member": isMember,
  67. "entniche": isEnt,
  68. "registedate": registedate,
  69. }
  70. }
  71. //招标信息是否被收藏
  72. func IsCollByBids(bids, userid string) []string {
  73. res := []string{}
  74. collBidMap := map[string]bool{}
  75. isCollkey := fmt.Sprintf("isColl_%s", userid)
  76. collStatus := redis.GetInt("other", isCollkey)
  77. if collStatus == 0 {
  78. if count := int(IC.MainMysql.CountBySql(fmt.Sprintf(`select count(1)
  79. from %s where userid = ?`, "bdcollection"), userid)); count > 100 {
  80. collStatus = 2
  81. } else if count == 0 {
  82. collStatus = 0
  83. } else {
  84. collStatus = 1
  85. }
  86. redis.Put("other", isCollkey, collStatus, 259200)
  87. }
  88. if collStatus == 1 { //100条内 取redis
  89. list := GetCollRedis(userid, collStatus)
  90. for _, v := range list {
  91. collBidMap[v] = true
  92. }
  93. } else if collStatus == 2 { //大于100条 取mysql
  94. if labArr := *IC.MainMysql.SelectBySql(fmt.Sprintf("select bid from %s where userid = ?", "bdcollection"), userid); len(labArr) > 0 {
  95. for _, v := range labArr {
  96. bid_id := common.ObjToString(v["bid"])
  97. collBidMap[bid_id] = true
  98. }
  99. }
  100. } else { //0条
  101. return res
  102. }
  103. if bids == "" {
  104. for k, _ := range collBidMap {
  105. res = append(res, k)
  106. }
  107. } else {
  108. for _, v := range strings.Split(bids, ",") {
  109. //招标信息解密
  110. bid := DecodeId(v)
  111. if collBidMap[bid] {
  112. // url.QueryEscape(v)
  113. res = append(res, v)
  114. }
  115. }
  116. }
  117. return res
  118. }
  119. /*
  120. isColl int: 收藏条数的状态 (是否超过100条 超过:2 没超过:1)
  121. return
  122. []string:收藏的id
  123. */
  124. func GetCollRedis(userid string, isColl int) []string {
  125. redisCollKey := fmt.Sprintf("coll_%s", userid) //列表
  126. redisArr := []string{}
  127. if isColl == 1 {
  128. redisArr, _ = redis.Get("other", redisCollKey).([]string)
  129. if len(redisArr) == 0 {
  130. data := IC.MainMysql.SelectBySql(fmt.Sprintf(`select bid from %s where userid ='%s'`, "bdcollection", userid))
  131. if data != nil && len(*data) > 0 {
  132. for _, v := range *data {
  133. redisArr = append(redisArr, common.ObjToString(v["bid"]))
  134. }
  135. redis.Put("other", redisCollKey, redisArr, 259200)
  136. }
  137. }
  138. }
  139. return redisArr
  140. }
  141. //招标信息 bid&userid 唯一
  142. type BidInfo struct {
  143. Bid string `json:"bid"` //招标信息id 加密后
  144. Buyerclass string `json:"buyerclass"` //采购单位类型
  145. Buyerinfo bool `json:"buyerinfo"` //是否有采购单位联系方式
  146. Winnerinfo bool `json:"winnerinfo"` //是否有中标企业联系方式
  147. Userid string `json:"userid"` //用户id
  148. Createdate string `json:"createdate"` //收藏时间
  149. Labelid string `json:"labelid"` //标签ids
  150. }
  151. func FormatColl(bidinfo []string) []BidInfo {
  152. es_ids := []string{}
  153. infos := map[string]interface{}{}
  154. for _, v := range bidinfo {
  155. es_ids = append(es_ids, DecodeId(v))
  156. }
  157. if len(es_ids) > 0 {
  158. list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
  159. if list != nil {
  160. for _, v := range *list {
  161. _id := common.ObjToString(v["_id"])
  162. //中标电话 需要查企业库 和三级页保持一致
  163. winnertel := common.ObjToString(v["winnertel"])
  164. if winnertel == "" && isbid(v["subtype"]) {
  165. v["winnertel"] = getwinnertel(v["s_winner"])
  166. }
  167. infos[_id] = v
  168. }
  169. }
  170. }
  171. var bids []BidInfo
  172. if len(infos) > 0 {
  173. for _, v := range bidinfo {
  174. var bid BidInfo
  175. id := DecodeId(v)
  176. bid.Bid = v
  177. if infos[id] != nil {
  178. infoMap, _ := (infos[id]).(map[string]interface{})
  179. if common.ObjToString(infoMap["winnertel"]) != "" {
  180. bid.Winnerinfo = true
  181. }
  182. if common.ObjToString(infoMap["buyertel"]) != "" {
  183. bid.Buyerinfo = true
  184. }
  185. if common.ObjToString(infoMap["buyerclass"]) != "" {
  186. bid.Buyerclass = common.ObjToString(infoMap["buyerclass"])
  187. }
  188. }
  189. bids = append(bids, bid)
  190. }
  191. }
  192. return bids
  193. }
  194. func isbid(typ interface{}) bool {
  195. if typ != nil {
  196. subtype := common.ObjToString(typ)
  197. if subtype == "中标" || subtype == "合同" || subtype == "成交" {
  198. return true
  199. }
  200. }
  201. return false
  202. }
  203. func getwinnertel(company interface{}) string {
  204. if company != nil {
  205. data, _ := IC.MgoEnt.FindOneByField("winner_enterprise", map[string]interface{}{
  206. "company_name": common.ObjToString(company),
  207. }, map[string]interface{}{"company_phone": 1})
  208. if (*data)["company_phone"] != nil {
  209. return common.ObjToString((*data)["company_phone"])
  210. }
  211. }
  212. return ""
  213. }
  214. //修改redis中的收藏条数;
  215. /* typ:"d"删除 typ:"a"添加
  216. list:需要添加或删除的bid_id
  217. */
  218. func UpdateCollListRedis(typ, userid string, list []string) bool {
  219. bl := false
  220. if len(list) == 0 {
  221. return true
  222. }
  223. Blist := []string{}
  224. m := map[string]bool{}
  225. redisCollKey := fmt.Sprintf("coll_%s", userid)
  226. collTime := 3600 * 2
  227. if 7200 > 0 {
  228. collTime = 7200
  229. }
  230. redisIsCollKey := fmt.Sprintf("isColl_%s", userid) //是否超过100条 超过:2 没超过:1
  231. isCollTime := 3600 * 24 * 3
  232. if 259200 > 0 {
  233. isCollTime = 259200
  234. }
  235. collStatus := redis.GetInt("other", redisIsCollKey)
  236. redisArr := GetCollRedis(userid, collStatus)
  237. if len(redisArr) > 0 {
  238. for _, v := range redisArr {
  239. m[v] = true
  240. }
  241. }
  242. if typ == "a" {
  243. for _, v := range list {
  244. if m[v] {
  245. continue //去重
  246. }
  247. Blist = append(Blist, v)
  248. }
  249. } else if typ == "d" {
  250. for _, v := range list {
  251. delete(m, v)
  252. }
  253. if len(m) > 0 {
  254. for k, _ := range m {
  255. Blist = append(Blist, k)
  256. }
  257. }
  258. }
  259. arr := append(redisArr, Blist...)
  260. status := 1
  261. if len(arr) > 100 {
  262. status = 2
  263. arr = []string{}
  264. } else if len(arr) == 0 {
  265. status = 0
  266. }
  267. bl = redis.Put("other", redisCollKey, arr, collTime) &&
  268. redis.Put("other", redisIsCollKey, status, isCollTime)
  269. return bl
  270. }
  271. var PushMapping = &pushMapping{}
  272. type pushMapping struct {
  273. Area map[string]int
  274. City map[string]int
  275. Toptype map[string]int
  276. Subtype map[string]int
  277. Buyerclass map[string]int
  278. Subscopeclass map[string]int
  279. }
  280. func (p *pushMapping) Init(MainMysql *mysql.Mysql) {
  281. infotype := MainMysql.SelectBySql("select id,type,name from infotype")
  282. p.Toptype = map[string]int{}
  283. p.Subtype = map[string]int{}
  284. p.Buyerclass = map[string]int{}
  285. p.Subscopeclass = map[string]int{}
  286. for _, v := range *infotype {
  287. id := common.IntAll(v["id"])
  288. tp := common.IntAll(v["type"])
  289. name := common.ObjToString(v["name"])
  290. if tp == 1 {
  291. p.Toptype[name] = id
  292. } else if tp == 2 {
  293. p.Subtype[name] = id
  294. } else if tp == 3 {
  295. p.Buyerclass[name] = id
  296. } else if tp == 4 {
  297. p.Subscopeclass[name] = id
  298. }
  299. }
  300. if len(p.Toptype) == 0 {
  301. log.Fatalln("PushMapping Toptype Init Error")
  302. }
  303. if len(p.Subtype) == 0 {
  304. log.Fatalln("PushMapping Subtype Init Error")
  305. }
  306. if len(p.Buyerclass) == 0 {
  307. log.Fatalln("PushMapping Buyerclass Init Error")
  308. }
  309. if len(p.Subscopeclass) == 0 {
  310. log.Fatalln("PushMapping Subscopeclass Init Error")
  311. }
  312. //
  313. p.Area = map[string]int{}
  314. p.City = map[string]int{}
  315. province := MainMysql.SelectBySql("select id,level,name from province")
  316. for _, v := range *province {
  317. id := common.IntAll(v["id"])
  318. level := common.IntAll(v["level"])
  319. name := common.ObjToString(v["name"])
  320. if level == 1 {
  321. p.Area[name] = id
  322. } else if level == 2 {
  323. p.City[name] = id
  324. }
  325. }
  326. if len(p.Area) == 0 {
  327. log.Fatalln("PushMapping Area Init Error")
  328. }
  329. if len(p.City) == 0 {
  330. log.Fatalln("PushMapping City Init Error")
  331. }
  332. }
  333. type InfoList struct {
  334. Id string `json:"_id"`
  335. Title string `json:"title"`
  336. Area string `json:"area"`
  337. Buyerclass string `json:"buyerclass"`
  338. Type string `json:"type"`
  339. S_subscopeclass string `json:"s_subscopeclass"`
  340. Publishtime int64 `json:"publishtime"`
  341. Budget interface{} `json:"budget"`
  342. Bidamount interface{} `json:"bidamount"`
  343. Buyer string `json:"buyer"`
  344. S_winner string `json:"s_winner"`
  345. Bidopentime int64 `json:"bidopentime"`
  346. FileExists bool `json:"fileExists"`
  347. }
  348. //根据id取内容
  349. func GetInfoById(Mgo_bidding mongodb.MongodbSim, bidding, bidding_back string, idlist []map[string]interface{}) []*InfoList {
  350. array := make([]*InfoList, len(idlist))
  351. if len(idlist) == 0 {
  352. return array
  353. }
  354. m := map[string]bool{}
  355. ids := []string{}
  356. for _, v := range idlist {
  357. if m[common.ObjToString(v["bid"])] {
  358. continue
  359. }
  360. m[common.ObjToString(v["bid"])] = true
  361. ids = append(ids, common.ObjToString(v["bid"]))
  362. }
  363. infos := map[string]map[string]interface{}{}
  364. //redis
  365. es_ids := []string{}
  366. for _, v := range ids {
  367. info_i := redis.Get("pushcache_1", fmt.Sprintf("info_%s", v))
  368. if info_i != nil {
  369. info_m, _ := info_i.(map[string]interface{})
  370. info_m["_id"] = v
  371. infos[v] = info_m
  372. } else {
  373. es_ids = append(es_ids, v)
  374. }
  375. }
  376. // log.Println(es_ids)
  377. //elasticsearch
  378. if len(es_ids) > 0 {
  379. list := elastic.Get("bidding", "bidding", fmt.Sprintf(querys, strings.Join(es_ids, `","`), len(es_ids)))
  380. if list != nil {
  381. for _, v := range *list {
  382. _id := common.ObjToString(v["_id"])
  383. v["attachment_count"] = common.If(v["filetext"] != nil, 1, 0).(int)
  384. infos[_id] = v
  385. }
  386. }
  387. }
  388. //mongodb bidding
  389. mgo_ids := []primitive.ObjectID{}
  390. for _, v := range es_ids {
  391. if infos[v] == nil {
  392. _id, _ := primitive.ObjectIDFromHex(v)
  393. mgo_ids = append(mgo_ids, _id)
  394. }
  395. }
  396. if len(mgo_ids) > 0 {
  397. list, ok := Mgo_bidding.Find(bidding, map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_ids}}, nil, mongodb_fields, false, -1, -1)
  398. if ok && *list != nil {
  399. for _, v := range *list {
  400. _id := mongodb.BsonIdToSId(v["_id"])
  401. v["_id"] = _id
  402. v["attachment_count"] = common.If(v["attach_text"] != nil, 1, 0).(int)
  403. infos[_id] = v
  404. }
  405. }
  406. }
  407. //mongodb bidding_back
  408. mgo_back_ids := []primitive.ObjectID{}
  409. for _, v := range mgo_ids {
  410. if infos[mongodb.BsonIdToSId(v)] == nil {
  411. mgo_back_ids = append(mgo_back_ids, v)
  412. }
  413. }
  414. if len(mgo_back_ids) > 0 {
  415. list, ok := Mgo_bidding.Find(bidding_back, map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_back_ids}}, nil, mongodb_fields, false, -1, -1)
  416. if ok && *list != nil {
  417. for _, v := range *list {
  418. _id := mongodb.BsonIdToSId(v["_id"])
  419. v["_id"] = _id
  420. v["attachment_count"] = common.If(v["attach_text"] != nil, 1, 0).(int)
  421. infos[_id] = v
  422. }
  423. }
  424. }
  425. //
  426. for k, v := range idlist {
  427. info := infos[common.ObjToString(v["bid"])]
  428. if info == nil {
  429. info = map[string]interface{}{}
  430. }
  431. array[k] = InfoFormat(common.ObjToString(v["bid"]), &info)
  432. }
  433. return array
  434. }
  435. //列表单条信息格式化
  436. func InfoFormat(p string, info *map[string]interface{}) *InfoList {
  437. area := common.ObjToString((*info)["area"])
  438. if area == "A" {
  439. area = "全国"
  440. }
  441. industry := common.ObjToString((*info)["s_subscopeclass"])
  442. scs := strings.Split(industry, ",")
  443. if len(scs) > 0 {
  444. industry = scs[0]
  445. if industry != "" {
  446. iss := strings.Split(industry, "_")
  447. if len(iss) > 0 {
  448. industry = iss[0]
  449. }
  450. }
  451. }
  452. infotype := common.ObjToString((*info)["subtype"])
  453. if infotype == "" {
  454. infotype = common.ObjToString((*info)["toptype"])
  455. }
  456. if infotype == "" {
  457. infotype = common.ObjToString((*info)["type"])
  458. if infotype == "tender" {
  459. infotype = "招标"
  460. } else if infotype == "bid" {
  461. infotype = "中标"
  462. }
  463. }
  464. _id := p
  465. if _id == "" {
  466. _id = common.ObjToString((*info)["_id"])
  467. }
  468. return &InfoList{
  469. Id: encrypt.EncodeArticleId2ByCheck(_id),
  470. Title: common.ObjToString((*info)["title"]),
  471. Area: area,
  472. Buyerclass: common.ObjToString((*info)["buyerclass"]),
  473. Type: infotype,
  474. S_subscopeclass: industry,
  475. Publishtime: common.Int64All((*info)["publishtime"]),
  476. Budget: (*info)["budget"],
  477. Bidamount: (*info)["bidamount"],
  478. Buyer: common.ObjToString((*info)["buyer"]),
  479. S_winner: common.ObjToString((*info)["s_winner"]),
  480. Bidopentime: common.Int64All((*info)["bidopentime"]),
  481. FileExists: common.IntAll((*info)["attachment_count"]) > 0,
  482. }
  483. }
  484. //搜藏列表
  485. func CollListSql(c *bxbase.ListReq, isPay bool, userid string) string {
  486. sql := fmt.Sprintf(`select bid from %s where userid ='%s'`, "bdcollection", userid)
  487. limit := 10
  488. //个人标签
  489. if c.Label != "" {
  490. i := 0
  491. sql += ` and `
  492. if labelArr := strings.Split(c.Label, ","); len(labelArr) > 0 {
  493. sql += `(`
  494. for _, v := range labelArr {
  495. i++
  496. labid := encrypt.SE.DecodeString(v)
  497. if i == len(labelArr) {
  498. sql += fmt.Sprintf(`FIND_IN_SET(%s,labelid)`, labid)
  499. } else {
  500. sql += fmt.Sprintf(`FIND_IN_SET(%s,labelid) or `, labid)
  501. }
  502. }
  503. sql += `)`
  504. }
  505. }
  506. now := time.Now()
  507. start, end := "", ""
  508. //收藏时间
  509. if c.SelectTime == "lately-7" { //最近7天
  510. start = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
  511. } else if c.SelectTime == "lately-30" { //最近30天
  512. start = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
  513. } else if c.SelectTime == "thisyear" { //去年
  514. start = fmt.Sprint(time.Date(now.Year()-1, 1, 1, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
  515. end = fmt.Sprint(time.Date(now.Year()-1, 12, 31, 23, 59, 59, 0, time.Local).Format(Date_Full_Layout))
  516. } else if len(strings.Split(c.SelectTime, "_")) == 2 {
  517. if c.SelectTime != "0_0" {
  518. starttime := strings.Split(c.SelectTime, "_")[0]
  519. startstamp, _ := strconv.Atoi(starttime)
  520. start = time.Unix(int64(startstamp), 0).Format(Date_Full_Layout)
  521. endtime := strings.Split(c.SelectTime, "_")[1]
  522. et, _ := strconv.ParseInt(endtime, 0, 64)
  523. etTime := time.Unix(et, 0)
  524. end = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
  525. }
  526. }
  527. if start != "" && end != "" {
  528. sql += ` and createdate >= '` + start + `' and createdate < '` + end + `'`
  529. } else if start != "" && end == "" {
  530. sql += ` and createdate >= '` + start + `'`
  531. } else if start == "" && end != "" {
  532. sql += ` and createdate < '` + end + `'`
  533. }
  534. if isPay {
  535. //采购单位 用,分隔开
  536. if c.Buyerclass != "" {
  537. i := 0
  538. sql += ` and buyerclass in (`
  539. if buyClassArr := strings.Split(c.Buyerclass, ","); len(buyClassArr) > 0 {
  540. for _, v := range buyClassArr {
  541. i++
  542. buyerclassid := fmt.Sprint(PushMapping.Buyerclass[v])
  543. if i == len(buyClassArr) {
  544. sql += buyerclassid + `)`
  545. } else {
  546. sql += buyerclassid + ","
  547. }
  548. }
  549. }
  550. }
  551. //是否存在采购单位电话
  552. if c.BuyerPhone == 1 {
  553. sql += ` and buyerinfo = 1`
  554. } else if c.BuyerPhone == -1 {
  555. sql += ` and buyerinfo = 0`
  556. }
  557. //是否存在中标单位电话
  558. if c.WinnerPhone == 1 {
  559. sql += ` and winnerinfo = 1`
  560. } else if c.WinnerPhone == -1 {
  561. sql += ` and winnerinfo = 0`
  562. }
  563. limit = 5000
  564. }
  565. sql += fmt.Sprintf(` order by createdate desc limit %v`, limit)
  566. return sql
  567. }