giftcard.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. package dao
  2. import (
  3. "bet24.com/database"
  4. "bet24.com/log"
  5. "bet24.com/servers/common"
  6. "runtime/debug"
  7. )
  8. // 礼品卡列表
  9. type (
  10. giftCardList_in struct {
  11. UserID int //用户ID
  12. Status int // 状态
  13. BeginTime string //开始时间
  14. EndTime string //截止时间
  15. PageIndex int //页索引
  16. PageSize int //页大小
  17. }
  18. giftCardListModel struct {
  19. Rid int // 标识
  20. UserID int // 用户ID
  21. NickName string // 昵称
  22. ItemID int // 道具id
  23. ItemName string // 道具名称
  24. ItemDesc string // 道具描述
  25. Key string // 兑换码
  26. ActivateTime string // 激活时间
  27. OperateStatus int // 操作状态
  28. Crdate string // 创建时间
  29. }
  30. giftCardList_out struct {
  31. RecordCount int
  32. List []giftCardListModel
  33. }
  34. giftCardList struct {
  35. database.Trans_base
  36. In giftCardList_in
  37. Out giftCardList_out
  38. }
  39. )
  40. func NewGiftCardList() *giftCardList {
  41. return &giftCardList{}
  42. }
  43. func (this *giftCardList) DoAction(ch chan<- interface{}) {
  44. defer func() {
  45. if err := recover(); err != nil {
  46. log.Error("transaction recover err %v", err)
  47. log.Error("%s", debug.Stack())
  48. }
  49. if ch != nil {
  50. ch <- this
  51. }
  52. }()
  53. statement := database.NewStatement()
  54. statement.SetNeedReturnValue(false)
  55. statement.SetOpenRecordSet(true)
  56. statement.SetProcName("Manage_GiftCard_GetList")
  57. statement.AddParamter("@UserID", database.AdParamInput, database.AdInteger, 4, this.In.UserID)
  58. statement.AddParamter("@OperateStatus", database.AdParamInput, database.AdInteger, 4, this.In.Status)
  59. statement.AddParamter("@BeginTime", database.AdParamInput, database.AdVarChar, 20, this.In.BeginTime)
  60. statement.AddParamter("@EndTime", database.AdParamInput, database.AdVarChar, 20, this.In.EndTime)
  61. statement.AddParamter("@PageIndex", database.AdParamInput, database.AdInteger, 4, this.In.PageIndex)
  62. statement.AddParamter("@PageSize", database.AdParamInput, database.AdInteger, 4, this.In.PageSize)
  63. statement.AddParamter("@RecordCount", database.AdParamOutput, database.AdInteger, 4, this.Out.RecordCount)
  64. sqlString := statement.GenSql()
  65. retRows := CenterDB.ExecSql(sqlString)
  66. rowLen := len(retRows)
  67. if rowLen <= 0 {
  68. this.State = false
  69. return
  70. }
  71. this.State = true
  72. if rowLen > 1 {
  73. this.Out.List = make([]giftCardListModel, rowLen-1)
  74. for i := 0; i < rowLen-1; i++ {
  75. ret := retRows[i]
  76. out := &this.Out.List[i]
  77. out.Rid = int((*ret[0].(*interface{})).(int64))
  78. out.UserID = int((*ret[1].(*interface{})).(int64))
  79. out.NickName = (*ret[2].(*interface{})).(string)
  80. out.ItemID = int((*ret[3].(*interface{})).(int64))
  81. out.Key = (*ret[4].(*interface{})).(string)
  82. activateTime := (*ret[5].(*interface{})).(int64)
  83. if activateTime > 0 {
  84. out.ActivateTime = common.TimeStampToString(activateTime)
  85. } else {
  86. out.ActivateTime = "<font color=\"#ccc\">未激活</font>"
  87. }
  88. out.OperateStatus = int((*ret[6].(*interface{})).(int64))
  89. out.Crdate = (*ret[7].(*interface{})).(string)
  90. }
  91. }
  92. this.Out.RecordCount = int((*retRows[rowLen-1][0].(*interface{})).(int64))
  93. }
  94. // 礼品卡处理
  95. type (
  96. giftCardDeal_in struct {
  97. OpUserID int // 操作员ID
  98. OpUserName string // 操作员名称
  99. Rid int // 标识
  100. Status int // 操作状态(0=待处理 1=已兑换 2=不予兑换)
  101. IpAddress string // IP地址
  102. }
  103. giftCardDeal_out struct {
  104. RetCode int
  105. }
  106. giftCardDeal struct {
  107. database.Trans_base
  108. In giftCardDeal_in
  109. Out giftCardDeal_out
  110. }
  111. )
  112. func NewGiftCardDeal() *giftCardDeal {
  113. return &giftCardDeal{}
  114. }
  115. func (this *giftCardDeal) DoAction(ch chan<- interface{}) {
  116. defer func() {
  117. if err := recover(); err != nil {
  118. log.Error("transaction recover err %v", err)
  119. log.Error("%s", debug.Stack())
  120. }
  121. if ch != nil {
  122. ch <- this
  123. }
  124. }()
  125. statement := database.NewStatement()
  126. statement.SetNeedReturnValue(false)
  127. statement.SetOpenRecordSet(true)
  128. statement.SetProcName("Manage_GiftCard_Deal")
  129. statement.AddParamter("@OpUserID", database.AdParamInput, database.AdInteger, 4, this.In.OpUserID)
  130. statement.AddParamter("@OpUserName", database.AdParamInput, database.AdVarChar, 20, this.In.OpUserName)
  131. statement.AddParamter("@Rid", database.AdParamInput, database.AdInteger, 4, this.In.Rid)
  132. statement.AddParamter("@OperateStatus", database.AdParamInput, database.AdInteger, 4, this.In.Status)
  133. statement.AddParamter("@IPAddress", database.AdParamInput, database.AdVarChar, 16, this.In.IpAddress)
  134. sqlString := statement.GenSql()
  135. retRows := CenterDB.ExecSql(sqlString)
  136. rowLen := len(retRows)
  137. if rowLen <= 0 {
  138. this.State = false
  139. return
  140. }
  141. this.State = true
  142. this.Out.RetCode = int((*retRows[0][0].(*interface{})).(int64))
  143. }