后台服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WxBillSettleBillMapper.xml 10 KiB

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