Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 

201 рядки
10 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.WxBillPropertyDepositMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillPropertyDeposit">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  8. <result column="property_contract_id" jdbcType="BIGINT" property="propertyContractId"/>
  9. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  10. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  11. <result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate" />
  12. <result column="pay_date" jdbcType="TIMESTAMP" property="payDate" />
  13. <result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
  14. <result column="expired_day" jdbcType="INTEGER" property="expiredDay" />
  15. <result column="owe" jdbcType="VARCHAR" property="owe"/>
  16. <result column="status" jdbcType="INTEGER" property="status" />
  17. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  18. <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
  19. <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
  20. <result column="is_del" jdbcType="INTEGER" property="isDel" />
  21. <result column="need_pay" jdbcType="VARCHAR" property="needPay" />
  22. <result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
  23. <result column="user_id" jdbcType="INTEGER" property="userId" />
  24. <result column="shop_id" jdbcType="INTEGER" property="shopId" />
  25. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
  26. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  27. <result column="return_price" jdbcType="VARCHAR" property="returnPrice"/>
  28. <result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/>
  29. <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
  30. <result column="freeze" property="freeze"/>
  31. <result column="service_charge_pay" property="serviceChargePay"/>
  32. <result column="merchant_name" property="merchantName"/>
  33. <result column="shop_number" property="shopNumber"/>
  34. <result column="bill_type_name" property="billTypeName"/>
  35. <result column="bill_remark" property="billRemark"/>
  36. </resultMap>
  37. <sql id="allColumns">
  38. `id`,`tenant_id`,`parent_tenant_id`,`property_contract_id`,`receive_pay`,`pay`,`receive_date`,
  39. `pay_date`,`createtime`,`expired_day`,`owe`,`status`,`is_del`,`need_pay`,`apply_status`,`apply_pay_img`,`apply_update_time`,
  40. `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,`return_price`,`shop_info`,`pay_way`,freeze,service_charge_pay,
  41. '物业押金' bill_type_name,'' bill_remark
  42. </sql>
  43. <sql id="dynamicWhereConditions">
  44. where 1 = 1
  45. <if test=" null != id "> and `id` = #{id} </if>
  46. <if test=" null != tenantId and '' != tenantId">
  47. and `tenant_id` = #{tenantId}
  48. </if>
  49. <if test=" null != parentTenantId and '' != parentTenantId">
  50. and `parent_tenant_id` = #{parentTenantId}
  51. </if>
  52. <if test=" null != propertyContractId "> and `property_contract_id` = #{propertyContractId} </if>
  53. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  54. <if test=" null != pay "> and `pay` = #{pay} </if>
  55. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  56. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  57. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  58. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
  59. <if test=" null != owe "> and `owe` = #{owe} </if>
  60. <if test=" null != status "> and `status` = #{status} </if>
  61. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  62. <if test=" null != isDel "> and `is_del` = #{isDel} </if>
  63. <if test=" null != needPay "> and `need_pay` = #{needPay} </if>
  64. <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
  65. <if test=" null != userId "> and `user_id` = #{userId} </if>
  66. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  67. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  68. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  69. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  70. <if test=" null != propertyContractIdList ">
  71. and property_contract_id in
  72. <foreach collection="propertyContractIdList" index="index" item="pidItem" open="(" separator="," close=")">
  73. #{pidItem}
  74. </foreach>
  75. </if>
  76. <if test=" null != ids ">
  77. and id in
  78. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  79. #{idItem}
  80. </foreach>
  81. </if>
  82. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  83. </sql>
  84. <select id="findList" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="BaseResultMap">
  85. select <include refid="allColumns" /> from wx_bill_property_deposit
  86. <include refid="dynamicWhereConditions" />
  87. </select>
  88. <select id="findPropertyContractIds" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="BaseResultMap">
  89. select distinct property_contract_id from wx_bill_property_deposit
  90. <include refid="dynamicWhereConditions" />
  91. </select>
  92. <sql id="queryBillDepositListConditions">
  93. <where>
  94. <if test=" null != id ">and br.`id` = #{id}</if>
  95. <if test=" null != tenantId and '' != tenantId">
  96. and br.`tenant_id` = #{tenantId}
  97. </if>
  98. <if test=" null != parentTenantId and '' != parentTenantId">
  99. and br.`parent_tenant_id` = #{parentTenantId}
  100. </if>
  101. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  102. <if test=" null != status ">and br.`status` = #{status}</if>
  103. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  104. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  105. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  106. <if test=" null != propertyContractId ">and br.`property_contract_id` = #{propertyContractId}</if>
  107. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  108. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  109. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  110. <if test=" null != month and '' != month">
  111. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  112. </if>
  113. <if test=" 1 == onlyOwe">and br.`owe` &gt; 0</if>
  114. <if test=" null != merchantIds ">
  115. and br.`merchant_id` in
  116. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  117. #{midItem}
  118. </foreach>
  119. </if>
  120. </where>
  121. </sql>
  122. <select id="queryBillDepositList" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="BaseResultMap">
  123. select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`,br.`owe`,br.`status`,
  124. br.`need_pay`,br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,br.`return_price`,br.`shop_info`,br.pay_way,
  125. br.freeze,br.service_charge_pay,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,'物业押金' bill_type_name,'' bill_remark
  126. from wx_bill_property_deposit br
  127. <include refid="queryBillDepositListConditions"/>
  128. order by id desc
  129. </select>
  130. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  131. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  132. <result column="paid" jdbcType="VARCHAR" property="paid" />
  133. <result column="owe" jdbcType="VARCHAR" property="owe"/>
  134. </resultMap>
  135. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="SumBaseResultMap">
  136. select sum(br.receive_pay) receive_pay , sum(br.pay) paid, sum(br.owe) owe from wx_bill_property_deposit br
  137. <include refid="queryBillDepositListConditions"/>
  138. </select>
  139. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultType="Long">
  140. select distinct merchant_id from wx_bill_property_deposit br
  141. <include refid="queryBillDepositListConditions"/>
  142. </select>
  143. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  144. select IFNULL((sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property_deposit
  145. where date_format(receive_date,'%Y-%m')=#{receiveDate}
  146. <if test=" null != tenantId and '' != tenantId">
  147. and `tenant_id` = #{tenantId}
  148. </if>
  149. <if test=" null != parentTenantId and '' != parentTenantId">
  150. and `parent_tenant_id` = #{parentTenantId}
  151. </if>
  152. group by tenant_id
  153. </select>
  154. <update id="updateNotPaidStatus" parameterType="hashmap">
  155. update wx_bill_property_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  156. where status!=#{paid}
  157. <if test=" null != tenantId and '' != tenantId">
  158. and `tenant_id` = #{tenantId}
  159. </if>
  160. <if test=" null != parentTenantId and '' != parentTenantId">
  161. and `parent_tenant_id` = #{parentTenantId}
  162. </if>
  163. and status!=5 and DATEDIFF(now(),receive_date)>0
  164. </update>
  165. <update id="updateWaitPayStatus" parameterType="hashmap">
  166. update wx_bill_property_deposit set status=#{waitPay} where id in(
  167. select a.id from (select br.id,rc.receive_period,br.property_contract_id,br.receive_date from wx_bill_property_deposit br
  168. left join wx_property_contract rc on br.property_contract_id=rc.id
  169. where br.status!=#{paid}
  170. <if test=" null != tenantId and '' != tenantId">
  171. and br.`tenant_id` = #{tenantId}
  172. </if>
  173. <if test=" null != parentTenantId and '' != parentTenantId">
  174. and br.`parent_tenant_id` = #{parentTenantId}
  175. </if>
  176. and br.status!=5 and now() &lt; br.receive_date
  177. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  178. </update>
  179. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxPropertyContract" resultType="Long">
  180. select count(*) from wx_property_contract r,wx_bill_property_deposit b
  181. where b.property_contract_id = r.id and b.status = 1
  182. <if test=" null != id ">and r.id = #{id}</if>
  183. <if test=" null != rentContractId ">and r.rent_contract_id = #{rentContractId}</if>
  184. </select>
  185. </mapper>