Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

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