AppGameBettingMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. <select id="getCount" resultType="com.game.business.vo.AppGameBettingDetailsCountVO">
  7. select
  8. game_id as gameId,
  9. count(id) as bettingCount,
  10. sum(betting_amount) as orderAmount,
  11. sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
  12. sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
  13. from app_game_betting where date_format(create_time, '%Y-%m-%d') = #{strDate} and user_id = #{userId}
  14. and betting_type = #{bettingType}
  15. group by game_id
  16. </select>
  17. <select id="getUserCount" resultType="com.game.business.vo.AppUserGameBettingCountVO">
  18. select tmp.*,agl.game_lottery_succ as gameLotterySucc,agl.game_record_date as gameRecordDate from (
  19. select
  20. game_date as gameDate,
  21. count(id) as bettingCount,
  22. sum(betting_amount) as orderAmount,
  23. sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
  24. sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
  25. from app_game_betting where game_id = #{gameId} and user_id = #{userId} and betting_type = #{bettingType}
  26. group by game_date
  27. ) tmp
  28. left join app_game_lottery agl on agl.game_date = tmp.gameDate and agl.game_id = #{gameId}
  29. where agl.is_lottery = 1
  30. order by tmp.gameDate desc
  31. </select>
  32. <select id="getUserBettingItemCount" resultType="com.game.business.vo.AppUserGameBettingDetailsCountVO">
  33. select
  34. betting_item as bettingTtem,
  35. sum(betting_amount) as orderAmount,
  36. sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
  37. sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
  38. from app_game_betting where game_id = #{gameId} and game_date = #{gameDate}
  39. and user_id = #{userId} and betting_type = #{bettingType} and betting_game_type = 0
  40. group by betting_item
  41. </select>
  42. <select id="getBettingAmountSum" resultType="java.util.Map">
  43. select
  44. ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
  45. ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum
  46. from app_game_betting
  47. <where>
  48. <if test="userId != null">
  49. and user_id = #{userId}
  50. </if>
  51. </where>
  52. </select>
  53. <select id="getBettingAmountByDateSum" resultType="java.util.Map" parameterType="com.game.business.dto.FinTranRecordDTO">
  54. select
  55. ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
  56. ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum
  57. from app_game_betting
  58. <where>
  59. <if test="userId != null">
  60. and user_id = #{userId}
  61. </if>
  62. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  63. and (date_format(create_time, '%Y-%m-%d') &gt;= #{beginTime} and date_format(create_time, '%Y-%m-%d') &lt;= #{endTime})
  64. </if>
  65. </where>
  66. </select>
  67. <select id="getBettingCount" resultType="java.lang.Integer">
  68. select
  69. ifnull(count(1), 0) as bettingCount
  70. from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
  71. </select>
  72. <select id="getBettingAmount" resultType="java.math.BigDecimal">
  73. select
  74. ifnull(sum(betting_amount), 0.00) as bettingAmount
  75. from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate} and betting_item = #{bettingItem}
  76. </select>
  77. </mapper>