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

304 строки
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.WxCardSpendMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCardSpend">
  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="card_id" jdbcType="BIGINT" property="cardId"/>
  9. <result column="owner_id" jdbcType="BIGINT" property="ownerId"/>
  10. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  11. <result column="order_id" jdbcType="BIGINT" property="orderId"/>
  12. <result column="pos_order_id" jdbcType="BIGINT" property="posOrderId"/>
  13. <result column="deduction_amount" jdbcType="INTEGER" property="deductionAmount"/>
  14. <result column="payment" jdbcType="INTEGER" property="payment"/>
  15. <result column="real_payment" jdbcType="INTEGER" property="realPayment"/>
  16. <result column="subsidy" jdbcType="INTEGER" property="subsidy"/>
  17. <result column="card_remain_amount" jdbcType="INTEGER" property="cardRemainAmount"/>
  18. <result column="card_before_amount" jdbcType="INTEGER" property="cardBeforeAmount"/>
  19. <result column="card_remain_real_amount" jdbcType="INTEGER" property="cardRemainRealAmount"/>
  20. <result column="card_before_real_amount" jdbcType="INTEGER" property="cardBeforeRealAmount"/>
  21. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  22. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  23. <result column="pay_status" jdbcType="INTEGER" property="payStatus"/>
  24. <result column="pay_from" jdbcType="INTEGER" property="payFrom"/>
  25. </resultMap>
  26. <sql id="allColumns">
  27. `id`,`tenant_id`,`parent_tenant_id`,`card_id`,`owner_id`,`merchant_id`,`order_id`,`pos_order_id`,
  28. `deduction_amount`,`payment`,`real_payment`,`subsidy`, `card_remain_amount`,
  29. `card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`,
  30. `create_date`, `update_date`, `pay_status`, `pay_from`
  31. </sql>
  32. <sql id="dynamicWhereConditions">
  33. where 1 = 1
  34. <if test=" null != id ">
  35. and `id` = #{id}
  36. </if>
  37. <if test=" null != tenantId and '' != tenantId">
  38. and `tenant_id` = #{tenantId}
  39. </if>
  40. <if test=" null != parentTenantId and '' != parentTenantId">
  41. and `parent_tenant_id` = #{parentTenantId}
  42. </if>
  43. <if test=" null != cardId ">
  44. and `card_id` = #{cardId}
  45. </if>
  46. <if test=" null != ownerId ">
  47. and `owner_id` = #{ownerId}
  48. </if>
  49. <if test=" null != merchantId ">
  50. and `merchant_id` = #{merchantId}
  51. </if>
  52. <if test=" null != orderId ">
  53. and `order_id` = #{orderId}
  54. </if>
  55. <if test=" null != posOrderId ">
  56. and `pos_order_id` = #{posOrderId}
  57. </if>
  58. <if test=" null != deductionAmount ">
  59. and `deduction_amount` = #{deductionAmount}
  60. </if>
  61. <if test=" null != payment ">
  62. and `payment` = #{payment}
  63. </if>
  64. <if test=" null != realPayment ">
  65. and `real_payment` = #{realPayment}
  66. </if>
  67. <if test=" null != cardRemainAmount ">
  68. and `card_remain_amount` = #{cardRemainAmount}
  69. </if>
  70. <if test=" null != cardBeforeAmount ">
  71. and `card_before_amount` = #{cardBeforeAmount}
  72. </if>
  73. <if test=" null != cardRemainRealAmount ">
  74. and `card_remain_real_amount` = #{cardRemainRealAmount}
  75. </if>
  76. <if test=" null != cardBeforeRealAmount ">
  77. and `card_before_real_amount` = #{cardBeforeRealAmount}
  78. </if>
  79. <if test=" null != createDate ">
  80. and `create_date` = #{createDate}
  81. </if>
  82. <if test=" null != updateDate ">
  83. and `update_date` = #{updateDate}
  84. </if>
  85. <if test=" null != payStatus ">
  86. and `pay_status` = #{payStatus}
  87. </if>
  88. <if test=" null != payFrom ">
  89. and `pay_from` = #{payFrom}
  90. </if>
  91. <if test=" null != startdate">
  92. and `create_date` &gt;= #{startdate}
  93. </if>
  94. <if test="null != enddate">
  95. and `create_date` &lt;= #{enddate}
  96. </if>
  97. <if test=" null != payStatusS ">
  98. and `pay_status` in
  99. <foreach collection="payStatusS" index="index" item="psItem" open="(" separator="," close=")">
  100. #{psItem}
  101. </foreach>
  102. </if>
  103. <if test=" null != cardIdList ">
  104. and `card_id` in
  105. <foreach collection="cardIdList" index="index" item="cardIdItem" open="(" separator="," close=")">
  106. #{cardIdItem}
  107. </foreach>
  108. </if>
  109. <if test=" null != ownerIdList ">
  110. and owner_id in
  111. <foreach collection="ownerIdList" index="index" item="owneridItem" open="(" separator="," close=")">
  112. #{owneridItem}
  113. </foreach>
  114. </if>
  115. <if test=" null != orderIdList ">
  116. and order_id in
  117. <foreach collection="orderIdList" index="index" item="oidItem" open="(" separator="," close=")">
  118. #{oidItem}
  119. </foreach>
  120. </if>
  121. <if test=" null != ids ">
  122. and id in
  123. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  124. #{idItem}
  125. </foreach>
  126. </if>
  127. <if test=" null != sortColumns">order by ${sortColumns}</if>
  128. </sql>
  129. <select id="findList" parameterType="com.iformall.domain.po.WxCardSpend" resultMap="BaseResultMap">
  130. select
  131. <include refid="allColumns"/>
  132. from wx_card_spend
  133. <include refid="dynamicWhereConditions"/>
  134. </select>
  135. <select id="updateByCond" parameterType="com.iformall.domain.po.WxCardSpend">
  136. update wx_card_spend
  137. set `pay_status` = #{payStatus}, `update_date` = #{updateDate}
  138. <where>
  139. <if test=" null != tenantId and '' != tenantId">
  140. and `tenant_id` = #{tenantId}
  141. </if>
  142. <if test=" null != parentTenantId and '' != parentTenantId">
  143. and `parent_tenant_id` = #{parentTenantId}
  144. </if>
  145. <if test=" null != startdate and null!=enddate">
  146. and `create_date` between #{startdate} and #{enddate}
  147. </if>
  148. <if test=" null != ids ">
  149. and id in
  150. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  151. #{idItem}
  152. </foreach>
  153. </if>
  154. </where>
  155. </select>
  156. <delete id="deleteForPrevCancel" parameterType="com.iformall.domain.po.WxCardSpend">
  157. delete from wx_card_spend
  158. where `tenant_id` = #{tenantId} and `id` = #{id} and `pay_status` = #{payStatus}
  159. </delete>
  160. <select id="findCount" parameterType="com.iformall.domain.po.WxCardSpend" resultType="Integer">
  161. select count(*)
  162. from wx_card_spend cs
  163. <if test=" null != businessId ">
  164. inner join wx_merchant m
  165. on m.id = cs.merchant_id
  166. and m.business_id = #{businessId}
  167. <if test=" null != subBusinessId ">
  168. and m.sub_business_id = #{subBusinessId}
  169. </if>
  170. </if>
  171. where 1 = 1
  172. <if test=" null != ownerId ">
  173. and cs.`owner_id` = #{ownerId}
  174. </if>
  175. <if test=" null != tenantId and '' != tenantId">
  176. and cs.`tenant_id` = #{tenantId}
  177. </if>
  178. <if test=" null != parentTenantId and '' != parentTenantId">
  179. and cs.`parent_tenant_id` = #{parentTenantId}
  180. </if>
  181. <if test=" null != startdate and null!=enddate">
  182. and cs.`create_date` between #{startdate} and #{enddate}
  183. </if>
  184. <if test=" 0 == timeSlot">
  185. and date_format(cs.create_date,'%H:%m') &gt;= '06:00'
  186. and date_format(cs.create_date,'%H:%m') &lt; '18:00'
  187. and date_format(cs.create_date,'%w') in (1,2,3,4,5)
  188. </if>
  189. <if test=" 1 == timeSlot">
  190. and ((date_format(cs.create_date,'%H:%m') &gt;= '18:00'
  191. and date_format(cs.create_date,'%w') in (1,2,3,4))
  192. or
  193. ((date_format(cs.create_date,'%H:%m') &lt; '06:00')
  194. and date_format(cs.create_date,'%w') in (1,2,3,4,5)))
  195. </if>
  196. <if test=" 2 == timeSlot">
  197. and date_format(cs.create_date,'%H:%m') &gt;= '06:00'
  198. and date_format(cs.create_date,'%H:%m') &lt; '18:00'
  199. and date_format(cs.create_date,'%w') in (0,6)
  200. </if>
  201. <if test=" 3 == timeSlot">
  202. and ((date_format(cs.create_date,'%H:%m') &gt;= '18:00'
  203. and date_format(cs.create_date,'%w') in (5,6,0))
  204. or
  205. ((date_format(cs.create_date,'%H:%m') &lt; '06:00')
  206. and date_format(cs.create_date,'%w') in (6,0)))
  207. </if>
  208. </select>
  209. <select id="getMerchantCount" parameterType="com.iformall.domain.po.WxCardSpend" resultType="hashmap">
  210. select cs.merchant_id as merchantId, count(1) as count
  211. from wx_card_spend cs
  212. where cs.`owner_id` = #{ownerId} and cs.`tenant_id` = #{tenantId}
  213. <if test=" null != parentTenantId and '' != parentTenantId">
  214. and cs.`parent_tenant_id` = #{parentTenantId}
  215. </if>
  216. <if test=" null != startdate and null!=enddate">
  217. and cs.`create_date` between #{startdate} and #{enddate}
  218. </if>
  219. <if test=" 0 == timeSlot">
  220. and date_format(cs.create_date,'%H:%m') &gt;= '06:00'
  221. and date_format(cs.create_date,'%H:%m') &lt; '18:00'
  222. and date_format(cs.create_date,'%w') in (1,2,3,4,5)
  223. </if>
  224. <if test=" 1 == timeSlot">
  225. and ((date_format(cs.create_date,'%H:%m') &gt;= '18:00'
  226. and date_format(cs.create_date,'%w') in (1,2,3,4))
  227. or
  228. ((date_format(cs.create_date,'%H:%m') &lt; '06:00')
  229. and date_format(cs.create_date,'%w') in (1,2,3,4,5)))
  230. </if>
  231. <if test=" 2 == timeSlot">
  232. and date_format(cs.create_date,'%H:%m') &gt;= '06:00'
  233. and date_format(cs.create_date,'%H:%m') &lt; '18:00'
  234. and date_format(cs.create_date,'%w') in (0,6)
  235. </if>
  236. <if test=" 3 == timeSlot">
  237. and ((date_format(cs.create_date,'%H:%m') &gt;= '18:00'
  238. and date_format(cs.create_date,'%w') in (5,6,0))
  239. or
  240. ((date_format(cs.create_date,'%H:%m') &lt; '06:00')
  241. and date_format(cs.create_date,'%w') in (6,0)))
  242. </if>
  243. group by cs.merchant_id
  244. </select>
  245. <select id="sumMerchant" parameterType="com.iformall.domain.po.WxCardSpend" resultType="hashmap">
  246. select cs.merchant_id
  247. IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount,
  248. IFNULL(SUM(cs.`payment`),0) as sum_payment,
  249. IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment,
  250. IFNULL(SUM(cs.`subsidy`),0) as sum_subsidy
  251. from wx_card_spend cs
  252. <include refid="dynamicWhereConditions"/>
  253. group by cs.merchant_id
  254. </select>
  255. <select id="getMerchantIdList" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="Long">
  256. select distinct cs.merchant_id
  257. from wx_card_spend cs
  258. <include refid="dynamicWhereConditions"/>
  259. </select>
  260. <select id="sumCardSpend" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="hashmap">
  261. select
  262. IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount,
  263. IFNULL(SUM(cs.`payment`),0) as sum_payment,
  264. IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment,
  265. IFNULL(SUM(cs.`subsidy`),0) as sum_subsidy
  266. from wx_card_spend cs
  267. <include refid="dynamicWhereConditions"/>
  268. </select>
  269. <select id="sumRealPayment" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="Integer">
  270. select
  271. IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment
  272. from wx_card_spend cs
  273. where cs.`tenant_id` = #{tenantId}
  274. and cs.`merchant_id` = #{merchantId}
  275. <if test=" null != startdate ">
  276. AND cs.`create_date` &gt;= #{startdate}
  277. </if>
  278. <if test=" null != enddate ">
  279. AND cs.`create_date` &lt;= #{enddate}
  280. </if>
  281. </select>
  282. </mapper>