track.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. package dao
  2. import (
  3. "runtime/debug"
  4. "time"
  5. "bet24.com/database"
  6. "bet24.com/log"
  7. "bet24.com/servers/common"
  8. )
  9. // 游戏轨迹记录
  10. type (
  11. userTrackList_in struct {
  12. BeginTime string
  13. EndTime string
  14. }
  15. userTrackListModel struct {
  16. Level string //1级类目
  17. Item string //类目
  18. Times int //次数
  19. Users int //用户数
  20. }
  21. userTrackList_out struct {
  22. RecordCount int
  23. List []userTrackListModel
  24. }
  25. userTrackList struct {
  26. database.Trans_base
  27. In userTrackList_in
  28. Out userTrackList_out
  29. }
  30. )
  31. func NewUserTrackList() *userTrackList {
  32. return &userTrackList{}
  33. }
  34. func (this *userTrackList) DoAction() {
  35. defer func() {
  36. if err := recover(); err != nil {
  37. log.Error("transaction recover err %v", err)
  38. log.Error("%s", debug.Stack())
  39. }
  40. }()
  41. statement := database.NewStatement()
  42. statement.SetNeedReturnValue(false)
  43. statement.SetOpenRecordSet(true)
  44. statement.SetProcName("Manage_UserTrack_GetList")
  45. statement.AddParamter("@BeginTime", database.AdParamInput, database.AdVarChar, 20, this.In.BeginTime)
  46. statement.AddParamter("@EndTime", database.AdParamInput, database.AdVarChar, 20, this.In.EndTime)
  47. sqlstring := statement.GenSql()
  48. retRows := CenterDB.ExecSql(sqlstring)
  49. rowLen := len(retRows)
  50. if rowLen <= 0 {
  51. return
  52. }
  53. this.Out.List = make([]userTrackListModel, rowLen)
  54. for i := 0; i < rowLen; i++ {
  55. ret := retRows[i]
  56. out := &this.Out.List[i]
  57. out.Level = (*ret[0].(*interface{})).(string)
  58. out.Item = (*ret[1].(*interface{})).(string)
  59. out.Times = int((*ret[2].(*interface{})).(int64))
  60. out.Users = int((*ret[3].(*interface{})).(int64))
  61. }
  62. return
  63. }
  64. // 游戏轨迹统计
  65. type (
  66. userTrackStat_in struct {
  67. BeginTime string
  68. EndTime string
  69. }
  70. userTrackStatModel struct {
  71. Level_1 string //1级类目
  72. Level_2 string //2级类目
  73. Level_3 string //3级类目
  74. Times int //次数
  75. Users int //用户数
  76. }
  77. userTrackStat_out struct {
  78. RecordCount int
  79. List []userTrackStatModel
  80. }
  81. userTrackStat struct {
  82. database.Trans_base
  83. In userTrackStat_in
  84. Out userTrackStat_out
  85. }
  86. )
  87. func NewUserTrackStat() *userTrackStat {
  88. return &userTrackStat{}
  89. }
  90. func (this *userTrackStat) DoAction() {
  91. defer func() {
  92. if err := recover(); err != nil {
  93. log.Error("transaction recover err %v", err)
  94. log.Error("%s", debug.Stack())
  95. }
  96. }()
  97. statement := database.NewStatement()
  98. statement.SetNeedReturnValue(false)
  99. statement.SetOpenRecordSet(true)
  100. statement.SetProcName("Manage_UserTrack_GetStat")
  101. statement.AddParamter("@BeginTime", database.AdParamInput, database.AdVarChar, 20, this.In.BeginTime)
  102. statement.AddParamter("@EndTime", database.AdParamInput, database.AdVarChar, 20, this.In.EndTime)
  103. sqlstring := statement.GenSql()
  104. retRows := CenterDB.ExecSql(sqlstring)
  105. rowLen := len(retRows)
  106. if rowLen <= 0 {
  107. return
  108. }
  109. this.Out.List = make([]userTrackStatModel, rowLen)
  110. for i := 0; i < rowLen; i++ {
  111. ret := retRows[i]
  112. out := &this.Out.List[i]
  113. out.Level_1 = (*ret[0].(*interface{})).(string)
  114. out.Level_2 = (*ret[1].(*interface{})).(string)
  115. out.Level_3 = (*ret[2].(*interface{})).(string)
  116. out.Times = int((*ret[3].(*interface{})).(int64))
  117. out.Users = int((*ret[4].(*interface{})).(int64))
  118. }
  119. return
  120. }
  121. // 用户足迹
  122. type (
  123. trackList_in struct {
  124. UserID int //用户ID
  125. BeginTime string //开始时间
  126. EndTime string //截止时间
  127. PageIndex int //页索引
  128. PageSize int //页大小
  129. }
  130. trackListModel struct {
  131. Rid int
  132. UserID int
  133. Crdate string
  134. Level_1 string
  135. Level_2 string
  136. Level_3 string
  137. Seconds float64
  138. currTime time.Time
  139. }
  140. trackList_out struct {
  141. RecordCount int
  142. List []trackListModel
  143. }
  144. trackList struct {
  145. database.Trans_base
  146. In trackList_in
  147. Out trackList_out
  148. }
  149. )
  150. func NewTrackList() *trackList {
  151. return &trackList{}
  152. }
  153. func (this *trackList) DoAction() {
  154. defer func() {
  155. if err := recover(); err != nil {
  156. log.Error("transaction recover err %v", err)
  157. log.Error("%s", debug.Stack())
  158. }
  159. }()
  160. statement := database.NewStatement()
  161. statement.SetNeedReturnValue(false)
  162. statement.SetOpenRecordSet(true)
  163. statement.SetProcName("Manage_AllUser_GetTrack")
  164. statement.AddParamter("@UserID", database.AdParamInput, database.AdInteger, 4, this.In.UserID)
  165. statement.AddParamter("@BeginTime", database.AdParamInput, database.AdVarChar, 20, this.In.BeginTime)
  166. statement.AddParamter("@EndTime", database.AdParamInput, database.AdVarChar, 20, this.In.EndTime)
  167. statement.AddParamter("@PageIndex", database.AdParamInput, database.AdInteger, 4, this.In.PageIndex)
  168. statement.AddParamter("@PageSize", database.AdParamInput, database.AdInteger, 4, this.In.PageSize)
  169. statement.AddParamter("@RecordCount", database.AdParamOutput, database.AdInteger, 4, this.Out.RecordCount)
  170. sqlstring := statement.GenSql()
  171. //log.Debug(sqlstring)
  172. retRows := CenterDB.ExecSql(sqlstring)
  173. rowLen := len(retRows)
  174. if rowLen > 1 {
  175. this.Out.List = make([]trackListModel, rowLen-1)
  176. for i := 0; i < rowLen-1; i++ {
  177. ret := retRows[i]
  178. out := &this.Out.List[i]
  179. out.Rid = int((*ret[0].(*interface{})).(int64))
  180. out.UserID = this.In.UserID
  181. out.Crdate = (*ret[1].(*interface{})).(string)
  182. out.Level_1 = (*ret[2].(*interface{})).(string)
  183. out.Level_2 = (*ret[3].(*interface{})).(string)
  184. out.Level_3 = (*ret[4].(*interface{})).(string)
  185. out.currTime, _ = time.Parse(common.Layout, out.Crdate)
  186. if i > 0 {
  187. out.Seconds = this.Out.List[i].currTime.Sub(this.Out.List[i-1].currTime).Seconds()
  188. }
  189. }
  190. }
  191. this.Out.RecordCount = int((*retRows[rowLen-1][0].(*interface{})).(int64))
  192. }