OverallMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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.juxiao.xchat.module.xbd.mapper.report.OverallMapper">
  6. <resultMap id="QueryResultMap" type="com.juxiao.xchat.module.xbd.vo.OverallRecordVO">
  7. <id column="uid" property="uid" jdbcType="BIGINT"/>
  8. <result column="phone" property="phone" jdbcType="VARCHAR"/>
  9. <result column="erban_no" property="erbanNo" jdbcType="BIGINT"/>
  10. <result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP"/>
  11. <result column="weixin_openid" property="weixinOpenid" jdbcType="VARCHAR"/>
  12. <result column="qq_openid" property="qqOpenid" jdbcType="VARCHAR"/>
  13. <result column="os" property="os" jdbcType="VARCHAR"/>
  14. <result column="sign_time" property="signTime" jdbcType="TIMESTAMP"/>
  15. <result column="channel" property="channel" jdbcType="VARCHAR"/>
  16. <result column="nick" property="nick" jdbcType="VARCHAR"/>
  17. <result column="gender" property="gender" jdbcType="TINYINT"/>
  18. <result column="charge_amount" property="chargeAmount" jdbcType="BIGINT"/>
  19. <result column="exechange_diamond" property="exechangeDiamond" jdbcType="DOUBLE"/>
  20. <result column="charm_change" property="charmChange" jdbcType="BIGINT"/>
  21. <result column="exper_change" property="experChange" jdbcType="BIGINT"/>
  22. </resultMap>
  23. <sql id="Query_Column_List">
  24. a.uid as uid, a.phone as phone, a.erban_no as erban_no, a.last_login_time as last_login_time,
  25. a.weixin_openid as weixin_openid, a.qq_openid as qq_openid, a.os as os,
  26. a.channel as channel, u.create_time as sign_time,
  27. u.gender as gender, u.nick as nick
  28. </sql>
  29. <select id="listOverallRecord" resultMap="QueryResultMap">
  30. select
  31. <include refid="Query_Column_List"/>
  32. <choose>
  33. <when test="orderBy==1">
  34. ,sum(c1.amount) as charge_amount
  35. </when>
  36. <when test="orderBy==2">
  37. ,sum(c2.ex_diamond_num) as exechange_diamond
  38. </when>
  39. <when test="orderBy==3">
  40. ,sum(c3.sum_gold) as charm_change
  41. </when>
  42. <when test="orderBy==4">
  43. ,sum(c4.sum_gold) as exper_change
  44. </when>
  45. </choose>
  46. from account a JOIN users u ON a.uid=u.uid
  47. <choose>
  48. <when test="orderBy==1">
  49. left join charge_record c1 on c1.uid=a.uid and c1.charge_status='2' AND c1.pingxx_charge_id IS NOT NULL
  50. and c1.create_time BETWEEN #{beginDate} and #{endDate}
  51. </when>
  52. <when test="orderBy==2">
  53. LEFT JOIN exchange_diamond_gold_record c2 on c2.uid=a.uid and c2.create_time BETWEEN #{beginDate} and
  54. #{endDate}
  55. </when>
  56. <when test="orderBy==3">
  57. LEFT JOIN one_day_room_recv_sum c3 FORCE index(key3) on c3.recv_uid=a.uid and c3.create_time BETWEEN
  58. #{beginDate} and #{endDate}
  59. </when>
  60. <when test="orderBy==4">
  61. LEFT JOIN one_day_room_send_sum c4 FORCE index(key3) on c4.send_uid=a.uid and c4.create_time BETWEEN
  62. #{beginDate} and #{endDate}
  63. </when>
  64. </choose>
  65. <where>
  66. <if test="signBegin!=null">
  67. AND u.create_time &gt;= #{signBegin}
  68. </if>
  69. <if test="signEnd!=null">
  70. AND u.create_time &lt;= #{signEnd}
  71. </if>
  72. <if test="erbanNo!=null and erbanNo!=''">
  73. AND u.erban_no=#{erbanNo}
  74. </if>
  75. <if test="os!=null and os!=''">
  76. AND a.os = #{os}
  77. </if>
  78. <if test="phone!=null and phone!=''">
  79. AND a.phone like concat('%', #{phone},'%')
  80. </if>
  81. <if test="channel!=null and channel!=''">
  82. AND u.channel=#{channel}
  83. </if>
  84. <if test="gender!=null">
  85. AND u.gender=#{gender}
  86. </if>
  87. <if test="nick!=null and nick!=''">
  88. AND u.nick like concat('%',#{nick},'%')
  89. </if>
  90. <choose>
  91. <when test="registerType==1">
  92. AND a.weixin_openid is null AND a.qq_openid is null
  93. </when>
  94. <when test="registerType==2">
  95. AND a.weixin_openid is not null
  96. </when>
  97. <when test="registerType==3">
  98. AND a.qq_openid is not null
  99. </when>
  100. </choose>
  101. </where>
  102. group by a.uid
  103. <choose>
  104. <when test="orderBy==1">
  105. order by charge_amount desc
  106. </when>
  107. <when test="orderBy==2">
  108. order by exechange_diamond desc
  109. </when>
  110. <when test="orderBy==3">
  111. order by charm_change desc
  112. </when>
  113. <when test="orderBy==4">
  114. order by exper_change desc
  115. </when>
  116. </choose>
  117. </select>
  118. <select id="selectByChargeAmount" resultType="com.juxiao.xchat.module.xbd.domain.report.OverallStat">
  119. SELECT c.uid, sum(c.amount)/100 as num FROM charge_record c force index(uid)
  120. WHERE c.uid in (${uidStr}) and c.charge_status='2' AND c.pingxx_charge_id IS NOT NULL and c.create_time BETWEEN #{beginDate} and #{endDate}
  121. GROUP BY c.uid
  122. </select>
  123. <select id="selectByExechangeDiamond" resultType="com.juxiao.xchat.module.xbd.domain.report.OverallStat">
  124. select c.uid, sum(c.ex_diamond_num) as doubleNum FROM exchange_diamond_gold_record c force index(uid)
  125. WHERE c.uid in (${uidStr}) and c.create_time BETWEEN #{beginDate} and #{endDate}
  126. GROUP BY c.uid
  127. </select>
  128. <select id="selectByCharmChange" resultType="com.juxiao.xchat.module.xbd.domain.report.OverallStat">
  129. SELECT c.recv_uid as uid, sum(c.sum_gold) as num FROM one_day_room_recv_sum c force index(key3)
  130. WHERE c.recv_uid in (${uidStr}) and c.create_time BETWEEN #{beginDate} and #{endDate}
  131. GROUP BY c.recv_uid
  132. </select>
  133. <select id="selectByExperChange" resultType="com.juxiao.xchat.module.xbd.domain.report.OverallStat">
  134. SELECT c.send_uid as uid, sum(c.sum_gold) as num
  135. FROM one_day_room_send_sum c force index(key3)
  136. WHERE c.send_uid in (${uidStr}) and c.create_time BETWEEN #{beginDate} and #{endDate}
  137. GROUP BY c.send_uid
  138. </select>
  139. <select id="listLatestLoginDate" resultType="com.juxiao.xchat.module.xbd.domain.report.OverallStat" >
  140. SELECT uid, max(create_time) as date FROM account_login_record
  141. WHERE uid IN (${uidStr})
  142. GROUP BY uid
  143. </select>
  144. <resultMap id="SelectByQueryMap" type="com.juxiao.xchat.module.xbd.domain.report.ExchangeDiamondRecord">
  145. <result column="record_id" property="recordId" jdbcType="VARCHAR" />
  146. <result column="uid" property="uid" jdbcType="BIGINT" />
  147. <result column="ex_diamond_num" property="exDiamondNum" jdbcType="DOUBLE" />
  148. <result column="ex_gold_num" property="exGoldNum" jdbcType="BIGINT" />
  149. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  150. <result column="erban_no" property="erbanNo" jdbcType="BIGINT" />
  151. <result column="phone" property="phone" jdbcType="VARCHAR" />
  152. <result column="nick" property="nick" jdbcType="VARCHAR" />
  153. <result column="alipay_account" property="alipayAccount" jdbcType="VARCHAR" />
  154. <result column="alipay_account_name" property="alipayAccountName" jdbcType="VARCHAR" />
  155. </resultMap>
  156. <select id="listExchangeGoldRecord" resultMap="SelectByQueryMap">
  157. SELECT e.record_id as record_id, e.uid as uid, e.ex_diamond_num as ex_diamond_num, e.ex_gold_num as ex_gold_num, e.create_time as create_time,
  158. u.nick as nick ,u.erban_no as erban_no,u.phone as phone ,u.alipay_account as alipay_account,u.alipay_account_name as alipay_account_name
  159. FROM exchange_diamond_gold_record e LEFT JOIN users u ON e.uid=u.uid
  160. WHERE u.def_user!='3'
  161. <if test="erbanNo!=null">
  162. AND u.erban_no=#{erbanNo}
  163. </if>
  164. <if test="beginDate!=null">
  165. AND e.create_time &gt;= #{beginDate}
  166. </if>
  167. <if test="endDate!=null">
  168. AND e.create_time &lt;= #{endDate}
  169. </if>
  170. order by e.create_time desc
  171. </select>
  172. <resultMap id="giftMap" type="com.juxiao.xchat.module.xbd.domain.report.CharmRecord" >
  173. <result column="sendNo" property="sendNo" jdbcType="BIGINT" />
  174. <result column="sendNick" property="sendNick" jdbcType="VARCHAR" />
  175. <result column="reciveNo" property="reciveNo" jdbcType="BIGINT" />
  176. <result column="reciveNick" property="reciveNick" jdbcType="VARCHAR" />
  177. <result column="roomNo" property="roomNo" jdbcType="BIGINT" />
  178. <result column="roomNick" property="roomNick" jdbcType="VARCHAR" />
  179. <result column="gift_name" property="giftName" jdbcType="VARCHAR" />
  180. <result column="gift_num" property="giftNum" jdbcType="BIGINT" />
  181. <result column="total_gold_num" property="totalGoldNum" jdbcType="BIGINT" />
  182. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  183. </resultMap>
  184. <select id="listGiftSend" resultMap="giftMap" >
  185. select se.erban_no as sendNo, se.nick as sendNick, re.erban_no as reciveNo, re.nick as reciveNick, ro.erban_no as roomNo, ro.nick as roomNick, gi.gift_name, g.gift_num, g.total_gold_num, g.create_time
  186. from gift_send_record g
  187. INNER JOIN users se on g.uid = se.uid
  188. INNER JOIN users re on g.recive_uid = re.uid
  189. LEFT JOIN users ro on g.room_uid = ro.uid
  190. INNER JOIN gift gi on g.gift_id = gi.gift_id
  191. where 1=1
  192. <if test="uid!=null">
  193. and g.uid = #{uid}
  194. </if>
  195. <if test="reciveUid!=null">
  196. and g.recive_uid = #{reciveUid}
  197. </if>
  198. <if test="beginDate!=null">
  199. and g.create_time &gt;= #{beginDate}
  200. </if>
  201. <if test="endDate!=null">
  202. and g.create_time &lt;= #{endDate}
  203. </if>
  204. order by g.create_time desc
  205. </select>
  206. </mapper>