You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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