Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

155 wiersze
7.2 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 tt.`id` = #{id}</if>
  25. <if test=" null != tenantId ">and tt.`tenant_id` = #{tenantId}</if>
  26. <if test=" null != merchantName and merchantName !='' ">and tt.merchantName like concat('%', #{merchantName},'%')</if>
  27. <if test="starttime != null">
  28. and tt.createtime &gt;= #{starttime}
  29. </if>
  30. <if test="endtime != null">
  31. and tt.createtime &lt;= #{endtime}
  32. </if>
  33. <if test=" null != settleNumber and settleNumber !='' ">and tt.`settle_number` = #{settleNumber}</if>
  34. <if test=" null != status">and tt.`status` = #{status}</if>
  35. <if test=" null != applyStatus">and tt.`apply_status` = #{applyStatus}</if>
  36. <if test="0 == direction">
  37. and (tt.receiveMoney-tt.payMoney-
  38. (select IFNULL(sum(settle_money),0) from wx_bill_settle_record where settle_id = tt.id)
  39. ) >0
  40. </if>
  41. <if test="1 == direction">
  42. and (tt.receiveMoney-tt.payMoney-
  43. (select IFNULL(sum(settle_money),0) from wx_bill_settle_record where settle_id = tt.id)
  44. ) &lt;0
  45. </if>
  46. <if test=" null != sortColumns">order by ${sortColumns}</if>
  47. </sql>
  48. <select id="findList" parameterType="com.iformall.domain.po.WxBillSettle" resultMap="BaseResultMap">
  49. select tt.*
  50. <if test="0 == filterSettleRecord">
  51. ,(tt.receiveMoney-tt.payMoney-
  52. (select IFNULL(sum(settle_money),0) from wx_bill_settle_record where settle_id = tt.id)
  53. ) balance
  54. </if>
  55. <if test="1 == filterSettleRecord">
  56. ,(tt.receiveMoney-tt.payMoney) balance
  57. </if>
  58. from (
  59. select s.*,m.name merchantName,
  60. (select IFNULL(sum(bill.owe),0) from wx_bill_settle_bill bb left join
  61. (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金'
  62. 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
  63. union all
  64. select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金'
  65. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  66. wx_bill_rent_deposit
  67. union all
  68. select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费'
  69. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  70. wx_bill_property where is_preview = 0
  71. union all
  72. select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金'
  73. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  74. wx_bill_property_deposit
  75. union all
  76. select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as
  77. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  78. type=1
  79. union all
  80. select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as
  81. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  82. type=2
  83. union all
  84. select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费' bill_type,0 as
  85. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  86. type=3
  87. union all
  88. select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他费用' bill_type,0 as
  89. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  90. union all
  91. select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
  92. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
  93. ) bill
  94. on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=0
  95. ) receiveMoney,
  96. (select IFNULL(sum(bill.owe),0) from wx_bill_settle_bill bb left join
  97. (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金'
  98. 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
  99. union all
  100. select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金'
  101. bill_type,need_pay,receive_pay,pay,receive_pay owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  102. wx_bill_rent_deposit
  103. union all
  104. select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费'
  105. bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  106. wx_bill_property where is_preview = 0
  107. union all
  108. select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金'
  109. bill_type,need_pay,receive_pay,pay,receive_pay owe,receive_date,pay_date,expired_day,status,rent_shop_type from
  110. wx_bill_property_deposit
  111. union all
  112. select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as
  113. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  114. type=1
  115. union all
  116. select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as
  117. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  118. type=2
  119. union all
  120. select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费' bill_type,0 as
  121. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where
  122. type=3
  123. union all
  124. select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他费用' bill_type,0 as
  125. need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other
  126. union all
  127. select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as
  128. need_pay,receive_pay,pay,receive_pay owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit
  129. union all
  130. select id,id merchant_id,'' shop_id,tenant_id,10 bill_type_value,'补贴' bill_type,0 as
  131. need_pay,subsidy receive_pay,0 pay,subsidy owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type from wx_merchant_subsidy
  132. ) bill
  133. on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=1
  134. ) payMoney
  135. from wx_bill_settle s left JOIN wx_merchant m on(s.merchant_id=m.id)
  136. ) tt
  137. <include refid="dynamicWhereConditions"/>
  138. <if test="null != limitStart and null != limitEnd">
  139. limit #{limitStart},#{limitEnd}
  140. </if>
  141. </select>
  142. </mapper>