智盟项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 rivejä
1.9 KiB

  1. package svc
  2. import (
  3. offical "applet/app/db/official"
  4. "applet/app/utils"
  5. "fmt"
  6. "strings"
  7. "time"
  8. )
  9. func MeituanStoreOrder() {
  10. pvdTimeKey := "meituan_store_time"
  11. // 获得最后时间
  12. latest := offical.SysCfgByKey(pvdTimeKey)
  13. if latest == nil {
  14. offical.DbsSysCfgInserts(pvdTimeKey, time.Now().String())
  15. latest = offical.SysCfgByKey(pvdTimeKey)
  16. }
  17. // 所有时间都是在操作秒数
  18. now := time.Now().Unix()
  19. strs := strings.Split(latest.V, ":")
  20. timeStr := latest.V
  21. if len(strs) == 3 {
  22. timeStr = strs[0] + ":" + strs[1] + ":00"
  23. }
  24. fmt.Println(timeStr)
  25. past := utils.TimeParseStd(timeStr).Unix()
  26. // 如果上次记录超过30天或者 过去时间大于当前时间戳, 把时间设置为此前20分钟
  27. if past < now-180*86400 || past > now {
  28. past = now
  29. }
  30. var (
  31. beginTime int64 = 0
  32. endTime int64 = 0
  33. pageNo int = 1
  34. pageSize int = 50
  35. nextPositionIndex string = ""
  36. )
  37. //怕时间不是走最新的
  38. leave := now - past
  39. if leave > 500 {
  40. leave = 0
  41. }
  42. past = past + leave
  43. beginTime = past - 300
  44. endTime = past
  45. if endTime > now {
  46. endTime = now
  47. }
  48. for {
  49. count := 0
  50. var positionIndex = ""
  51. if pageNo == 1 {
  52. nextPositionIndex = ""
  53. }
  54. count, positionIndex = OrdersMeituanGet(nextPositionIndex, pageSize, beginTime, endTime, "update", 2)
  55. if count == 0 {
  56. nextPositionIndex = ""
  57. goto ChkArg
  58. }
  59. // 判断是否分页已经全部取完了
  60. if count <= pageSize {
  61. nextPositionIndex = positionIndex
  62. pageNo++
  63. fmt.Println("========下一页========" + utils.IntToStr(pageNo))
  64. count = 0
  65. continue
  66. }
  67. ChkArg:
  68. nextPositionIndex = ""
  69. // 查询完后重置时间, 最后查询时间
  70. if endTime < now {
  71. pageNo = 1
  72. offical.DbsSysCfgUpdate(pvdTimeKey, utils.TimeToStr(endTime))
  73. beginTime = endTime
  74. endTime = endTime + 300
  75. if endTime > now {
  76. endTime = now
  77. }
  78. count = 0
  79. continue
  80. }
  81. count = 0
  82. break
  83. }
  84. }