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.
 
 
 
 
 

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