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

1069 строки
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="listRentManageBillData" 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,#{billTypeName} name,#{manageFeeType} billTypeValue,#{billTypeName} billType,
  295. need_pay needPay,receive_pay receivePay,pay pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-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_manage bill
  299. where bill.manage_fee_type = #{manageFeeType}
  300. and rent_contract_id in (select id from wx_rent_contract where status in (2,3,4))
  301. <include refid="billSql"/>
  302. </select>
  303. <select id="listRentDepositBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
  304. select '' settle_number,id,merchant_id merchant_id,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租赁押金' name,2 billTypeValue,'租赁押金' billType,
  305. need_pay needPay,receive_pay receivePay,pay,(receive_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,
  306. status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,0 serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
  307. from wx_bill_rent_deposit bill
  308. where rent_contract_id in (select id from wx_rent_contract where status in (2,3,4))
  309. <include refid="billSql"/>
  310. </select>
  311. <select id="listPropertyBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
  312. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'物业费' name,3 billTypeValue,'物业费' billType,
  313. 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,
  314. DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,freeze,ifnull(late_pay_price,0) latePayPrice,
  315. service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
  316. from wx_bill_property bill
  317. where is_preview = 0
  318. and property_contract_id in (select id from wx_property_contract where status in(2,3,4))
  319. <include refid="billSql"/>
  320. </select>
  321. <select id="listPropertyDepositBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
  322. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'物业押金' name,4 billTypeValue,'物业押金' billType,
  323. need_pay needPay,receive_pay receivePay,pay,(receive_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,
  324. endtime,rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,0 serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
  325. from wx_bill_property_deposit bill
  326. where property_contract_id in (select id from wx_property_contract where status in (2,3,4))
  327. <include refid="billSql"/>
  328. </select>
  329. <select id="listDailyBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
  330. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,
  331. case when type=1 then '水费' when type=2 then '电费' else '空调费' end name,
  332. case when type=1 then 5 when type=2 then 6 else 9 end billTypeValue,
  333. case when type=1 then '水费' when type=2 then '电费' else '空调费' end billType, 0 as needPay,receive_pay receivePay,
  334. pay,(receive_pay+service_charge_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,
  335. 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
  336. from wx_bill_daily bill where bill.merchant_id=#{merchantId}
  337. <include refid="billSql"/>
  338. </select>
  339. <select id="listOtherBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
  340. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,name,7 billTypeValue,'其他费用' billType,0 as needPay,
  341. 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,
  342. rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
  343. from wx_bill_other bill where bill.merchant_id=#{merchantId}
  344. <include refid="billSql"/>
  345. </select>
  346. <select id="listOtherDepositBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
  347. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,comments as name,8 billTypeValue,'其他押金' billType,
  348. 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,
  349. '' 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
  350. from wx_bill_other_deposit bill where bill.merchant_id=#{merchantId}
  351. <include refid="billSql"/>
  352. </select>
  353. <select id="listSettleBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
  354. 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,
  355. settle_receive_pay receivePay,0 pay,0 owe,createtime receiveDate,'' pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,
  356. status,'' starttime,'' endtime,'' rentShopType,'' priceDetail, 0 freeze,0 latePayPrice,0 serviceChargePay
  357. from wx_bill_settle_schedule bill where bill.status >0
  358. <include refid="billSql"/>
  359. </select>
  360. <select id="detailRentBillData" resultType="hashmap" parameterType="Long">
  361. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租金' name,1 billTypeValue,'租金' billType,
  362. need_pay needPay,receive_pay receivePay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) owe,
  363. receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,
  364. freeze,ifnull(late_pay_price,0) latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
  365. from wx_bill_rent bill
  366. where bill.id = #{id}
  367. </select>
  368. <select id="detailRentDepositBillData" resultType="hashmap" parameterType="Long">
  369. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租赁押金' name,2 billTypeValue,'租赁押金' billType,
  370. need_pay needPay,receive_pay receivePay,pay,(receive_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,
  371. status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,0 serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
  372. from wx_bill_rent_deposit bill
  373. where bill.id = #{id}
  374. </select>
  375. <select id="detailPropertyBillData" resultType="hashmap" parameterType="Long">
  376. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'物业费' name,3 billTypeValue,'物业费' billType,
  377. 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,
  378. DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,freeze,ifnull(late_pay_price,0) latePayPrice,
  379. service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
  380. from wx_bill_property bill
  381. where bill.id = #{id}
  382. </select>
  383. <select id="detailPropertyDepositBillData" resultType="hashmap" parameterType="Long">
  384. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'物业押金' name,4 billTypeValue,'物业押金' billType,
  385. need_pay needPay,receive_pay receivePay,pay,(receive_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,
  386. endtime,rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,0 serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
  387. from wx_bill_property_deposit bill
  388. where bill.id = #{id}
  389. </select>
  390. <select id="detailDailyBillData" resultType="hashmap" parameterType="Long">
  391. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,
  392. case when type=1 then '水费' when type=2 then '电费' else '空调费' end name,
  393. case when type=1 then 5 when type=2 then 6 else 9 end billTypeValue,
  394. case when type=1 then '水费' when type=2 then '电费' else '空调费' end billType, 0 as needPay,receive_pay receivePay,
  395. pay,(receive_pay+service_charge_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,
  396. 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
  397. from wx_bill_daily bill where bill.id = #{id}
  398. </select>
  399. <select id="detailOtherBillData" resultType="hashmap" parameterType="Long">
  400. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,name,7 billTypeValue,'其他费用' billType,0 as needPay,
  401. 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,
  402. rent_shop_type rentShopType,'' priceDetail,freeze,0 latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
  403. from wx_bill_other bill where bill.id = #{id}
  404. </select>
  405. <select id="detailOtherDepositBillData" resultType="hashmap" parameterType="Long">
  406. select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,comments as name,8 billTypeValue,'其他押金' billType,
  407. 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,
  408. '' 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
  409. from wx_bill_other_deposit bill where bill.id = #{id}
  410. </select>
  411. <select id="getWaitPayBill" resultType="hashmap">
  412. select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.receive_date receiveDate,
  413. bill.need_pay needPay,m.link_phone linkPhone,app.appname,m.email,bill.bill_type billType from (
  414. select bill.bill_type,bill.tenant_id,parent_tenant_id,bill.merchant_id,bill.receive_date,ifnull(sum(need_pay),0) need_pay from (
  415. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  416. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  417. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  418. union all
  419. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  420. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  421. endtime,rent_shop_type from wx_bill_rent_deposit
  422. union all
  423. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  424. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  425. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  426. union all
  427. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  428. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  429. endtime,rent_shop_type from wx_bill_property_deposit
  430. union all
  431. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  432. 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
  433. from wx_bill_daily where type=1
  434. union all
  435. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  436. 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
  437. from wx_bill_daily where type=2
  438. union all
  439. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
  440. 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
  441. from wx_bill_daily where type=3
  442. union all
  443. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
  444. 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
  445. from wx_bill_other
  446. union all
  447. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  448. 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
  449. from wx_bill_other_deposit
  450. ) bill
  451. where bill.status not in(3,5,6)
  452. group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.receive_date) bill
  453. left join wx_merchant m on bill.merchant_id=m.id
  454. 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
  455. where m.status=1 and DATEDIFF(bill.receive_date,now())=m.bill_setting
  456. </select>
  457. <select id="getOweBill" resultType="hashmap">
  458. 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 (
  459. select bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,sum(owe) owe from (
  460. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  461. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  462. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  463. union all
  464. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  465. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  466. endtime,rent_shop_type from wx_bill_rent_deposit
  467. union all
  468. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  469. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  470. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  471. union all
  472. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  473. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  474. endtime,rent_shop_type from wx_bill_property_deposit
  475. union all
  476. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  477. 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
  478. from wx_bill_daily where type=1
  479. union all
  480. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  481. 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
  482. from wx_bill_daily where type=2
  483. union all
  484. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
  485. 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
  486. from wx_bill_daily where type=3
  487. union all
  488. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
  489. 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
  490. from wx_bill_other
  491. union all
  492. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  493. 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
  494. from wx_bill_other_deposit
  495. ) bill
  496. where DATEDIFF(bill.receive_date,now())&lt;0 and bill.status not in(3,5,6)
  497. group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id) bill
  498. left join wx_merchant m on bill.merchant_id=m.id
  499. 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
  500. where m.status=1
  501. </select>
  502. <select id="getWaitPayBillForEmail" resultType="hashmap">
  503. select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.receive_date receiveDate,
  504. bill.need_pay needPay,m.link_phone linkPhone,app.appname,m.email,bill.bill_type billType,ws.manager,ws.manager_phone managerPhone from (
  505. 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 (
  506. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  507. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  508. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  509. union all
  510. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  511. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  512. endtime,rent_shop_type from wx_bill_rent_deposit
  513. union all
  514. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  515. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  516. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  517. union
  518. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  519. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  520. endtime,rent_shop_type from wx_bill_property_deposit
  521. union all
  522. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  523. 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
  524. from wx_bill_daily where type=1
  525. union all
  526. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  527. 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
  528. from wx_bill_daily where type=2
  529. union all
  530. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
  531. 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
  532. from wx_bill_daily where type=3
  533. union all
  534. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
  535. 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
  536. from wx_bill_other
  537. union all
  538. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  539. 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
  540. from wx_bill_other_deposit
  541. ) bill
  542. where bill.status not in(3,5,6)
  543. group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.receive_date,bill.bill_type
  544. ) bill
  545. left join wx_merchant m on bill.merchant_id=m.id
  546. 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
  547. left join wx_merchant_shop wms on wms.merchant_id = m.id
  548. left join wx_shop ws on wms.shop_id = ws.id
  549. where m.status=1 and DATEDIFF(bill.receive_date,now())=m.bill_setting
  550. </select>
  551. <select id="getOweBillForEmail" resultType="hashmap">
  552. 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
  553. ,DATEDIFF(now(),bill.receive_date) expiredDay from (
  554. select bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.bill_type,sum(owe) owe,bill.receive_date,bill.expired_day from (
  555. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  556. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  557. endtime,rent_shop_type from wx_bill_rent where is_preview = 0
  558. union all
  559. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
  560. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  561. endtime,rent_shop_type from wx_bill_rent_deposit
  562. union all
  563. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  564. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  565. endtime,rent_shop_type from wx_bill_property where is_preview = 0
  566. union all
  567. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
  568. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  569. endtime,rent_shop_type from wx_bill_property_deposit
  570. union all
  571. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as
  572. 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
  573. from wx_bill_daily where type=1
  574. union all
  575. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as
  576. 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
  577. from wx_bill_daily where type=2
  578. union all
  579. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as
  580. 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
  581. from wx_bill_daily where type=3
  582. union all
  583. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as
  584. 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
  585. from wx_bill_other
  586. union all
  587. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as
  588. 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
  589. from wx_bill_other_deposit
  590. ) bill
  591. where DATEDIFF(bill.receive_date,now())&lt;0 and bill.status not in(3,5,6)
  592. group by bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.bill_type) bill
  593. left join wx_merchant m on bill.merchant_id=m.id
  594. 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
  595. where m.status=1
  596. </select>
  597. <sql id="getOweBillAsPageConditions">
  598. and status !=6
  599. <if test="null != status ">
  600. and status = #{status}
  601. </if>
  602. <if test=" null != month and ''!=month">
  603. and date_format(receive_date,'%Y-%m')=#{month}
  604. </if>
  605. <if test=" null != starttime and ''!=starttime">
  606. and receive_date >= #{starttime}
  607. </if>
  608. <if test=" null != endtime and ''!=endtime">
  609. and receive_date &lt;= #{endtime}
  610. </if>
  611. </sql>
  612. <select id="getOweBillAsPage" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  613. select bill.tenant_id tenantId,bill.parent_tenant_id parentTenantId,bill.merchant_id merchantId,m.name merchantName,bill.bill_type billType,
  614. m.link_phone managerPhone,m.`link_person` manager,m.email,
  615. bill.receive_date receiveDate,DATEDIFF(now(),bill.receive_date) expiredDay,
  616. round(bill.rentOwe/100,2) rentOwe,
  617. round(bill.bmOwe/100,2) bussinessManageOwe,
  618. round(bill.omOwe/100,2) operatingManageOwe,
  619. round(bill.propertyOwe/100,2) propertyOwe,
  620. round(bill.depositOwe/100,2) depositOwe,
  621. round(bill.otherOwe/100,2) otherOwe,
  622. round((bill.rentOwe+bill.bmOwe+bill.omOwe+bill.propertyOwe+bill.depositOwe+bill.otherOwe)/100,2) totalOwe,
  623. <choose>
  624. <when test="1==filterHasPay">
  625. round((bill.rentReceivePay+bill.rentLatePay+bill.rentServiceChargePay-bill.rentPay)/100,2)
  626. rentReceivePay,
  627. round((bill.bmReceivePay+bill.bmLatePay+bill.bmServiceChargePay-bill.bmPay)/100,2)
  628. bussinessManageReceivePay,
  629. round((bill.omReceivePay+bill.omLatePay+bill.omServiceChargePay-bill.omPay)/100,2)
  630. operatingManageReceivePay,
  631. round((bill.propertyReceivePay+bill.propertyLatePay+bill.propertyServiceChargePay-bill.propertyPay)/100,2)
  632. propertyReceivePay,
  633. round((bill.depositReceivePay+bill.depositLatePay+bill.depositServiceChargePay-bill.depositPay)/100,2)
  634. depositReceivePay,
  635. round((bill.otherReceivePay+bill.otherLatePay+bill.otherServiceChargePay-bill.otherPay)/100,2)
  636. otherReceivePay,
  637. round((bill.rentReceivePay+bill.bmReceivePay+bill.omReceivePay+bill.propertyReceivePay+bill.depositReceivePay+bill.otherReceivePay
  638. +bill.rentLatePay+bill.propertyLatePay+bill.depositLatePay+bill.otherLatePay
  639. +bill.rentServiceChargePay+bill.propertyServiceChargePay+bill.depositServiceChargePay+bill.otherServiceChargePay
  640. -bill.rentPay-bill.propertyPay-bill.depositPay-bill.otherPay)/100,2) totalReceivePay
  641. </when>
  642. <otherwise>
  643. round((bill.rentReceivePay+bill.rentLatePay+bill.rentServiceChargePay)/100,2) rentReceivePay,
  644. round((bill.bmReceivePay+bill.bmLatePay+bill.bmServiceChargePay)/100,2) bussinessManageReceivePay,
  645. round((bill.omReceivePay+bill.omLatePay+bill.omServiceChargePay)/100,2) operatingManageReceivePay,
  646. round((bill.propertyReceivePay+bill.propertyLatePay+bill.propertyServiceChargePay)/100,2)
  647. propertyReceivePay,
  648. round((bill.depositReceivePay+bill.depositLatePay+bill.depositServiceChargePay)/100,2)
  649. depositReceivePay,
  650. round((bill.otherReceivePay+bill.otherLatePay+bill.otherServiceChargePay)/100,2) otherReceivePay,
  651. round((bill.rentReceivePay+bill.bmReceivePay+bill.omReceivePay+bill.propertyReceivePay+bill.depositReceivePay
  652. +bill.otherReceivePay+bill.rentLatePay+bill.propertyLatePay+bill.depositLatePay
  653. +bill.otherLatePay+bill.rentServiceChargePay+bill.propertyServiceChargePay+bill.depositServiceChargePay+bill.otherServiceChargePay)/100,2)
  654. totalReceivePay
  655. </otherwise>
  656. </choose>
  657. from (
  658. select oweList.*,
  659. max(case oweList.bill_type when '租金' then oweList.owe else 0 end) rentOwe,
  660. max(case oweList.bill_type when '商业管理费' then oweList.owe else 0 end) bmOwe,
  661. max(case oweList.bill_type when '营业管理费' then oweList.owe else 0 end) omOwe,
  662. max(case oweList.bill_type when '物业费' then oweList.owe else 0 end) propertyOwe,
  663. max(case oweList.bill_type when '欠缴押金' then oweList.owe else 0 end) depositOwe,
  664. max(case oweList.bill_type when '其他费用' then oweList.owe else 0 end) otherOwe,
  665. max(case oweList.bill_type when '租金' then oweList.receive_pay else 0 end) rentReceivePay,
  666. max(case oweList.bill_type when '商业管理费' then oweList.receive_pay else 0 end) bmReceivePay,
  667. max(case oweList.bill_type when '营业管理费' then oweList.receive_pay else 0 end) omReceivePay,
  668. max(case oweList.bill_type when '物业费' then oweList.receive_pay else 0 end) propertyReceivePay,
  669. max(case oweList.bill_type when '欠缴押金' then oweList.receive_pay else 0 end) depositReceivePay,
  670. max(case oweList.bill_type when '其他费用' then oweList.receive_pay else 0 end) otherReceivePay,
  671. max(case oweList.bill_type when '租金' then oweList.pay else 0 end) rentPay,
  672. max(case oweList.bill_type when '商业管理费' then oweList.pay else 0 end) bmPay,
  673. max(case oweList.bill_type when '营业管理费' then oweList.pay else 0 end) omPay,
  674. max(case oweList.bill_type when '物业费' then oweList.pay else 0 end) propertyPay,
  675. max(case oweList.bill_type when '欠缴押金' then oweList.pay else 0 end) depositPay,
  676. max(case oweList.bill_type when '其他费用' then oweList.pay else 0 end) otherPay,
  677. max(case oweList.bill_type when '租金' then oweList.latePayPrice else 0 end) rentLatePay,
  678. max(case oweList.bill_type when '商业管理费' then oweList.latePayPrice else 0 end) bmLatePay,
  679. max(case oweList.bill_type when '营业管理费' then oweList.latePayPrice else 0 end) omLatePay,
  680. max(case oweList.bill_type when '物业费' then oweList.latePayPrice else 0 end) propertyLatePay,
  681. max(case oweList.bill_type when '欠缴押金' then oweList.latePayPrice else 0 end) depositLatePay,
  682. max(case oweList.bill_type when '其他费用' then oweList.latePayPrice else 0 end) otherLatePay,
  683. max(case oweList.bill_type when '租金' then oweList.serviceChargePay else 0 end) rentServiceChargePay,
  684. max(case oweList.bill_type when '商业管理费' then oweList.serviceChargePay else 0 end) bmServiceChargePay,
  685. max(case oweList.bill_type when '营业管理费' then oweList.serviceChargePay else 0 end) omServiceChargePay,
  686. max(case oweList.bill_type when '物业费' then oweList.serviceChargePay else 0 end) propertyServiceChargePay,
  687. max(case oweList.bill_type when '欠缴押金' then oweList.serviceChargePay else 0 end) depositServiceChargePay,
  688. max(case oweList.bill_type when '其他费用' then oweList.serviceChargePay else 0 end) otherServiceChargePay
  689. from(
  690. select bill.tenant_id,bill.parent_tenant_id,bill.merchant_id,bill.bill_type,sum(owe)
  691. owe,bill.receive_date,bill.expired_day,sum(bill.receive_pay) receive_pay,sum(bill.pay)
  692. pay,sum(ifnull(bill.late_pay_price,0)) latePayPrice,sum(bill.service_charge_pay) serviceChargePay from (
  693. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租金' name,1 bill_type_value,'租金'
  694. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d')
  695. receive_date,pay_date,expired_day,status,'' starttime,''
  696. endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_rent
  697. where is_preview = 0
  698. <if test=" null != tenantId and '' != tenantId">
  699. and `tenant_id` = #{tenantId}
  700. </if>
  701. <if test=" null != parentTenantId and '' != parentTenantId">
  702. and `parent_tenant_id` = #{parentTenantId}
  703. </if>
  704. <include refid="getOweBillAsPageConditions"/>
  705. union all
  706. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'商业管理费' name,11 bill_type_value,'商业管理费'
  707. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d')
  708. receive_date,pay_date,expired_day,status,'' starttime,''
  709. endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_rent_manage
  710. where manage_fee_type = 1
  711. <if test=" null != tenantId and '' != tenantId">
  712. and `tenant_id` = #{tenantId}
  713. </if>
  714. <if test=" null != parentTenantId and '' != parentTenantId">
  715. and `parent_tenant_id` = #{parentTenantId}
  716. </if>
  717. <include refid="getOweBillAsPageConditions"/>
  718. union all
  719. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'营业管理费' name,12 bill_type_value,'营业管理费'
  720. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d')
  721. receive_date,pay_date,expired_day,status,'' starttime,''
  722. endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_rent_manage
  723. where manage_fee_type = 2
  724. <if test=" null != tenantId and '' != tenantId">
  725. and `tenant_id` = #{tenantId}
  726. </if>
  727. <if test=" null != parentTenantId and '' != parentTenantId">
  728. and `parent_tenant_id` = #{parentTenantId}
  729. </if>
  730. <include refid="getOweBillAsPageConditions"/>
  731. union all
  732. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业费' name,3 bill_type_value,'物业费'
  733. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  734. endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_property where is_preview = 0
  735. <if test=" null != tenantId and '' != tenantId">
  736. and `tenant_id` = #{tenantId}
  737. </if>
  738. <if test=" null != parentTenantId and '' != parentTenantId">
  739. and `parent_tenant_id` = #{parentTenantId}
  740. </if>
  741. <include refid="getOweBillAsPageConditions"/>
  742. union all
  743. 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,
  744. res.receive_pay,res.pay,res.owe
  745. owe,res.receive_date,res.pay_date,res.expired_day,res.status,res.starttime,res.endtime,res.rent_shop_type,0
  746. late_pay_price,0 service_charge_pay from(
  747. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'欠缴押金' name,2 bill_type_value,'欠缴押金'
  748. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  749. endtime,rent_shop_type,service_charge_pay from wx_bill_rent_deposit where 1=1
  750. <if test=" null != tenantId and '' != tenantId">
  751. and `tenant_id` = #{tenantId}
  752. </if>
  753. <if test=" null != parentTenantId and '' != parentTenantId">
  754. and `parent_tenant_id` = #{parentTenantId}
  755. </if>
  756. <include refid="getOweBillAsPageConditions"/>
  757. union all
  758. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'欠缴押金' name,4 bill_type_value,'欠缴押金'
  759. bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,''
  760. endtime,rent_shop_type,0 service_charge_pay from wx_bill_property_deposit where 1=1
  761. <if test=" null != tenantId and '' != tenantId">
  762. and `tenant_id` = #{tenantId}
  763. </if>
  764. <if test=" null != parentTenantId and '' != parentTenantId">
  765. and `parent_tenant_id` = #{parentTenantId}
  766. </if>
  767. <include refid="getOweBillAsPageConditions"/>
  768. union all
  769. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'欠缴押金' name,8 bill_type_value,'欠缴押金' bill_type,0 as
  770. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,
  771. pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay
  772. from wx_bill_other_deposit where 1=1
  773. <if test=" null != tenantId and '' != tenantId">
  774. and `tenant_id` = #{tenantId}
  775. </if>
  776. <if test=" null != parentTenantId and '' != parentTenantId">
  777. and `parent_tenant_id` = #{parentTenantId}
  778. </if>
  779. <include refid="getOweBillAsPageConditions"/>
  780. ) res
  781. union all
  782. 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,
  783. res.receive_pay,res.pay,res.owe
  784. owe,res.receive_date,res.pay_date,res.expired_day,res.status,res.starttime,res.endtime,res.rent_shop_type,0
  785. late_pay_price,service_charge_pay from(
  786. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'其他费用' name,5 bill_type_value,'其他费用' bill_type,0 as
  787. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,
  788. expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay
  789. from wx_bill_daily where type in(1,2,3)
  790. <if test=" null != tenantId and '' != tenantId">
  791. and `tenant_id` = #{tenantId}
  792. </if>
  793. <if test=" null != parentTenantId and '' != parentTenantId">
  794. and `parent_tenant_id` = #{parentTenantId}
  795. </if>
  796. <include refid="getOweBillAsPageConditions"/>
  797. union all
  798. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'其他费用' name,7 bill_type_value,'其他费用' bill_type,0 as
  799. need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,
  800. expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay
  801. from wx_bill_other where 1=1
  802. <if test=" null != tenantId and '' != tenantId">
  803. and `tenant_id` = #{tenantId}
  804. </if>
  805. <if test=" null != parentTenantId and '' != parentTenantId">
  806. and `parent_tenant_id` = #{parentTenantId}
  807. </if>
  808. <include refid="getOweBillAsPageConditions"/>
  809. ) res
  810. ) bill
  811. where bill.status not in(3,5,6)
  812. group by bill.merchant_id,bill.bill_type
  813. ) oweList group by oweList.merchant_id
  814. ) bill
  815. left join wx_merchant m on bill.merchant_id=m.id
  816. where 1=1
  817. <if test=" null != tenantId and '' != tenantId">
  818. and m.`tenant_id` = #{tenantId}
  819. </if>
  820. <if test=" null != parentTenantId and '' != parentTenantId">
  821. and m.`parent_tenant_id` = #{parentTenantId}
  822. </if>
  823. <if test=" null != merchantName and '' != merchantName">and m.name like concat('%', #{merchantName},'%')</if>
  824. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  825. <if test=" null == sortColumns"> order by totalOwe desc </if>
  826. </select>
  827. <select id="getReceiveAndPayBillAsPage" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
  828. select tt.* from (
  829. 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,
  830. xb.title business,rc.rental_start_date rentalStartDate,rc.rental_end_date rentalEndDate,rc.rent_shop_type,
  831. ifnull(round(
  832. (select sum(bill.receive_pay)+sum(bill.late_pay_price)+sum(bill.receivePay) from (
  833. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
  834. wx_bill_rent where is_preview = 0 and status not in(3,6)
  835. union all
  836. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
  837. wx_bill_rent_manage where status not in(3,6)
  838. union all
  839. select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
  840. wx_bill_rent_deposit where status not in(3,6)
  841. union all
  842. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
  843. wx_bill_property where is_preview = 0 and status not in(3,6)
  844. union all
  845. select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
  846. wx_bill_property_deposit where status not in(3,6)
  847. union all
  848. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  849. wx_bill_daily where type in(1,2,3) and status not in(3,6)
  850. union all
  851. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  852. wx_bill_other where status not in(3,6)
  853. union all
  854. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  855. wx_bill_other_deposit where status not in(3,6)
  856. ) bill where bill.merchant_id = m.id
  857. )/100,2),0) receivePay,
  858. ifnull(round(
  859. (select sum(ss.money) from (
  860. select subsidy money,merchant_id id from wx_merchant_subsidy where status = 0
  861. union all
  862. select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3
  863. union all
  864. select receive_pay money,merchant_id id from wx_bill_property_deposit where status = 3
  865. union all
  866. select receive_pay money,merchant_id id from wx_bill_other_deposit where status = 3
  867. )ss where ss.id = m.id
  868. )/100,2),0) payOut,
  869. (ifnull(round(
  870. (select sum(bill.receive_pay)+sum(bill.late_pay_price)+sum(bill.receivePay) from (
  871. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
  872. wx_bill_rent
  873. where is_preview = 0 and status not in(3,6)
  874. union all
  875. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
  876. wx_bill_rent_manage
  877. where status not in(3,6)
  878. union all
  879. select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
  880. wx_bill_rent_deposit where status not in(3,6)
  881. union all
  882. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,late_pay_price from
  883. wx_bill_property where is_preview = 0 and status not in(3,6)
  884. union all
  885. select merchant_id,receive_pay,0 receivePay,0 late_pay_price from
  886. wx_bill_property_deposit where status not in(3,6)
  887. union all
  888. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  889. wx_bill_daily where type in(1,2,3) and status not in(3,6)
  890. union all
  891. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  892. wx_bill_other where status not in(3,6)
  893. union all
  894. select merchant_id,receive_pay,ifnull(service_charge_pay,0) receivePay,0 late_pay_price from
  895. wx_bill_other_deposit where status not in(3,6)
  896. ) bill where bill.merchant_id = m.id
  897. )/100,2),0)-
  898. ifnull(round(
  899. (select sum(ss.money) from (
  900. select subsidy money,merchant_id id from wx_merchant_subsidy where order_type in(3,0) and status = 0
  901. union all
  902. select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3
  903. union all
  904. select receive_pay money,merchant_id id from wx_bill_property_deposit where status = 3
  905. union all
  906. select receive_pay money,merchant_id id from wx_bill_other_deposit where status = 3
  907. )ss where ss.id = m.id
  908. )/100,2),0)) balance
  909. from wx_merchant m
  910. left join (select ms.merchant_id,s.type,GROUP_CONCAT(s.shop_number) as shop_number
  911. from wx_merchant_shop ms inner join wx_shop s on ms.shop_id=s.id where ms.is_del=0
  912. group by ms.merchant_id) ws on m.id=ws.merchant_id
  913. left join wx_business xb on(m.business_id = xb.id)
  914. left join wx_rent_contract rc on(rc.merchant_id = m.id)
  915. where m.status=1
  916. ) tt where 1=1
  917. <if test=" null != tenantId and '' != tenantId">
  918. and tt.`tenant_id` = #{tenantId}
  919. </if>
  920. <if test=" null != parentTenantId and '' != parentTenantId">
  921. and tt.`parent_tenant_id` = #{parentTenantId}
  922. </if>
  923. <if test=" null != merchantId"> and tt.id = #{merchantId} </if>
  924. <if test=" null != merchantName and ''!=merchantName">and tt.name like concat('%', #{merchantName},'%')</if>
  925. <if test=" null != rentShopType"> and tt.rent_shop_type = #{rentShopType} </if>
  926. and (receivePay >0 or payOut>0)
  927. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  928. <if test=" null == sortColumns"> order by tt.id desc </if>
  929. <if test="null != limitStart and null != limitEnd">
  930. limit #{limitStart},#{limitEnd}
  931. </if>
  932. </select>
  933. <select id="allDepositList" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
  934. select bill.*
  935. from (
  936. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'租赁押金' name,2 billTypeValue,'租赁押金'
  937. billType,need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze,0
  938. late_pay_price,0
  939. service_charge_pay
  940. from wx_bill_rent_deposit where 1=1
  941. <if test=" null != tenantId and '' != tenantId">
  942. and `tenant_id` = #{tenantId}
  943. </if>
  944. <if test=" null != parentTenantId and '' != parentTenantId">
  945. and `parent_tenant_id` = #{parentTenantId}
  946. </if>
  947. union all
  948. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,'物业押金' name,4 billTypeValue,'物业押金'
  949. billType,need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze,0
  950. late_pay_price,0
  951. service_charge_pay
  952. from wx_bill_property_deposit where 1=1
  953. <if test=" null != tenantId and '' != tenantId">
  954. and `tenant_id` = #{tenantId}
  955. </if>
  956. <if test=" null != parentTenantId and '' != parentTenantId">
  957. and `parent_tenant_id` = #{parentTenantId}
  958. </if>
  959. union all
  960. select id,merchant_id,shop_id,tenant_id,parent_tenant_id,comments as name,8 billTypeValue,concat('其他押金-',comments) as
  961. billType,0 as need_pay,receive_pay receivePay,pay,owe,receive_date
  962. receiveDate,pay_date,expired_day,status,freeze,0
  963. late_pay_price,service_charge_pay
  964. from wx_bill_other_deposit where 1=1
  965. <if test=" null != tenantId and '' != tenantId">
  966. and `tenant_id` = #{tenantId}
  967. </if>
  968. <if test=" null != parentTenantId and '' != parentTenantId">
  969. and `parent_tenant_id` = #{parentTenantId}
  970. </if>
  971. ) bill
  972. where 1=1
  973. <if test=" null != freeze"> and bill.freeze = #{freeze} </if>
  974. <if test=" null != status"> and bill.status = #{status} </if>
  975. <if test=" null != merchantId">and bill.merchant_id=#{merchantId}</if>
  976. </select>
  977. </mapper>