AppGameBettingMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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.*,agl.game_lottery_succ as gameLotterySucc,agl.game_record_date as gameRecordDate from (
  39. select
  40. game_date as gameDate,
  41. count(id) as bettingCount,
  42. sum(betting_amount) as orderAmount,
  43. sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
  44. sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
  45. from app_game_betting where game_id = #{gameId} and user_id = #{userId} and betting_type = #{bettingType}
  46. group by game_date
  47. ) tmp
  48. left join app_game_lottery agl on agl.game_date = tmp.gameDate and agl.game_id = #{gameId}
  49. where agl.is_lottery = 1
  50. order by tmp.gameDate desc
  51. </select>
  52. <select id="getUserBettingItemCount" resultType="com.game.business.vo.AppUserGameBettingDetailsCountVO">
  53. select
  54. betting_item as bettingTtem,
  55. sum(betting_amount) as orderAmount,
  56. sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
  57. sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
  58. from app_game_betting where game_id = #{gameId} and game_date = #{gameDate}
  59. and user_id = #{userId} and betting_type = #{bettingType} and betting_game_type = 0
  60. group by betting_item
  61. </select>
  62. <select id="getBettingAmountSum" resultType="java.util.Map">
  63. select
  64. ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
  65. ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum
  66. from app_game_betting
  67. <where>
  68. <if test="userId != null">
  69. and user_id = #{userId}
  70. </if>
  71. </where>
  72. </select>
  73. <select id="getBettingAmountByDateSum" resultType="java.util.Map" parameterType="com.game.business.dto.FinTranRecordDTO">
  74. select
  75. ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
  76. ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum
  77. from app_game_betting
  78. <where>
  79. <if test="userId != null">
  80. and user_id = #{userId}
  81. </if>
  82. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  83. and (date_format(create_time, '%Y-%m-%d') &gt;= #{beginTime} and date_format(create_time, '%Y-%m-%d') &lt;= #{endTime})
  84. </if>
  85. </where>
  86. </select>
  87. <select id="getBettingCount" resultType="java.lang.Integer">
  88. select ifnull(count(1), 0) as bettingCount from (
  89. select
  90. betting_item
  91. from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate} and betting_item != #{bettingItem}
  92. group by betting_item
  93. ) tmp
  94. </select>
  95. <select id="getBettingAmount" resultType="java.math.BigDecimal">
  96. select
  97. ifnull(sum(betting_amount), 0.00) as bettingAmount
  98. from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
  99. <if test="bettingItem != null and bettingItem != ''">
  100. and betting_item = #{bettingItem}
  101. </if>
  102. </select>
  103. <sql id="selectAppGameBettingVo">
  104. 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
  105. </sql>
  106. <select id="selectAppGameBettingList" parameterType="com.game.business.domain.AppGameBetting" resultMap="AppGameBettingResult">
  107. <include refid="selectAppGameBettingVo"/>
  108. <where>
  109. <if test="classId != null "> and class_id = #{classId}</if>
  110. <if test="gameId != null "> and game_id = #{gameId}</if>
  111. <if test="userId != null "> and user_id = #{userId}</if>
  112. <if test="gameDate != null and gameDate != ''"> and game_date = #{gameDate}</if>
  113. <if test="liveUserId != null "> and live_user_id = #{liveUserId}</if>
  114. <if test="liveRoomId != null "> and live_room_id = #{liveRoomId}</if>
  115. <if test="moneyId != null "> and money_id = #{moneyId}</if>
  116. <if test="isLive != null and isLive != ''"> and is_live = #{isLive}</if>
  117. <if test="bettingType != null and bettingType != ''"> and betting_type = #{bettingType}</if>
  118. <if test="bettingGameType != null and bettingGameType != ''"> and betting_game_type = #{bettingGameType}</if>
  119. <if test="bettingItem != null and bettingItem != ''"> and betting_item = #{bettingItem}</if>
  120. <if test="bettingMultiple != null "> and betting_multiple = #{bettingMultiple}</if>
  121. <if test="bettingAmount != null "> and betting_amount = #{bettingAmount}</if>
  122. <if test="bettingCommission != null "> and betting_commission = #{bettingCommission}</if>
  123. <if test="isWinning != null and isWinning != ''"> and is_winning = #{isWinning}</if>
  124. </where>
  125. </select>
  126. <select id="selectAppGameBettingById" parameterType="Long" resultMap="AppGameBettingResult">
  127. <include refid="selectAppGameBettingVo"/>
  128. where id = #{id}
  129. </select>
  130. <insert id="insertAppGameBetting" parameterType="com.game.business.domain.AppGameBetting" useGeneratedKeys="true" keyProperty="id">
  131. insert into app_game_betting
  132. <trim prefix="(" suffix=")" suffixOverrides=",">
  133. <if test="classId != null">class_id,</if>
  134. <if test="gameId != null">game_id,</if>
  135. <if test="userId != null">user_id,</if>
  136. <if test="gameDate != null">game_date,</if>
  137. <if test="liveUserId != null">live_user_id,</if>
  138. <if test="liveRoomId != null">live_room_id,</if>
  139. <if test="moneyId != null">money_id,</if>
  140. <if test="isLive != null">is_live,</if>
  141. <if test="bettingType != null">betting_type,</if>
  142. <if test="bettingGameType != null">betting_game_type,</if>
  143. <if test="bettingItem != null">betting_item,</if>
  144. <if test="bettingMultiple != null">betting_multiple,</if>
  145. <if test="bettingAmount != null">betting_amount,</if>
  146. <if test="bettingCommission != null">betting_commission,</if>
  147. <if test="isWinning != null">is_winning,</if>
  148. <if test="createTime != null">create_time,</if>
  149. <if test="updateTime != null">update_time,</if>
  150. </trim>
  151. <trim prefix="values (" suffix=")" suffixOverrides=",">
  152. <if test="classId != null">#{classId},</if>
  153. <if test="gameId != null">#{gameId},</if>
  154. <if test="userId != null">#{userId},</if>
  155. <if test="gameDate != null">#{gameDate},</if>
  156. <if test="liveUserId != null">#{liveUserId},</if>
  157. <if test="liveRoomId != null">#{liveRoomId},</if>
  158. <if test="moneyId != null">#{moneyId},</if>
  159. <if test="isLive != null">#{isLive},</if>
  160. <if test="bettingType != null">#{bettingType},</if>
  161. <if test="bettingGameType != null">#{bettingGameType},</if>
  162. <if test="bettingItem != null">#{bettingItem},</if>
  163. <if test="bettingMultiple != null">#{bettingMultiple},</if>
  164. <if test="bettingAmount != null">#{bettingAmount},</if>
  165. <if test="bettingCommission != null">#{bettingCommission},</if>
  166. <if test="isWinning != null">#{isWinning},</if>
  167. <if test="createTime != null">#{createTime},</if>
  168. <if test="updateTime != null">#{updateTime},</if>
  169. </trim>
  170. </insert>
  171. <update id="updateAppGameBetting" parameterType="com.game.business.domain.AppGameBetting">
  172. update app_game_betting
  173. <trim prefix="SET" suffixOverrides=",">
  174. <if test="classId != null">class_id = #{classId},</if>
  175. <if test="gameId != null">game_id = #{gameId},</if>
  176. <if test="userId != null">user_id = #{userId},</if>
  177. <if test="gameDate != null">game_date = #{gameDate},</if>
  178. <if test="liveUserId != null">live_user_id = #{liveUserId},</if>
  179. <if test="liveRoomId != null">live_room_id = #{liveRoomId},</if>
  180. <if test="moneyId != null">money_id = #{moneyId},</if>
  181. <if test="isLive != null">is_live = #{isLive},</if>
  182. <if test="bettingType != null">betting_type = #{bettingType},</if>
  183. <if test="bettingGameType != null">betting_game_type = #{bettingGameType},</if>
  184. <if test="bettingItem != null">betting_item = #{bettingItem},</if>
  185. <if test="bettingMultiple != null">betting_multiple = #{bettingMultiple},</if>
  186. <if test="bettingAmount != null">betting_amount = #{bettingAmount},</if>
  187. <if test="bettingCommission != null">betting_commission = #{bettingCommission},</if>
  188. <if test="isWinning != null">is_winning = #{isWinning},</if>
  189. <if test="createTime != null">create_time = #{createTime},</if>
  190. <if test="updateTime != null">update_time = #{updateTime},</if>
  191. </trim>
  192. where id = #{id}
  193. </update>
  194. <delete id="deleteAppGameBettingById" parameterType="Long">
  195. delete from app_game_betting where id = #{id}
  196. </delete>
  197. <delete id="deleteAppGameBettingByIds" parameterType="String">
  198. delete from app_game_betting where id in
  199. <foreach item="id" collection="array" open="(" separator="," close=")">
  200. #{id}
  201. </foreach>
  202. </delete>
  203. </mapper>