You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

125 line
6.3 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.WxBillSettleMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillSettle">
  5. <id column="id" property="id"/>
  6. <result column="tenant_id" property="tenantId"/>
  7. <result column="settle_number" property="settleNumber"/>
  8. <result column="merchant_id" property="merchantId"/>
  9. <result column="status" property="status"/>
  10. <result column="apply_status" property="applyStatus"/>
  11. <result column="receiveMoney" property="receiveMoney"/>
  12. <result column="payMoney" property="payMoney"/>
  13. <result column="settletime" property="settletime"/>
  14. <result column="createtime" property="createtime"/>
  15. <result column="updatetime" property="updatetime"/>
  16. <result column="merchantName" property="merchantName"/>
  17. </resultMap>
  18. <sql id="allColumns">
  19. `id`,`tenant_id`,`settle_number`,`merchant_id`,`status`,`apply_status`,
  20. `receive_money`,`pay_money`,`settletime`,`createtime`,`updatetime`
  21. </sql>
  22. <sql id="dynamicWhereConditions">
  23. where 1=1
  24. <if test=" null != id ">and s.`id` = #{id}</if>
  25. <if test=" null != tenantId ">and s.`tenant_id` = #{tenantId}</if>
  26. <if test=" null != merchantName and merchantName !='' ">and m.name like concat('%', #{merchantName},'%')</if>
  27. <if test="startTime != null and startTime !=''">
  28. and createtime &gt;= #{startTime}
  29. </if>
  30. <if test="endTime != null and endTime !=''">
  31. and createtime &lt;= #{endTime}
  32. </if>
  33. <if test=" null != settleNumber and settleNumber !='' ">and s.`settle_number` = #{settleNumber}</if>
  34. <if test=" null != status and status !=''">and s.`status` = #{status}</if>
  35. <if test=" null != applyStatus and applyStatus !=''">and s.`apply_status` = #{applyStatus}</if>
  36. <if test=" null != sortColumns">order by ${sortColumns}</if>
  37. </sql>
  38. <select id="findList" parameterType="com.iformall.domain.po.WxBillSettle" resultMap="BaseResultMap">
  39. select s.*,m.name merchantName,
  40. (select IFNULL(sum(bill.receive_pay),0) from wx_bill_settle_bill bb left join
  41. (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金'
  42. 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
  43. union all
  44. select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金'
  45. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  46. wx_bill_rent_deposit
  47. union all
  48. select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费'
  49. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  50. wx_bill_property where is_preview = 0
  51. union all
  52. select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金'
  53. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  54. wx_bill_property_deposit
  55. union all
  56. select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as
  57. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  58. type=1
  59. union all
  60. select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as
  61. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  62. type=2
  63. union all
  64. select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费' bill_type,0 as
  65. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  66. type=3
  67. union all
  68. select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他费用' bill_type,0 as
  69. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  70. union all
  71. select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
  72. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
  73. ) bill
  74. on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=0
  75. ) receiveMoney,
  76. (select IFNULL(sum(bill.receive_pay),0) from wx_bill_settle_bill bb left join
  77. (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金'
  78. 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
  79. union all
  80. select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金'
  81. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  82. wx_bill_rent_deposit
  83. union all
  84. select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费'
  85. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  86. wx_bill_property where is_preview = 0
  87. union all
  88. select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金'
  89. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  90. wx_bill_property_deposit
  91. union all
  92. select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as
  93. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  94. type=1
  95. union all
  96. select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as
  97. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  98. type=2
  99. union all
  100. select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费' bill_type,0 as
  101. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  102. type=3
  103. union all
  104. select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他费用' bill_type,0 as
  105. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  106. union all
  107. select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
  108. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
  109. ) bill
  110. on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=1
  111. ) payMoney
  112. from wx_bill_settle s left JOIN wx_merchant m on(s.merchant_id=m.id)
  113. <include refid="dynamicWhereConditions"/>
  114. </select>
  115. </mapper>