智盟项目
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

db_life_order.go 3.1 KiB

há 5 meses
há 4 meses
há 5 meses
há 4 meses
há 5 meses
há 4 meses
há 5 meses
há 4 meses
há 5 meses
há 4 meses
há 5 meses
há 4 meses
há 5 meses
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "fmt"
  6. "strings"
  7. )
  8. func GetLifeOrderByOne(oid, mid, types string) *model.LifeOrder {
  9. var data model.LifeOrder
  10. get, err := ZhimengDb.Where("uid=? and pvd_oid=? and pvd=?", mid, oid, types).Get(&data)
  11. if get == false || err != nil {
  12. fmt.Println(err)
  13. return nil
  14. }
  15. return &data
  16. }
  17. func GetLifeOrderList(args map[string]string) []model.LifeOrder {
  18. /***
  19. p 页数
  20. size 个数
  21. start_time 开始时间
  22. end_time 结束时间
  23. ord_type 订单类型
  24. video_type 视频类型
  25. status 订单状态
  26. settle_status 结算状态
  27. oid 订单号
  28. sort 排序
  29. is_to_settle 智盟结算
  30. to_settle_time 结算上月时间
  31. */
  32. var data = make([]model.LifeOrder, 0)
  33. size := utils.StrToInt(args["size"])
  34. offet := (utils.StrToInt(args["p"]) - 1) * size
  35. sess := ZhimengDb.Where("1=1")
  36. if args["start_time"] != "" {
  37. sess = sess.And("update_time>=?", args["start_time"])
  38. }
  39. if args["end_time"] != "" {
  40. sess = sess.And("update_time<=?", args["end_time"])
  41. }
  42. if args["type"] != "" {
  43. sess = sess.And("pvd=?", args["type"])
  44. }
  45. if args["uid"] != "" {
  46. sess = sess.And("uid=?", args["uid"])
  47. }
  48. if args["pvd"] != "" {
  49. sess = sess.In("pvd", strings.Split(args["pvd"], ","))
  50. }
  51. if args["status"] != "" {
  52. sess = sess.In("status", strings.Split(args["status"], ","))
  53. }
  54. if args["to_settle_time"] != "" {
  55. if args["is_to_settle"] == "1" {
  56. sess = sess.And("platform_settle_time<?", args["to_settle_time"])
  57. }
  58. if args["is_to_settle"] == "2" {
  59. sess = sess.And("create_time<?", args["to_settle_time"])
  60. }
  61. }
  62. sort := "update_time desc,id desc"
  63. if args["sort"] != "" {
  64. sort = args["sort"]
  65. }
  66. if args["is_to_settle"] == "1" {
  67. sess = sess.And("settle_time=?", 0)
  68. }
  69. if args["is_commission"] == "1" {
  70. sess = sess.And("real_commission>?", 0)
  71. }
  72. err := sess.Limit(size, offet).OrderBy(sort).Find(&data)
  73. fmt.Println(err)
  74. fmt.Println(sess.LastSQL())
  75. return data
  76. }
  77. func GetLifeOrderListTotal(args map[string]string) ([]model.LifeOrder, int64) {
  78. var data = make([]model.LifeOrder, 0)
  79. size := utils.StrToInt(args["size"])
  80. offet := (utils.StrToInt(args["p"]) - 1) * size
  81. sess := ZhimengDb.Where("1=1")
  82. if args["start_time"] != "" {
  83. sess = sess.And("create_time>=?", utils.TimeStdParseUnix(args["start_time"]))
  84. }
  85. if args["end_time"] != "" {
  86. sess = sess.And("create_time<=?", utils.TimeStdParseUnix(args["end_time"]))
  87. }
  88. if args["type"] != "" {
  89. sess = sess.And("pvd=?", args["type"])
  90. }
  91. if args["settle_type"] == "0" {
  92. sess = sess.And("settle_time=?", 0)
  93. }
  94. if args["settle_type"] == "1" {
  95. sess = sess.And("settle_time>?", 0)
  96. }
  97. if args["uid"] != "" {
  98. sess = sess.And("uid=?", args["uid"])
  99. }
  100. if args["oid"] != "" {
  101. sess = sess.And("pvd_oid like ?", "%"+args["oid"]+"%")
  102. }
  103. if args["zuid"] != "" {
  104. sess = sess.And("station_uid=?", args["zuid"])
  105. }
  106. if args["status"] != "" {
  107. sess = sess.And("status=?", args["status"])
  108. }
  109. if args["source"] != "" {
  110. sess = sess.And("pvd=?", args["source"])
  111. }
  112. sort := "create_time desc,id desc"
  113. if args["sort"] != "" {
  114. sort = args["sort"]
  115. }
  116. total, err := sess.Limit(size, offet).OrderBy(sort).FindAndCount(&data)
  117. fmt.Println(err)
  118. fmt.Println(sess.LastSQL())
  119. return data, total
  120. }