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.
 
 
 
 
 

218 righe
8.6 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.WxCardSpendMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCardSpend">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="card_id" jdbcType="BIGINT" property="cardId" />
  8. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  9. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  10. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  11. <result column="deduction_amount" jdbcType="INTEGER" property="deductionAmount" />
  12. <result column="payment" jdbcType="INTEGER" property="payment" />
  13. <result column="real_payment" jdbcType="INTEGER" property="realPayment" />
  14. <result column="card_remain_amount" jdbcType="INTEGER" property="cardRemainAmount" />
  15. <result column="card_before_amount" jdbcType="INTEGER" property="cardBeforeAmount" />
  16. <result column="card_remain_real_amount" jdbcType="INTEGER" property="cardRemainRealAmount" />
  17. <result column="card_before_real_amount" jdbcType="INTEGER" property="cardBeforeRealAmount" />
  18. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  19. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  20. </resultMap>
  21. <sql id="allColumns">
  22. `id`,`tenant_id`,`card_id`,`owner_id`,`merchant_id`,`order_id`,`deduction_amount`,`payment`,`real_payment`,
  23. `card_remain_amount`,`card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`,`create_date`,`update_date`
  24. </sql>
  25. <sql id="dynamicWhereConditions">
  26. where 1 = 1
  27. <if test=" null != id ">
  28. and `id` = #{id}
  29. </if>
  30. <if test=" null != tenantId ">
  31. and `tenant_id` = #{tenantId}
  32. </if>
  33. <if test=" null != cardId ">
  34. and `card_id` = #{cardId}
  35. </if>
  36. <if test=" null != ownerId ">
  37. and `owner_id` = #{ownerId}
  38. </if>
  39. <if test=" null != merchantId ">
  40. and `merchant_id` = #{merchantId}
  41. </if>
  42. <if test=" null != orderId ">
  43. and `order_id` = #{orderId}
  44. </if>
  45. <if test=" null != deductionAmount ">
  46. and `deduction_amount` = #{deductionAmount}
  47. </if>
  48. <if test=" null != payment ">
  49. and `payment` = #{payment}
  50. </if>
  51. <if test=" null != realPayment ">
  52. and `real_payment` = #{realPayment}
  53. </if>
  54. <if test=" null != cardRemainAmount ">
  55. and `card_remain_amount` = #{cardRemainAmount}
  56. </if>
  57. <if test=" null != cardBeforeAmount ">
  58. and `card_before_amount` = #{cardBeforeAmount}
  59. </if>
  60. <if test=" null != cardRemainRealAmount ">
  61. and `card_remain_real_amount` = #{cardRemainRealAmount}
  62. </if>
  63. <if test=" null != cardBeforeRealAmount ">
  64. and `card_before_real_amount` = #{cardBeforeRealAmount}
  65. </if>
  66. <if test=" null != createDate ">
  67. and `create_date` = #{createDate}
  68. </if>
  69. <if test=" null != updateDate ">
  70. and `update_date` = #{updateDate}
  71. </if>
  72. <if test=" null != startdate and null!=enddate">
  73. and `create_date` between #{startdate} and #{enddate}
  74. </if>
  75. <if test=" null != ids ">
  76. and id in
  77. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  78. #{idItem}
  79. </foreach>
  80. </if>
  81. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  82. </sql>
  83. <select id="findList" parameterType="com.iformall.domain.po.WxCardSpend" resultMap="BaseResultMap">
  84. select <include refid="allColumns" /> from wx_card_spend
  85. <include refid="dynamicWhereConditions" />
  86. </select>
  87. <resultMap id="VoResultMap" type="com.iformall.domain.vo.WxCardSpendVo">
  88. <id column="id" jdbcType="BIGINT" property="id" />
  89. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  90. <result column="card_id" jdbcType="BIGINT" property="cardId" />
  91. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  92. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  93. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  94. <result column="deduction_amount" jdbcType="INTEGER" property="deductionAmount" />
  95. <result column="payment" jdbcType="INTEGER" property="payment" />
  96. <result column="real_payment" jdbcType="INTEGER" property="realPayment" />
  97. <result column="card_remain_amount" jdbcType="INTEGER" property="cardRemainAmount" />
  98. <result column="card_before_amount" jdbcType="INTEGER" property="cardBeforeAmount" />
  99. <result column="card_remain_real_amount" jdbcType="INTEGER" property="cardRemainRealAmount" />
  100. <result column="card_before_real_amount" jdbcType="INTEGER" property="cardBeforeRealAmount" />
  101. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  102. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  103. <result column="title" jdbcType="VARCHAR" property="title"/>
  104. <result column="name" jdbcType="VARCHAR" property="merchantName"/>
  105. <result column="subsidy" jdbcType="INTEGER" property="subsidy" />
  106. <result column="real_subsidy" jdbcType="INTEGER" property="realSubsidy" />
  107. <result column="status" jdbcType="INTEGER" property="status" />
  108. <result column="onick_name" jdbcType="VARCHAR" property="onickName"/>
  109. <result column="ou_phone" jdbcType="VARCHAR" property="ouPhone"/>
  110. </resultMap>
  111. <sql id="allVoColumns">
  112. cs.`id`,cs.`tenant_id`,cs.`card_id`,cs.`owner_id`,cs.`merchant_id`,cs.`order_id`,cs.`deduction_amount`,cs.`payment`,cs.`real_payment`,
  113. cs.`card_remain_amount`,cs.`card_before_amount`,cs.`card_remain_real_amount`,cs.`card_before_real_amount`,cs.`create_date`,cs.`update_date`,
  114. m.`name`, c.`title`,
  115. ms.`subsidy`,ms.`real_subsidy`,ms.`status`,
  116. ou.`nick_name` as onick_name, ou.`phone` as ou_phone
  117. </sql>
  118. <sql id="dynamicVoWhereConditions">
  119. where 1 = 1
  120. <if test=" null != id ">
  121. and cs.`id` = #{id}
  122. </if>
  123. <if test=" null != tenantId ">
  124. and cs.`tenant_id` = #{tenantId}
  125. </if>
  126. <if test=" null != cardId ">
  127. and cs.`card_id` = #{cardId}
  128. </if>
  129. <if test=" null != ownerId ">
  130. and cs.`owner_id` = #{ownerId}
  131. </if>
  132. <if test=" null != merchantId ">
  133. and cs.`merchant_id` = #{merchantId}
  134. </if>
  135. <if test=" null != orderId ">
  136. and cs.`order_id` = #{orderId}
  137. </if>
  138. <if test=" null != deductionAmount ">
  139. and cs.`deduction_amount` = #{deductionAmount}
  140. </if>
  141. <if test=" null != payment ">
  142. and cs.`payment` = #{payment}
  143. </if>
  144. <if test=" null != realPayment ">
  145. and cs.`real_payment` = #{realPayment}
  146. </if>
  147. <if test=" null != cardRemainAmount ">
  148. and cs.`card_remain_amount` = #{cardRemainAmount}
  149. </if>
  150. <if test=" null != cardBeforeAmount ">
  151. and cs.`card_before_amount` = #{cardBeforeAmount}
  152. </if>
  153. <if test=" null != cardRemainRealAmount ">
  154. and cs.`card_remain_real_amount` = #{cardRemainRealAmount}
  155. </if>
  156. <if test=" null != cardBeforeRealAmount ">
  157. and cs.`card_before_real_amount` = #{cardBeforeRealAmount}
  158. </if>
  159. <if test=" null != createDate ">
  160. and cs.`create_date` = #{createDate}
  161. </if>
  162. <if test=" null != updateDate ">
  163. and cs.`update_date` = #{updateDate}
  164. </if>
  165. <if test=" null != ouPhone ">
  166. and ou.`phone` = #{ouPhone}
  167. </if>
  168. <if test=" null != startdate and null!=enddate">
  169. and cs.`create_date` between #{startdate} and #{enddate}
  170. </if>
  171. <if test=" null != ids ">
  172. and cs.id in
  173. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  174. #{idItem}
  175. </foreach>
  176. </if>
  177. </sql>
  178. <select id="findCardSpendVoList" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultMap="VoResultMap">
  179. select
  180. <include refid="allVoColumns"/>
  181. from wx_card_spend cs
  182. left join wx_coupon_order co on co.id = cs.card_id
  183. left join wx_coupon c on c.id = co.coupon_id
  184. left join wx_merchant m on m.id = cs.merchant_id
  185. left join wx_merchant_subsidy ms on ms.order_id = cs.order_id
  186. left join wx_c_user ou on ou.id = co.owner_id
  187. <include refid="dynamicVoWhereConditions" />
  188. </select>
  189. <select id="sumCardSpendVo" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="hashmap">
  190. select
  191. IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount,
  192. IFNULL(SUM(cs.`payment`),0) as sum_payment,
  193. IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment
  194. from wx_card_spend cs
  195. left join wx_coupon_order co on co.id = cs.card_id
  196. left join wx_coupon c on c.id = co.coupon_id
  197. left join wx_merchant m on m.id = cs.merchant_id
  198. left join wx_merchant_subsidy ms on ms.order_id = cs.order_id
  199. left join wx_c_user ou on ou.id = co.owner_id
  200. <include refid="dynamicVoWhereConditions" />
  201. </select>
  202. </mapper>