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

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