Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

1118 řádky
59 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.WxBillAllMapper">
  4. <resultMap id="allVoResultMap" type="com.iformall.domain.vo.WxBillAllVo">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenantId" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="parentTenantId" jdbcType="VARCHAR" property="parentTenantId" />
  8. <result column="merchantId" jdbcType="INTEGER" property="merchantId" />
  9. <result column="shopId" jdbcType="INTEGER" property="shopId" />
  10. <result column="billTypeValue" jdbcType="INTEGER" property="billTypeValue"/>
  11. <result column="billType" jdbcType="VARCHAR" property="billType"/>
  12. <result column="needPay" jdbcType="BIGINT" property="needPay"/>
  13. <result column="merchantName" jdbcType="VARCHAR" property="merchantName" />
  14. <result column="rentShopType" jdbcType="INTEGER" property="rentShopType"/>
  15. <result column="receiveDate" jdbcType="TIMESTAMP" property="receiveDate" />
  16. <result column="expiredDay" jdbcType="INTEGER" property="expiredDay" />
  17. <result column="status" jdbcType="INTEGER" property="status" />
  18. <result column="receivePay" jdbcType="BIGINT" property="receivePay"/>
  19. <result column="owe" jdbcType="BIGINT" property="owe"/>
  20. <result column="pay" jdbcType="BIGINT" property="pay"/>
  21. <result column="payDate" jdbcType="TIMESTAMP" property="payDate" />
  22. <result column="starttime" jdbcType="TIMESTAMP" property="starttime" />
  23. <result column="endtime" jdbcType="TIMESTAMP" property="endtime" />
  24. <result column="shopNumber" jdbcType="VARCHAR" property="shopNumber"/>
  25. <result column="manager" jdbcType="VARCHAR" property="manager"/>
  26. <result column="managerPhone" jdbcType="VARCHAR" property="managerPhone"/>
  27. <result column="shopInfo" jdbcType="VARCHAR" property="shopInfo"/>
  28. <result column="name" jdbcType="VARCHAR" property="name"/>
  29. <result column="comments" property="comments"/>
  30. <result column="price_detail" property="priceDetail"/>
  31. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
  32. <result column="freeze" property="freeze"/>
  33. <result column="late_pay_price" property="latePayPrice"/>
  34. <result column="service_charge_pay" property="serviceChargePay"/>
  35. </resultMap>
  36. <select id="list" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
  37. select
  38. bill.id,bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,bill.shop_id shopId,
  39. bill.bill_type_value billTypeValue,bill.bill_type billType,bill.need_pay needPay,
  40. bill.receive_pay receivePay,bill.pay,bill.owe,bill.receive_date receiveDate,
  41. bill.pay_date payDate,expired_day expiredDay,bill.status,bill.starttime,
  42. bill.endtime,bill.name,bill.rent_shop_type rentShopType,m.name merchantName,
  43. s.shop_number shopNumber, s.manager, s.manager_phone managerPhone,bill.shop_info
  44. shopInfo,bill.comments,bill.price_detail,updatetime,bill.freeze,bill.late_pay_price,bill.service_charge_pay
  45. from (
  46. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  47. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,
  48. endtime,rent_shop_type,case when shop_info is null then '[]' else shop_info end shop_info,comments,''
  49. price_detail,updatetime,freeze,ifnull(late_pay_price,0) late_pay_price,service_charge_pay
  50. from wx_bill_rent
  51. where is_preview = 0
  52. <if test=" null != tenantId and '' != tenantId">
  53. and `tenant_id` = #{tenantId}
  54. </if>
  55. <if test=" null != parentTenantId and '' != parentTenantId">
  56. and `parent_tenant_id` = #{parentTenantId}
  57. </if>
  58. union all
  59. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  60. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,
  61. endtime,rent_shop_type,shop_info,NULL comments,'' price_detail,updatetime,freeze,0
  62. late_pay_price,0 service_charge_pay
  63. from wx_bill_rent_deposit
  64. where 1=1
  65. <if test=" null != tenantId and '' != tenantId">
  66. and `tenant_id` = #{tenantId}
  67. </if>
  68. <if test=" null != parentTenantId and '' != parentTenantId">
  69. and `parent_tenant_id` = #{parentTenantId}
  70. </if>
  71. union all
  72. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  73. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,
  74. endtime,rent_shop_type,case when shop_info is null then '[]' else shop_info end shop_info,comments,''
  75. price_detail,updatetime,freeze,ifnull(late_pay_price,0) late_pay_price,service_charge_pay
  76. from wx_bill_property
  77. where is_preview = 0
  78. <if test=" null != tenantId and '' != tenantId">
  79. and `tenant_id` = #{tenantId}
  80. </if>
  81. <if test=" null != parentTenantId and '' != parentTenantId">
  82. and `parent_tenant_id` = #{parentTenantId}
  83. </if>
  84. union all
  85. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  86. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,
  87. endtime,rent_shop_type,shop_info,NULL comments,'' price_detail,updatetime,freeze,0
  88. late_pay_price,0 service_charge_pay
  89. from wx_bill_property_deposit
  90. where 1=1
  91. <if test=" null != tenantId and '' != tenantId">
  92. and `tenant_id` = #{tenantId}
  93. </if>
  94. <if test=" null != parentTenantId and '' != parentTenantId">
  95. and `parent_tenant_id` = #{parentTenantId}
  96. </if>
  97. union all
  98. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,case when type=1 then '水费' when type=2 then '电费' else '空调费' end name,
  99. case when type=1 then 5 when type=2 then 6 else 9 end bill_type_value,
  100. case when type=1 then '水费' when type=2 then '电费' else '空调费' end bill_type,0 as
  101. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,
  102. rent_shop_type,'[]' shop_info, NULL comments,price_detail,updatetime,freeze,0 late_pay_price,service_charge_pay
  103. from wx_bill_daily where 1=1
  104. <if test=" null != tenantId and '' != tenantId">
  105. and `tenant_id` = #{tenantId}
  106. </if>
  107. <if test=" null != parentTenantId and '' != parentTenantId">
  108. and `parent_tenant_id` = #{parentTenantId}
  109. </if>
  110. union all
  111. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,concat('其他费用-',name) as bill_type,0 as
  112. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,
  113. rent_shop_type,'[]' shop_info,comments,'' price_detail,updatetime,freeze,0 late_pay_price,service_charge_pay
  114. from wx_bill_other
  115. where 1=1
  116. <if test=" null != tenantId and '' != tenantId">
  117. and `tenant_id` = #{tenantId}
  118. </if>
  119. <if test=" null != parentTenantId and '' != parentTenantId">
  120. and `parent_tenant_id` = #{parentTenantId}
  121. </if>
  122. union all
  123. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,comments as name,8 bill_type_value,concat('其他押金-',comments) as
  124. bill_type,0 as
  125. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,
  126. rent_shop_type,'[]' shop_info,comments,'' price_detail,updatetime,freeze,0 late_pay_price,service_charge_pay
  127. from wx_bill_other_deposit
  128. where 1=1
  129. <if test=" null != tenantId and '' != tenantId">
  130. and `tenant_id` = #{tenantId}
  131. </if>
  132. <if test=" null != parentTenantId and '' != parentTenantId">
  133. and `parent_tenant_id` = #{parentTenantId}
  134. </if>
  135. ) bill
  136. left join wx_merchant m on bill.merchant_id=m.id
  137. left join wx_shop s on bill.shop_id=s.id
  138. where 1=1
  139. <if test=" null != tenantId and '' != tenantId">
  140. and bill.`tenant_id` = #{tenantId}
  141. </if>
  142. <if test=" null != parentTenantId and '' != parentTenantId">
  143. and bill.`parent_tenant_id` = #{parentTenantId}
  144. </if>
  145. <if test=" null != month and ''!=month">
  146. and date_format(bill.receive_date,'%Y-%m')=#{month}
  147. </if>
  148. <if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if>
  149. <if test=" null != billTypeValue ">and bill.bill_type_value = #{billTypeValue}</if>
  150. <if test=" null != status ">and bill.`status` = #{status}</if>
  151. <if test=" null != rentShopType ">and bill.rent_shop_type = #{rentShopType}</if>
  152. <if test=" null != starttime and null!= endtime and '' != starttime and ''!= endtime ">
  153. and bill.receive_date between #{starttime} and #{endtime}
  154. </if>
  155. <if test=" null != merchantId and ''!=merchantId">
  156. and bill.merchant_id=#{merchantId}
  157. </if>
  158. <if test=" null != statusList ">
  159. and bill.`status` in
  160. <foreach collection="statusList" index="index" item="status" open="(" separator="," close=")">
  161. #{status}
  162. </foreach>
  163. </if>
  164. <if test=" null != typeList ">
  165. and bill.`bill_type_value` in
  166. <foreach collection="typeList" index="index" item="type" open="(" separator="," close=")">
  167. #{type}
  168. </foreach>
  169. </if>
  170. <if test=" null != freeze ">and bill.freeze = #{freeze}</if>
  171. <if test=" null != id ">and bill.id = #{id}</if>
  172. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  173. <if test=" null == sortColumns"> order by bill.receive_date,bill.id desc,bill.merchant_id,bill.status</if>
  174. </select>
  175. <select id="queryOweInfo" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  176. select count(bill.id) owncount,IFNULL(sum(bill.owe),0) owe from (
  177. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,1 bill_type_value,'租金'
  178. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0
  179. union all
  180. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,2 bill_type_value,'租赁押金'
  181. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  182. wx_bill_rent_deposit
  183. union all
  184. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,3 bill_type_value,'物业费'
  185. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  186. wx_bill_property where is_preview = 0
  187. union all
  188. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,4 bill_type_value,'物业押金'
  189. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  190. wx_bill_property_deposit
  191. union all
  192. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,5 bill_type_value,'水费' bill_type,0 as
  193. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  194. type=1
  195. union all
  196. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,6 bill_type_value,'电费' bill_type,0 as
  197. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  198. type=2
  199. union all
  200. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,9 bill_type_value,'空调费' bill_type,0 as
  201. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  202. type=3
  203. union all
  204. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,7 bill_type_value,'其他费用' bill_type,0 as
  205. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  206. union all
  207. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
  208. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
  209. ) bill
  210. where bill.status=#{status}
  211. <if test=" null != tenantId and '' != tenantId">
  212. and bill.`tenant_id` = #{tenantId}
  213. </if>
  214. <if test=" null != parentTenantId and '' != parentTenantId">
  215. and bill.`parent_tenant_id` = #{parentTenantId}
  216. </if>
  217. <if test=" null != starttime and null!= endtime ">
  218. and bill.receive_date between #{starttime} and #{endtime}
  219. </if>
  220. <if test=" null != month ">
  221. and date_format(bill.receive_date,'%Y-%m')=#{month}
  222. </if>
  223. <if test=" null != rentShopType ">
  224. and bill.rent_shop_type = #{rentShopType}
  225. </if>
  226. <if test=" null != billTypeList ">
  227. and bill.bill_type_value in
  228. <foreach collection="billTypeList" index="index" item="type" open="(" separator="," close=")">
  229. #{type}
  230. </foreach>
  231. </if>
  232. </select>
  233. <select id="queryPaidInfo" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  234. select count(bill.id) paycount,IFNULL(sum(bill.pay),0) pay from (
  235. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,1 bill_type_value,'租金'
  236. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0
  237. union all
  238. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,2 bill_type_value,'租赁押金'
  239. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  240. wx_bill_rent_deposit
  241. union all
  242. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,3 bill_type_value,'物业费'
  243. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  244. wx_bill_property where is_preview = 0
  245. union all
  246. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,4 bill_type_value,'物业押金'
  247. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  248. wx_bill_property_deposit
  249. union all
  250. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,5 bill_type_value,'水费' bill_type,0 as
  251. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  252. type=1
  253. union all
  254. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,6 bill_type_value,'电费' bill_type,0 as
  255. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  256. type=2
  257. union all
  258. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,9 bill_type_value,'空调费' bill_type,0 as
  259. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  260. type=3
  261. union all
  262. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,7 bill_type_value,'其他费用' bill_type,0 as
  263. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  264. union all
  265. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
  266. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
  267. ) bill
  268. where bill.status=#{status}
  269. <if test=" null != tenantId and '' != tenantId">
  270. and bill.`tenant_id` = #{tenantId}
  271. </if>
  272. <if test=" null != parentTenantId and '' != parentTenantId">
  273. and bill.`parent_tenant_id` = #{parentTenantId}
  274. </if>
  275. <if test=" null != starttime and null!= endtime ">
  276. and bill.receive_date between #{starttime} and #{endtime}
  277. </if>
  278. <if test=" null != month ">
  279. and date_format(bill.receive_date,'%Y-%m')=#{month}
  280. </if>
  281. <if test=" null != rentShopType ">
  282. and bill.rent_shop_type = #{rentShopType}
  283. </if>
  284. </select>
  285. <select id="listData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
  286. select bill.settle_number,bill.id,bill.merchant_id merchantId,bill.shop_id shopId,bill.bill_type_value billTypeValue,bill.bill_type billType,bill.need_pay needPay,
  287. bill.receive_pay receivePay,bill.pay,bill.owe,bill.receive_date receiveDate,bill.pay_date payDate,DATEDIFF(now(),bill.receive_date) expiredDay,bill.status,
  288. bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,m.name merchantName,s.shop_number shopNumber,bill.starttime,bill.endtime,bill.name,pb.pay_bill_status payBillStatus,
  289. pb.pay_time_end tradeTime,pb.transaction_id transactionId,pb.pay_amount payAmount,bill.rent_shop_type
  290. rentShopType,bill.price_detail priceDetail,bill.freeze,bill.late_pay_price latePayPrice,bill.service_charge_pay
  291. serviceChargePay from (
  292. select '' settle_number,id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  293. bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay)
  294. owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type,''
  295. price_detail,freeze,ifnull(late_pay_price,0) late_pay_price,service_charge_pay
  296. from wx_bill_rent
  297. where is_preview = 0
  298. <if test=" null != tenantId and '' != tenantId">
  299. and `tenant_id` = #{tenantId}
  300. </if>
  301. <if test=" null != parentTenantId and '' != parentTenantId">
  302. and `parent_tenant_id` = #{parentTenantId}
  303. </if>
  304. and rent_contract_id in (select id from wx_rent_contract where status in (2,3,4))
  305. union all
  306. select '' settle_number,id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  307. bill_type,need_pay,receive_pay,pay,(receive_pay-pay)
  308. owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type,''
  309. price_detail,freeze,0 late_pay_price,0 service_charge_pay
  310. from wx_bill_rent_deposit
  311. where 1=1
  312. <if test=" null != tenantId and '' != tenantId">
  313. and `tenant_id` = #{tenantId}
  314. </if>
  315. <if test=" null != parentTenantId and '' != parentTenantId">
  316. and `parent_tenant_id` = #{parentTenantId}
  317. </if>
  318. and rent_contract_id in (select id from wx_rent_contract
  319. where status in (2,3,4))
  320. union all
  321. select '' settle_number,id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  322. bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay)
  323. owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type,''
  324. price_detail,freeze,ifnull(late_pay_price,0) late_pay_price,service_charge_pay
  325. from wx_bill_property
  326. where is_preview = 0
  327. <if test=" null != tenantId and '' != tenantId">
  328. and `tenant_id` = #{tenantId}
  329. </if>
  330. <if test=" null != parentTenantId and '' != parentTenantId">
  331. and `parent_tenant_id` = #{parentTenantId}
  332. </if>
  333. and property_contract_id in (select id from
  334. wx_property_contract
  335. where status in(2,3,4))
  336. union all
  337. select '' settle_number,id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  338. bill_type,need_pay,receive_pay,pay,(receive_pay-pay)
  339. owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type,''
  340. price_detail,freeze,0 late_pay_price,0 service_charge_pay
  341. from wx_bill_property_deposit
  342. where 1=1
  343. <if test=" null != tenantId and '' != tenantId">
  344. and `tenant_id` = #{tenantId}
  345. </if>
  346. <if test=" null != parentTenantId and '' != parentTenantId">
  347. and `parent_tenant_id` = #{parentTenantId}
  348. </if>
  349. and property_contract_id in (select id from
  350. wx_property_contract where status in
  351. (2,3,4))
  352. union all
  353. select '' settle_number,id,merchant_id,shop_id,tenant_id,parent_tenant_id,case when type=1 then '水费' when type=2 then '电费' else '空调费' end name,
  354. case when type=1 then 5 when type=2 then 6 else 9 end bill_type_value,
  355. case when type=1 then '水费' when type=2 then '电费' else '空调费' end bill_type, 0 as need_pay,receive_pay,
  356. pay,(receive_pay+service_charge_pay-pay) owe,receive_date,pay_date,expired_day,status,starttime,endtime,
  357. rent_shop_type,price_detail,freeze,0 late_pay_price,service_charge_pay
  358. from wx_bill_daily where 1=1
  359. <if test=" null != tenantId and '' != tenantId">
  360. and `tenant_id` = #{tenantId}
  361. </if>
  362. <if test=" null != parentTenantId and '' != parentTenantId">
  363. and `parent_tenant_id` = #{parentTenantId}
  364. </if>
  365. union all
  366. select '' settle_number,id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_vaue,'其他费用' bill_type,0 as
  367. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) owe,receive_date,pay_date,expired_day,status,''
  368. starttime,'' endtime,rent_shop_type,''
  369. price_detail,freeze,0 late_pay_price,service_charge_pay
  370. from wx_bill_other where 1=1
  371. <if test=" null != tenantId and '' != tenantId">
  372. and `tenant_id` = #{tenantId}
  373. </if>
  374. <if test=" null != parentTenantId and '' != parentTenantId">
  375. and `parent_tenant_id` = #{parentTenantId}
  376. </if>
  377. union all
  378. select '' settle_number,id,merchant_id,shop_id,tenant_id,parent_tenant_id,comments as name,8 bill_type_value,'其他押金' bill_type,0 as
  379. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) owe,receive_date,pay_date,expired_day,status,''
  380. starttime,'' endtime,rent_shop_type,''
  381. price_detail,freeze,0 late_pay_price,service_charge_pay
  382. from wx_bill_other_deposit where 1=1
  383. <if test=" null != tenantId and '' != tenantId">
  384. and `tenant_id` = #{tenantId}
  385. </if>
  386. <if test=" null != parentTenantId and '' != parentTenantId">
  387. and `parent_tenant_id` = #{parentTenantId}
  388. </if>
  389. union all
  390. select s.settle_number,s.id,s.merchant_id,'' shop_id,s.tenant_id,parent_tenant_id,'结算单' name, 10 bill_type_value,'结算单' bill_type,0 need_pay,
  391. ((select IFNULL(sum(bill.owe),0) from wx_bill_settle_bill bb left join
  392. (select id,merchant_id,shop_id,tenant_id,parent_tenant_id,1 bill_type_value,'租金'
  393. bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay)
  394. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0
  395. union all
  396. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,2 bill_type_value,'租赁押金'
  397. bill_type,need_pay,receive_pay,pay,(receive_pay-pay)
  398. owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  399. wx_bill_rent_deposit
  400. union all
  401. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,3 bill_type_value,'物业费'
  402. bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay)
  403. owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  404. wx_bill_property where is_preview = 0
  405. union all
  406. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,4 bill_type_value,'物业押金'
  407. bill_type,need_pay,receive_pay,pay,(receive_pay-pay)
  408. owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  409. wx_bill_property_deposit
  410. union all
  411. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,5 bill_type_value,'水费' bill_type,0 as
  412. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay)
  413. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  414. type=1
  415. union all
  416. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,6 bill_type_value,'电费' bill_type,0 as
  417. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay)
  418. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  419. type=2
  420. union all
  421. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,9 bill_type_value,'空调费' bill_type,0 as
  422. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay)
  423. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  424. type=3
  425. union all
  426. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,7 bill_type_value,'其他费用' bill_type,0 as
  427. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay)
  428. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  429. union all
  430. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
  431. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay)
  432. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
  433. union all
  434. select id,id merchant_id,'' shop_id,tenant_id,parent_tenant_id,10 bill_type_value,'补贴' bill_type,0 as
  435. need_pay,subsidy receive_pay,0 pay,0 owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type from wx_merchant_subsidy
  436. ) bill
  437. on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=0)
  438. -
  439. (select IFNULL(sum(bill.owe),0) from wx_bill_settle_bill bb left join
  440. (select id,merchant_id,shop_id,tenant_id,parent_tenant_id,1 bill_type_value,'租金'
  441. bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay)
  442. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0
  443. union all
  444. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,2 bill_type_value,'租赁押金'
  445. bill_type,need_pay,receive_pay,pay,(receive_pay-pay)
  446. owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  447. wx_bill_rent_deposit
  448. union all
  449. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,3 bill_type_value,'物业费'
  450. bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay)
  451. owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  452. wx_bill_property where is_preview = 0
  453. union all
  454. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,4 bill_type_value,'物业押金'
  455. bill_type,need_pay,receive_pay,pay,(receive_pay-pay)
  456. owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  457. wx_bill_property_deposit
  458. union all
  459. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,5 bill_type_value,'水费' bill_type,0 as
  460. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay)
  461. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  462. type=1
  463. union all
  464. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,6 bill_type_value,'电费' bill_type,0 as
  465. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay)
  466. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  467. type=2
  468. union all
  469. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,9 bill_type_value,'空调费' bill_type,0 as
  470. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay)
  471. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  472. type=3
  473. union all
  474. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,7 bill_type_value,'其他费用' bill_type,0 as
  475. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  476. union all
  477. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
  478. need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay)
  479. owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
  480. union all
  481. select id,id merchant_id,'' shop_id,tenant_id,parent_tenant_id,10 bill_type_value,'补贴' bill_type,0 as
  482. need_pay,subsidy receive_pay,0 pay,subsidy owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type from wx_merchant_subsidy
  483. ) bill
  484. on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=1
  485. )
  486. ) receive_pay
  487. ,0 pay,0 owe,s.createtime receive_date,'' pay_date,0 expired_day,
  488. status,'' starttime,'' endtime,'' rent_shop_type,'' price_detail, 0 freeze,
  489. 0 late_pay_price,0 service_charge_pay
  490. from wx_bill_settle s where s.status >0
  491. <if test=" null != tenantId and '' != tenantId">
  492. and s.`tenant_id` = #{tenantId}
  493. </if>
  494. <if test=" null != parentTenantId and '' != parentTenantId">
  495. and s.`parent_tenant_id` = #{parentTenantId}
  496. </if>
  497. ) bill
  498. left join wx_merchant m on bill.merchant_id=m.id
  499. left join wx_shop s on bill.shop_id=s.id
  500. left join wx_pay_bill pb on bill.id=pb.bill_id
  501. where 1=1
  502. <if test=" null != id ">
  503. and bill.id=#{id}
  504. </if>
  505. <if test=" null != tenantId and '' != tenantId">
  506. and bill.`tenant_id` = #{tenantId}
  507. </if>
  508. <if test=" null != parentTenantId and '' != parentTenantId">
  509. and bill.`parent_tenant_id` = #{parentTenantId}
  510. </if>
  511. <if test=" null != merchantId ">
  512. and bill.merchant_id=#{merchantId}
  513. </if>
  514. <if test=" null != statusList ">
  515. and bill.`status` in
  516. <foreach collection="statusList" index="index" item="status" open="(" separator="," close=")">
  517. #{status}
  518. </foreach>
  519. </if>
  520. <if test=" null != typeList ">
  521. and bill.`bill_type_value` in
  522. <foreach collection="typeList" index="index" item="type" open="(" separator="," close=")">
  523. #{type}
  524. </foreach>
  525. </if>
  526. <if test="null!=starttime and null!=endtime and ''!=starttime and ''!=endtime ">
  527. and DATE_FORMAT(bill.receive_date,'%Y-%m') between #{starttime} and #{endtime}
  528. </if>
  529. <if test=" null != status ">
  530. and bill.status=#{status}
  531. </if>
  532. <if test=" null != billTypeValue ">
  533. and bill.bill_type_value=#{billTypeValue}
  534. </if>
  535. <if test=" null != rentShopType ">
  536. and bill.rent_shop_type = #{rentShopType}
  537. </if>
  538. order by bill.merchant_id,bill.status desc,bill.receive_date desc
  539. </select>
  540. <select id="getWaitPayBill" resultType="hashmap">
  541. select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.receive_date receiveDate,
  542. bill.need_pay needPay,m.link_phone linkPhone,app.appname,m.email,bill.bill_type billType from (
  543. select bill.bill_type,bill.tenant_id,parent_tenant_id,bill.merchant_id,bill.receive_date,ifnull(sum(need_pay),0) need_pay from (
  544. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  545. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  546. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  547. union all
  548. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  549. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  550. endtime,rent_shop_type from wx_bill_rent_deposit
  551. union all
  552. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  553. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  554. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  555. union all
  556. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  557. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  558. endtime,rent_shop_type from wx_bill_property_deposit
  559. union all
  560. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  561. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  562. from wx_bill_daily where type=1
  563. union all
  564. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  565. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  566. from wx_bill_daily where type=2
  567. union all
  568. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
  569. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  570. from wx_bill_daily where type=3
  571. union all
  572. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
  573. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  574. from wx_bill_other
  575. union all
  576. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  577. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  578. from wx_bill_other_deposit
  579. ) bill
  580. where bill.status not in(3,5,6)
  581. group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.receive_date) bill
  582. left join wx_merchant m on bill.merchant_id=m.id
  583. left join (select tenant_id,parent_tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
  584. where m.status=1 and DATEDIFF(bill.receive_date,now())=m.bill_setting
  585. </select>
  586. <select id="getOweBill" resultType="hashmap">
  587. select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.owe,m.link_phone linkPhone,app.appname from (
  588. select bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,sum(owe) owe from (
  589. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  590. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  591. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  592. union all
  593. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  594. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  595. endtime,rent_shop_type from wx_bill_rent_deposit
  596. union all
  597. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  598. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  599. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  600. union all
  601. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  602. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  603. endtime,rent_shop_type from wx_bill_property_deposit
  604. union all
  605. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  606. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  607. from wx_bill_daily where type=1
  608. union all
  609. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  610. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  611. from wx_bill_daily where type=2
  612. union all
  613. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
  614. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  615. from wx_bill_daily where type=3
  616. union all
  617. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
  618. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  619. from wx_bill_other
  620. union all
  621. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  622. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  623. from wx_bill_other_deposit
  624. ) bill
  625. where DATEDIFF(bill.receive_date,now())&lt;0 and bill.status not in(3,5,6)
  626. group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id) bill
  627. left join wx_merchant m on bill.merchant_id=m.id
  628. left join (select tenant_id,parent_tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
  629. where m.status=1
  630. </select>
  631. <select id="getWaitPayBillForEmail" resultType="hashmap">
  632. select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.receive_date receiveDate,
  633. bill.need_pay needPay,m.link_phone linkPhone,app.appname,m.email,bill.bill_type billType,ws.manager,ws.manager_phone managerPhone from (
  634. select bill.bill_type,bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.receive_date,ifnull(sum(need_pay),0) need_pay from (
  635. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  636. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  637. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  638. union all
  639. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  640. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  641. endtime,rent_shop_type from wx_bill_rent_deposit
  642. union all
  643. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  644. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  645. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  646. union
  647. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  648. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  649. endtime,rent_shop_type from wx_bill_property_deposit
  650. union all
  651. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  652. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  653. from wx_bill_daily where type=1
  654. union all
  655. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  656. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  657. from wx_bill_daily where type=2
  658. union all
  659. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
  660. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  661. from wx_bill_daily where type=3
  662. union all
  663. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
  664. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  665. from wx_bill_other
  666. union all
  667. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  668. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  669. from wx_bill_other_deposit
  670. ) bill
  671. where bill.status not in(3,5,6)
  672. group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.receive_date,bill.bill_type
  673. ) bill
  674. left join wx_merchant m on bill.merchant_id=m.id
  675. left join (select tenant_id,parent_tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
  676. left join wx_merchant_shop wms on wms.merchant_id = m.id
  677. left join wx_shop ws on wms.shop_id = ws.id
  678. where m.status=1 and DATEDIFF(bill.receive_date,now())=m.bill_setting
  679. </select>
  680. <select id="getOweBillForEmail" resultType="hashmap">
  681. select bill.tenant_id tenantId,bill.parent_tenant_id, parentTenantId,bill.merchant_id merchantId,bill.bill_type billType,bill.owe owe,m.link_phone managerPhone,m.`link_person` manager,m.email,app.appname,bill.receive_date receiveDate
  682. ,DATEDIFF(now(),bill.receive_date) expiredDay from (
  683. select bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.bill_type,sum(owe) owe,bill.receive_date,bill.expired_day from (
  684. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  685. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  686. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  687. union all
  688. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  689. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  690. endtime,rent_shop_type from wx_bill_rent_deposit
  691. union all
  692. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  693. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  694. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  695. union all
  696. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  697. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  698. endtime,rent_shop_type from wx_bill_property_deposit
  699. union all
  700. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  701. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  702. from wx_bill_daily where type=1
  703. union all
  704. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  705. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  706. from wx_bill_daily where type=2
  707. union all
  708. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
  709. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  710. from wx_bill_daily where type=3
  711. union all
  712. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
  713. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  714. from wx_bill_other
  715. union all
  716. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  717. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  718. from wx_bill_other_deposit
  719. ) bill
  720. where DATEDIFF(bill.receive_date,now())&lt;0 and bill.status not in(3,5,6)
  721. group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.bill_type) bill
  722. left join wx_merchant m on bill.merchant_id=m.id
  723. left join (select tenant_id,parent_tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
  724. where m.status=1
  725. </select>
  726. <sql id="getOweBillAsPageConditions">
  727. and status !=6
  728. <if test="null != status ">
  729. and status = #{status}
  730. </if>
  731. <if test=" null != month and ''!=month">
  732. and date_format(receive_date,'%Y-%m')=#{month}
  733. </if>
  734. <if test=" null != starttime and ''!=starttime">
  735. and receive_date >= #{starttime}
  736. </if>
  737. <if test=" null != endtime and ''!=endtime">
  738. and receive_date &lt;= #{endtime}
  739. </if>
  740. </sql>
  741. <select id="getOweBillAsPage" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  742. select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.bill_type billType,
  743. m.link_phone managerPhone,m.`link_person` manager,m.email,
  744. bill.receive_date receiveDate,DATEDIFF(now(),bill.receive_date) expiredDay,
  745. round(bill.rentOwe/100,2) rentOwe,
  746. round(bill.propertyOwe/100,2) propertyOwe,
  747. round(bill.depositOwe/100,2) depositOwe,
  748. round(bill.otherOwe/100,2) otherOwe,
  749. round((bill.rentOwe+bill.propertyOwe+bill.depositOwe+bill.otherOwe)/100,2) totalOwe,
  750. <choose>
  751. <when test="1==filterHasPay">
  752. round((bill.rentReceivePay+bill.rentLatePay+bill.rentServiceChargePay-bill.rentPay)/100,2)
  753. rentReceivePay,
  754. round((bill.propertyReceivePay+bill.propertyLatePay+bill.propertyServiceChargePay-bill.propertyPay)/100,2)
  755. propertyReceivePay,
  756. round((bill.depositReceivePay+bill.depositLatePay+bill.depositServiceChargePay-bill.depositPay)/100,2)
  757. depositReceivePay,
  758. round((bill.otherReceivePay+bill.otherLatePay+bill.otherServiceChargePay-bill.otherPay)/100,2)
  759. otherReceivePay,
  760. round((bill.rentReceivePay+bill.propertyReceivePay+bill.depositReceivePay+bill.otherReceivePay
  761. +bill.rentLatePay+bill.propertyLatePay+bill.depositLatePay+bill.otherLatePay
  762. +bill.rentServiceChargePay+bill.propertyServiceChargePay+bill.depositServiceChargePay+bill.otherServiceChargePay
  763. -bill.rentPay-bill.propertyPay-bill.depositPay-bill.otherPay)/100,2) totalReceivePay
  764. </when>
  765. <otherwise>
  766. round((bill.rentReceivePay+bill.rentLatePay+bill.rentServiceChargePay)/100,2) rentReceivePay,
  767. round((bill.propertyReceivePay+bill.propertyLatePay+bill.propertyServiceChargePay)/100,2)
  768. propertyReceivePay,
  769. round((bill.depositReceivePay+bill.depositLatePay+bill.depositServiceChargePay)/100,2)
  770. depositReceivePay,
  771. round((bill.otherReceivePay+bill.otherLatePay+bill.otherServiceChargePay)/100,2) otherReceivePay,
  772. round((bill.rentReceivePay+bill.propertyReceivePay+bill.depositReceivePay
  773. +bill.otherReceivePay+bill.rentLatePay+bill.propertyLatePay+bill.depositLatePay
  774. +bill.otherLatePay+bill.rentServiceChargePay+bill.propertyServiceChargePay+bill.depositServiceChargePay+bill.otherServiceChargePay)/100,2)
  775. totalReceivePay
  776. </otherwise>
  777. </choose>
  778. from (
  779. select oweList.*,
  780. max(case oweList.bill_type when '租金' then oweList.owe else 0 end) rentOwe,
  781. max(case oweList.bill_type when '物业费' then oweList.owe else 0 end) propertyOwe,
  782. max(case oweList.bill_type when '欠缴押金' then oweList.owe else 0 end) depositOwe,
  783. max(case oweList.bill_type when '其他费用' then oweList.owe else 0 end) otherOwe,
  784. max(case oweList.bill_type when '租金' then oweList.receive_pay else 0 end) rentReceivePay,
  785. max(case oweList.bill_type when '物业费' then oweList.receive_pay else 0 end) propertyReceivePay,
  786. max(case oweList.bill_type when '欠缴押金' then oweList.receive_pay else 0 end) depositReceivePay,
  787. max(case oweList.bill_type when '其他费用' then oweList.receive_pay else 0 end) otherReceivePay,
  788. max(case oweList.bill_type when '租金' then oweList.pay else 0 end) rentPay,
  789. max(case oweList.bill_type when '物业费' then oweList.pay else 0 end) propertyPay,
  790. max(case oweList.bill_type when '欠缴押金' then oweList.pay else 0 end) depositPay,
  791. max(case oweList.bill_type when '其他费用' then oweList.pay else 0 end) otherPay,
  792. max(case oweList.bill_type when '租金' then oweList.latePayPrice else 0 end) rentLatePay,
  793. max(case oweList.bill_type when '物业费' then oweList.latePayPrice else 0 end) propertyLatePay,
  794. max(case oweList.bill_type when '欠缴押金' then oweList.latePayPrice else 0 end) depositLatePay,
  795. max(case oweList.bill_type when '其他费用' then oweList.latePayPrice else 0 end) otherLatePay,
  796. max(case oweList.bill_type when '租金' then oweList.serviceChargePay else 0 end) rentServiceChargePay,
  797. max(case oweList.bill_type when '物业费' then oweList.serviceChargePay else 0 end) propertyServiceChargePay,
  798. max(case oweList.bill_type when '欠缴押金' then oweList.serviceChargePay else 0 end) depositServiceChargePay,
  799. max(case oweList.bill_type when '其他费用' then oweList.serviceChargePay else 0 end) otherServiceChargePay
  800. from(
  801. select bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.bill_type,sum(owe)
  802. owe,bill.receive_date,bill.expired_day,sum(bill.receive_pay) receive_pay,sum(bill.pay)
  803. pay,sum(ifnull(bill.late_pay_price,0)) latePayPrice,sum(bill.service_charge_pay) serviceChargePay from (
  804. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  805. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d')
  806. receive_date,pay_date,expired_day,status,'' starttime,''
  807. endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_rent
  808. where is_preview = 0
  809. <if test=" null != tenantId and '' != tenantId">
  810. and `tenant_id` = #{tenantId}
  811. </if>
  812. <if test=" null != parentTenantId and '' != parentTenantId">
  813. and `parent_tenant_id` = #{parentTenantId}
  814. </if>
  815. <include refid="getOweBillAsPageConditions"/>
  816. union all
  817. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  818. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  819. endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_property where is_preview = 0
  820. <if test=" null != tenantId and '' != tenantId">
  821. and `tenant_id` = #{tenantId}
  822. </if>
  823. <if test=" null != parentTenantId and '' != parentTenantId">
  824. and `parent_tenant_id` = #{parentTenantId}
  825. </if>
  826. <include refid="getOweBillAsPageConditions"/>
  827. union all
  828. select res.id,res.merchant_id,res.shop_id,res.tenant_id,res.parent_tenant_id,res.name,res.bill_type_value,res.bill_type,res.need_pay,
  829. res.receive_pay,res.pay,res.owe
  830. owe,res.receive_date,res.pay_date,res.expired_day,res.status,res.starttime,res.endtime,res.rent_shop_type,0
  831. late_pay_price,0 service_charge_pay from(
  832. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'欠缴押金' name,2 bill_type_value,'欠缴押金'
  833. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  834. endtime,rent_shop_type,service_charge_pay from wx_bill_rent_deposit where 1=1
  835. <if test=" null != tenantId and '' != tenantId">
  836. and `tenant_id` = #{tenantId}
  837. </if>
  838. <if test=" null != parentTenantId and '' != parentTenantId">
  839. and `parent_tenant_id` = #{parentTenantId}
  840. </if>
  841. <include refid="getOweBillAsPageConditions"/>
  842. union all
  843. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'欠缴押金' name,4 bill_type_value,'欠缴押金'
  844. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  845. endtime,rent_shop_type,0 service_charge_pay from wx_bill_property_deposit where 1=1
  846. <if test=" null != tenantId and '' != tenantId">
  847. and `tenant_id` = #{tenantId}
  848. </if>
  849. <if test=" null != parentTenantId and '' != parentTenantId">
  850. and `parent_tenant_id` = #{parentTenantId}
  851. </if>
  852. <include refid="getOweBillAsPageConditions"/>
  853. union all
  854. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'欠缴押金' name,8 bill_type_value,'欠缴押金' bill_type,0 as
  855. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,
  856. pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay
  857. from wx_bill_other_deposit where 1=1
  858. <if test=" null != tenantId and '' != tenantId">
  859. and `tenant_id` = #{tenantId}
  860. </if>
  861. <if test=" null != parentTenantId and '' != parentTenantId">
  862. and `parent_tenant_id` = #{parentTenantId}
  863. </if>
  864. <include refid="getOweBillAsPageConditions"/>
  865. ) res
  866. union all
  867. select res.id,res.merchant_id,res.shop_id,res.tenant_id,res.parent_tenant_id,res.name,res.bill_type_value,res.bill_type,res.need_pay,
  868. res.receive_pay,res.pay,res.owe
  869. owe,res.receive_date,res.pay_date,res.expired_day,res.status,res.starttime,res.endtime,res.rent_shop_type,0
  870. late_pay_price,service_charge_pay from(
  871. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'其他费用' name,5 bill_type_value,'其他费用' bill_type,0 as
  872. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,
  873. expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay
  874. from wx_bill_daily where type in(1,2,3)
  875. <if test=" null != tenantId and '' != tenantId">
  876. and `tenant_id` = #{tenantId}
  877. </if>
  878. <if test=" null != parentTenantId and '' != parentTenantId">
  879. and `parent_tenant_id` = #{parentTenantId}
  880. </if>
  881. <include refid="getOweBillAsPageConditions"/>
  882. union all
  883. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'其他费用' name,7 bill_type_value,'其他费用' bill_type,0 as
  884. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,
  885. expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay
  886. from wx_bill_other where 1=1
  887. <if test=" null != tenantId and '' != tenantId">
  888. and `tenant_id` = #{tenantId}
  889. </if>
  890. <if test=" null != parentTenantId and '' != parentTenantId">
  891. and `parent_tenant_id` = #{parentTenantId}
  892. </if>
  893. <include refid="getOweBillAsPageConditions"/>
  894. ) res
  895. ) bill
  896. where bill.status not in(3,5,6)
  897. group by bill.merchant_id,bill.bill_type
  898. ) oweList group by oweList.merchant_id
  899. ) bill
  900. left join wx_merchant m on bill.merchant_id=m.id
  901. where 1=1
  902. <if test=" null != tenantId and '' != tenantId">
  903. and m.`tenant_id` = #{tenantId}
  904. </if>
  905. <if test=" null != parentTenantId and '' != parentTenantId">
  906. and m.`parent_tenant_id` = #{parentTenantId}
  907. </if>
  908. <if test=" null != merchantName and '' != merchantName">and m.name like concat('%', #{merchantName},'%')</if>
  909. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  910. <if test=" null == sortColumns"> order by totalOwe desc </if>
  911. </select>
  912. <select id="getReceiveAndPayBillAsPage" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  913. select tt.* from (
  914. select m.tenant_id,m.parent_tenant_id,m.id,m.name,ws.shop_number shopNumber,ws.type,m.link_person linkPerson,m.link_phone linkPhone,
  915. xb.title business,rc.rental_start_date rentalStartDate,rc.rental_end_date rentalEndDate,rc.rent_shop_type,
  916. ifnull(round(
  917. (select sum(bill.receive_pay)+sum(bill.late_pay_price)+sum(bill.receivePay) from (
  918. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
  919. wx_bill_rent where is_preview = 0 and status not in(3,6)
  920. union all
  921. select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
  922. wx_bill_rent_deposit where status not in(3,6)
  923. union all
  924. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
  925. wx_bill_property where is_preview = 0 and status not in(3,6)
  926. union all
  927. select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
  928. wx_bill_property_deposit where status not in(3,6)
  929. union all
  930. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  931. wx_bill_daily where type in(1,2,3) and status not in(3,6)
  932. union all
  933. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  934. wx_bill_other where status not in(3,6)
  935. union all
  936. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  937. wx_bill_other_deposit where status not in(3,6)
  938. ) bill where bill.merchant_id = m.id
  939. )/100,2),0) receivePay,
  940. ifnull(round(
  941. (select sum(ss.money) from (
  942. select subsidy money,merchant_id id from wx_merchant_subsidy where status = 0
  943. union all
  944. select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3
  945. union all
  946. select receive_pay money,merchant_id id from wx_bill_property_deposit where status = 3
  947. union all
  948. select receive_pay money,merchant_id id from wx_bill_other_deposit where status = 3
  949. )ss where ss.id = m.id
  950. )/100,2),0) payOut,
  951. (ifnull(round(
  952. (select sum(bill.receive_pay)+sum(bill.late_pay_price)+sum(bill.receivePay) from (
  953. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
  954. wx_bill_rent
  955. where is_preview = 0 and status not in(3,6)
  956. union all
  957. select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
  958. wx_bill_rent_deposit where status not in(3,6)
  959. union all
  960. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
  961. wx_bill_property where is_preview = 0 and status not in(3,6)
  962. union all
  963. select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
  964. wx_bill_property_deposit where status not in(3,6)
  965. union all
  966. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  967. wx_bill_daily where type in(1,2,3) and status not in(3,6)
  968. union all
  969. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  970. wx_bill_other where status not in(3,6)
  971. union all
  972. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  973. wx_bill_other_deposit where status not in(3,6)
  974. ) bill where bill.merchant_id = m.id
  975. )/100,2),0)-
  976. ifnull(round(
  977. (select sum(ss.money) from (
  978. select subsidy money,merchant_id id from wx_merchant_subsidy where order_type in(3,0) and status = 0
  979. union all
  980. select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3
  981. union all
  982. select receive_pay money,merchant_id id from wx_bill_property_deposit where status = 3
  983. union all
  984. select receive_pay money,merchant_id id from wx_bill_other_deposit where status = 3
  985. )ss where ss.id = m.id
  986. )/100,2),0)) balance
  987. from wx_merchant m
  988. left join (select ms.merchant_id,s.type,GROUP_CONCAT(s.shop_number) as shop_number
  989. from wx_merchant_shop ms inner join wx_shop s on ms.shop_id=s.id where ms.is_del=0
  990. group by ms.merchant_id) ws on m.id=ws.merchant_id
  991. left join wx_business xb on(m.business_id = xb.id)
  992. left join wx_rent_contract rc on(rc.merchant_id = m.id)
  993. where m.status=1
  994. ) tt where 1=1
  995. <if test=" null != tenantId and '' != tenantId">
  996. and tt.`tenant_id` = #{tenantId}
  997. </if>
  998. <if test=" null != parentTenantId and '' != parentTenantId">
  999. and tt.`parent_tenant_id` = #{parentTenantId}
  1000. </if>
  1001. <if test=" null != merchantId"> and tt.id = #{merchantId} </if>
  1002. <if test=" null != merchantName and ''!=merchantName">and tt.name like concat('%', #{merchantName},'%')</if>
  1003. <if test=" null != rentShopType"> and tt.rent_shop_type = #{rentShopType} </if>
  1004. and (receivePay >0 or payOut>0)
  1005. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  1006. <if test=" null == sortColumns"> order by tt.id desc </if>
  1007. <if test="null != limitStart and null != limitEnd">
  1008. limit #{limitStart},#{limitEnd}
  1009. </if>
  1010. </select>
  1011. <select id="allDepositList" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
  1012. select bill.*
  1013. from (
  1014. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 billTypeValue,'租赁押金'
  1015. billType,need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze,0
  1016. late_pay_price,0
  1017. service_charge_pay
  1018. from wx_bill_rent_deposit where 1=1
  1019. <if test=" null != tenantId and '' != tenantId">
  1020. and `tenant_id` = #{tenantId}
  1021. </if>
  1022. <if test=" null != parentTenantId and '' != parentTenantId">
  1023. and `parent_tenant_id` = #{parentTenantId}
  1024. </if>
  1025. union all
  1026. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 billTypeValue,'物业押金'
  1027. billType,need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze,0
  1028. late_pay_price,0
  1029. service_charge_pay
  1030. from wx_bill_property_deposit where 1=1
  1031. <if test=" null != tenantId and '' != tenantId">
  1032. and `tenant_id` = #{tenantId}
  1033. </if>
  1034. <if test=" null != parentTenantId and '' != parentTenantId">
  1035. and `parent_tenant_id` = #{parentTenantId}
  1036. </if>
  1037. union all
  1038. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,comments as name,8 billTypeValue,concat('其他押金-',comments) as
  1039. billType,0 as need_pay,receive_pay receivePay,pay,owe,receive_date
  1040. receiveDate,pay_date,expired_day,status,freeze,0
  1041. late_pay_price,service_charge_pay
  1042. from wx_bill_other_deposit where 1=1
  1043. <if test=" null != tenantId and '' != tenantId">
  1044. and `tenant_id` = #{tenantId}
  1045. </if>
  1046. <if test=" null != parentTenantId and '' != parentTenantId">
  1047. and `parent_tenant_id` = #{parentTenantId}
  1048. </if>
  1049. ) bill
  1050. where 1=1
  1051. <if test=" null != freeze"> and bill.freeze = #{freeze} </if>
  1052. <if test=" null != status"> and bill.status = #{status} </if>
  1053. <if test=" null != merchantId">and bill.merchant_id=#{merchantId}</if>
  1054. </select>
  1055. </mapper>