Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

307 rindas
14 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.WxBillDepositMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillDeposit">
  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="rent_contract_id" jdbcType="BIGINT" property="rentContractId" />
  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="BIGINT" 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="BIGINT" property="merchantId" />
  22. <result column="user_id" jdbcType="BIGINT" property="userId" />
  23. <result column="shop_id" jdbcType="BIGINT" 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="pay_way" jdbcType="INTEGER" property="payWay"/>
  28. <result column="service_charge_pay" property="serviceChargePay"/>
  29. <result column="shop_info" property="shopInfo"/>
  30. <result column="freeze" property="freeze"/>
  31. <result column="merchant_name" property="merchantName"/>
  32. <result column="shop_number" property="shopNumber"/>
  33. <result column="bill_type_name" property="billTypeName"/>
  34. <result column="bill_remark" property="billRemark"/>
  35. <result column="contract_depoist_detail" property="contractDepoistDetail"/>
  36. </resultMap>
  37. <sql id="allColumns">
  38. `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,
  39. `expired_day`,`status`,`is_del`,`need_pay`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`apply_status`,`apply_pay_img`,`apply_update_time`,
  40. `rent_shop_type`,`return_price`,`pay_way`,service_charge_pay,'租赁押金' bill_type_name,'' bill_remark,contract_depoist_detail
  41. </sql>
  42. <sql id="dynamicWhereConditions">
  43. where 1 = 1
  44. <if test=" null != id "> and `id` = #{id} </if>
  45. <if test=" null != tenantId and '' != tenantId">
  46. and `tenant_id` = #{tenantId}
  47. </if>
  48. <if test=" null != parentTenantId and '' != parentTenantId">
  49. and `parent_tenant_id` = #{parentTenantId}
  50. </if>
  51. <if test=" null != rentContractId "> and `rent_contract_id` = #{rentContractId} </if>
  52. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  53. <if test=" null != pay "> and `pay` = #{pay} </if>
  54. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  55. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  56. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  57. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
  58. <if test=" null != status "> and `status` = #{status} </if>
  59. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  60. <if test=" null != isDel "> and `is_del` = #{isDel} </if>
  61. <if test=" null != needPay "> and `need_pay` = #{needPay} </if>
  62. <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
  63. <if test=" null != userId "> and `user_id` = #{userId} </if>
  64. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  65. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  66. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  67. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  68. <if test=" null != contractDepoistDetail and '' != contractDepoistDetail">
  69. and `contract_depoist_detail` like concat('%', #{contractDepoistDetail},'%')
  70. </if>
  71. <if test=" null != starttime">and `starttime` &lt;= #{starttime}</if>
  72. <if test=" null != endtime">and `endtime` &gt;= #{endtime}</if>
  73. <if test=" null != month and '' != month">
  74. and date_format(starttime,'%Y-%m') &lt;= #{month} and date_format(endtime,'%Y-%m') &gt;= #{month}
  75. </if>
  76. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  77. and (`starttime` &lt;= #{oweBillLastTime} and `receive_pay` - `pay` &gt; 0 and status not in (3,6))
  78. </if>
  79. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  80. and (`starttime` &gt; #{oweBillLastTime} and `starttime` &lt;= #{nearBillLastTime} and status not in (3,6))
  81. </if>
  82. <if test=" null != merchantIds ">
  83. and `merchant_id` in
  84. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  85. #{midItem}
  86. </foreach>
  87. </if>
  88. <if test=" null != rentContractIdList ">
  89. and rent_contract_id in
  90. <foreach collection="rentContractIdList" index="index" item="rdItem" open="(" separator="," close=")">
  91. #{rdItem}
  92. </foreach>
  93. </if>
  94. <if test=" null != ids ">
  95. and id in
  96. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  97. #{idItem}
  98. </foreach>
  99. </if>
  100. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  101. </sql>
  102. <select id="findList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="BaseResultMap">
  103. select <include refid="allColumns" /> from wx_bill_rent_deposit
  104. <include refid="dynamicWhereConditions" />
  105. </select>
  106. <select id="findRentContractIds" parameterType="com.iformall.domain.po.WxBillDeposit" resultType="Long">
  107. select distinct rent_contract_id from wx_bill_rent_deposit
  108. <include refid="dynamicWhereConditions" />
  109. </select>
  110. <select id="queryBillDepositList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="BaseResultMap">
  111. select br.`id`,br.`tenant_id`,br.`parent_tenant_id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`,
  112. br.`status`,br.`need_pay`,br.`updatetime`,br.`merchant_id`,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,br.`contract_depoist_detail`,
  113. br.`rent_shop_type`,br.`return_price`, br.pay_way,br.shop_info ,br.freeze,br.service_charge_pay,'租赁押金' bill_type_name,'' bill_remark
  114. from wx_bill_rent_deposit br
  115. <include refid="queryBillRentListCondition"/>
  116. order by br.id desc
  117. </select>
  118. <sql id="queryBillRentListCondition">
  119. <where>
  120. 1 = 1
  121. <if test=" null != id ">and br.`id` = #{id}</if>
  122. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  123. <if test=" null != tenantId and '' != tenantId">
  124. and br.`tenant_id` = #{tenantId}
  125. </if>
  126. <if test=" null != parentTenantId and '' != parentTenantId">
  127. and br.`parent_tenant_id` = #{parentTenantId}
  128. </if>
  129. <if test=" null != status ">and br.`status` = #{status}</if>
  130. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  131. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  132. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  133. <if test=" null != rentContractId ">and br.`rent_contract_id` = #{rentContractId}</if>
  134. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  135. <if test=" null != contractDepoistDetail and '' != contractDepoistDetail">
  136. and br.`contract_depoist_detail` like concat('%', #{contractDepoistDetail},'%')
  137. </if>
  138. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  139. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  140. <if test=" null != month and '' != month">
  141. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  142. </if>
  143. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  144. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` &gt; 0 and br.status not in (3,6))
  145. </if>
  146. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  147. and (br.`starttime` &gt; #{oweBillLastTime} and br.`starttime` &lt;= #{nearBillLastTime} and br.status not in (3,6))
  148. </if>
  149. <if test=" null != merchantIds ">
  150. and br.`merchant_id` in
  151. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  152. #{midItem}
  153. </foreach>
  154. </if>
  155. </where>
  156. </sql>
  157. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  158. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  159. <result column="paid" jdbcType="VARCHAR" property="paid" />
  160. </resultMap>
  161. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="SumBaseResultMap">
  162. select sum(br.receive_pay) receive_pay , sum(br.pay) paid from wx_bill_rent_deposit br
  163. <include refid="queryBillRentListCondition"/>
  164. </select>
  165. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillDeposit" resultType="Long">
  166. select distinct merchant_id from wx_bill_rent_deposit br
  167. <include refid="queryBillRentListCondition"/>
  168. </select>
  169. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  170. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  171. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  172. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  173. </resultMap>
  174. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="HotNotifyBaseResultMap">
  175. select count(1) total_count , sum(br.`receive_pay` - br.`pay`) total_money,MIN(br.starttime) min_begin_time from wx_bill_rent_deposit br
  176. <include refid="queryBillRentListCondition"/>
  177. </select>
  178. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  179. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id,parent_tenant_id from wx_bill_rent_deposit
  180. where 1=1
  181. <if test=" null != tenantId and '' != tenantId">
  182. and `tenant_id` = #{tenantId}
  183. </if>
  184. <if test=" null != parentTenantId and '' != parentTenantId">
  185. and `parent_tenant_id` = #{parentTenantId}
  186. </if>
  187. and date_format(receive_date,'%Y-%m')=#{receiveDate}
  188. group by tenant_id,parent_tenant_id
  189. </select>
  190. <select id="queryPayInfoAllTotal" resultType="hashmap" parameterType="hashmap">
  191. select round(sum(res.receivepay)/100,2) receivepay,round(sum(res.pay)/100,2) pay,res.tenant_id from
  192. (
  193. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_rent_deposit
  194. where 1=1
  195. <if test=" null != tenantId and '' != tenantId">
  196. and `tenant_id` = #{tenantId}
  197. </if>
  198. <if test=" null != parentTenantId and '' != parentTenantId">
  199. and `parent_tenant_id` = #{parentTenantId}
  200. </if>
  201. and receive_date between #{startdate} and #{enddate}
  202. union all
  203. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property_deposit
  204. where 1=1
  205. <if test=" null != tenantId and '' != tenantId">
  206. and `tenant_id` = #{tenantId}
  207. </if>
  208. <if test=" null != parentTenantId and '' != parentTenantId">
  209. and `parent_tenant_id` = #{parentTenantId}
  210. </if>
  211. and receive_date between #{startdate} and #{enddate}
  212. union all
  213. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_other_deposit
  214. where 1=1
  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. and receive_date between #{startdate} and #{enddate}
  222. ) res
  223. </select>
  224. <select id="queryOweInfoAll" resultType="hashmap" parameterType="hashmap">
  225. select IFNULL(round(sum(res.owe)/100,2),0) owe,res.tenant_id from
  226. (
  227. select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_rent_deposit
  228. where status = 1
  229. <if test=" null != tenantId and '' != tenantId">
  230. and `tenant_id` = #{tenantId}
  231. </if>
  232. <if test=" null != parentTenantId and '' != parentTenantId">
  233. and `parent_tenant_id` = #{parentTenantId}
  234. </if>
  235. and receive_date between #{startdate} and #{enddate}
  236. union all
  237. select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_property_deposit
  238. where status = 1
  239. <if test=" null != tenantId and '' != tenantId">
  240. and `tenant_id` = #{tenantId}
  241. </if>
  242. <if test=" null != parentTenantId and '' != parentTenantId">
  243. and `parent_tenant_id` = #{parentTenantId}
  244. </if>
  245. and receive_date between #{startdate} and #{enddate}
  246. union all
  247. select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_other_deposit
  248. where status = 1
  249. <if test=" null != tenantId and '' != tenantId">
  250. and `tenant_id` = #{tenantId}
  251. </if>
  252. <if test=" null != parentTenantId and '' != parentTenantId">
  253. and `parent_tenant_id` = #{parentTenantId}
  254. </if>
  255. and receive_date between #{startdate} and #{enddate}
  256. ) res
  257. </select>
  258. <update id="updateNotPaidStatus" parameterType="hashmap">
  259. update wx_bill_rent_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  260. where status!=#{paid}
  261. <if test=" null != tenantId and '' != tenantId">
  262. and `tenant_id` = #{tenantId}
  263. </if>
  264. <if test=" null != parentTenantId and '' != parentTenantId">
  265. and `parent_tenant_id` = #{parentTenantId}
  266. </if>
  267. and status!=5 and DATEDIFF(now(),receive_date)>0
  268. </update>
  269. <update id="updateWaitPayStatus" parameterType="hashmap">
  270. update wx_bill_rent_deposit set status=#{waitPay} where id in(
  271. select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent_deposit br
  272. left join wx_rent_contract rc on br.rent_contract_id=rc.id
  273. where br.status!=#{paid}
  274. <if test=" null != tenantId and '' != tenantId">
  275. and br.`tenant_id` = #{tenantId}
  276. </if>
  277. <if test=" null != parentTenantId and '' != parentTenantId">
  278. and br.`parent_tenant_id` = #{parentTenantId}
  279. </if>
  280. and br.status!=5 and now() &lt; br.receive_date
  281. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  282. </update>
  283. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  284. select count(*) c from wx_rent_contract r,wx_bill_rent_deposit b
  285. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  286. </select>
  287. </mapper>