Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

209 righe
9.6 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.WxBillSettleBillMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillSettleBill">
  5. <id column="id" property="id"/>
  6. <result column="tenant_id" property="tenantId"/>
  7. <result column="settle_id" property="settleId"/>
  8. <result column="type" property="type"/>
  9. <result column="bill_id" property="billId"/>
  10. <result column="bill_type" property="billType"/>
  11. <result column="createtime" property="createtime"/>
  12. <result column="updatetime" property="updatetime"/>
  13. <result column="billName" property="billName"/>
  14. <result column="receivePay" property="receivePay"/>
  15. <result column="starttime" property="starttime"/>
  16. <result column="endtime" property="endtime"/>
  17. </resultMap>
  18. <sql id="allColumns">
  19. `id`,`tenant_id`,`settle_id`,`type`,`bill_id`,`bill_type`
  20. ,`createtime`,`updatetime`
  21. </sql>
  22. <sql id="dynamicWhereConditions">
  23. where 1=1
  24. <if test=" null != id ">and `id` = #{id}</if>
  25. <if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if>
  26. <if test=" null != ids ">
  27. and id in
  28. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  29. #{idItem}
  30. </foreach>
  31. </if>
  32. <if test=" null != sortColumns">order by ${sortColumns}</if>
  33. </sql>
  34. <select id="findBySettleId" parameterType="com.iformall.domain.po.WxBillSettleBill" resultMap="BaseResultMap">
  35. select bl.`type`,bill.starttime,bill.endtime,bl.bill_id,bl.bill_type,bill.bill_type billName,IFNULL(bill.owe,0) receivePay
  36. from wx_bill_settle_bill bl left join
  37. (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金-租金'
  38. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_rent where is_preview = 0
  39. union all
  40. select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金-租赁押金'
  41. bill_type,need_pay,receive_pay,pay,
  42. <choose>
  43. <when test="1==type">
  44. receive_pay owe
  45. </when>
  46. <otherwise>
  47. owe
  48. </otherwise>
  49. </choose>
  50. ,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from
  51. wx_bill_rent_deposit
  52. union all
  53. select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费-物业费'
  54. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from
  55. wx_bill_property where is_preview = 0
  56. union all
  57. select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金-物业押金'
  58. bill_type,need_pay,receive_pay,pay,
  59. <choose>
  60. <when test="1==type">
  61. receive_pay owe
  62. </when>
  63. <otherwise>
  64. owe
  65. </otherwise>
  66. </choose>
  67. ,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from
  68. wx_bill_property_deposit
  69. union all
  70. select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费-水费' bill_type,0 as
  71. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where
  72. type=1
  73. union all
  74. select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费-电费' bill_type,0 as
  75. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where
  76. type=2
  77. union all
  78. select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费-空调费' bill_type,0 as
  79. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where
  80. type=3
  81. union all
  82. select id,merchant_id,shop_id,tenant_id,7 bill_type_value,concat('其他费用-',name) as bill_type,0 as
  83. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_other
  84. union all
  85. select id,merchant_id,shop_id,tenant_id,8 bill_type_value,concat('其他押金-',comments) as bill_type,0 as
  86. need_pay,receive_pay,pay,
  87. <choose>
  88. <when test="1==type">
  89. receive_pay owe
  90. </when>
  91. <otherwise>
  92. owe
  93. </otherwise>
  94. </choose>
  95. ,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_other_deposit
  96. union all
  97. select id, id merchant_id,'' shop_id,tenant_id,10 bill_type_value,'补贴-补贴' bill_type,0 as
  98. need_pay,subsidy receive_pay,0 pay,subsidy owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type,'' starttime,'' endtime from wx_merchant_subsidy
  99. ) bill
  100. on(bl.bill_id = bill.id)
  101. where 1=1
  102. <if test=" null != billId ">and bill.`id` = #{billId}</if>
  103. <if test=" null != tenantId ">and bl.`tenant_id` = #{tenantId}</if>
  104. <if test=" null != settleId ">and bl.`settle_id` = #{settleId}</if>
  105. <if test=" null != type ">and bl.`type` = #{type}</if>
  106. </select>
  107. <!--同上面的sql-->
  108. <select id="findByBillId" parameterType="com.iformall.domain.po.WxBillSettleBill" resultMap="BaseResultMap">
  109. select bill.bill_type billName,bill.owe receivePay FROM
  110. (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金-租金'
  111. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_rent where is_preview = 0
  112. union all
  113. select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金-租赁押金'
  114. bill_type,need_pay,receive_pay,pay,
  115. <choose>
  116. <when test="1==type">
  117. receive_pay owe
  118. </when>
  119. <otherwise>
  120. owe
  121. </otherwise>
  122. </choose>
  123. ,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from
  124. wx_bill_rent_deposit
  125. union all
  126. select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费-物业费'
  127. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from
  128. wx_bill_property where is_preview = 0
  129. union all
  130. select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金-物业押金'
  131. bill_type,need_pay,receive_pay,pay,
  132. <choose>
  133. <when test="1==type">
  134. receive_pay owe
  135. </when>
  136. <otherwise>
  137. owe
  138. </otherwise>
  139. </choose>
  140. ,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from
  141. wx_bill_property_deposit
  142. union all
  143. select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费-水费' bill_type,0 as
  144. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where
  145. type=1
  146. union all
  147. select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费-电费' bill_type,0 as
  148. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where
  149. type=2
  150. union all
  151. select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费-空调费' bill_type,0 as
  152. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where
  153. type=3
  154. union all
  155. select id,merchant_id,shop_id,tenant_id,7 bill_type_value,concat('其他费用-',name) as bill_type,0 as
  156. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_other
  157. union all
  158. select id,merchant_id,shop_id,tenant_id,8 bill_type_value,concat('其他押金-',comments) as bill_type,0 as
  159. need_pay,receive_pay,pay,
  160. <choose>
  161. <when test="1==type">
  162. receive_pay owe
  163. </when>
  164. <otherwise>
  165. owe
  166. </otherwise>
  167. </choose>
  168. ,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_other_deposit
  169. union all
  170. select id, id merchant_id,'' shop_id,tenant_id,10 bill_type_value,'补贴-补贴' bill_type,0 as
  171. need_pay,subsidy receive_pay,0 pay,subsidy owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type,'' starttime,'' endtime from wx_merchant_subsidy
  172. ) bill
  173. where 1=1
  174. <if test=" null != billId ">and bill.`id` = #{billId}</if>
  175. </select>
  176. <update id="delBySettleId" parameterType="com.iformall.domain.po.WxBillSettle">
  177. delete from wx_bill_settle_bill where settle_id = #{id}
  178. </update>
  179. <select id="findExist" parameterType="com.iformall.domain.po.WxBillSettle" resultMap="BaseResultMap">
  180. select * from wx_bill_settle_bill where 1=1
  181. <if test=" null != id ">
  182. and settle_id !=#{id}
  183. </if>
  184. <if test=" null != receiveBillIds ">
  185. and bill_id in
  186. <foreach collection="receiveBillIds" index="index" item="idItem" open="(" separator="," close=")">
  187. #{idItem.billId}
  188. </foreach>
  189. </if>
  190. </select>
  191. </mapper>