后台服务
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.

351 rader
13 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 != statusS ">
  93. and `status` in
  94. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  95. #{sItem}
  96. </foreach>
  97. </if>
  98. <if test=" null != ids ">
  99. and id in
  100. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  101. #{idItem}
  102. </foreach>
  103. </if>
  104. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  105. </sql>
  106. <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  107. select <include refid="allColumns" /> from wx_merchant_subsidy where id = #{id} and tenant_id = #{tenantId}
  108. </select>
  109. <delete id="deleteById" parameterType="java.util.HashMap">
  110. delete from wx_merchant_subsidy where id = #{id} and tenant_id = #{tenantId}
  111. </delete>
  112. <select id="findList" parameterType="com.iformall.domain.po.WxMerchantSubsidy" resultMap="BaseResultMap">
  113. select <include refid="allColumns" /> from wx_merchant_subsidy
  114. <include refid="dynamicWhereConditions" />
  115. </select>
  116. <update id="updateByCond" parameterType="com.iformall.domain.po.WxMerchantSubsidy">
  117. update wx_merchant_subsidy
  118. set `status` = #{status}
  119. where 1=1
  120. <if test=" null != tenantId and '' != tenantId">
  121. and `tenant_id` = #{tenantId}
  122. </if>
  123. <if test=" null != parentTenantId and '' != parentTenantId">
  124. and `parent_tenant_id` = #{parentTenantId}
  125. </if>
  126. <if test=" null != merchantId ">
  127. and `merchant_id`=#{merchantId}
  128. </if>
  129. <if test=" null != bTenantId and '' != bTenantId">
  130. and `b_tenant_id` = #{bTenantId}
  131. </if>
  132. <if test=" null != ids ">
  133. and id in
  134. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  135. #{idItem}
  136. </foreach>
  137. </if>
  138. </update>
  139. <resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.WxMerchantSubsidyVo">
  140. <id column="id" jdbcType="BIGINT" property="id" />
  141. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  142. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  143. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  144. <result column="order_type" jdbcType="INTEGER" property="orderType" />
  145. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  146. <result column="b_tenant_id" jdbcType="VARCHAR" property="bTenantId" />
  147. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" />
  148. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  149. <result column="order_payment" jdbcType="INTEGER" property="orderPayment" />
  150. <result column="receiver_payment" jdbcType="INTEGER" property="receiverPayment" />
  151. <result column="real_payment" jdbcType="INTEGER" property="realPayment" />
  152. <result column="subsidy" jdbcType="INTEGER" property="subsidy" />
  153. <result column="real_subsidy" jdbcType="INTEGER" property="realSubsidy" />
  154. <result column="status" jdbcType="INTEGER" property="status" />
  155. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  156. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  157. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  158. <result column="title" jdbcType="VARCHAR" property="title" />
  159. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  160. <result column="detail" jdbcType="VARCHAR" property="detail" />
  161. <result column="unit" jdbcType="INTEGER" property="unit" />
  162. <result column="remark" jdbcType="VARCHAR" property="remark" />
  163. <result column="name" jdbcType="VARCHAR" property="merchantName" />
  164. <result column="nick_name" jdbcType="VARCHAR" property="nickName" />
  165. <result column="phone" jdbcType="VARCHAR" property="phone" />
  166. <result column="freeze" property="freeze" />
  167. <result column="source" property="source"/>
  168. <result column="type" property="type"/>
  169. </resultMap>
  170. <sql id="allVoColumns">
  171. 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`,
  172. ms.`order_payment`,ms.`receiver_payment`,ms.`real_payment`,
  173. ms.`subsidy`,ms.`real_subsidy`,ms.`status`,ms.`create_date`,ms.`update_date`,
  174. c.`title`,c.`sub_title`,c.`unit`,m.`name`,
  175. cu.`nick_name`, cu.`phone`,ms.freeze
  176. </sql>
  177. <sql id="dynamicVoWhereConditions">
  178. <if test=" null != id ">
  179. and t.`id` = #{id}
  180. </if>
  181. <if test=" null != tenantId and '' != tenantId">
  182. and t.`tenant_id` = #{tenantId}
  183. </if>
  184. <if test=" null != parentTenantId and '' != parentTenantId">
  185. and t.`parent_tenant_id` = #{parentTenantId}
  186. </if>
  187. <if test=" null != orderId ">
  188. and t.`order_id` = #{orderId}
  189. </if>
  190. <if test=" null != orderType ">
  191. and t.`order_type` = #{orderType}
  192. </if>
  193. <if test=" null != merchantId ">
  194. and t.`merchant_id` = #{merchantId}
  195. </if>
  196. <if test=" null != bTenantId and '' != bTenantId">
  197. and t.`b_tenant_id` = #{bTenantId}
  198. </if>
  199. <if test=" null != couponOrderId ">
  200. and t.`coupon_order_id` = #{couponOrderId}
  201. </if>
  202. <if test=" null != couponType ">
  203. and t.`coupon_type` = #{couponType}
  204. </if>
  205. <if test=" null != orderPayment ">
  206. and t.`order_payment` = #{orderPayment}
  207. </if>
  208. <if test=" null != receiverPayment ">
  209. and t.`receiver_payment` = #{receiverPayment}
  210. </if>
  211. <if test=" null != realPayment ">
  212. and t.`real_payment` = #{realPayment}
  213. </if>
  214. <if test=" null != subsidy ">
  215. and t.`subsidy` = #{subsidy}
  216. </if>
  217. <if test=" null != realSubsidy ">
  218. and t.`real_subsidy` = #{realSubsidy}
  219. </if>
  220. <if test=" null != status ">
  221. and t.`status` = #{status}
  222. </if>
  223. <if test=" null != createDate ">
  224. and t.`create_date` = #{createDate}
  225. </if>
  226. <if test=" null != updateDate ">
  227. and t.`update_date` = #{updateDate}
  228. </if>
  229. <if test=" null != startdate and null!=enddate">
  230. and t.`create_date` between #{startdate} and #{enddate}
  231. </if>
  232. <if test=" null != title">
  233. and t.`title` like concat('%', #{title},'%')
  234. </if>
  235. <if test=" null != statusS ">
  236. and t.`status` in
  237. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  238. #{sItem}
  239. </foreach>
  240. </if>
  241. <if test=" null != ids ">
  242. and t.`id` in
  243. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  244. #{idItem}
  245. </foreach>
  246. </if>
  247. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  248. </sql>
  249. <select id="findVoList" parameterType="com.iformall.domain.vo.WxMerchantSubsidyVo" resultMap="VoBaseResultMap">
  250. select ms.id,ms.order_id,m.name,ms.source,ms.type,
  251. ms.create_date create_date,ms.subsidy subsidy,ms.real_subsidy,ms.status,ms.freeze
  252. from wx_merchant_subsidy ms left join wx_merchant m on ms.merchant_id=m.id
  253. where 1=1
  254. <if test=" null != tenantId and '' != tenantId">
  255. and ms.`tenant_id` = #{tenantId}
  256. </if>
  257. <if test=" null != parentTenantId and '' != parentTenantId">
  258. and ms.`parent_tenant_id` = #{parentTenantId}
  259. </if>
  260. <if test=" null != orderId ">
  261. and ms.`order_id` = #{orderId}
  262. </if>
  263. <if test=" null != merchantId ">
  264. and ms.`merchant_id` = #{merchantId}
  265. </if>
  266. <if test=" null != bTenantId and '' != bTenantId">
  267. and ms.`b_tenant_id` = #{bTenantId}
  268. </if>
  269. <if test=" null != source ">
  270. and ms.`source` = #{source}
  271. </if>
  272. <if test=" null != type ">
  273. and ms.`type` = #{type}
  274. </if>
  275. <if test=" null != status">
  276. <choose>
  277. <when test="status==0">
  278. and ms.`status` = #{status}
  279. </when>
  280. <otherwise>
  281. and ms.`status` in (1,2)
  282. </otherwise>
  283. </choose>
  284. </if>
  285. <if test=" null != freeze ">
  286. and ms.`freeze` = #{freeze}
  287. </if>
  288. <if test=" null != startdate and null!=enddate">
  289. and ms.`create_date` between #{startdate} and #{enddate}
  290. </if>
  291. <if test=" null != sortColumns">order by ${sortColumns}</if>
  292. </select>
  293. <select id="sumVoList" parameterType="com.iformall.domain.vo.WxMerchantSubsidyVo" resultType="hashmap">
  294. select ms.`merchant_id` merchantId, m.`name` as merchantName,
  295. IFNULL(sum(ms.`order_payment`),0) as sumOrderPayment,
  296. IFNULL(sum(ms.`receiver_payment`),0) as sumReceiverPayment,
  297. IFNULL(sum(ms.`subsidy`),0) as sumSubsidy,
  298. IFNULL(sum(ms.`real_subsidy`),0) as sumRealSubsidy
  299. from wx_merchant_subsidy ms
  300. left join wx_coupon_order co on co.id = ms.coupon_order_id
  301. left join wx_coupon c on c.id = co.coupon_id
  302. left join wx_merchant m on m.id = ms.merchant_id
  303. <where>
  304. <if test=" null != status ">
  305. and ms.`status` = #{status}
  306. </if>
  307. <if test=" null != merchantId ">
  308. and ms.`merchant_id` = #{merchantId}
  309. </if>
  310. <if test=" null != bTenantId and '' != bTenantId">
  311. and ms.`b_tenant_id` = #{bTenantId}
  312. </if>
  313. <if test=" null != title ">
  314. and c.`title` like concat('%', #{title},'%')
  315. </if>
  316. <if test=" null != statusS ">
  317. and ms.`status` in
  318. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  319. #{sItem}
  320. </foreach>
  321. </if>
  322. <if test=" null != startdate and null!=enddate">
  323. and ms.`create_date` between #{startdate} and #{enddate}
  324. </if>
  325. </where>
  326. group by ms.`merchant_id`
  327. </select>
  328. </mapper>