common.go 17 KB

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