xwuserinfo.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. package dao
  2. import (
  3. "runtime/debug"
  4. "bet24.com/database"
  5. "bet24.com/log"
  6. )
  7. //闲玩统计
  8. type (
  9. xwInfoStatModel struct {
  10. InfoID int //信息ID
  11. InfoType int //类型 1=赢金 2=充值 3=冲级(每档前5名)
  12. Amount int //数额
  13. RMBMoney int //单价(人民币:分)
  14. UserCountLimit int //用户数上限 -1=无限制 >0 限制
  15. UserCount int //用户数
  16. TotalRMBMoney int //消耗(人民币:分)
  17. }
  18. xwInfoStat_out struct {
  19. RecordCount int
  20. PayRMBMoney int //充值消耗
  21. WinRMBMoney int //赢金消耗
  22. WinRankRMBMoney int //冲金消耗
  23. List []xwInfoStatModel
  24. }
  25. xwInfoStat struct {
  26. database.Trans_base
  27. Out xwInfoStat_out
  28. }
  29. )
  30. func NewXwInfoStat() *xwInfoStat {
  31. return &xwInfoStat{}
  32. }
  33. func (this *xwInfoStat) DoAction() {
  34. defer func() {
  35. if err := recover(); err != nil {
  36. log.Error("transaction recover err %v", err)
  37. log.Error("%s", debug.Stack())
  38. }
  39. }()
  40. statement := database.NewStatement()
  41. statement.SetNeedReturnValue(false)
  42. statement.SetOpenRecordSet(true)
  43. statement.SetProcName("Manage_XWInfoStat_GetList")
  44. sqlstring := statement.GenSql()
  45. retRows := CenterDB.ExecSql(sqlstring)
  46. rowLen := len(retRows)
  47. if rowLen <= 0 {
  48. return
  49. }
  50. this.Out.RecordCount = rowLen
  51. this.Out.List = make([]xwInfoStatModel, rowLen)
  52. for i := 0; i < rowLen; i++ {
  53. ret := retRows[i]
  54. out := &this.Out.List[i]
  55. out.InfoID = int((*ret[0].(*interface{})).(int64))
  56. out.InfoType = int((*ret[1].(*interface{})).(int64))
  57. out.Amount = int((*ret[2].(*interface{})).(int64))
  58. out.RMBMoney = int((*ret[3].(*interface{})).(int64))
  59. out.UserCountLimit = int((*ret[4].(*interface{})).(int64))
  60. out.UserCount = int((*ret[5].(*interface{})).(int64))
  61. userCount := out.UserCount
  62. if out.UserCountLimit > 0 && out.UserCount >= out.UserCountLimit {
  63. userCount = out.UserCountLimit
  64. }
  65. out.TotalRMBMoney = out.RMBMoney * userCount
  66. switch out.InfoType {
  67. case 1: //充值
  68. this.Out.PayRMBMoney = this.Out.PayRMBMoney + out.TotalRMBMoney
  69. case 2: //冲金
  70. this.Out.WinRankRMBMoney = this.Out.WinRankRMBMoney + out.TotalRMBMoney
  71. case 3: //赢金
  72. this.Out.WinRMBMoney = this.Out.WinRMBMoney + out.TotalRMBMoney
  73. }
  74. }
  75. }
  76. //闲玩用户信息
  77. type (
  78. xwUserInfoList_in struct {
  79. InfoID int //信息ID
  80. PageIndex int //页索引
  81. PageSize int //页大小
  82. }
  83. xwUserInfoListModel struct {
  84. RowNumber int //序号
  85. UserID int //用户ID
  86. NickName string //昵称
  87. Deviceid string //设备号
  88. Win_gold int //赢金
  89. Payamount int //充值
  90. Crdate string //时间
  91. }
  92. xwUserInfoList_out struct {
  93. RecordCount int
  94. List []xwUserInfoListModel
  95. }
  96. xwUserInfoList struct {
  97. database.Trans_base
  98. In xwUserInfoList_in
  99. Out xwUserInfoList_out
  100. }
  101. )
  102. func NewXwUserInfoList() *xwUserInfoList {
  103. return &xwUserInfoList{}
  104. }
  105. func (this *xwUserInfoList) DoAction() {
  106. defer func() {
  107. if err := recover(); err != nil {
  108. log.Error("transaction recover err %v", err)
  109. log.Error("%s", debug.Stack())
  110. }
  111. }()
  112. statement := database.NewStatement()
  113. statement.SetNeedReturnValue(false)
  114. statement.SetOpenRecordSet(true)
  115. statement.SetProcName("Manage_XWInfoStat_GetUserList")
  116. statement.AddParamter("@InfoID", database.AdParamInput, database.AdInteger, 4, this.In.InfoID)
  117. statement.AddParamter("@PageIndex", database.AdParamInput, database.AdInteger, 4, this.In.PageIndex)
  118. statement.AddParamter("@PageSize", database.AdParamInput, database.AdInteger, 4, this.In.PageSize)
  119. statement.AddParamter("@RecordCount", database.AdParamOutput, database.AdInteger, 4, this.Out.RecordCount)
  120. sqlstring := statement.GenSql()
  121. log.Debug(sqlstring)
  122. retRows := CenterDB.ExecSql(sqlstring)
  123. rowLen := len(retRows)
  124. if rowLen <= 0 {
  125. return
  126. }
  127. if rowLen > 1 {
  128. this.Out.List = make([]xwUserInfoListModel, rowLen-1)
  129. for i := 0; i < rowLen-1; i++ {
  130. ret := retRows[i]
  131. out := &this.Out.List[i]
  132. out.RowNumber = int((*ret[0].(*interface{})).(int64))
  133. out.UserID = int((*ret[1].(*interface{})).(int64))
  134. out.NickName = (*ret[2].(*interface{})).(string)
  135. if info := tagMgr.getInfo(out.UserID); info != nil {
  136. out.NickName = info.NickName
  137. }
  138. out.Deviceid = (*ret[3].(*interface{})).(string)
  139. out.Win_gold = int((*ret[4].(*interface{})).(int64))
  140. out.Payamount = int((*ret[5].(*interface{})).(int64))
  141. out.Crdate = (*ret[6].(*interface{})).(string)
  142. }
  143. }
  144. this.Out.RecordCount = int((*retRows[rowLen-1][0].(*interface{})).(int64))
  145. }