OfficialGoldRecordMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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.users.OfficialGoldRecordMapper">
  6. <resultMap id="BaseResultMap" type="com.juxiao.xchat.module.xbd.domain.users.OfficialGoldRecord" >
  7. <id column="record_id" property="recordId" jdbcType="INTEGER" />
  8. <result column="uid" property="uid" jdbcType="BIGINT" />
  9. <result column="gold_num" property="goldNum" jdbcType="BIGINT" />
  10. <result column="type" property="type" jdbcType="TINYINT" />
  11. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  12. <result column="admin_id " property="adminId" jdbcType="INTEGER" />
  13. <result column="remark" property="remark" jdbcType="VARCHAR"/>
  14. </resultMap>
  15. <sql id="Base_Column_List" >
  16. record_id, uid, gold_num, type, create_time, admin_id
  17. </sql>
  18. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  19. select
  20. <include refid="Base_Column_List" />
  21. from official_gold_record
  22. where record_id = #{recordId,jdbcType=INTEGER}
  23. </select>
  24. <insert id="insert" parameterType="com.juxiao.xchat.module.xbd.domain.users.OfficialGoldRecord" >
  25. <selectKey resultType="java.lang.Integer" keyProperty="recordId" order="AFTER" >
  26. SELECT LAST_INSERT_ID()
  27. </selectKey>
  28. insert into official_gold_record (uid, gold_num, type,
  29. create_time, admin_id,remark)
  30. values (#{uid,jdbcType=BIGINT}, #{goldNum,jdbcType=BIGINT}, #{type,jdbcType=TINYINT},
  31. #{createTime,jdbcType=TIMESTAMP}, #{adminId,jdbcType=INTEGER},#{remark,jdbcType=VARCHAR})
  32. </insert>
  33. <insert id="insertSelective" parameterType="com.juxiao.xchat.module.xbd.domain.users.OfficialGoldRecord" >
  34. <selectKey resultType="java.lang.Integer" keyProperty="recordId" order="AFTER" >
  35. SELECT LAST_INSERT_ID()
  36. </selectKey>
  37. insert into official_gold_record
  38. <trim prefix="(" suffix=")" suffixOverrides="," >
  39. <if test="uid != null" >
  40. uid,
  41. </if>
  42. <if test="goldNum != null" >
  43. gold_num,
  44. </if>
  45. <if test="type != null" >
  46. type,
  47. </if>
  48. <if test="createTime != null" >
  49. create_time,
  50. </if>
  51. <if test="adminId != null" >
  52. admin_id,
  53. </if>
  54. <if test="remark != null" >
  55. remark,
  56. </if>
  57. </trim>
  58. <trim prefix="values (" suffix=")" suffixOverrides="," >
  59. <if test="uid != null" >
  60. #{uid,jdbcType=BIGINT},
  61. </if>
  62. <if test="goldNum != null" >
  63. #{goldNum,jdbcType=BIGINT},
  64. </if>
  65. <if test="type != null" >
  66. #{type,jdbcType=TINYINT},
  67. </if>
  68. <if test="createTime != null" >
  69. #{createTime,jdbcType=TIMESTAMP},
  70. </if>
  71. <if test="adminId != null" >
  72. #{adminId,jdbcType=INTEGER},
  73. </if>
  74. <if test="remark != null" >
  75. #{remark,jdbcType=VARCHAR},
  76. </if>
  77. </trim>
  78. </insert>
  79. <update id="updateByPrimaryKeySelective" parameterType="com.juxiao.xchat.module.xbd.domain.users.OfficialGoldRecord" >
  80. update official_gold_record
  81. <set >
  82. <if test="uid != null" >
  83. uid = #{uid,jdbcType=BIGINT},
  84. </if>
  85. <if test="goldNum != null" >
  86. gold_num = #{goldNum,jdbcType=BIGINT},
  87. </if>
  88. <if test="type != null" >
  89. type = #{type,jdbcType=TINYINT},
  90. </if>
  91. <if test="createTime != null" >
  92. create_time = #{createTime,jdbcType=TIMESTAMP},
  93. </if>
  94. <if test="adminId != null">
  95. admin_id = #{adminId, jdbcType=INTEGER},
  96. </if>
  97. <if test="remark != null">
  98. remark = #{adminId, jdbcType=VARCHAR},
  99. </if>
  100. </set>
  101. where record_id = #{recordId,jdbcType=INTEGER}
  102. </update>
  103. <update id="updateByPrimaryKey" parameterType="com.juxiao.xchat.module.xbd.domain.users.OfficialGoldRecord" >
  104. update official_gold_record
  105. set uid = #{uid,jdbcType=BIGINT},
  106. gold_num = #{goldNum,jdbcType=BIGINT},
  107. type = #{type,jdbcType=TINYINT},
  108. create_time = #{createTime,jdbcType=TIMESTAMP},
  109. admin_id = #{adminId, jdbcType=INTEGER},
  110. remark = #{remark, jdbcType=VARCHAR}
  111. where record_id = #{recordId,jdbcType=INTEGER}
  112. </update>
  113. <select id="selectByUidOrType" resultType="com.juxiao.xchat.module.xbd.domain.users.OfficialGoldRecord">
  114. select record_id as recordId,uid,gold_num as goldNum,type,create_time as createTime,admin_id as adminId
  115. from official_gold_record
  116. where uid = #{uid} and type = #{type}
  117. </select>
  118. <select id="selectByOfficialGoldRecord" resultType="com.juxiao.xchat.module.xbd.vo.GiveGoldRecordVO">
  119. SELECT
  120. o.record_id as recordId,
  121. o.gold_num as goldNum,
  122. o.type,
  123. o.uid,
  124. o.create_time as createTime,
  125. o.admin_id as adminId,
  126. u.nick,
  127. u.erban_no as erbanNo,
  128. u.phone,
  129. u.avatar,
  130. su.user_name as adminName,
  131. o.remark
  132. FROM
  133. official_gold_record o
  134. LEFT JOIN users u ON o.uid = u.uid
  135. LEFT JOIN sys_user su ON su.user_id = o.admin_Id
  136. <include refid="record_sql"/>
  137. ORDER BY o.create_time DESC
  138. </select>
  139. <select id="sumChargeTotal" resultType="java.lang.Long">
  140. SELECT ifnull(SUM(o.gold_num),0)
  141. FROM
  142. official_gold_record o
  143. LEFT JOIN users u ON o.uid = u.uid
  144. LEFT JOIN sys_user su ON su.user_id = o.admin_Id
  145. <include refid="record_sql"/>
  146. </select>
  147. <sql id="record_sql">
  148. <where>
  149. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  150. AND o.create_time between #{beginTime} and #{endTime}
  151. </if>
  152. <if test="erBanNo != null">
  153. AND u.erban_no = #{erBanNo}
  154. </if>
  155. <if test="type != null">
  156. AND o.type = #{type}
  157. </if>
  158. <if test="adminName != null and adminName != ''">
  159. AND su.user_name = #{adminName}
  160. </if>
  161. </where>
  162. </sql>
  163. </mapper>