No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

284 líneas
10 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.WxMerchantSubsidyMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMerchantSubsidy">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  7. <result column="order_type" jdbcType="INTEGER" property="orderType" />
  8. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  9. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" />
  10. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  11. <result column="order_payment" jdbcType="INTEGER" property="orderPayment" />
  12. <result column="receiver_payment" jdbcType="INTEGER" property="receiverPayment" />
  13. <result column="real_payment" jdbcType="INTEGER" property="realPayment" />
  14. <result column="subsidy" jdbcType="INTEGER" property="subsidy" />
  15. <result column="real_subsidy" jdbcType="INTEGER" property="realSubsidy" />
  16. <result column="status" jdbcType="INTEGER" property="status" />
  17. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  18. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  19. <result column="freeze" property="freeze" />
  20. </resultMap>
  21. <sql id="allColumns">
  22. `id`,`order_id`,`order_type`,`merchant_id`,`coupon_order_id`,`coupon_type`,`order_payment`,`receiver_payment`,`real_payment`,`subsidy`,`real_subsidy`,`status`,`create_date`,`update_date`,freeze
  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 != tenantId ">
  30. and `tenant_id` = #{tenantId}
  31. </if>
  32. <if test=" null != orderId ">
  33. and `order_id` = #{orderId}
  34. </if>
  35. <if test=" null != orderType ">
  36. and `order_type` = #{orderType}
  37. </if>
  38. <if test=" null != merchantId ">
  39. and `merchant_id` = #{merchantId}
  40. </if>
  41. <if test=" null != couponOrderId ">
  42. and `coupon_order_id` = #{couponOrderId}
  43. </if>
  44. <if test=" null != couponType ">
  45. and `coupon_type` = #{couponType}
  46. </if>
  47. <if test=" null != orderPayment ">
  48. and `order_payment` = #{orderPayment}
  49. </if>
  50. <if test=" null != receiverPayment ">
  51. and `receiver_payment` = #{receiverPayment}
  52. </if>
  53. <if test=" null != realPayment ">
  54. and `real_payment` = #{realPayment}
  55. </if>
  56. <if test=" null != subsidy ">
  57. and `subsidy` = #{subsidy}
  58. </if>
  59. <if test=" null != realSubsidy ">
  60. and `real_subsidy` = #{realSubsidy}
  61. </if>
  62. <if test=" null != status ">
  63. and `status` = #{status}
  64. </if>
  65. <if test=" null != createDate ">
  66. and `create_date` = #{createDate}
  67. </if>
  68. <if test=" null != updateDate ">
  69. and `update_date` = #{updateDate}
  70. </if>
  71. <if test=" null != startdate and null!=enddate">
  72. and `create_date` between #{startdate} and #{enddate}
  73. </if>
  74. <if test=" null != statusS ">
  75. and `status` in
  76. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  77. #{sItem}
  78. </foreach>
  79. </if>
  80. <if test=" null != ids ">
  81. and id in
  82. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  83. #{idItem}
  84. </foreach>
  85. </if>
  86. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  87. </sql>
  88. <select id="findList" parameterType="com.iformall.domain.po.WxMerchantSubsidy" resultMap="BaseResultMap">
  89. select <include refid="allColumns" /> from wx_merchant_subsidy
  90. <include refid="dynamicWhereConditions" />
  91. </select>
  92. <update id="updateByCond" parameterType="com.iformall.domain.po.WxMerchantSubsidy">
  93. update wx_merchant_subsidy
  94. set `status` = #{status}
  95. where 1=1
  96. <if test=" null != tenantId ">
  97. and `tenant_id`=#{tenantId}
  98. </if>
  99. <if test=" null != merchantId ">
  100. and `merchant_id`=#{merchantId}
  101. </if>
  102. <if test=" null != ids ">
  103. and id in
  104. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  105. #{idItem}
  106. </foreach>
  107. </if>
  108. </update>
  109. <resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.WxMerchantSubsidyVo">
  110. <id column="id" jdbcType="BIGINT" property="id" />
  111. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  112. <result column="order_type" jdbcType="INTEGER" property="orderType" />
  113. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  114. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" />
  115. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  116. <result column="order_payment" jdbcType="INTEGER" property="orderPayment" />
  117. <result column="receiver_payment" jdbcType="INTEGER" property="receiverPayment" />
  118. <result column="real_payment" jdbcType="INTEGER" property="realPayment" />
  119. <result column="subsidy" jdbcType="INTEGER" property="subsidy" />
  120. <result column="real_subsidy" jdbcType="INTEGER" property="realSubsidy" />
  121. <result column="status" jdbcType="INTEGER" property="status" />
  122. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  123. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  124. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  125. <result column="title" jdbcType="VARCHAR" property="title" />
  126. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  127. <result column="detail" jdbcType="VARCHAR" property="detail" />
  128. <result column="unit" jdbcType="INTEGER" property="unit" />
  129. <result column="remark" jdbcType="VARCHAR" property="remark" />
  130. <result column="name" jdbcType="VARCHAR" property="merchantName" />
  131. <result column="nick_name" jdbcType="VARCHAR" property="nickName" />
  132. <result column="phone" jdbcType="VARCHAR" property="phone" />
  133. <result column="freeze" property="freeze" />
  134. </resultMap>
  135. <sql id="allVoColumns">
  136. ms.`id`,ms.`tenant_id`,ms.`order_id`,ms.`order_type`,ms.`merchant_id`,ms.`coupon_order_id`,ms.`coupon_type`,
  137. ms.`order_payment`,ms.`receiver_payment`,ms.`real_payment`,
  138. ms.`subsidy`,ms.`real_subsidy`,ms.`status`,ms.`create_date`,ms.`update_date`,
  139. c.`title`,c.`sub_title`,c.`unit`,m.`name`,
  140. cu.`nick_name`, cu.`phone`,ms.freeze
  141. </sql>
  142. <sql id="dynamicVoWhereConditions">
  143. <if test=" null != id ">
  144. and t.`id` = #{id}
  145. </if>
  146. <if test=" null != tenantId ">
  147. and t.`tenant_id` = #{tenantId}
  148. </if>
  149. <if test=" null != orderId ">
  150. and t.`order_id` = #{orderId}
  151. </if>
  152. <if test=" null != orderType ">
  153. and t.`order_type` = #{orderType}
  154. </if>
  155. <if test=" null != merchantId ">
  156. and t.`merchant_id` = #{merchantId}
  157. </if>
  158. <if test=" null != couponOrderId ">
  159. and t.`coupon_order_id` = #{couponOrderId}
  160. </if>
  161. <if test=" null != couponType ">
  162. and t.`coupon_type` = #{couponType}
  163. </if>
  164. <if test=" null != orderPayment ">
  165. and t.`order_payment` = #{orderPayment}
  166. </if>
  167. <if test=" null != receiverPayment ">
  168. and t.`receiver_payment` = #{receiverPayment}
  169. </if>
  170. <if test=" null != realPayment ">
  171. and t.`real_payment` = #{realPayment}
  172. </if>
  173. <if test=" null != subsidy ">
  174. and t.`subsidy` = #{subsidy}
  175. </if>
  176. <if test=" null != realSubsidy ">
  177. and t.`real_subsidy` = #{realSubsidy}
  178. </if>
  179. <if test=" null != status ">
  180. and t.`status` = #{status}
  181. </if>
  182. <if test=" null != createDate ">
  183. and t.`create_date` = #{createDate}
  184. </if>
  185. <if test=" null != updateDate ">
  186. and t.`update_date` = #{updateDate}
  187. </if>
  188. <if test=" null != startdate and null!=enddate">
  189. and t.`create_date` between #{startdate} and #{enddate}
  190. </if>
  191. <if test=" null != title">
  192. and t.`title` like concat('%', #{title},'%')
  193. </if>
  194. <if test=" null != statusS ">
  195. and t.`status` in
  196. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  197. #{sItem}
  198. </foreach>
  199. </if>
  200. <if test=" null != ids ">
  201. and t.`id` in
  202. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  203. #{idItem}
  204. </foreach>
  205. </if>
  206. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  207. </sql>
  208. <select id="findVoList" parameterType="com.iformall.domain.vo.WxMerchantSubsidyVo" resultMap="VoBaseResultMap">
  209. select * from
  210. (
  211. select <include refid="allVoColumns" />
  212. from wx_merchant_subsidy ms
  213. left join wx_coupon_order co on co.id = ms.coupon_order_id
  214. left join wx_coupon c on c.id = co.coupon_id
  215. left join wx_merchant m on m.id = ms.merchant_id
  216. left join wx_card_spend cs on cs.order_id = ms.order_id
  217. left join wx_c_user cu on cu.id = cs.owner_id
  218. where ms.order_type = 3
  219. union
  220. select <include refid="allVoColumns" />
  221. from wx_merchant_subsidy ms
  222. left join wx_coupon_order co on co.id = ms.coupon_order_id
  223. left join wx_coupon c on c.id = co.coupon_id
  224. left join wx_merchant m on m.id = ms.merchant_id
  225. left join wx_order o on o.id = ms.order_id
  226. left join wx_c_user cu on cu.id = o.c_user_id
  227. where ms.order_type = 0
  228. ) t
  229. where 1=1
  230. <include refid="dynamicVoWhereConditions" />
  231. </select>
  232. <select id="sumVoList" parameterType="com.iformall.domain.vo.WxMerchantSubsidyVo" resultType="hashmap">
  233. select ms.`merchant_id` merchantId, m.`name` as merchantName,
  234. IFNULL(sum(ms.`order_payment`),0) as sumOrderPayment,
  235. IFNULL(sum(ms.`receiver_payment`),0) as sumReceiverPayment,
  236. IFNULL(sum(ms.`subsidy`),0) as sumSubsidy,
  237. IFNULL(sum(ms.`real_subsidy`),0) as sumRealSubsidy
  238. from wx_merchant_subsidy ms
  239. left join wx_coupon_order co on co.id = ms.coupon_order_id
  240. left join wx_coupon c on c.id = co.coupon_id
  241. left join wx_merchant m on m.id = ms.merchant_id
  242. <where>
  243. <if test=" null != status ">
  244. and ms.`status` = #{status}
  245. </if>
  246. <if test=" null != merchantId ">
  247. and ms.`merchant_id` = #{merchantId}
  248. </if>
  249. <if test=" null != title ">
  250. and c.`title` like concat('%', #{title},'%')
  251. </if>
  252. <if test=" null != statusS ">
  253. and ms.`status` in
  254. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  255. #{sItem}
  256. </foreach>
  257. </if>
  258. <if test=" null != startdate and null!=enddate">
  259. and ms.`create_date` between #{startdate} and #{enddate}
  260. </if>
  261. </where>
  262. group by ms.`merchant_id`
  263. </select>
  264. </mapper>