Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

276 linhas
15 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="create_by" jdbcType="BIGINT" property="createBy"/>
  15. <result column="create_by_name" jdbcType="VARCHAR" property="createByName"/>
  16. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  17. <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/>
  18. <result column="expired_day" jdbcType="INTEGER" property="expiredDay" />
  19. <result column="status" jdbcType="INTEGER" property="status" />
  20. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  21. <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
  22. <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
  23. <result column="is_del" jdbcType="INTEGER" property="isDel" />
  24. <result column="need_pay" jdbcType="VARCHAR" property="needPay" />
  25. <result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
  26. <result column="user_id" jdbcType="INTEGER" property="userId" />
  27. <result column="shop_id" jdbcType="INTEGER" property="shopId" />
  28. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
  29. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  30. <result column="return_price" jdbcType="VARCHAR" property="returnPrice"/>
  31. <result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/>
  32. <result column="pay_way" jdbcType="BIGINT" property="payWay"/>
  33. <result column="freeze" property="freeze"/>
  34. <result column="service_charge_pay" property="serviceChargePay"/>
  35. <result column="starttime" property="starttime"/>
  36. <result column="endtime" property="endtime"/>
  37. <result column="last_owe_call_time" jdbcType="TIMESTAMP" property="lastOweCallTime"/>
  38. <result column="last_owe_call_user" jdbcType="VARCHAR" property="lastOweCallUser"/>
  39. <result column="merchant_name" property="merchantName"/>
  40. <result column="shop_number" property="shopNumber"/>
  41. <result column="energy_fees_id" jdbcType="BIGINT" property="energyFeesId"/>
  42. <result column="set_off" jdbcType="VARCHAR" property="setOff"/>
  43. </resultMap>
  44. <sql id="allColumns">
  45. `id`,`tenant_id`,`parent_tenant_id`,`property_contract_id`,`receive_pay`,`pay`,`receive_date`,`starttime`,`endtime`,
  46. `pay_date`,`createtime`,`expired_day`,`status`,`is_del`,`need_pay`,`apply_status`,`apply_pay_img`,`apply_update_time`,`last_owe_call_user`,
  47. `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,`return_price`,`shop_info`,`pay_way`,freeze,service_charge_pay,
  48. `create_by`,`create_by_name`,`update_by`,`update_by_name`,`energy_fees_id`,`set_off`
  49. </sql>
  50. <sql id="dynamicWhereConditions">
  51. where 1 = 1
  52. <if test=" null != id "> and `id` = #{id} </if>
  53. <if test=" null != tenantId and '' != tenantId">
  54. and `tenant_id` = #{tenantId}
  55. </if>
  56. <if test=" null != parentTenantId and '' != parentTenantId">
  57. and `parent_tenant_id` = #{parentTenantId}
  58. </if>
  59. <if test=" null != propertyContractId "> and `property_contract_id` = #{propertyContractId} </if>
  60. <if test=" null != energyFeesId ">and `energy_fees_id` = #{energyFeesId}</if>
  61. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  62. <if test=" null != pay "> and `pay` = #{pay} </if>
  63. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  64. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  65. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  66. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
  67. <if test=" null != status "> and `status` = #{status} </if>
  68. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  69. <if test=" null != isDel "> and `is_del` = #{isDel} </if>
  70. <if test=" null != needPay "> and `need_pay` = #{needPay} </if>
  71. <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
  72. <if test=" null != userId "> and `user_id` = #{userId} </if>
  73. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  74. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  75. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  76. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  77. <if test=" 1 == notifyed ">and (`last_owe_call_time` is not null and `receive_pay` - `pay` - `set_off` &gt; 0 and status not in (3,6,7) )</if>
  78. <if test=" null != propertyContractIdList ">
  79. and property_contract_id in
  80. <foreach collection="propertyContractIdList" index="index" item="pidItem" open="(" separator="," close=")">
  81. #{pidItem}
  82. </foreach>
  83. </if>
  84. <if test=" null != statusList ">
  85. and status in
  86. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  87. #{stItem}
  88. </foreach>
  89. </if>
  90. <if test=" null != ids ">
  91. and id in
  92. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  93. #{idItem}
  94. </foreach>
  95. </if>
  96. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  97. </sql>
  98. <select id="findList" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="BaseResultMap">
  99. select <include refid="allColumns" /> from wx_bill_property_deposit
  100. <include refid="dynamicWhereConditions" />
  101. </select>
  102. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  103. select <include refid="allColumns" /> from wx_bill_property_deposit
  104. where id = #{id} and tenant_id = #{tenantId}
  105. </select>
  106. <select id="findPropertyContractIds" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="BaseResultMap">
  107. select distinct property_contract_id from wx_bill_property_deposit
  108. <include refid="dynamicWhereConditions" />
  109. </select>
  110. <sql id="queryBillDepositListConditions">
  111. <where>
  112. <if test=" null != id ">and br.`id` = #{id}</if>
  113. <if test=" null != tenantId and '' != tenantId">
  114. and br.`tenant_id` = #{tenantId}
  115. </if>
  116. <if test=" null != parentTenantId and '' != parentTenantId">
  117. and br.`parent_tenant_id` = #{parentTenantId}
  118. </if>
  119. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  120. <if test=" null != status ">and br.`status` = #{status}</if>
  121. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  122. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  123. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  124. <if test=" null != propertyContractId ">and br.`property_contract_id` = #{propertyContractId}</if>
  125. <if test=" null != energyFeesId ">and br.`energy_fees_id` = #{energyFeesId}</if>
  126. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  127. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  128. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  129. <if test=" null != month and '' != month">
  130. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  131. </if>
  132. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  133. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  134. </if>
  135. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  136. and (br.`starttime` &gt; #{oweBillLastTime} and br.`starttime` &lt;= #{nearBillLastTime} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  137. </if>
  138. <if test=" null != needPayStartDay">
  139. and (br.`starttime` &lt;= #{needPayStartDay} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  140. </if>
  141. <if test=" 1 == notifyed ">and (br.`last_owe_call_time` is not null and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7) )</if>
  142. <if test=" null != merchantIds ">
  143. and br.`merchant_id` in
  144. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  145. #{midItem}
  146. </foreach>
  147. </if>
  148. <if test=" null != statusList ">
  149. and br.status in
  150. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  151. #{stItem}
  152. </foreach>
  153. </if>
  154. </where>
  155. </sql>
  156. <select id="queryBillDepositList" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="BaseResultMap">
  157. select br.`id`,br.`tenant_id`,br.`parent_tenant_id`,br.`property_contract_id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`,br.`status`,
  158. br.`need_pay`,br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,br.`return_price`,br.`shop_info`,br.pay_way,br.`starttime`,br.`endtime`,br.`last_owe_call_user`,,br.`set_off`,
  159. br.freeze,br.service_charge_pay,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,br.`create_by`,br.`create_by_name`,br.`update_by`,br.`update_by_name`,br.`energy_fees_id`
  160. from wx_bill_property_deposit br
  161. <include refid="queryBillDepositListConditions"/>
  162. order by id desc
  163. </select>
  164. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  165. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  166. <result column="paid" jdbcType="VARCHAR" property="paid" />
  167. <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
  168. <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
  169. <result column="service_pay" jdbcType="VARCHAR" property="servicePay"/>
  170. <result column="late_pay" jdbcType="VARCHAR" property="latePay"/>
  171. <result column="return_pay" jdbcType="VARCHAR" property="returnPay"/>
  172. </resultMap>
  173. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="SumBaseResultMap">
  174. select
  175. sum(CAST(br.receive_pay AS DECIMAL(20,2))) receive_pay ,
  176. sum(CAST(br.pay AS DECIMAL(20,2))) paid,
  177. min(starttime) min_date,
  178. max(endtime) max_date,
  179. sum(CAST(br.service_charge_pay AS DECIMAL(20,2))) service_pay ,
  180. '0' late_pay,
  181. sum(CAST(br.return_price AS DECIMAL(20,2))) return_pay
  182. from wx_bill_property_deposit br
  183. <include refid="queryBillDepositListConditions"/>
  184. </select>
  185. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultType="Long">
  186. select distinct merchant_id from wx_bill_property_deposit br
  187. <include refid="queryBillDepositListConditions"/>
  188. </select>
  189. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  190. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  191. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  192. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  193. </resultMap>
  194. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="HotNotifyBaseResultMap">
  195. select count(1) total_count , sum(CAST(br.`receive_pay` AS DECIMAL(20,2)) - CAST(br.`pay` AS DECIMAL(20,2)) - CAST(IFNULL(br.`set_off`,"0") AS DECIMAL(20,2))) total_money,MIN(br.starttime) min_begin_time from wx_bill_property_deposit br
  196. <include refid="queryBillDepositListConditions"/>
  197. </select>
  198. <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
  199. <result column="bill_type" jdbcType="INTEGER" property="billType"/>
  200. <result column="bill_type_name" jdbcType="VARCHAR" property="billTypeName" />
  201. <result column="bill_id" jdbcType="BIGINT" property="billId" />
  202. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  203. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  204. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  205. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  206. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  207. </resultMap>
  208. <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="NotifyResultMap">
  209. select #{billType} bill_type,#{billTypeName} bill_type_name,br.id as bill_id, br.starttime,br.endtime,br.receive_pay,br.pay,br.merchant_id from wx_bill_property_deposit br
  210. <include refid="queryBillDepositListConditions"/>
  211. </select>
  212. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  213. select IFNULL((sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property_deposit
  214. where date_format(receive_date,'%Y-%m')=#{receiveDate}
  215. <if test=" null != tenantId and '' != tenantId">
  216. and `tenant_id` = #{tenantId}
  217. </if>
  218. <if test=" null != parentTenantId and '' != parentTenantId">
  219. and `parent_tenant_id` = #{parentTenantId}
  220. </if>
  221. group by tenant_id
  222. </select>
  223. <update id="updateNotPaidStatus" parameterType="hashmap">
  224. update wx_bill_property_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  225. where status!=#{paid}
  226. <if test=" null != tenantId and '' != tenantId">
  227. and `tenant_id` = #{tenantId}
  228. </if>
  229. <if test=" null != parentTenantId and '' != parentTenantId">
  230. and `parent_tenant_id` = #{parentTenantId}
  231. </if>
  232. and status!=5 and DATEDIFF(now(),receive_date)>0
  233. </update>
  234. <update id="updateWaitPayStatus" parameterType="hashmap">
  235. update wx_bill_property_deposit set status=#{waitPay} where id in(
  236. select a.id from (select br.id,rc.receive_period,br.property_contract_id,br.receive_date from wx_bill_property_deposit br
  237. left join wx_property_contract rc on br.property_contract_id=rc.id
  238. where br.status!=#{paid}
  239. <if test=" null != tenantId and '' != tenantId">
  240. and br.`tenant_id` = #{tenantId}
  241. </if>
  242. <if test=" null != parentTenantId and '' != parentTenantId">
  243. and br.`parent_tenant_id` = #{parentTenantId}
  244. </if>
  245. and br.status!=5 and now() &lt; br.receive_date
  246. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  247. </update>
  248. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxPropertyContract" resultType="Long">
  249. select count(*) from wx_property_contract r,wx_bill_property_deposit b
  250. where b.property_contract_id = r.id and b.status = 1
  251. <if test=" null != id ">and r.id = #{id}</if>
  252. <if test=" null != rentContractId ">and r.rent_contract_id = #{rentContractId}</if>
  253. </select>
  254. <delete id = "deleteById" parameterType="HashMap">
  255. delete from wx_bill_property_deposit where id = #{id} and tenant_id = #{tenantId}
  256. </delete>
  257. </mapper>