Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

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