Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

246 rader
13 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="status" jdbcType="INTEGER" property="status" />
  16. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  17. <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
  18. <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
  19. <result column="is_del" jdbcType="INTEGER" property="isDel" />
  20. <result column="need_pay" jdbcType="VARCHAR" property="needPay" />
  21. <result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
  22. <result column="user_id" jdbcType="INTEGER" property="userId" />
  23. <result column="shop_id" jdbcType="INTEGER" property="shopId" />
  24. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
  25. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  26. <result column="return_price" jdbcType="VARCHAR" property="returnPrice"/>
  27. <result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/>
  28. <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
  29. <result column="freeze" property="freeze"/>
  30. <result column="service_charge_pay" property="serviceChargePay"/>
  31. <result column="starttime" property="starttime"/>
  32. <result column="endtime" property="endtime"/>
  33. <result column="last_owe_call_time" jdbcType="TIMESTAMP" property="lastOweCallTime"/>
  34. <result column="last_owe_call_user" jdbcType="VARCHAR" property="lastOweCallUser"/>
  35. <result column="merchant_name" property="merchantName"/>
  36. <result column="shop_number" property="shopNumber"/>
  37. </resultMap>
  38. <sql id="allColumns">
  39. `id`,`tenant_id`,`parent_tenant_id`,`property_contract_id`,`receive_pay`,`pay`,`receive_date`,`starttime`,`endtime`,
  40. `pay_date`,`createtime`,`expired_day`,`status`,`is_del`,`need_pay`,`apply_status`,`apply_pay_img`,`apply_update_time`,`last_owe_call_user`,
  41. `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,`return_price`,`shop_info`,`pay_way`,freeze,service_charge_pay
  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 != status "> and `status` = #{status} </if>
  60. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  61. <if test=" null != isDel "> and `is_del` = #{isDel} </if>
  62. <if test=" null != needPay "> and `need_pay` = #{needPay} </if>
  63. <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
  64. <if test=" null != userId "> and `user_id` = #{userId} </if>
  65. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  66. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  67. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  68. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  69. <if test=" 1 == notifyed ">and (`last_owe_call_time` is not null and `receive_pay` - `pay` &gt; 0 and status not in (3,6,7) )</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="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  89. select <include refid="allColumns" /> from wx_bill_property_deposit
  90. where id = #{id} and tenant_id = #{tenantId}
  91. </select>
  92. <select id="findPropertyContractIds" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="BaseResultMap">
  93. select distinct property_contract_id from wx_bill_property_deposit
  94. <include refid="dynamicWhereConditions" />
  95. </select>
  96. <sql id="queryBillDepositListConditions">
  97. <where>
  98. <if test=" null != id ">and br.`id` = #{id}</if>
  99. <if test=" null != tenantId and '' != tenantId">
  100. and br.`tenant_id` = #{tenantId}
  101. </if>
  102. <if test=" null != parentTenantId and '' != parentTenantId">
  103. and br.`parent_tenant_id` = #{parentTenantId}
  104. </if>
  105. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  106. <if test=" null != status ">and br.`status` = #{status}</if>
  107. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  108. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  109. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  110. <if test=" null != propertyContractId ">and br.`property_contract_id` = #{propertyContractId}</if>
  111. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  112. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  113. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  114. <if test=" null != month and '' != month">
  115. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  116. </if>
  117. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  118. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` &gt; 0 and br.status not in (3,6,7))
  119. </if>
  120. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  121. and (br.`starttime` &gt; #{oweBillLastTime} and br.`starttime` &lt;= #{nearBillLastTime} and br.status not in (3,6,7))
  122. </if>
  123. <if test=" 1 == notifyed ">and (br.`last_owe_call_time` is not null and br.`receive_pay` - br.`pay` &gt; 0 and br.status not in (3,6,7) )</if>
  124. <if test=" null != merchantIds ">
  125. and br.`merchant_id` in
  126. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  127. #{midItem}
  128. </foreach>
  129. </if>
  130. </where>
  131. </sql>
  132. <select id="queryBillDepositList" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="BaseResultMap">
  133. 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`,
  134. 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`,
  135. br.freeze,br.service_charge_pay,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`
  136. from wx_bill_property_deposit br
  137. <include refid="queryBillDepositListConditions"/>
  138. order by id desc
  139. </select>
  140. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  141. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  142. <result column="paid" jdbcType="VARCHAR" property="paid" />
  143. <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
  144. <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
  145. </resultMap>
  146. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="SumBaseResultMap">
  147. select
  148. sum(CAST(br.receive_pay AS DECIMAL(20,2))) receive_pay ,
  149. sum(CAST(br.pay AS DECIMAL(20,2))) paid,
  150. min(starttime) min_date,
  151. max(endtime) max_date
  152. from wx_bill_property_deposit br
  153. <include refid="queryBillDepositListConditions"/>
  154. </select>
  155. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultType="Long">
  156. select distinct merchant_id from wx_bill_property_deposit br
  157. <include refid="queryBillDepositListConditions"/>
  158. </select>
  159. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  160. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  161. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  162. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  163. </resultMap>
  164. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="HotNotifyBaseResultMap">
  165. select count(1) total_count , sum(CAST(br.`receive_pay` AS DECIMAL(20,2)) - CAST(br.`pay` AS DECIMAL(20,2))) total_money,MIN(br.starttime) min_begin_time from wx_bill_property_deposit br
  166. <include refid="queryBillDepositListConditions"/>
  167. </select>
  168. <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
  169. <result column="bill_type" jdbcType="INTEGER" property="billType"/>
  170. <result column="bill_type_name" jdbcType="VARCHAR" property="billTypeName" />
  171. <result column="bill_id" jdbcType="BIGINT" property="billId" />
  172. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  173. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  174. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  175. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  176. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  177. </resultMap>
  178. <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxBillPropertyDeposit" resultMap="NotifyResultMap">
  179. 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
  180. <include refid="queryBillDepositListConditions"/>
  181. </select>
  182. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  183. select IFNULL((sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property_deposit
  184. where date_format(receive_date,'%Y-%m')=#{receiveDate}
  185. <if test=" null != tenantId and '' != tenantId">
  186. and `tenant_id` = #{tenantId}
  187. </if>
  188. <if test=" null != parentTenantId and '' != parentTenantId">
  189. and `parent_tenant_id` = #{parentTenantId}
  190. </if>
  191. group by tenant_id
  192. </select>
  193. <update id="updateNotPaidStatus" parameterType="hashmap">
  194. update wx_bill_property_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  195. where status!=#{paid}
  196. <if test=" null != tenantId and '' != tenantId">
  197. and `tenant_id` = #{tenantId}
  198. </if>
  199. <if test=" null != parentTenantId and '' != parentTenantId">
  200. and `parent_tenant_id` = #{parentTenantId}
  201. </if>
  202. and status!=5 and DATEDIFF(now(),receive_date)>0
  203. </update>
  204. <update id="updateWaitPayStatus" parameterType="hashmap">
  205. update wx_bill_property_deposit set status=#{waitPay} where id in(
  206. select a.id from (select br.id,rc.receive_period,br.property_contract_id,br.receive_date from wx_bill_property_deposit br
  207. left join wx_property_contract rc on br.property_contract_id=rc.id
  208. where br.status!=#{paid}
  209. <if test=" null != tenantId and '' != tenantId">
  210. and br.`tenant_id` = #{tenantId}
  211. </if>
  212. <if test=" null != parentTenantId and '' != parentTenantId">
  213. and br.`parent_tenant_id` = #{parentTenantId}
  214. </if>
  215. and br.status!=5 and now() &lt; br.receive_date
  216. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  217. </update>
  218. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxPropertyContract" resultType="Long">
  219. select count(*) from wx_property_contract r,wx_bill_property_deposit b
  220. where b.property_contract_id = r.id and b.status = 1
  221. <if test=" null != id ">and r.id = #{id}</if>
  222. <if test=" null != rentContractId ">and r.rent_contract_id = #{rentContractId}</if>
  223. </select>
  224. <delete id = "deleteById" parameterType="HashMap">
  225. delete from wx_bill_property_deposit where id = #{id} and tenant_id = #{tenantId}
  226. </delete>
  227. </mapper>