game.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. package dao
  2. import (
  3. "runtime/debug"
  4. "strconv"
  5. "bet24.com/database"
  6. "bet24.com/log"
  7. "bet24.com/redis"
  8. )
  9. // 所有游戏
  10. type (
  11. getAllGames_in struct {
  12. GameID int
  13. }
  14. AllGameInfo struct {
  15. GameID int //游戏ID
  16. ChineseName string //中文名
  17. EnglishName string //英文名
  18. DisplaySort int //显示顺序
  19. Enabled int //是否启用
  20. DBName string //数据库名
  21. GameName string //游戏名
  22. GameType int // 游戏类型 (0=无限制 1=金币游戏 2=元宝游戏)
  23. NeedLevel int // 所需等级
  24. }
  25. getAllGames struct {
  26. database.Trans_base
  27. In getAllGames_in
  28. Out []AllGameInfo
  29. }
  30. )
  31. func NewGetAllGames() *getAllGames {
  32. return &getAllGames{}
  33. }
  34. func (this *getAllGames) DoAction(ch chan<- interface{}) {
  35. defer func() {
  36. if err := recover(); err != nil {
  37. log.Release("transaction recover %v", err)
  38. log.Release("%s", debug.Stack())
  39. }
  40. if ch != nil {
  41. ch <- this
  42. }
  43. }()
  44. statement := database.NewStatement()
  45. statement.SetNeedReturnValue(false)
  46. statement.SetOpenRecordSet(true)
  47. statement.SetProcName("Manage_AllGame_GetList")
  48. statement.AddParamter("@GameID", database.AdParamInput, database.AdInteger, 4, this.In.GameID)
  49. sqlstring := statement.GenSql()
  50. //log.Debug(sqlstring)
  51. retRows := CenterDB.ExecSql(sqlstring)
  52. rowLen := len(retRows)
  53. if rowLen <= 0 {
  54. this.State = false
  55. return
  56. }
  57. this.State = true
  58. this.Out = make([]AllGameInfo, rowLen)
  59. for i := 0; i < rowLen; i++ {
  60. ret := retRows[i]
  61. out := &this.Out[i]
  62. out.GameID = int((*ret[0].(*interface{})).(int64))
  63. out.ChineseName = (*ret[1].(*interface{})).(string)
  64. out.EnglishName = (*ret[2].(*interface{})).(string)
  65. out.DisplaySort = int((*ret[3].(*interface{})).(int64))
  66. out.Enabled = int((*ret[4].(*interface{})).(int64))
  67. out.DBName = (*ret[5].(*interface{})).(string)
  68. out.GameName = (*ret[6].(*interface{})).(string)
  69. out.GameType = int((*ret[7].(*interface{})).(int64))
  70. out.NeedLevel = int((*ret[8].(*interface{})).(int64))
  71. }
  72. }
  73. // 审核游戏列表
  74. type (
  75. gameRequestList_in struct {
  76. PartnerID int
  77. }
  78. gameRequestInfo struct {
  79. PartnerID int //渠道ID
  80. PartnerName string //渠道名称
  81. VersionCode int //版本
  82. GameName string //游戏名称
  83. ChineseName string //中文名称
  84. }
  85. gameRequestList_out struct {
  86. RecordCount int //记录数
  87. List []gameRequestInfo
  88. }
  89. getGameRequestList struct {
  90. database.Trans_base
  91. In gameRequestList_in
  92. Out gameRequestList_out
  93. }
  94. )
  95. func NewGetGameRequestList() *getGameRequestList {
  96. return &getGameRequestList{}
  97. }
  98. func (this *getGameRequestList) DoAction(ch chan<- interface{}) {
  99. defer func() {
  100. if err := recover(); err != nil {
  101. log.Release("transaction recover %v", err)
  102. log.Release("%s", debug.Stack())
  103. }
  104. if ch != nil {
  105. ch <- this
  106. }
  107. }()
  108. statement := database.NewStatement()
  109. statement.SetNeedReturnValue(false)
  110. statement.SetOpenRecordSet(true)
  111. statement.SetProcName("Manage_GameRequest_GetList")
  112. sqlstring := statement.GenSql()
  113. //log.Debug(sqlstring)
  114. retRows := CenterDB.ExecSql(sqlstring)
  115. rowLen := len(retRows)
  116. if rowLen <= 0 {
  117. this.State = false
  118. return
  119. }
  120. this.State = true
  121. this.Out.List = make([]gameRequestInfo, rowLen)
  122. for i := 0; i < rowLen; i++ {
  123. ret := retRows[i]
  124. out := &this.Out.List[i]
  125. out.PartnerID = int((*ret[0].(*interface{})).(int64))
  126. out.PartnerName = (*ret[1].(*interface{})).(string)
  127. out.VersionCode = int((*ret[2].(*interface{})).(int64))
  128. out.GameName = (*ret[3].(*interface{})).(string)
  129. out.ChineseName = (*ret[4].(*interface{})).(string)
  130. }
  131. }
  132. // 添加审核
  133. type (
  134. gameRequestAdd_in struct {
  135. OpUserID int //操作员ID
  136. OpUserName string //操作员名称
  137. PartnerID int //渠道ID
  138. PartnerName string //渠道名称
  139. VersionCode int //版本号
  140. GameName string //游戏名称
  141. IpAddress string //IP地址
  142. }
  143. gameRequestAdd_out struct {
  144. RetCode int //操作结果
  145. ErrorMsg string //操作描述
  146. }
  147. gameRequestAdd struct {
  148. database.Trans_base
  149. In gameRequestAdd_in
  150. Out gameRequestAdd_out
  151. }
  152. )
  153. func NewGameRequestAdd() *gameRequestAdd {
  154. return &gameRequestAdd{}
  155. }
  156. func (this *gameRequestAdd) DoAction(ch chan<- interface{}) {
  157. defer func() {
  158. if err := recover(); err != nil {
  159. log.Release("transaction recover fail %v", err)
  160. log.Release("%s", debug.Stack())
  161. }
  162. if ch != nil {
  163. ch <- this
  164. }
  165. }()
  166. statement := database.NewStatement()
  167. statement.SetNeedReturnValue(false)
  168. statement.SetOpenRecordSet(true)
  169. statement.SetProcName("Manage_GameRequest_Add")
  170. statement.AddParamter("@OpUserID", database.AdParamInput, database.AdInteger, 4, this.In.OpUserID)
  171. statement.AddParamter("@OpUserName", database.AdParamInput, database.AdVarChar, 32, this.In.OpUserName)
  172. statement.AddParamter("@PartnerID", database.AdParamInput, database.AdInteger, 20, this.In.PartnerID)
  173. statement.AddParamter("@PartnerName", database.AdParamInput, database.AdNVarChar, 32, this.In.PartnerName)
  174. statement.AddParamter("@VersionCode", database.AdParamInput, database.AdInteger, 20, this.In.VersionCode)
  175. statement.AddParamter("@GameName", database.AdParamInput, database.AdVarChar, 32, this.In.GameName)
  176. statement.AddParamter("@IPAddress", database.AdParamInput, database.AdVarChar, 16, this.In.IpAddress)
  177. statement.AddParamter("@RetCode", database.AdParamOutput, database.AdInteger, 4, this.Out.RetCode)
  178. sqlstring := statement.GenSql()
  179. retRows := CenterDB.ExecSql(sqlstring)
  180. rowLen := len(retRows)
  181. if rowLen <= 0 {
  182. this.State = false
  183. return
  184. }
  185. this.Out.RetCode = int((*retRows[0][0].(*interface{})).(int64))
  186. }
  187. // 删除审核
  188. type (
  189. gameRequestDel_in struct {
  190. OpUserID int //操作员ID
  191. OpUserName string //操作员名称
  192. PartnerID int //渠道ID
  193. IpAddress string //IP地址
  194. }
  195. gameRequestDel_out struct {
  196. RetCode int //操作结果
  197. ErrorMsg string //操作描述
  198. }
  199. gameRequestDel struct {
  200. database.Trans_base
  201. In gameRequestDel_in
  202. Out gameRequestDel_out
  203. }
  204. )
  205. func NewGameRequestDel() *gameRequestDel {
  206. return &gameRequestDel{}
  207. }
  208. func (this *gameRequestDel) DoAction(ch chan<- interface{}) {
  209. defer func() {
  210. if err := recover(); err != nil {
  211. log.Release("transaction recover fail %v", err)
  212. log.Release("%s", debug.Stack())
  213. }
  214. if ch != nil {
  215. ch <- this
  216. }
  217. }()
  218. statement := database.NewStatement()
  219. statement.SetNeedReturnValue(false)
  220. statement.SetOpenRecordSet(true)
  221. statement.SetProcName("Manage_GameRequest_Del")
  222. statement.AddParamter("@OpUserID", database.AdParamInput, database.AdInteger, 4, this.In.OpUserID)
  223. statement.AddParamter("@OpUserName", database.AdParamInput, database.AdVarChar, 32, this.In.OpUserName)
  224. statement.AddParamter("@PartnerID", database.AdParamInput, database.AdInteger, 20, this.In.PartnerID)
  225. statement.AddParamter("@IPAddress", database.AdParamInput, database.AdVarChar, 16, this.In.IpAddress)
  226. statement.AddParamter("@RetCode", database.AdParamOutput, database.AdInteger, 4, this.Out.RetCode)
  227. sqlstring := statement.GenSql()
  228. retRows := CenterDB.ExecSql(sqlstring)
  229. rowLen := len(retRows)
  230. if rowLen <= 0 {
  231. this.State = false
  232. return
  233. }
  234. this.Out.RetCode = int((*retRows[0][0].(*interface{})).(int64))
  235. }
  236. // 游戏信息修改
  237. type (
  238. allGameUpd_in struct {
  239. OpUserID int //操作员ID
  240. OpUserName string //操作员名称
  241. GameID int //渠道ID
  242. IpAddress string //IP地址
  243. Enabled int //是否启用
  244. DisplaySort int //显示顺序
  245. GameType int //游戏类型 (0=无限制 1=金币游戏 2=元宝游戏)
  246. NeedLevel int // 所需等级
  247. }
  248. allGameUpd struct {
  249. database.Trans_base
  250. In allGameUpd_in
  251. }
  252. )
  253. func NewAllGameUpd() *allGameUpd {
  254. return &allGameUpd{}
  255. }
  256. func (this *allGameUpd) DoAction(ch chan<- interface{}) {
  257. defer func() {
  258. if err := recover(); err != nil {
  259. log.Release("transaction recover fail %v", err)
  260. log.Release("%s", debug.Stack())
  261. }
  262. if ch != nil {
  263. ch <- this
  264. }
  265. }()
  266. statement := database.NewStatement()
  267. statement.SetNeedReturnValue(false)
  268. statement.SetOpenRecordSet(true)
  269. statement.SetProcName("Manage_AllGame_Update")
  270. statement.AddParamter("@OpUserID", database.AdParamInput, database.AdInteger, 4, this.In.OpUserID)
  271. statement.AddParamter("@OpUserName", database.AdParamInput, database.AdVarChar, 32, this.In.OpUserName)
  272. statement.AddParamter("@GameID", database.AdParamInput, database.AdInteger, 4, this.In.GameID)
  273. statement.AddParamter("@IPAddress", database.AdParamInput, database.AdVarChar, 16, this.In.IpAddress)
  274. statement.AddParamter("@Enabled", database.AdParamInput, database.AdInteger, 4, this.In.Enabled)
  275. statement.AddParamter("@DisplaySort", database.AdParamInput, database.AdInteger, 4, this.In.DisplaySort)
  276. statement.AddParamter("@GameType", database.AdParamInput, database.AdInteger, 4, this.In.GameType)
  277. statement.AddParamter("@NeedLevel", database.AdParamInput, database.AdInteger, 4, this.In.NeedLevel)
  278. sqlstring := statement.GenSql()
  279. retRows := CenterDB.ExecSql(sqlstring)
  280. rowLen := len(retRows)
  281. if rowLen <= 0 {
  282. this.State = false
  283. return
  284. }
  285. }
  286. const (
  287. _ = iota
  288. Odds_Sys //系统返还比率
  289. Odds_RoomOdds_EC //EC:浅水滩(初级)
  290. Odds_RoomOdds_AO //AO:深海寻宝(中级)
  291. Odds_RoomOdds_AC //AC:海底密藏(高级)
  292. Odds_RoomOdds_DM //DM:深海沉船(大师)
  293. Odds_RoomOdds_MAX
  294. )
  295. // 系统返还率
  296. type sysOdds struct {
  297. Type int `json:"Type"` //类型
  298. Odd int `json:"Odd"` //比率
  299. }
  300. func NewSysOdds() *sysOdds {
  301. return &sysOdds{}
  302. }
  303. func (s *sysOdds) getKey(oddType int) string {
  304. switch oddType {
  305. case Odds_Sys:
  306. return "fish:sysodds" //系统返还比率
  307. case Odds_RoomOdds_EC:
  308. return "fish:roomodds:EC" //EC:浅水滩(初级)
  309. case Odds_RoomOdds_AO:
  310. return "fish:roomodds:AO" //AO:深海寻宝(中级)
  311. case Odds_RoomOdds_AC:
  312. return "fish:roomodds:AC" //AC:海底密藏(高级)
  313. case Odds_RoomOdds_DM:
  314. return "fish:roomodds:DM" //DM:深海沉船(大师)
  315. default:
  316. log.Error("NewSysOdds getKey type=%d is not exist", oddType)
  317. }
  318. return ""
  319. }
  320. // 获取系统返还比率
  321. func (s *sysOdds) Get() []*sysOdds {
  322. var odds []*sysOdds
  323. for oddType := 1; oddType < Odds_RoomOdds_MAX; oddType++ {
  324. key := s.getKey(oddType)
  325. odds = append(odds, &sysOdds{
  326. Type: oddType,
  327. Odd: redis.String_GetInt(key),
  328. })
  329. }
  330. return odds
  331. }
  332. // 设置系统返还比率
  333. func (s *sysOdds) Set() bool {
  334. if s.Odd < 0 {
  335. log.Error("SetSysOdds odds(%d) 参数有误", s.Odd)
  336. return false
  337. }
  338. key := s.getKey(s.Type)
  339. if key == "" {
  340. return false
  341. }
  342. return redis.String_Set(key, strconv.Itoa(s.Odd))
  343. }