智盟项目
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

112 行
2.7 KiB

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