You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

191 lines
6.4 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. </resultMap>
  21. <sql id="allColumns">
  22. `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`
  23. </sql>
  24. <sql id="dynamicWhereConditions">
  25. where 1 = 1
  26. <if test=" null != id ">
  27. and `id` = #{id}
  28. </if>
  29. <if test=" null != cUserId ">
  30. and `c_user_id` = #{cUserId}
  31. </if>
  32. <if test=" null != creditAmount ">
  33. and `credit_amount` = #{creditAmount}
  34. </if>
  35. <if test=" null != creditNum ">
  36. and `credit_num` = #{creditNum}
  37. </if>
  38. <if test=" null != creditType ">
  39. and `credit_type` = #{creditType}
  40. </if>
  41. <if test=" null != receiptUrl ">
  42. and `receipt_url` like concat('%', #{receiptUrl},'%')
  43. </if>
  44. <if test=" null != operatorType ">
  45. and `operator_type` = #{operatorType}
  46. </if>
  47. <if test=" null != operatorId ">
  48. and `operator_id` = #{operatorId}
  49. </if>
  50. <if test=" null != merchantId ">
  51. and `merchant_id` = #{merchantId}
  52. </if>
  53. <if test=" null != couponId ">
  54. and `coupon_id` = #{couponId}
  55. </if>
  56. <if test=" null != businessId ">
  57. and `business_id` = #{businessId}
  58. </if>
  59. <if test=" null != spend ">
  60. and `spend` = #{spend}
  61. </if>
  62. <if test=" null != changePurpose ">
  63. and `change_purpose` = #{changePurpose}
  64. </if>
  65. <if test=" null != ids ">
  66. and id in
  67. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  68. #{idItem}
  69. </foreach>
  70. </if>
  71. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  72. </sql>
  73. <sql id="customWhereConditions">
  74. where 1 = 1
  75. <if test=" null != name and '' != name">
  76. and basic.nick_name like concat('%', #{name},'%')
  77. </if>
  78. <if test=" null != phone and '' != phone">
  79. and basic.phone like concat('%', #{phone},'%')
  80. </if>
  81. <if test=" null != startTime ">
  82. and credit.create_date &gt;= #{startTime}
  83. </if>
  84. <if test=" null != endTime">
  85. and credit.create_date &lt; #{endTime}
  86. </if>
  87. <if test=" null != tenantId ">
  88. and credit.tenant_id = #{tenantId}
  89. </if>
  90. <if test=" null != operatorType ">
  91. and credit.operator_type = #{operatorType}
  92. </if>
  93. <if test=" null != operatorId ">
  94. and credit.operator_id = #{operatorId}
  95. </if>
  96. <if test=" null != creditType ">
  97. and credit.credit_type = #{creditType}
  98. </if>
  99. <if test=" null != cUserId ">
  100. and credit.c_user_id = #{cUserId}
  101. </if>
  102. <if test=" null != merchantId ">
  103. and credit.merchant_id = #{merchantId}
  104. </if>
  105. </sql>
  106. <select id="findList" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap">
  107. select <include refid="allColumns" /> from wx_credit_history
  108. <include refid="dynamicWhereConditions" />
  109. </select>
  110. <select id="findListMore" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.WxCreditHistoryVo">
  111. SELECT
  112. credit.id creditId,
  113. basic.nick_name name,
  114. basic.phone phone,
  115. basic.sex sex,
  116. credit.tenant_id tenantId,
  117. credit.c_user_id cUserId,
  118. credit.credit_amount creditAmount,
  119. credit.credit_num creditNum,
  120. credit.create_date createDate,
  121. credit.credit_type creditType,
  122. credit.receipt_url receiptUrl,
  123. credit.operator_type operatorType,
  124. credit.operator_id operatorId,
  125. merchant.NAME merchantName,
  126. credit.merchant_id merchantId
  127. FROM
  128. wx_c_user_basic_info basic
  129. INNER JOIN wx_credit_history credit ON basic.id = credit.c_user_id
  130. LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
  131. <include refid="customWhereConditions"/>
  132. ORDER BY
  133. credit.id DESC
  134. </select>
  135. <select id="loginCount" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Integer">
  136. select COUNT(0) from wx_credit_history
  137. where 1=1
  138. <if test=" null != tenantId ">
  139. and `tenant_id` = #{tenantId}
  140. </if>
  141. <if test=" null != cUserId ">
  142. and `c_user_id` = #{cUserId}
  143. </if>
  144. <if test=" null != creditType ">
  145. and `credit_type` = #{creditType}
  146. </if>
  147. and DATEDIFF(`create_date`,now())=0
  148. </select>
  149. <select id="countTodayList" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Integer">
  150. select count(0)
  151. from wx_credit_history
  152. where 1=1
  153. <if test=" null != tenantId ">
  154. and `tenant_id` = #{tenantId}
  155. </if>
  156. <if test=" null != cUserId ">
  157. and `c_user_id` = #{cUserId}
  158. </if>
  159. <if test=" null != creditType ">
  160. and `credit_type` = #{creditType}
  161. </if>
  162. and DATEDIFF(`create_date`,now())=0
  163. </select>
  164. <select id="creditAmount" parameterType="java.lang.Long" resultType="java.lang.Integer">
  165. SELECT credit_amount FROM wx_credit_history where c_user_id = #{cUserId} ORDER BY id desc limit 1
  166. </select>
  167. <select id="countList" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Integer">
  168. select count(0)
  169. from wx_credit_history
  170. where 1=1
  171. <if test=" null != tenantId ">
  172. and `tenant_id` = #{tenantId}
  173. </if>
  174. <if test=" null != cUserId ">
  175. and `c_user_id` = #{cUserId}
  176. </if>
  177. <if test=" null != creditType ">
  178. and `credit_type` = #{creditType}
  179. </if>
  180. </select>
  181. </mapper>