Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

295 строки
15 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
  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
  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. ) bill
  38. left join wx_merchant m on bill.merchant_id=m.id
  39. left join wx_shop s on bill.shop_id=s.id
  40. where date_format(bill.receive_date,'%Y-%m')=#{month}
  41. <if test=" null != tenantId ">
  42. and bill.tenant_id=#{tenantId}
  43. </if>
  44. <if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if>
  45. <if test=" null != billTypeValue ">and bill.bill_type_value = #{billTypeValue}</if>
  46. <if test=" null != status ">and bill.`status` = #{status}</if>
  47. <if test=" null != rentShopType ">and bill.rent_shop_type = #{rentShopType}</if>
  48. order by bill.id desc,bill.merchant_id,bill.status,bill.receive_date desc
  49. </select>
  50. <select id="queryOweInfo" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  51. select count(bill.id) owncount,IFNULL(sum(bill.owe),0) owe from (
  52. select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金'
  53. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent
  54. union
  55. select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金'
  56. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  57. wx_bill_rent_deposit
  58. union
  59. select id,merchant_id,shop_id,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 from
  61. wx_bill_property
  62. union
  63. select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金'
  64. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  65. wx_bill_property_deposit
  66. union
  67. select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as
  68. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  69. type=1
  70. union
  71. select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as
  72. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  73. type=2
  74. union
  75. select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他' bill_type,0 as
  76. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  77. ) bill
  78. where bill.tenant_id=#{tenantId} and bill.status=#{status}
  79. <if test=" null != starttime and null!= endtime ">
  80. and bill.receive_date between #{starttime} and #{endtime}
  81. </if>
  82. <if test=" null != month ">
  83. and date_format(bill.receive_date,'%Y-%m')=#{month}
  84. </if>
  85. <if test=" null != rentShopType ">
  86. and bill.rent_shop_type = #{rentShopType}
  87. </if>
  88. </select>
  89. <select id="queryPaidInfo" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  90. select count(bill.id) paycount,IFNULL(sum(bill.pay),0) pay from (
  91. select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金'
  92. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent
  93. union
  94. select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金'
  95. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  96. wx_bill_rent_deposit
  97. union
  98. select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费'
  99. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  100. wx_bill_property
  101. union
  102. select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金'
  103. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  104. wx_bill_property_deposit
  105. union
  106. select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as
  107. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  108. type=1
  109. union
  110. select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as
  111. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  112. type=2
  113. union
  114. select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他' bill_type,0 as
  115. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  116. ) bill
  117. where bill.tenant_id=#{tenantId} and bill.status=#{status}
  118. <if test=" null != starttime and null!= endtime ">
  119. and bill.receive_date between #{starttime} and #{endtime}
  120. </if>
  121. <if test=" null != month ">
  122. and date_format(bill.receive_date,'%Y-%m')=#{month}
  123. </if>
  124. <if test=" null != rentShopType ">
  125. and bill.rent_shop_type = #{rentShopType}
  126. </if>
  127. </select>
  128. <select id="listData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
  129. select bill.id,bill.merchant_id merchantId,bill.shop_id shopId,bill.bill_type_value billTypeValue,bill.bill_type billType,bill.need_pay needPay,
  130. bill.receive_pay receivePay,bill.pay,bill.owe,bill.receive_date receiveDate,bill.pay_date payDate,bill.expired_day expiredDay,bill.status,
  131. bill.tenant_id tenantId,m.name merchantName,s.shop_number shopNumber,bill.starttime,bill.endtime,bill.name,pb.pay_bill_status payBillStatus,
  132. pb.pay_time_end tradeTime,pb.transaction_id transactionId,pb.pay_amount payAmount,bill.rent_shop_type
  133. rentShopType from (
  134. select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金'
  135. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type
  136. from wx_bill_rent
  137. union
  138. select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  139. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type
  140. from wx_bill_rent_deposit
  141. union
  142. select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费'
  143. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type
  144. from wx_bill_property
  145. union
  146. select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  147. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type
  148. from wx_bill_property_deposit
  149. union
  150. select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type, 0 as
  151. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  152. from wx_bill_daily where type=1
  153. union
  154. select id,merchant_id,shop_id,tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  155. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  156. from wx_bill_daily where type=2
  157. union
  158. select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,'其他' bill_type,0 as
  159. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type
  160. from wx_bill_other
  161. ) bill
  162. left join wx_merchant m on bill.merchant_id=m.id
  163. left join wx_shop s on bill.shop_id=s.id
  164. left join wx_pay_bill pb on bill.id=pb.bill_id
  165. where 1=1
  166. <if test=" null != id ">
  167. and bill.id=#{id}
  168. </if>
  169. <if test=" null != tenantId ">
  170. and bill.tenant_id=#{tenantId}
  171. </if>
  172. <if test=" null != merchantId ">
  173. and bill.merchant_id=#{merchantId}
  174. </if>
  175. <if test=" null != statusList ">
  176. and bill.`status` in
  177. <foreach collection="statusList" index="index" item="status" open="(" separator="," close=")">
  178. #{status}
  179. </foreach>
  180. </if>
  181. <if test=" null != typeList ">
  182. and bill.`bill_type_value` in
  183. <foreach collection="typeList" index="index" item="type" open="(" separator="," close=")">
  184. #{type}
  185. </foreach>
  186. </if>
  187. <if test="null!=starttime and null!=endtime">
  188. and DATE_FORMAT(bill.receive_date,'%Y-%m') between #{starttime} and #{endtime}
  189. </if>
  190. <if test=" null != status ">
  191. and bill.status=#{status}
  192. </if>
  193. <if test=" null != billTypeValue ">
  194. and bill.bill_type_value=#{billTypeValue}
  195. </if>
  196. <if test=" null != rentShopType ">
  197. and bill.rent_shop_type = #{rentShopType}
  198. </if>
  199. order by bill.merchant_id,bill.status,bill.receive_date desc
  200. </select>
  201. <select id="getWaitPayBill" resultType="hashmap">
  202. select bill.tenant_id tenantId,bill.merchant_id merchantId,bill.receive_date receiveDate,
  203. bill.need_pay needPay,m.link_phone linkPhone,app.appname from (
  204. select bill.tenant_id,bill.merchant_id,bill.receive_date,ifnull(sum(need_pay),0) need_pay from (
  205. select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金'
  206. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  207. endtime,rent_shop_type from wx_bill_rent
  208. union
  209. select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  210. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  211. endtime,rent_shop_type from wx_bill_rent_deposit
  212. union
  213. select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费'
  214. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  215. endtime,rent_shop_type from wx_bill_property
  216. union
  217. select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  218. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  219. endtime,rent_shop_type from wx_bill_property_deposit
  220. union
  221. select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  222. 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
  223. from wx_bill_daily where type=1
  224. union
  225. select id,merchant_id,shop_id,tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  226. 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
  227. from wx_bill_daily where type=2
  228. union
  229. select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,'其他' bill_type,0 as
  230. 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
  231. from wx_bill_other
  232. ) bill
  233. where DATEDIFF(bill.receive_date,now())=3 and bill.status!=3
  234. group by bill.tenant_id,bill.merchant_id,bill.receive_date) bill
  235. left join wx_merchant m on bill.merchant_id=m.id
  236. left join (select tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
  237. </select>
  238. <select id="getOweBill" resultType="hashmap">
  239. select bill.tenant_id tenantId,bill.merchant_id merchantId,bill.owe,m.link_phone linkPhone,app.appname from (
  240. select bill.tenant_id,bill.merchant_id,sum(owe) owe from (
  241. select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金'
  242. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  243. endtime,rent_shop_type from wx_bill_rent
  244. union
  245. select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  246. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  247. endtime,rent_shop_type from wx_bill_rent_deposit
  248. union
  249. select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费'
  250. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  251. endtime,rent_shop_type from wx_bill_property
  252. union
  253. select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  254. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  255. endtime,rent_shop_type from wx_bill_property_deposit
  256. union
  257. select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  258. 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
  259. from wx_bill_daily where type=1
  260. union
  261. select id,merchant_id,shop_id,tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  262. 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
  263. from wx_bill_daily where type=2
  264. union
  265. select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,'其他' bill_type,0 as
  266. 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
  267. from wx_bill_other
  268. ) bill
  269. where DATEDIFF(bill.receive_date,now())&lt;0 and bill.status!=3
  270. group by bill.tenant_id,bill.merchant_id) bill
  271. left join wx_merchant m on bill.merchant_id=m.id
  272. left join (select tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id
  273. </select>
  274. </mapper>