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.
 
 
 
 
 

368 lines
21 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. <select id="list" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  5. select bill.id,bill.merchant_id merchantId,bill.shop_id shopId,bill.bill_type_value billTypeValue,bill.bill_type billType,bill.need_pay needPay,
  6. bill.receive_pay receivePay,bill.pay,bill.owe,bill.receive_date receiveDate,bill.pay_date payDate,bill.expired_day expiredDay,bill.status,
  7. bill.tenant_id tenantId,m.name merchantName,s.shop_number
  8. shopNumber,bill.starttime,bill.endtime,bill.name,s.manager,s.manager_phone managerPhone,
  9. bill.rent_shop_type rentShopType from (
  10. select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金'
  11. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,''
  12. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  13. union
  14. select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  15. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,''
  16. endtime,rent_shop_type from wx_bill_rent_deposit
  17. union
  18. select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费'
  19. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,''
  20. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  21. union
  22. select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  23. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,''
  24. endtime,rent_shop_type from wx_bill_property_deposit
  25. union
  26. select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  27. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  28. from wx_bill_daily where type=1
  29. union
  30. select id,merchant_id,shop_id,tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  31. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  32. from wx_bill_daily where type=2
  33. union
  34. select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,'其他' bill_type,0 as
  35. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  36. from wx_bill_other
  37. union
  38. select id,merchant_id,shop_id,tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  39. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  40. from wx_bill_other_deposit
  41. ) bill
  42. left join wx_merchant m on bill.merchant_id=m.id
  43. left join wx_shop s on bill.shop_id=s.id
  44. where 1=1
  45. <if test=" null != tenantId ">
  46. and bill.tenant_id=#{tenantId}
  47. </if>
  48. <if test=" null != month and ''!=month">
  49. and date_format(bill.receive_date,'%Y-%m')=#{month}
  50. </if>
  51. <if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if>
  52. <if test=" null != billTypeValue ">and bill.bill_type_value = #{billTypeValue}</if>
  53. <if test=" null != status ">and bill.`status` = #{status}</if>
  54. <if test=" null != rentShopType ">and bill.rent_shop_type = #{rentShopType}</if>
  55. order by bill.id desc,bill.merchant_id,bill.status,bill.receive_date desc
  56. </select>
  57. <select id="queryOweInfo" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  58. select count(bill.id) owncount,IFNULL(sum(bill.owe),0) owe from (
  59. select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金'
  60. 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
  61. union
  62. select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金'
  63. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  64. wx_bill_rent_deposit
  65. union
  66. select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费'
  67. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  68. wx_bill_property where is_preview = 0
  69. union
  70. select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金'
  71. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  72. wx_bill_property_deposit
  73. union
  74. select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as
  75. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  76. type=1
  77. union
  78. select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as
  79. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  80. type=2
  81. union
  82. select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他' bill_type,0 as
  83. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  84. union
  85. select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
  86. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
  87. ) bill
  88. where bill.tenant_id=#{tenantId} and bill.status=#{status}
  89. <if test=" null != starttime and null!= endtime ">
  90. and bill.receive_date between #{starttime} and #{endtime}
  91. </if>
  92. <if test=" null != month ">
  93. and date_format(bill.receive_date,'%Y-%m')=#{month}
  94. </if>
  95. <if test=" null != rentShopType ">
  96. and bill.rent_shop_type = #{rentShopType}
  97. </if>
  98. </select>
  99. <select id="queryPaidInfo" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  100. select count(bill.id) paycount,IFNULL(sum(bill.pay),0) pay from (
  101. select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金'
  102. 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
  103. union
  104. select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金'
  105. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  106. wx_bill_rent_deposit
  107. union
  108. select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费'
  109. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  110. wx_bill_property where is_preview = 0
  111. union
  112. select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金'
  113. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  114. wx_bill_property_deposit
  115. union
  116. select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as
  117. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  118. type=1
  119. union
  120. select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as
  121. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  122. type=2
  123. union
  124. select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他' bill_type,0 as
  125. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  126. union
  127. select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
  128. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
  129. ) bill
  130. where bill.tenant_id=#{tenantId} and bill.status=#{status}
  131. <if test=" null != starttime and null!= endtime ">
  132. and bill.receive_date between #{starttime} and #{endtime}
  133. </if>
  134. <if test=" null != month ">
  135. and date_format(bill.receive_date,'%Y-%m')=#{month}
  136. </if>
  137. <if test=" null != rentShopType ">
  138. and bill.rent_shop_type = #{rentShopType}
  139. </if>
  140. </select>
  141. <select id="listData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
  142. select bill.id,bill.merchant_id merchantId,bill.shop_id shopId,bill.bill_type_value billTypeValue,bill.bill_type billType,bill.need_pay needPay,
  143. bill.receive_pay receivePay,bill.pay,bill.owe,bill.receive_date receiveDate,bill.pay_date payDate,bill.expired_day expiredDay,bill.status,
  144. bill.tenant_id tenantId,m.name merchantName,s.shop_number shopNumber,bill.starttime,bill.endtime,bill.name,pb.pay_bill_status payBillStatus,
  145. pb.pay_time_end tradeTime,pb.transaction_id transactionId,pb.pay_amount payAmount,bill.rent_shop_type
  146. rentShopType from (
  147. select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金'
  148. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type
  149. from wx_bill_rent where is_preview = 0 and rent_contract_id in (select id from wx_rent_contract where status in
  150. (2,3,4))
  151. union
  152. select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  153. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type
  154. from wx_bill_rent_deposit where rent_contract_id in (select id from wx_rent_contract where status in (2,3,4))
  155. union
  156. select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费'
  157. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type
  158. from wx_bill_property where is_preview = 0 and property_contract_id in (select id from wx_property_contract
  159. where status in(2,3,4))
  160. union
  161. select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  162. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type
  163. from wx_bill_property_deposit where property_contract_id in (select id from wx_property_contract where status in
  164. (2,3,4))
  165. union
  166. select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type, 0 as
  167. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  168. from wx_bill_daily where type=1
  169. union
  170. select id,merchant_id,shop_id,tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  171. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  172. from wx_bill_daily where type=2
  173. union
  174. select id,merchant_id,shop_id,tenant_id,name,7 bill_type_vaue,'其他' bill_type,0 as
  175. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  176. from wx_bill_other
  177. union
  178. select id,merchant_id,shop_id,tenant_id,comments as name,8 bill_type_value,'其他押金' bill_type,0 as
  179. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  180. from wx_bill_other_deposit
  181. ) bill
  182. left join wx_merchant m on bill.merchant_id=m.id
  183. left join wx_shop s on bill.shop_id=s.id
  184. left join wx_pay_bill pb on bill.id=pb.bill_id
  185. where 1=1
  186. <if test=" null != id ">
  187. and bill.id=#{id}
  188. </if>
  189. <if test=" null != tenantId ">
  190. and bill.tenant_id=#{tenantId}
  191. </if>
  192. <if test=" null != merchantId ">
  193. and bill.merchant_id=#{merchantId}
  194. </if>
  195. <if test=" null != statusList ">
  196. and bill.`status` in
  197. <foreach collection="statusList" index="index" item="status" open="(" separator="," close=")">
  198. #{status}
  199. </foreach>
  200. </if>
  201. <if test=" null != typeList ">
  202. and bill.`bill_type_value` in
  203. <foreach collection="typeList" index="index" item="type" open="(" separator="," close=")">
  204. #{type}
  205. </foreach>
  206. </if>
  207. <if test="null!=starttime and null!=endtime">
  208. and DATE_FORMAT(bill.receive_date,'%Y-%m') between #{starttime} and #{endtime}
  209. </if>
  210. <if test=" null != status ">
  211. and bill.status=#{status}
  212. </if>
  213. <if test=" null != billTypeValue ">
  214. and bill.bill_type_value=#{billTypeValue}
  215. </if>
  216. <if test=" null != rentShopType ">
  217. and bill.rent_shop_type = #{rentShopType}
  218. </if>
  219. order by bill.merchant_id,bill.status,bill.receive_date desc
  220. </select>
  221. <select id="getWaitPayBill" resultType="hashmap">
  222. select bill.tenant_id tenantId,bill.merchant_id merchantId,bill.receive_date receiveDate,
  223. bill.need_pay needPay,m.link_phone linkPhone,app.appname from (
  224. select bill.tenant_id,bill.merchant_id,bill.receive_date,ifnull(sum(need_pay),0) need_pay from (
  225. select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金'
  226. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  227. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  228. union
  229. select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  230. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  231. endtime,rent_shop_type from wx_bill_rent_deposit
  232. union
  233. select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费'
  234. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  235. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  236. union
  237. select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  238. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  239. endtime,rent_shop_type from wx_bill_property_deposit
  240. union
  241. select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  242. 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
  243. from wx_bill_daily where type=1
  244. union
  245. select id,merchant_id,shop_id,tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  246. 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
  247. from wx_bill_daily where type=2
  248. union
  249. select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,'其他' bill_type,0 as
  250. 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
  251. from wx_bill_other
  252. union
  253. select id,merchant_id,shop_id,tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  254. 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
  255. from wx_bill_other_deposit
  256. ) bill
  257. where DATEDIFF(bill.receive_date,now())=3 and bill.status not in(3,5,6)
  258. group by bill.tenant_id,bill.merchant_id,bill.receive_date) bill
  259. left join wx_merchant m on bill.merchant_id=m.id
  260. left join (select tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
  261. where m.status=1
  262. </select>
  263. <select id="getWaitPayBillForEmail" resultType="hashmap">
  264. select bill.tenant_id tenantId,bill.merchant_id merchantId,bill.receive_date receiveDate,
  265. bill.need_pay needPay,m.link_phone linkPhone,app.appname,m.email,bill.bill_type billType,ws.manager,ws.manager_phone managerPhone from (
  266. select bill.bill_type,bill.tenant_id,bill.merchant_id,bill.receive_date,ifnull(sum(need_pay),0) need_pay from (
  267. select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金'
  268. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  269. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  270. union
  271. select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  272. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  273. endtime,rent_shop_type from wx_bill_rent_deposit
  274. union
  275. select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费'
  276. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  277. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  278. union
  279. select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  280. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  281. endtime,rent_shop_type from wx_bill_property_deposit
  282. union
  283. select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  284. 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
  285. from wx_bill_daily where type=1
  286. union
  287. select id,merchant_id,shop_id,tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  288. 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
  289. from wx_bill_daily where type=2
  290. union
  291. select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,'其他' bill_type,0 as
  292. 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
  293. from wx_bill_other
  294. union
  295. select id,merchant_id,shop_id,tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  296. 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
  297. from wx_bill_other_deposit
  298. ) bill
  299. group by bill.tenant_id,bill.merchant_id,bill.receive_date,bill.bill_type
  300. ) bill
  301. left join wx_merchant m on bill.merchant_id=m.id
  302. left join (select tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
  303. left join wx_merchant_shop wms on wms.merchant_id = m.id
  304. left join wx_shop ws on wms.shop_id = ws.id
  305. where m.status=1
  306. </select>
  307. <select id="getOweBill" resultType="hashmap">
  308. select bill.tenant_id tenantId,bill.merchant_id merchantId,bill.owe,m.link_phone linkPhone,app.appname from (
  309. select bill.tenant_id,bill.merchant_id,sum(owe) owe from (
  310. select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金'
  311. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  312. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  313. union
  314. select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  315. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  316. endtime,rent_shop_type from wx_bill_rent_deposit
  317. union
  318. select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费'
  319. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  320. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  321. union
  322. select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  323. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  324. endtime,rent_shop_type from wx_bill_property_deposit
  325. union
  326. select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  327. 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
  328. from wx_bill_daily where type=1
  329. union
  330. select id,merchant_id,shop_id,tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  331. 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
  332. from wx_bill_daily where type=2
  333. union
  334. select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,'其他' bill_type,0 as
  335. 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
  336. from wx_bill_other
  337. union
  338. select id,merchant_id,shop_id,tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  339. 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
  340. from wx_bill_other_deposit
  341. ) bill
  342. where DATEDIFF(bill.receive_date,now())&lt;0 and bill.status not in(3,5,6)
  343. group by bill.tenant_id,bill.merchant_id) bill
  344. left join wx_merchant m on bill.merchant_id=m.id
  345. left join (select tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
  346. where m.status=1
  347. </select>
  348. </mapper>