后台服务
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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