智盟项目
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

db_master_withdrawal_flow.go 3.2 KiB

il y a 1 an
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. type MasterWithdrawalFlowDb struct {
  8. Db *xorm.Engine `json:"db"`
  9. }
  10. func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) Set() { // set方法
  11. masterWithdrawalFlowDb.Db = ZhimengDb
  12. }
  13. func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) GetWithdrawalFlowListWithTotal(id string, args map[string]string) (*[]model.MasterWithdrawalFlow, int64) {
  14. var data []model.MasterWithdrawalFlow
  15. sess := masterWithdrawalFlowDb.Db.Where("uid=?", id)
  16. if args["start_time"] != "" {
  17. sess = sess.And("time>=?", args["start_time"])
  18. }
  19. if args["end_time"] != "" {
  20. sess = sess.And("time<=?", args["end_time"])
  21. }
  22. if args["check_start_time"] != "" {
  23. sess = sess.And("check_time>=?", args["check_start_time"])
  24. }
  25. if args["check_end_time"] != "" {
  26. sess = sess.And("check_time<=?", args["check_end_time"])
  27. }
  28. if args["status"] != "" {
  29. sess = sess.And("status=?", args["status"])
  30. }
  31. if args["alipay"] != "" {
  32. sess = sess.And("alipay LIKE ?", "%"+args["alipay"]+"%")
  33. }
  34. p := utils.StrToInt(args["p"])
  35. size := utils.StrToInt(args["size"])
  36. offet := (p - 1) * size
  37. total, err := sess.Limit(size, offet).OrderBy("time desc,id desc").FindAndCount(&data)
  38. if err != nil {
  39. return nil, total
  40. }
  41. return &data, total
  42. }
  43. func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) GetWithdrawalFlowList(id string, args map[string]string) *[]model.MasterWithdrawalFlow {
  44. var data []model.MasterWithdrawalFlow
  45. sess := masterWithdrawalFlowDb.Db.Where("uid=?", id)
  46. if args["start_time"] != "" {
  47. sess = sess.And("time>=?", args["start_time"])
  48. }
  49. if args["end_time"] != "" {
  50. sess = sess.And("time<=?", args["end_time"])
  51. }
  52. if args["check_start_time"] != "" {
  53. sess = sess.And("check_time>=?", args["check_start_time"])
  54. }
  55. if args["check_end_time"] != "" {
  56. sess = sess.And("check_time<=?", args["check_end_time"])
  57. }
  58. if args["status"] != "" {
  59. sess = sess.And("status=?", args["status"])
  60. }
  61. if args["alipay"] != "" {
  62. sess = sess.And("alipay LIKE ?", "%"+args["alipay"]+"%")
  63. }
  64. p := utils.StrToInt(args["p"])
  65. size := utils.StrToInt(args["size"])
  66. offet := (p - 1) * size
  67. err := sess.Limit(size, offet).OrderBy("time desc,id desc").Find(&data)
  68. if err != nil {
  69. return nil
  70. }
  71. return &data
  72. }
  73. func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) MasterWithdrawalFlowInsert(data *model.MasterWithdrawalFlow) bool {
  74. get, err := masterWithdrawalFlowDb.Db.InsertOne(data)
  75. if get == 0 || err != nil {
  76. return false
  77. }
  78. return true
  79. }
  80. func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) MasterWithdrawalFlowInsertUpdate(data *model.MasterWithdrawalFlow) bool {
  81. get, err := masterWithdrawalFlowDb.Db.Where("id=?", data.Id).Update(data)
  82. if get == 0 || err != nil {
  83. return false
  84. }
  85. return true
  86. }
  87. func MasterWithdrawalFlowInsertWithSess(sess *xorm.Session, data *model.MasterWithdrawalFlow) bool {
  88. get, err := sess.InsertOne(data)
  89. if get == 0 || err != nil {
  90. return false
  91. }
  92. return true
  93. }
  94. func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) MasterWithdrawalFlowById(id string) *model.MasterWithdrawalFlow {
  95. var data model.MasterWithdrawalFlow
  96. get, err := masterWithdrawalFlowDb.Db.Where("id=?", id).Get(&data)
  97. if get == false || err != nil {
  98. return nil
  99. }
  100. return &data
  101. }