AppUserAgentMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.AppUserAgentMapper">
  6. <resultMap type="com.game.business.domain.AppUserAgent" id="AppUserAgentResult">
  7. <result property="id" column="id" />
  8. <result property="userId" column="user_id" />
  9. <result property="pid" column="pid" />
  10. <result property="topId" column="top_id" />
  11. <result property="liveRate" column="live_rate" />
  12. <result property="dividendGuaranteeRate" column="dividend_guarantee_rate" />
  13. <result property="auditStatus" column="audit_status" />
  14. <result property="createTime" column="create_time" />
  15. <result property="updateTime" column="update_time" />
  16. </resultMap>
  17. <sql id="selectAppUserAgentVo">
  18. select id, user_id, pid, top_id, live_rate, dividend_guarantee_rate, audit_status, create_time, update_time from app_user_agent
  19. </sql>
  20. <select id="selectAppUserAgentList" parameterType="com.game.business.domain.AppUserAgent" resultMap="AppUserAgentResult">
  21. <include refid="selectAppUserAgentVo"/>
  22. <where>
  23. <if test="userId != null "> and user_id = #{userId}</if>
  24. <if test="pid != null "> and pid = #{pid}</if>
  25. <if test="topId != null "> and top_id = #{topId}</if>
  26. <if test="liveRate != null "> and live_rate = #{liveRate}</if>
  27. <if test="dividendGuaranteeRate != null "> and dividend_guarantee_rate = #{dividendGuaranteeRate}</if>
  28. <if test="auditStatus != null and auditStatus != ''"> and audit_status = #{auditStatus}</if>
  29. </where>
  30. </select>
  31. <select id="selectAppUserAgentById" parameterType="Long" resultMap="AppUserAgentResult">
  32. <include refid="selectAppUserAgentVo"/>
  33. where id = #{id}
  34. </select>
  35. <insert id="insertAppUserAgent" parameterType="com.game.business.domain.AppUserAgent" useGeneratedKeys="true" keyProperty="id">
  36. insert into app_user_agent
  37. <trim prefix="(" suffix=")" suffixOverrides=",">
  38. <if test="id != null">id,</if>
  39. <if test="userId != null">user_id,</if>
  40. <if test="pid != null">pid,</if>
  41. <if test="topId != null">top_id,</if>
  42. <if test="liveRate != null">live_rate,</if>
  43. <if test="dividendGuaranteeRate != null">dividend_guarantee_rate,</if>
  44. <if test="auditStatus != null">audit_status,</if>
  45. <if test="createTime != null">create_time,</if>
  46. <if test="updateTime != null">update_time,</if>
  47. </trim>
  48. <trim prefix="values (" suffix=")" suffixOverrides=",">
  49. <if test="id != null">#{id},</if>
  50. <if test="userId != null">#{userId},</if>
  51. <if test="pid != null">#{pid},</if>
  52. <if test="topId != null">#{topId},</if>
  53. <if test="liveRate != null">#{liveRate},</if>
  54. <if test="dividendGuaranteeRate != null">#{dividendGuaranteeRate},</if>
  55. <if test="auditStatus != null">#{auditStatus},</if>
  56. <if test="createTime != null">#{createTime},</if>
  57. <if test="updateTime != null">#{updateTime},</if>
  58. </trim>
  59. </insert>
  60. <update id="updateAppUserAgent" parameterType="com.game.business.domain.AppUserAgent">
  61. update app_user_agent
  62. <trim prefix="SET" suffixOverrides=",">
  63. <if test="userId != null">user_id = #{userId},</if>
  64. <if test="pid != null">pid = #{pid},</if>
  65. <if test="topId != null">top_id = #{topId},</if>
  66. <if test="liveRate != null">live_rate = #{liveRate},</if>
  67. <if test="dividendGuaranteeRate != null">dividend_guarantee_rate = #{dividendGuaranteeRate},</if>
  68. <if test="auditStatus != null">audit_status = #{auditStatus},</if>
  69. <if test="createTime != null">create_time = #{createTime},</if>
  70. <if test="updateTime != null">update_time = #{updateTime},</if>
  71. </trim>
  72. where id = #{id}
  73. </update>
  74. <delete id="deleteAppUserAgentById" parameterType="Long">
  75. delete from app_user_agent where id = #{id}
  76. </delete>
  77. <delete id="deleteAppUserAgentByIds" parameterType="String">
  78. delete from app_user_agent where id in
  79. <foreach item="id" collection="array" open="(" separator="," close=")">
  80. #{id}
  81. </foreach>
  82. </delete>
  83. <select id="sumBetting" resultType="java.lang.Double">
  84. select IFNULL(sum(betting_amount),0) as amount
  85. from app_user_agent as a left join app_game_betting as b on a.user_id = b.user_id
  86. where b.create_time between #{beginTime} and #{endTime}
  87. and a.pid = #{pid}
  88. </select>
  89. <select id="teamList" resultType="com.game.business.vo.AppAgentTeamVo">
  90. select
  91. a.user_id as userId,
  92. c.username as nickName,
  93. a.pid as pid,
  94. (select IFNULL(sum(betting_amount),0) from app_game_betting as b where b.user_id = a.user_id) as bettingAmount,
  95. (select IFNULL(sum(d.live_commission + d.game_commission),0) from app_user_count as d where d.user_id = a.user_id) as commission,
  96. (select IFNULL(sum(e.game_win_amount - e.game_lose_amount),0) from app_user_count as e where e.user_id = a.user_id) as gameAmount,
  97. a.live_rate as liveRate,
  98. a.dividend_guarantee_rate as dividendGuaranteeRate
  99. from app_user_agent as a left join mugozbg_live.app_user as c on a.user_id = c.userid where (a.pid = #{teamDto.pid} or a.user_id = #{teamDto.pid})
  100. <if test="teamDto.userId != null ">
  101. and a.user_id = #{teamDto.userId}
  102. </if>
  103. <if test="teamDto.nickName != null and teamDto.nickName != ''">
  104. and c.username = #{teamDto.nickName}
  105. </if>
  106. </select>
  107. </mapper>