ChargeRecordMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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.record.ChargeRecordMapper">
  6. <resultMap id="BaseResultMap" type="com.juxiao.xchat.module.xbd.domain.record.ChargeRecord" >
  7. <id column="charge_record_id" property="chargeRecordId" jdbcType="VARCHAR" />
  8. <result column="uid" property="uid" jdbcType="BIGINT" />
  9. <result column="room_uid" property="roomUid" jdbcType="BIGINT" />
  10. <result column="pingxx_charge_id" property="pingxxChargeId" jdbcType="VARCHAR" />
  11. <result column="charge_prod_id" property="chargeProdId" jdbcType="VARCHAR" />
  12. <result column="channel" property="channel" jdbcType="VARCHAR" />
  13. <result column="buss_type" property="bussType" jdbcType="TINYINT" />
  14. <result column="charge_status" property="chargeStatus" jdbcType="TINYINT" />
  15. <result column="charge_status_desc" property="chargeStatusDesc" jdbcType="VARCHAR" />
  16. <result column="amount" property="amount" jdbcType="BIGINT" />
  17. <result column="total_gold" property="totalGold" jdbcType="BIGINT" />
  18. <result column="client_ip" property="clientIp" jdbcType="VARCHAR" />
  19. <result column="wx_pub_openid" property="wxPubOpenid" jdbcType="VARCHAR" />
  20. <result column="subject" property="subject" jdbcType="VARCHAR" />
  21. <result column="body" property="body" jdbcType="VARCHAR" />
  22. <result column="extra" property="extra" jdbcType="VARCHAR" />
  23. <result column="metadata" property="metadata" jdbcType="VARCHAR" />
  24. <result column="charge_desc" property="chargeDesc" jdbcType="VARCHAR" />
  25. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  26. <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  27. </resultMap>
  28. <resultMap id="QueryResultMap" type="com.juxiao.xchat.module.xbd.vo.ChargeRecordVO" >
  29. <id column="charge_record_id" property="chargeRecordId" jdbcType="VARCHAR" />
  30. <result column="pingxx_charge_id" property="pingxxChargeId" jdbcType="VARCHAR" />
  31. <result column="channel" property="channel" jdbcType="VARCHAR" />
  32. <result column="buss_type" property="bussType" jdbcType="TINYINT" />
  33. <result column="charge_status" property="chargeStatus" jdbcType="TINYINT" />
  34. <result column="amount" property="amount" jdbcType="BIGINT" />
  35. <result column="total_gold" property="totalGold" jdbcType="BIGINT" />
  36. <result column="client_ip" property="clientIp" jdbcType="VARCHAR" />
  37. <result column="subject" property="subject" jdbcType="VARCHAR" />
  38. <result column="charge_desc" property="chargeDesc" jdbcType="VARCHAR" />
  39. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  40. <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  41. <result column="os" property="os" jdbcType="VARCHAR" />
  42. <result column="uid" property="uid" jdbcType="BIGINT" />
  43. <result column="erban_no" property="erbanNo" jdbcType="BIGINT" />
  44. <result column="phone" property="phone" jdbcType="VARCHAR" />
  45. <result column="nick" property="nick" jdbcType="VARCHAR" />
  46. <result column="gender" property="gender"/>
  47. </resultMap>
  48. <sql id="Base_Column_List" >
  49. charge_record_id, uid, room_uid, pingxx_charge_id, charge_prod_id, channel, buss_type,
  50. charge_status, charge_status_desc, amount, total_gold, client_ip, wx_pub_openid,
  51. subject, body, extra, metadata, charge_desc, create_time, update_time
  52. </sql>
  53. <sql id="Query_Column_List" >
  54. c.charge_record_id as charge_record_id, c.pingxx_charge_id as pingxx_charge_id, c.channel as channel,c.buss_type as buss_type,
  55. c.charge_status as charge_status, c.amount as amount, c.total_gold as total_gold, c.client_ip as client_ip,
  56. c.subject as subject,c.charge_desc as charge_desc, c.create_time as create_time, c.update_time as update_time,
  57. u.uid as uid,u.erban_no as erban_no,u.phone as phone ,u.nick as nick,u.os as os,u.gender as gender
  58. </sql>
  59. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  60. select
  61. <include refid="Base_Column_List" />
  62. from charge_record
  63. where charge_record_id = #{chargeRecordId,jdbcType=VARCHAR}
  64. </select>
  65. <insert id="insert" parameterType="com.juxiao.xchat.module.xbd.domain.record.ChargeRecord" >
  66. insert into charge_record (charge_record_id, uid, room_uid,
  67. pingxx_charge_id, charge_prod_id, channel,
  68. buss_type, charge_status, charge_status_desc,
  69. amount, total_gold, client_ip,
  70. wx_pub_openid, subject, body,
  71. extra, metadata, charge_desc,
  72. create_time, update_time)
  73. values (#{chargeRecordId,jdbcType=VARCHAR}, #{uid,jdbcType=BIGINT}, #{roomUid,jdbcType=BIGINT},
  74. #{pingxxChargeId,jdbcType=VARCHAR}, #{chargeProdId,jdbcType=VARCHAR}, #{channel,jdbcType=VARCHAR},
  75. #{bussType,jdbcType=TINYINT}, #{chargeStatus,jdbcType=TINYINT}, #{chargeStatusDesc,jdbcType=VARCHAR},
  76. #{amount,jdbcType=BIGINT}, #{totalGold,jdbcType=BIGINT}, #{clientIp,jdbcType=VARCHAR},
  77. #{wxPubOpenid,jdbcType=VARCHAR}, #{subject,jdbcType=VARCHAR}, #{body,jdbcType=VARCHAR},
  78. #{extra,jdbcType=VARCHAR}, #{metadata,jdbcType=VARCHAR}, #{chargeDesc,jdbcType=VARCHAR},
  79. #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
  80. </insert>
  81. <insert id="insertSelective" parameterType="com.juxiao.xchat.module.xbd.domain.record.ChargeRecord" >
  82. insert into charge_record
  83. <trim prefix="(" suffix=")" suffixOverrides="," >
  84. <if test="chargeRecordId != null" >
  85. charge_record_id,
  86. </if>
  87. <if test="uid != null" >
  88. uid,
  89. </if>
  90. <if test="roomUid != null" >
  91. room_uid,
  92. </if>
  93. <if test="pingxxChargeId != null" >
  94. pingxx_charge_id,
  95. </if>
  96. <if test="chargeProdId != null" >
  97. charge_prod_id,
  98. </if>
  99. <if test="channel != null" >
  100. channel,
  101. </if>
  102. <if test="bussType != null" >
  103. buss_type,
  104. </if>
  105. <if test="chargeStatus != null" >
  106. charge_status,
  107. </if>
  108. <if test="chargeStatusDesc != null" >
  109. charge_status_desc,
  110. </if>
  111. <if test="amount != null" >
  112. amount,
  113. </if>
  114. <if test="totalGold != null" >
  115. total_gold,
  116. </if>
  117. <if test="clientIp != null" >
  118. client_ip,
  119. </if>
  120. <if test="wxPubOpenid != null" >
  121. wx_pub_openid,
  122. </if>
  123. <if test="subject != null" >
  124. subject,
  125. </if>
  126. <if test="body != null" >
  127. body,
  128. </if>
  129. <if test="extra != null" >
  130. extra,
  131. </if>
  132. <if test="metadata != null" >
  133. metadata,
  134. </if>
  135. <if test="chargeDesc != null" >
  136. charge_desc,
  137. </if>
  138. <if test="createTime != null" >
  139. create_time,
  140. </if>
  141. <if test="updateTime != null" >
  142. update_time,
  143. </if>
  144. </trim>
  145. <trim prefix="values (" suffix=")" suffixOverrides="," >
  146. <if test="chargeRecordId != null" >
  147. #{chargeRecordId,jdbcType=VARCHAR},
  148. </if>
  149. <if test="uid != null" >
  150. #{uid,jdbcType=BIGINT},
  151. </if>
  152. <if test="roomUid != null" >
  153. #{roomUid,jdbcType=BIGINT},
  154. </if>
  155. <if test="pingxxChargeId != null" >
  156. #{pingxxChargeId,jdbcType=VARCHAR},
  157. </if>
  158. <if test="chargeProdId != null" >
  159. #{chargeProdId,jdbcType=VARCHAR},
  160. </if>
  161. <if test="channel != null" >
  162. #{channel,jdbcType=VARCHAR},
  163. </if>
  164. <if test="bussType != null" >
  165. #{bussType,jdbcType=TINYINT},
  166. </if>
  167. <if test="chargeStatus != null" >
  168. #{chargeStatus,jdbcType=TINYINT},
  169. </if>
  170. <if test="chargeStatusDesc != null" >
  171. #{chargeStatusDesc,jdbcType=VARCHAR},
  172. </if>
  173. <if test="amount != null" >
  174. #{amount,jdbcType=BIGINT},
  175. </if>
  176. <if test="totalGold != null" >
  177. #{totalGold,jdbcType=BIGINT},
  178. </if>
  179. <if test="clientIp != null" >
  180. #{clientIp,jdbcType=VARCHAR},
  181. </if>
  182. <if test="wxPubOpenid != null" >
  183. #{wxPubOpenid,jdbcType=VARCHAR},
  184. </if>
  185. <if test="subject != null" >
  186. #{subject,jdbcType=VARCHAR},
  187. </if>
  188. <if test="body != null" >
  189. #{body,jdbcType=VARCHAR},
  190. </if>
  191. <if test="extra != null" >
  192. #{extra,jdbcType=VARCHAR},
  193. </if>
  194. <if test="metadata != null" >
  195. #{metadata,jdbcType=VARCHAR},
  196. </if>
  197. <if test="chargeDesc != null" >
  198. #{chargeDesc,jdbcType=VARCHAR},
  199. </if>
  200. <if test="createTime != null" >
  201. #{createTime,jdbcType=TIMESTAMP},
  202. </if>
  203. <if test="updateTime != null" >
  204. #{updateTime,jdbcType=TIMESTAMP},
  205. </if>
  206. </trim>
  207. </insert>
  208. <update id="updateByPrimaryKeySelective" parameterType="com.juxiao.xchat.module.xbd.domain.record.ChargeRecord" >
  209. update charge_record
  210. <set >
  211. <if test="uid != null" >
  212. uid = #{uid,jdbcType=BIGINT},
  213. </if>
  214. <if test="roomUid != null" >
  215. room_uid = #{roomUid,jdbcType=BIGINT},
  216. </if>
  217. <if test="pingxxChargeId != null" >
  218. pingxx_charge_id = #{pingxxChargeId,jdbcType=VARCHAR},
  219. </if>
  220. <if test="chargeProdId != null" >
  221. charge_prod_id = #{chargeProdId,jdbcType=VARCHAR},
  222. </if>
  223. <if test="channel != null" >
  224. channel = #{channel,jdbcType=VARCHAR},
  225. </if>
  226. <if test="bussType != null" >
  227. buss_type = #{bussType,jdbcType=TINYINT},
  228. </if>
  229. <if test="chargeStatus != null" >
  230. charge_status = #{chargeStatus,jdbcType=TINYINT},
  231. </if>
  232. <if test="chargeStatusDesc != null" >
  233. charge_status_desc = #{chargeStatusDesc,jdbcType=VARCHAR},
  234. </if>
  235. <if test="amount != null" >
  236. amount = #{amount,jdbcType=BIGINT},
  237. </if>
  238. <if test="totalGold != null" >
  239. total_gold = #{totalGold,jdbcType=BIGINT},
  240. </if>
  241. <if test="clientIp != null" >
  242. client_ip = #{clientIp,jdbcType=VARCHAR},
  243. </if>
  244. <if test="wxPubOpenid != null" >
  245. wx_pub_openid = #{wxPubOpenid,jdbcType=VARCHAR},
  246. </if>
  247. <if test="subject != null" >
  248. subject = #{subject,jdbcType=VARCHAR},
  249. </if>
  250. <if test="body != null" >
  251. body = #{body,jdbcType=VARCHAR},
  252. </if>
  253. <if test="extra != null" >
  254. extra = #{extra,jdbcType=VARCHAR},
  255. </if>
  256. <if test="metadata != null" >
  257. metadata = #{metadata,jdbcType=VARCHAR},
  258. </if>
  259. <if test="chargeDesc != null" >
  260. charge_desc = #{chargeDesc,jdbcType=VARCHAR},
  261. </if>
  262. <if test="createTime != null" >
  263. create_time = #{createTime,jdbcType=TIMESTAMP},
  264. </if>
  265. <if test="updateTime != null" >
  266. update_time = #{updateTime,jdbcType=TIMESTAMP},
  267. </if>
  268. </set>
  269. where charge_record_id = #{chargeRecordId,jdbcType=VARCHAR}
  270. </update>
  271. <update id="updateByPrimaryKey" parameterType="com.juxiao.xchat.module.xbd.domain.record.ChargeRecord" >
  272. update charge_record
  273. set uid = #{uid,jdbcType=BIGINT},
  274. room_uid = #{roomUid,jdbcType=BIGINT},
  275. pingxx_charge_id = #{pingxxChargeId,jdbcType=VARCHAR},
  276. charge_prod_id = #{chargeProdId,jdbcType=VARCHAR},
  277. channel = #{channel,jdbcType=VARCHAR},
  278. buss_type = #{bussType,jdbcType=TINYINT},
  279. charge_status = #{chargeStatus,jdbcType=TINYINT},
  280. charge_status_desc = #{chargeStatusDesc,jdbcType=VARCHAR},
  281. amount = #{amount,jdbcType=BIGINT},
  282. total_gold = #{totalGold,jdbcType=BIGINT},
  283. client_ip = #{clientIp,jdbcType=VARCHAR},
  284. wx_pub_openid = #{wxPubOpenid,jdbcType=VARCHAR},
  285. subject = #{subject,jdbcType=VARCHAR},
  286. body = #{body,jdbcType=VARCHAR},
  287. extra = #{extra,jdbcType=VARCHAR},
  288. metadata = #{metadata,jdbcType=VARCHAR},
  289. charge_desc = #{chargeDesc,jdbcType=VARCHAR},
  290. create_time = #{createTime,jdbcType=TIMESTAMP},
  291. update_time = #{updateTime,jdbcType=TIMESTAMP}
  292. where charge_record_id = #{chargeRecordId,jdbcType=VARCHAR}
  293. </update>
  294. <select id="selectByChargeTotal" resultType="java.math.BigDecimal">
  295. select sum(c.amount)
  296. from charge_record c LEFT JOIN users u ON c.uid=u.uid
  297. <where>
  298. <include refid="Query_where"></include>
  299. </where>
  300. </select>
  301. <select id="selectUsersByGender" resultType="com.juxiao.xchat.module.xbd.vo.ChargeRecordVO">
  302. select u.gender as gender, COUNT(DISTINCT c.uid) as num
  303. from charge_record c LEFT JOIN users u ON c.uid=u.uid
  304. <where>
  305. <include refid="Query_where"></include>
  306. </where>
  307. group BY u.gender
  308. </select>
  309. <select id="selectChargeRecordByQuery" resultMap="QueryResultMap">
  310. select
  311. <include refid="Query_Column_List" />
  312. from charge_record c LEFT JOIN users u ON c.uid=u.uid
  313. <where>
  314. <include refid="Query_where"></include>
  315. </where>
  316. ORDER BY c.create_time DESC
  317. </select>
  318. <sql id="Query_where">
  319. u.def_user!='3'
  320. <if test="erbanNo!= null">
  321. AND u.erban_no=#{erbanNo}
  322. </if>
  323. <if test="osType != null and osType != ''">
  324. AND u.os=#{osType}
  325. </if>
  326. <if test="recordId != null and recordId != ''">
  327. and c.charge_record_id = #{recordId}
  328. </if>
  329. <if test="pingxxId != null and pingxxId != ''">
  330. and c.pingxx_charge_id = #{pingxxId}
  331. </if>
  332. <if test="gender != null">
  333. AND u.gender=#{gender}
  334. </if>
  335. <if test="chargeType != null and chargeType != ''">
  336. AND c.charge_prod_id=#{chargeType}
  337. </if>
  338. <if test="beginTime != null and beginTime != ''">
  339. AND c.create_time &gt;= #{beginTime}
  340. </if>
  341. <if test="endTime != null and endTime != ''">
  342. AND c.create_time &lt;= #{endTime}
  343. </if>
  344. <if test="payStatus != null">
  345. AND c.charge_status=#{payStatus}
  346. </if>
  347. <if test="payChannel != null and payChannel != ''">
  348. AND c.channel=#{payChannel}
  349. </if>
  350. <choose >
  351. <when test="goldChargeType == 1" >
  352. and not c.charge_prod_id in ('exchange','company')
  353. </when>
  354. <when test="goldChargeType == 2" >
  355. and c.charge_prod_id = 'exchange'
  356. </when>
  357. <when test="goldChargeType == 3" >
  358. and c.charge_prod_id = 'company'
  359. </when>
  360. </choose>
  361. </sql>
  362. <select id="selectChargeAccessData" resultType="com.juxiao.xchat.module.xbd.vo.ChargeAccessData">
  363. select sum(amount) / 100 as total, DATE_FORMAT(update_time,'%Y-%m-%d') as date
  364. from charge_record
  365. where charge_status = 2 and channel <![CDATA[ <> ]]> 'exchange' and date_format(update_time, '%Y%m' ) = date_format(curdate( ) , '%Y%m' )
  366. group by date
  367. </select>
  368. </mapper>