Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

148 строки
7.7 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="rent_contract_id" jdbcType="BIGINT" property="rentContractId" />
  7. <result column="receive_pay" jdbcType="BIGINT" property="receivePay"/>
  8. <result column="pay" jdbcType="BIGINT" property="pay"/>
  9. <result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate" />
  10. <result column="pay_date" jdbcType="TIMESTAMP" property="payDate" />
  11. <result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
  12. <result column="expired_day" jdbcType="BIGINT" property="expiredDay" />
  13. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  14. <result column="owe" jdbcType="BIGINT" property="owe"/>
  15. <result column="status" jdbcType="INTEGER" property="status" />
  16. <result column="is_del" jdbcType="INTEGER" property="isDel" />
  17. <result column="need_pay" jdbcType="BIGINT" property="needPay"/>
  18. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  19. <result column="user_id" jdbcType="BIGINT" property="userId" />
  20. <result column="shop_id" jdbcType="BIGINT" property="shopId" />
  21. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
  22. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  23. <result column="return_price" jdbcType="BIGINT" property="returnPrice"/>
  24. <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
  25. </resultMap>
  26. <sql id="allColumns">
  27. `id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,
  28. `expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,
  29. `rent_shop_type`,`return_price`,`pay_way`
  30. </sql>
  31. <sql id="dynamicWhereConditions">
  32. where 1 = 1
  33. <if test=" null != id "> and `id` = #{id} </if>
  34. <if test=" null != rentContractId "> and `rent_contract_id` = #{rentContractId} </if>
  35. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  36. <if test=" null != pay "> and `pay` = #{pay} </if>
  37. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  38. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  39. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  40. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
  41. <if test=" null != tenantId "> and `tenant_id` = #{tenantId} </if>
  42. <if test=" null != owe "> and `owe` = #{owe} </if>
  43. <if test=" null != status "> and `status` = #{status} </if>
  44. <if test=" null != isDel "> and `is_del` = #{isDel} </if>
  45. <if test=" null != needPay "> and `need_pay` = #{needPay} </if>
  46. <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
  47. <if test=" null != userId "> and `user_id` = #{userId} </if>
  48. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  49. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  50. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  51. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  52. <if test=" null != ids ">
  53. and id in
  54. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  55. #{idItem}
  56. </foreach>
  57. </if>
  58. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  59. </sql>
  60. <select id="findList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="BaseResultMap">
  61. select <include refid="allColumns" /> from wx_bill_rent_deposit
  62. <include refid="dynamicWhereConditions" />
  63. </select>
  64. <select id="queryBillDepositList" parameterType="com.iformall.domain.po.WxRentContract" resultType="hashmap">
  65. select br.`id`,br.`receive_pay` receivePay,br.`pay`,br.`receive_date` receiveDate,
  66. br.`pay_date` payDate,br.`createtime`,br.`expired_day` expiredDay,br.`owe`,br.`status`,
  67. br.`need_pay` needPay,m.`name` merchantName,s.shop_number shopNumber,br.`updatetime`,
  68. br.`merchant_id` merchantId,br.`rent_shop_type` rentShopType,br.`return_price` returnPrice,
  69. br.pay_way payWay,br.shop_info shopInfo
  70. from wx_bill_rent_deposit br left join wx_merchant m on br.merchant_id=m.id
  71. left join wx_shop s on br.shop_id=s.id
  72. <where>
  73. <if test=" null != id ">and br.`id` = #{id}</if>
  74. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  75. <if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if>
  76. <if test=" null != tenantId ">and br.`tenant_id` = #{tenantId}</if>
  77. <if test=" null != status ">and br.`status` = #{status}</if>
  78. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  79. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  80. <if test=" null != rentContractId ">and br.`rent_contract_id` = #{rentContractId}</if>
  81. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  82. </where>
  83. order by id desc
  84. </select>
  85. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  86. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_rent_deposit
  87. where tenant_id=#{tenantId} and date_format(receive_date,'%Y-%m')=#{receiveDate}
  88. group by tenant_id
  89. </select>
  90. <select id="queryPayInfoAllTotal" resultType="hashmap" parameterType="hashmap">
  91. select round(sum(res.receivepay)/100,2) receivepay,round(sum(res.pay)/100,2) pay,res.tenant_id from
  92. (
  93. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_rent_deposit
  94. where tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate}
  95. union all
  96. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property_deposit
  97. where tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate}
  98. union all
  99. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_other_deposit
  100. where tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate}
  101. ) res
  102. </select>
  103. <select id="queryOweInfoAll" resultType="hashmap" parameterType="hashmap">
  104. select IFNULL(round(sum(res.owe)/100,2),0) owe,res.tenant_id from
  105. (
  106. select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_rent_deposit
  107. where status = 1 and tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate}
  108. union all
  109. select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_property_deposit
  110. where status = 1 and tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate}
  111. union all
  112. select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_other_deposit
  113. where status = 1 and tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate}
  114. ) res
  115. </select>
  116. <update id="updateNotPaidStatus" parameterType="hashmap">
  117. update wx_bill_rent_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  118. where tenant_id=#{tenantId} and status!=#{paid} and status!=5 and DATEDIFF(now(),receive_date)>0
  119. </update>
  120. <update id="updateWaitPayStatus" parameterType="hashmap">
  121. update wx_bill_rent_deposit set status=#{waitPay} where id in(
  122. select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent_deposit br
  123. left join wx_rent_contract rc on br.rent_contract_id=rc.id
  124. where br.tenant_id=#{tenantId} and br.status!=#{paid} and br.status!=5 and now() &lt; br.receive_date
  125. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  126. </update>
  127. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  128. select count(*) c from wx_rent_contract r,wx_bill_rent_deposit b
  129. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  130. </select>
  131. </mapper>