Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

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