Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

264 строки
9.5 KiB

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.iformall.mapper.WxCreditHistoryMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCreditHistory">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  8. <result column="credit_amount" jdbcType="INTEGER" property="creditAmount" />
  9. <result column="credit_num" jdbcType="INTEGER" property="creditNum" />
  10. <result column="credit_type" jdbcType="INTEGER" property="creditType" />
  11. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  12. <result column="receipt_url" jdbcType="VARCHAR" property="receiptUrl" />
  13. <result column="operator_type" jdbcType="INTEGER" property="operatorType" />
  14. <result column="operator_id" jdbcType="BIGINT" property="operatorId" />
  15. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  16. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  17. <result column="business_id" jdbcType="BIGINT" property="businessId" />
  18. <result column="spend" jdbcType="INTEGER" property="spend" />
  19. <result column="change_purpose" jdbcType="VARCHAR" property="changePurpose" />
  20. <result column="ticket_number" jdbcType="VARCHAR" property="ticketNumber"/>
  21. <result column="buser_id" jdbcType="BIGINT" property="buserId"/>
  22. </resultMap>
  23. <sql id="allColumns">
  24. `id`,`tenant_id`,`c_user_id`,`credit_amount`,`credit_num`,`credit_type`,`create_date`,`receipt_url`,`operator_type`,`operator_id`,`merchant_id`,`coupon_id`,`business_id`,`spend`,`change_purpose`,`ticket_number`,`buser_id`
  25. </sql>
  26. <sql id="dynamicWhereConditions">
  27. where 1 = 1
  28. <if test=" null != id ">
  29. and `id` = #{id}
  30. </if>
  31. <if test=" null != cUserId ">
  32. and `c_user_id` = #{cUserId}
  33. </if>
  34. <if test=" null != creditAmount ">
  35. and `credit_amount` = #{creditAmount}
  36. </if>
  37. <if test=" null != creditNum ">
  38. and `credit_num` = #{creditNum}
  39. </if>
  40. <if test=" null != creditType ">
  41. and `credit_type` = #{creditType}
  42. </if>
  43. <if test=" null != receiptUrl ">
  44. and `receipt_url` like concat('%', #{receiptUrl},'%')
  45. </if>
  46. <if test=" null != operatorType ">
  47. and `operator_type` = #{operatorType}
  48. </if>
  49. <if test=" null != operatorId ">
  50. and `operator_id` = #{operatorId}
  51. </if>
  52. <if test=" null != merchantId ">
  53. and `merchant_id` = #{merchantId}
  54. </if>
  55. <if test=" null != couponId ">
  56. and `coupon_id` = #{couponId}
  57. </if>
  58. <if test=" null != businessId ">
  59. and `business_id` = #{businessId}
  60. </if>
  61. <if test=" null != spend ">
  62. and `spend` = #{spend}
  63. </if>
  64. <if test=" null != changePurpose ">
  65. and `change_purpose` = #{changePurpose}
  66. </if>
  67. <if test=" null != ticketNumber and ''!=ticketNumber ">
  68. and ticket_number like concat('%', #{ticketNumber},'%')
  69. </if>
  70. <if test=" null != buserId ">
  71. and `buser_id` = #{buserId}
  72. </if>
  73. <if test=" null != ids ">
  74. and id in
  75. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  76. #{idItem}
  77. </foreach>
  78. </if>
  79. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  80. </sql>
  81. <sql id="customWhereConditions">
  82. where 1 = 1
  83. <if test=" null != name and '' != name">
  84. and basic.nick_name like concat('%', #{name},'%')
  85. </if>
  86. <if test=" null != phone and '' != phone">
  87. and basic.phone like concat('%', #{phone},'%')
  88. </if>
  89. <if test=" null != startTime ">
  90. and credit.create_date &gt;= #{startTime}
  91. </if>
  92. <if test=" null != endTime">
  93. and credit.create_date &lt; #{endTime}
  94. </if>
  95. <if test=" null != tenantId ">
  96. and credit.tenant_id = #{tenantId}
  97. </if>
  98. <if test=" null != operatorType ">
  99. and credit.operator_type = #{operatorType}
  100. </if>
  101. <if test=" null != operatorId ">
  102. and credit.operator_id = #{operatorId}
  103. </if>
  104. <if test=" null != creditType ">
  105. and credit.credit_type = #{creditType}
  106. </if>
  107. <if test=" null != cUserId ">
  108. and credit.c_user_id = #{cUserId}
  109. </if>
  110. <if test=" null != merchantId ">
  111. and credit.merchant_id = #{merchantId}
  112. </if>
  113. <if test=" null != merchantName and ''!=merchantName ">
  114. and merchant.name like concat('%', #{merchantName},'%')
  115. </if>
  116. <if test=" null != ticketNumber and ''!=ticketNumber ">
  117. and credit.ticket_number like concat('%', #{ticketNumber},'%')
  118. </if>
  119. <if test=" null != buserId ">
  120. and credit.buser_id = #{buserId}
  121. </if>
  122. </sql>
  123. <select id="findList" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap">
  124. select <include refid="allColumns" /> from wx_credit_history
  125. <include refid="dynamicWhereConditions" />
  126. </select>
  127. <select id="findListMore" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.WxCreditHistoryVo">
  128. SELECT
  129. credit.id creditId,
  130. case when basic.nick_name is null then basic.name else basic.nick_name end name,
  131. basic.phone phone,
  132. basic.sex sex,
  133. credit.tenant_id tenantId,
  134. credit.c_user_id cUserId,
  135. credit.credit_amount creditAmount,
  136. credit.credit_num creditNum,
  137. credit.create_date createDate,
  138. credit.credit_type creditType,
  139. credit.receipt_url receiptUrl,
  140. credit.operator_type operatorType,
  141. credit.operator_id operatorId,
  142. merchant.NAME merchantName,
  143. credit.merchant_id merchantId,
  144. credit.ticket_number ticketNumber,
  145. case when credit.operator_type=4 then (select name from mall_user_info where id=credit.operator_id)
  146. when credit.operator_type=3 then (select name from wx_merchant_b_user where id=credit.operator_id)
  147. when credit.operator_type=1 then (select nick_name from wx_c_user where id=credit.operator_id)
  148. else '' end operator
  149. FROM
  150. wx_c_user_basic_info basic
  151. INNER JOIN wx_credit_history credit ON basic.id = credit.c_user_id
  152. LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
  153. <include refid="customWhereConditions"/>
  154. ORDER BY
  155. credit.create_date desc,credit.id DESC
  156. </select>
  157. <select id="loginCount" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Integer">
  158. select COUNT(0) from wx_credit_history
  159. where 1=1
  160. <if test=" null != tenantId ">
  161. and `tenant_id` = #{tenantId}
  162. </if>
  163. <if test=" null != cUserId ">
  164. and `c_user_id` = #{cUserId}
  165. </if>
  166. <if test=" null != creditType ">
  167. and `credit_type` = #{creditType}
  168. </if>
  169. and DATEDIFF(`create_date`,now())=0
  170. </select>
  171. <select id="countTodayList" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Integer">
  172. select count(0)
  173. from wx_credit_history
  174. where 1=1
  175. <if test=" null != tenantId ">
  176. and `tenant_id` = #{tenantId}
  177. </if>
  178. <if test=" null != cUserId ">
  179. and `c_user_id` = #{cUserId}
  180. </if>
  181. <if test=" null != creditType ">
  182. and `credit_type` = #{creditType}
  183. </if>
  184. and DATEDIFF(`create_date`,now())=0
  185. </select>
  186. <select id="creditAmount" parameterType="java.lang.Long" resultType="java.lang.Integer">
  187. SELECT credit_amount FROM wx_credit_history where c_user_id = #{cUserId} ORDER BY id desc limit 1
  188. </select>
  189. <select id="countList" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Integer">
  190. select count(0)
  191. from wx_credit_history
  192. where 1=1
  193. <if test=" null != tenantId ">
  194. and `tenant_id` = #{tenantId}
  195. </if>
  196. <if test=" null != cUserId ">
  197. and `c_user_id` = #{cUserId}
  198. </if>
  199. <if test=" null != creditType ">
  200. and `credit_type` = #{creditType}
  201. </if>
  202. </select>
  203. <update id="updateNewId" parameterType="com.iformall.domain.vo.WxCreditHistoryNewIdVo">
  204. update wx_credit_history
  205. set c_user_id=#{newUserId}
  206. where tenant_id=#{tenantId}
  207. and c_user_id = #{cUserId}
  208. </update>
  209. <select id="getTotalCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory"
  210. resultType="java.lang.Long">
  211. select ifnull(sum(credit.amount),0) amount from (
  212. select basic.credit as amount,credit.c_user_id from wx_credit_history credit
  213. INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id
  214. LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
  215. <include refid="customWhereConditions"/>
  216. group by credit.c_user_id
  217. ) credit
  218. </select>
  219. <select id="getIncrementCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory"
  220. resultType="java.lang.Long">
  221. select ifnull(sum(credit.credit_num),0) amount from wx_credit_history credit
  222. INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id
  223. LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
  224. <include refid="customWhereConditions"/>
  225. and credit.credit_num>0
  226. </select>
  227. <select id="getDecrementCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory"
  228. resultType="java.lang.Long">
  229. select ABS(ifnull(sum(credit.credit_num),0)) amount from wx_credit_history credit
  230. INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id
  231. LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
  232. <include refid="customWhereConditions"/>
  233. and credit.credit_num &lt; 0
  234. </select>
  235. <select id="getPeopleCount" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Long">
  236. select count(*) people from (
  237. select count(*) people from wx_credit_history credit
  238. INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id
  239. LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
  240. <include refid="customWhereConditions"/>
  241. group by credit.c_user_id
  242. ) credit
  243. </select>
  244. </mapper>