AppGameBettingMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.game.business.mapper.AppGameBettingMapper">
  6. <resultMap type="com.game.business.domain.AppGameBetting" id="AppGameBettingResult">
  7. <result property="id" column="id" />
  8. <result property="classId" column="class_id" />
  9. <result property="gameId" column="game_id" />
  10. <result property="userId" column="user_id" />
  11. <result property="gameDate" column="game_date" />
  12. <result property="liveUserId" column="live_user_id" />
  13. <result property="liveRoomId" column="live_room_id" />
  14. <result property="moneyId" column="money_id" />
  15. <result property="isLive" column="is_live" />
  16. <result property="bettingType" column="betting_type" />
  17. <result property="bettingGameType" column="betting_game_type" />
  18. <result property="bettingItem" column="betting_item" />
  19. <result property="bettingMultiple" column="betting_multiple" />
  20. <result property="bettingAmount" column="betting_amount" />
  21. <result property="bettingCommission" column="betting_commission" />
  22. <result property="isWinning" column="is_winning" />
  23. <result property="createTime" column="create_time" />
  24. <result property="updateTime" column="update_time" />
  25. </resultMap>
  26. <select id="getCount" resultType="com.game.business.vo.AppGameBettingDetailsCountVO">
  27. select
  28. game_id as gameId,
  29. count(id) as bettingCount,
  30. sum(betting_amount) as orderAmount,
  31. sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
  32. sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
  33. from app_game_betting where date_format(create_time, '%Y-%m-%d') = #{strDate} and user_id = #{userId}
  34. and betting_type = #{bettingType}
  35. group by game_id
  36. </select>
  37. <select id="getUserCount" resultType="com.game.business.vo.AppUserGameBettingCountVO">
  38. select tmp.*,
  39. agl.game_lottery_succ as gameLotterySucc,agl.game_record_date as gameRecordDate,agl.is_lottery as isLottery
  40. from (
  41. select
  42. game_date as gameDate,
  43. count(id) as bettingCount,
  44. sum(betting_amount) as orderAmount,
  45. sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
  46. sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
  47. from app_game_betting where game_id = #{gameId} and user_id = #{userId} and betting_type = #{bettingType}
  48. group by game_date
  49. ) tmp
  50. left join app_game_lottery agl on agl.game_date = tmp.gameDate and agl.game_id = #{gameId}
  51. order by tmp.gameDate desc
  52. </select>
  53. <select id="getUserWebCount" resultType="com.game.business.vo.AppUserGameBettingWebCountVO">
  54. select tmp.*,
  55. ag.name as gameName,
  56. agl.game_lottery_succ as gameLotterySucc,agl.game_record_date as gameRecordDate,agl.is_lottery as isLottery
  57. from (
  58. select
  59. user_id as userId,
  60. game_id as gameId,
  61. game_date as gameDate,
  62. betting_type as bettingType,
  63. betting_game_type as bettingGameType,
  64. min(create_time) as bettingDate,
  65. count(id) as bettingCount,
  66. sum(betting_amount) as orderAmount,
  67. sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
  68. sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
  69. from app_game_betting
  70. <where>
  71. <if test="userId != null">
  72. and user_id = #{userId}
  73. </if>
  74. <if test="gameId != null">
  75. and game_id = #{gameId}
  76. </if>
  77. <if test="bettingType != null">
  78. and betting_type = #{bettingType}
  79. </if>
  80. <if test="beginTime != null and beginTime != ''">
  81. and create_time &gt;= #{beginTime}
  82. </if>
  83. <if test="endTime != null and endTime != ''">
  84. and create_time &lt;= #{endTime}
  85. </if>
  86. </where>
  87. group by user_id, game_id, game_date, betting_game_type
  88. ) tmp
  89. left join mugozbg_live.app_game ag on ag.id = tmp.gameId
  90. left join app_game_lottery agl on agl.game_date = tmp.gameDate and agl.game_id = tmp.gameId
  91. order by tmp.bettingDate desc
  92. </select>
  93. <select id="getUserBettingItemCount" resultType="com.game.business.vo.AppUserGameBettingDetailsCountVO">
  94. select
  95. betting_item as bettingTtem,
  96. sum(betting_amount) as orderAmount,
  97. sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
  98. sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
  99. from app_game_betting where game_id = #{gameId} and game_date = #{gameDate}
  100. and user_id = #{userId} and betting_type = #{bettingType} and betting_game_type = 0
  101. group by betting_item
  102. </select>
  103. <select id="getBettingAmountSum" resultType="java.util.Map">
  104. select
  105. ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
  106. ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum
  107. from app_game_betting
  108. <where>
  109. <if test="userId != null">
  110. and user_id = #{userId}
  111. </if>
  112. </where>
  113. </select>
  114. <select id="getBettingAmountByDateSum" resultType="java.util.Map" parameterType="com.game.business.dto.FinTranRecordDTO">
  115. select
  116. ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
  117. ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum
  118. from app_game_betting
  119. <where>
  120. <if test="userId != null">
  121. and user_id = #{userId}
  122. </if>
  123. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  124. and (date_format(create_time, '%Y-%m-%d') &gt;= #{beginTime} and date_format(create_time, '%Y-%m-%d') &lt;= #{endTime})
  125. </if>
  126. </where>
  127. </select>
  128. <select id="getBettingCount" resultType="java.lang.Integer">
  129. select ifnull(count(1), 0) as bettingCount from (
  130. select
  131. betting_item
  132. from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate} and betting_item != #{bettingItem}
  133. group by betting_item
  134. ) tmp
  135. </select>
  136. <select id="getBettingItem" resultType="java.lang.String">
  137. select
  138. betting_item
  139. from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
  140. group by betting_item
  141. </select>
  142. <select id="getBettingItemCount" resultType="java.lang.Integer">
  143. select
  144. ifnull(count(1), 0) as bettingCount
  145. from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
  146. <if test="bettingItem != null and bettingItem != ''">
  147. and betting_item = #{bettingItem}
  148. </if>
  149. </select>
  150. <select id="getBettingAmount" resultType="java.math.BigDecimal">
  151. select
  152. ifnull(sum(betting_amount), 0.00) as bettingAmount
  153. from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
  154. <if test="bettingItem != null and bettingItem != ''">
  155. and betting_item = #{bettingItem}
  156. </if>
  157. </select>
  158. <select id="getBettingAmountByDate" resultType="java.util.Map">
  159. select
  160. ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
  161. ifnull(sum(case when betting_type = 1 and is_winning = 1 then betting_amount * betting_multiple else 0.00 end), 0.00) as coinWin,
  162. ifnull(sum(case when betting_type = 1 and is_winning = 2 then betting_amount else 0.00 end), 0.00) as coinLose,
  163. ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum,
  164. ifnull(sum(case when betting_type = 0 and is_winning = 1 then betting_amount * betting_multiple else 0.00 end), 0.00) as diamondCoinWin,
  165. ifnull(sum(case when betting_type = 0 and is_winning = 2 then betting_amount else 0.00 end), 0.00) as diamondCoinLose
  166. from app_game_betting where game_id = #{gameId} and date_format(create_time, '%Y-%m-%d') = #{dateStr}
  167. </select>
  168. <select id="getBettingAmountByGameDate" resultType="com.game.business.vo.AppUserGameBettingDetailsCountVO">
  169. select
  170. betting_item as bettingTtem,
  171. sum(betting_amount) as orderAmount,
  172. sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
  173. sum(case when is_winning = 2 then betting_amount else 0.00 end) as loseAmount
  174. from app_game_betting where game_id = #{gameId} and game_date = #{gameDate} and betting_type = #{bettingType}
  175. group by betting_item
  176. </select>
  177. <sql id="selectAppGameBettingVo">
  178. select id, class_id, game_id, user_id, game_date, live_user_id, live_room_id, money_id, is_live, betting_type, betting_game_type, betting_item, betting_multiple, betting_amount, betting_commission, is_winning, create_time, update_time from app_game_betting
  179. </sql>
  180. <select id="selectAppGameBettingList" parameterType="com.game.business.domain.AppGameBetting" resultMap="AppGameBettingResult">
  181. <include refid="selectAppGameBettingVo"/>
  182. <where>
  183. <if test="classId != null "> and class_id = #{classId}</if>
  184. <if test="gameId != null "> and game_id = #{gameId}</if>
  185. <if test="userId != null "> and user_id = #{userId}</if>
  186. <if test="gameDate != null and gameDate != ''"> and game_date = #{gameDate}</if>
  187. <if test="liveUserId != null "> and live_user_id = #{liveUserId}</if>
  188. <if test="liveRoomId != null "> and live_room_id = #{liveRoomId}</if>
  189. <if test="moneyId != null "> and money_id = #{moneyId}</if>
  190. <if test="isLive != null and isLive != ''"> and is_live = #{isLive}</if>
  191. <if test="bettingType != null and bettingType != ''"> and betting_type = #{bettingType}</if>
  192. <if test="bettingGameType != null and bettingGameType != ''"> and betting_game_type = #{bettingGameType}</if>
  193. <if test="bettingItem != null and bettingItem != ''"> and betting_item = #{bettingItem}</if>
  194. <if test="bettingMultiple != null "> and betting_multiple = #{bettingMultiple}</if>
  195. <if test="bettingAmount != null "> and betting_amount = #{bettingAmount}</if>
  196. <if test="bettingCommission != null "> and betting_commission = #{bettingCommission}</if>
  197. <if test="isWinning != null and isWinning != ''"> and is_winning = #{isWinning}</if>
  198. <if test="beginTime != null and beginTime != ''"> and create_time &gt; CONCAT(#{beginTime},' 00:00:00')</if>
  199. <if test="endTime != null and endTime != ''"> and create_time &lt; CONCAT(#{endTime},' 23:59:59')</if>
  200. </where>
  201. order by create_time desc
  202. </select>
  203. <select id="selectAppGameBettingById" parameterType="Long" resultMap="AppGameBettingResult">
  204. <include refid="selectAppGameBettingVo"/>
  205. where id = #{id}
  206. </select>
  207. <insert id="insertAppGameBetting" parameterType="com.game.business.domain.AppGameBetting" useGeneratedKeys="true" keyProperty="id">
  208. insert into app_game_betting
  209. <trim prefix="(" suffix=")" suffixOverrides=",">
  210. <if test="classId != null">class_id,</if>
  211. <if test="gameId != null">game_id,</if>
  212. <if test="userId != null">user_id,</if>
  213. <if test="gameDate != null">game_date,</if>
  214. <if test="liveUserId != null">live_user_id,</if>
  215. <if test="liveRoomId != null">live_room_id,</if>
  216. <if test="moneyId != null">money_id,</if>
  217. <if test="isLive != null">is_live,</if>
  218. <if test="bettingType != null">betting_type,</if>
  219. <if test="bettingGameType != null">betting_game_type,</if>
  220. <if test="bettingItem != null">betting_item,</if>
  221. <if test="bettingMultiple != null">betting_multiple,</if>
  222. <if test="bettingAmount != null">betting_amount,</if>
  223. <if test="bettingCommission != null">betting_commission,</if>
  224. <if test="isWinning != null">is_winning,</if>
  225. <if test="createTime != null">create_time,</if>
  226. <if test="updateTime != null">update_time,</if>
  227. </trim>
  228. <trim prefix="values (" suffix=")" suffixOverrides=",">
  229. <if test="classId != null">#{classId},</if>
  230. <if test="gameId != null">#{gameId},</if>
  231. <if test="userId != null">#{userId},</if>
  232. <if test="gameDate != null">#{gameDate},</if>
  233. <if test="liveUserId != null">#{liveUserId},</if>
  234. <if test="liveRoomId != null">#{liveRoomId},</if>
  235. <if test="moneyId != null">#{moneyId},</if>
  236. <if test="isLive != null">#{isLive},</if>
  237. <if test="bettingType != null">#{bettingType},</if>
  238. <if test="bettingGameType != null">#{bettingGameType},</if>
  239. <if test="bettingItem != null">#{bettingItem},</if>
  240. <if test="bettingMultiple != null">#{bettingMultiple},</if>
  241. <if test="bettingAmount != null">#{bettingAmount},</if>
  242. <if test="bettingCommission != null">#{bettingCommission},</if>
  243. <if test="isWinning != null">#{isWinning},</if>
  244. <if test="createTime != null">#{createTime},</if>
  245. <if test="updateTime != null">#{updateTime},</if>
  246. </trim>
  247. </insert>
  248. <update id="updateAppGameBetting" parameterType="com.game.business.domain.AppGameBetting">
  249. update app_game_betting
  250. <trim prefix="SET" suffixOverrides=",">
  251. <if test="classId != null">class_id = #{classId},</if>
  252. <if test="gameId != null">game_id = #{gameId},</if>
  253. <if test="userId != null">user_id = #{userId},</if>
  254. <if test="gameDate != null">game_date = #{gameDate},</if>
  255. <if test="liveUserId != null">live_user_id = #{liveUserId},</if>
  256. <if test="liveRoomId != null">live_room_id = #{liveRoomId},</if>
  257. <if test="moneyId != null">money_id = #{moneyId},</if>
  258. <if test="isLive != null">is_live = #{isLive},</if>
  259. <if test="bettingType != null">betting_type = #{bettingType},</if>
  260. <if test="bettingGameType != null">betting_game_type = #{bettingGameType},</if>
  261. <if test="bettingItem != null">betting_item = #{bettingItem},</if>
  262. <if test="bettingMultiple != null">betting_multiple = #{bettingMultiple},</if>
  263. <if test="bettingAmount != null">betting_amount = #{bettingAmount},</if>
  264. <if test="bettingCommission != null">betting_commission = #{bettingCommission},</if>
  265. <if test="isWinning != null">is_winning = #{isWinning},</if>
  266. <if test="createTime != null">create_time = #{createTime},</if>
  267. <if test="updateTime != null">update_time = #{updateTime},</if>
  268. </trim>
  269. where id = #{id}
  270. </update>
  271. <delete id="deleteAppGameBettingById" parameterType="Long">
  272. delete from app_game_betting where id = #{id}
  273. </delete>
  274. <delete id="deleteAppGameBettingByIds" parameterType="String">
  275. delete from app_game_betting where id in
  276. <foreach item="id" collection="array" open="(" separator="," close=")">
  277. #{id}
  278. </foreach>
  279. </delete>
  280. <select id="sumBettingAmount" resultType="java.lang.Double">
  281. select ifNull(sum(betting_amount),0) from app_game_betting
  282. <where>
  283. <if test="userId != null ">
  284. and user_id = #{userId}
  285. </if>
  286. <if test="gameId != null ">
  287. and game_id = #{gameId}
  288. </if>
  289. <if test="bettingType != null ">
  290. and betting_type = #{bettingType}
  291. </if>
  292. <if test="beginTime != null and beginTime != '' ">
  293. and create_time &gt;= #{beginTime}
  294. </if>
  295. <if test="endTime != null and endTime != '' ">
  296. and create_time &lt;= #{endTime}
  297. </if>
  298. </where>
  299. </select>
  300. </mapper>