Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

188 righe
6.3 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`,`credate_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 != operatorId ">
  91. and `operator_id` = #{operatorId}
  92. </if>
  93. <if test=" null != creditType ">
  94. and `credit_type` = #{creditType}
  95. </if>
  96. <if test=" null != cUserId ">
  97. and `c_user_id` = #{cUserId}
  98. </if>
  99. <if test=" null != merchantId ">
  100. and `merchant_id` = #{merchantId}
  101. </if>
  102. </sql>
  103. <select id="findList" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap">
  104. select <include refid="allColumns" /> from wx_credit_history
  105. <include refid="dynamicWhereConditions" />
  106. </select>
  107. <select id="findListMore" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.WxCreditHistoryVo">
  108. SELECT
  109. credit.id creditId,
  110. basic.nick_name name,
  111. basic.phone phone,
  112. basic.sex sex,
  113. credit.tenant_id tenantId,
  114. credit.c_user_id cUserId,
  115. credit.credit_amount creditAmount,
  116. credit.credit_num creditNum,
  117. credit.create_date createDate,
  118. credit.credit_type creditType,
  119. credit.receipt_url receiptUrl,
  120. credit.operator_type operatorType,
  121. credit.operator_id operatorId,
  122. merchant.NAME merchantName,
  123. credit.merchant_id merchantId
  124. FROM
  125. wx_c_user_basic_info basic
  126. INNER JOIN wx_credit_history credit ON basic.id = credit.c_user_id
  127. LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
  128. <include refid="customWhereConditions"/>
  129. ORDER BY
  130. credit.id DESC
  131. </select>
  132. <select id="loginCount" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Integer">
  133. select COUNT(0) from wx_credit_history
  134. where 1=1
  135. <if test=" null != tenantId ">
  136. and `tenant_id` = #{tenantId}
  137. </if>
  138. <if test=" null != cUserId ">
  139. and `c_user_id` = #{cUserId}
  140. </if>
  141. <if test=" null != creditType ">
  142. and `credit_type` = #{creditType}
  143. </if>
  144. and DATEDIFF(`create_date`,now())=0
  145. </select>
  146. <select id="countTodayList" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Integer">
  147. select count(0)
  148. from wx_credit_history
  149. where 1=1
  150. <if test=" null != tenantId ">
  151. and `tenant_id` = #{tenantId}
  152. </if>
  153. <if test=" null != cUserId ">
  154. and `c_user_id` = #{cUserId}
  155. </if>
  156. <if test=" null != creditType ">
  157. and `credit_type` = #{creditType}
  158. </if>
  159. and DATEDIFF(`create_date`,now())=0
  160. </select>
  161. <select id="creditAmount" parameterType="java.lang.Long" resultType="java.lang.Integer">
  162. SELECT credit_amount FROM wx_credit_history where c_user_id = #{cUserId} ORDER BY id desc limit 1
  163. </select>
  164. <select id="countList" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Integer">
  165. select count(0)
  166. from wx_credit_history
  167. where 1=1
  168. <if test=" null != tenantId ">
  169. and `tenant_id` = #{tenantId}
  170. </if>
  171. <if test=" null != cUserId ">
  172. and `c_user_id` = #{cUserId}
  173. </if>
  174. <if test=" null != creditType ">
  175. and `credit_type` = #{creditType}
  176. </if>
  177. </select>
  178. </mapper>