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

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