Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

124 lignes
6.6 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.WxBillRentMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillRent">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/>
  7. <result column="receive_pay" jdbcType="INTEGER" property="receivePay"/>
  8. <result column="pay" jdbcType="INTEGER" 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="INTEGER" 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="INTEGER" 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="revenue" jdbcType="INTEGER" property="revenue"/>
  24. <result column="late_pay_ratio" jdbcType="INTEGER" property="latePayRatio"/>
  25. <result column="late_pay_time" jdbcType="TIMESTAMP" property="latePayTime"/>
  26. <result column="late_pay_price" jdbcType="INTEGER" property="latePayPrice"/>
  27. <result column="period" jdbcType="INTEGER" property="period"/>
  28. </resultMap>
  29. <sql id="allColumns">
  30. `id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,
  31. `createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`,
  32. `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,
  33. `revenue`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,`period`
  34. </sql>
  35. <sql id="dynamicWhereConditions">
  36. where 1 = 1
  37. <if test=" null != id ">and `id` = #{id}</if>
  38. <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
  39. <if test=" null != receivePay ">and `receive_pay` = #{receivePay}</if>
  40. <if test=" null != pay ">and `pay` = #{pay}</if>
  41. <if test=" null != receiveDate ">and `receive_date` = #{receiveDate}</if>
  42. <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
  43. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  44. <if test=" null != expiredDay ">and `expired_day` = #{expiredDay}</if>
  45. <if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if>
  46. <if test=" null != owe ">and `owe` = #{owe}</if>
  47. <if test=" null != status ">and `status` = #{status}</if>
  48. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  49. <if test=" null != needPay ">and `need_pay` = #{needPay}</if>
  50. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  51. <if test=" null != userId ">and `user_id` = #{userId}</if>
  52. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  53. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  54. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  55. <if test=" null != ids ">
  56. and id in
  57. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  58. #{idItem}
  59. </foreach>
  60. </if>
  61. <if test=" null != sortColumns">order by ${sortColumns}</if>
  62. </sql>
  63. <select id="findList" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
  64. select
  65. <include refid="allColumns"/>
  66. from wx_bill_rent
  67. <include refid="dynamicWhereConditions"/>
  68. </select>
  69. <select id="queryBillRentList" parameterType="com.iformall.domain.po.WxRentContract" resultType="hashmap">
  70. select br.`id`,br.`receive_pay` receivePay,br.`pay`,br.`receive_date` receiveDate,
  71. br.`pay_date` payDate,br.`createtime`,br.`expired_day` expiredDay,br.`owe`,br.`status`,
  72. br.`need_pay` needPay,m.`name` merchantName,s.shop_number shopNumber,br.`updatetime`,
  73. br.`merchant_id` merchantId,br.`rent_shop_type` rentShopType,r.type rentType,r.pay_ratio payRatio,
  74. br.`revenue`,br.`late_pay_ratio` latePayRatio,br.`late_pay_time` latePayTime,br.`period`,
  75. br.`rent_contract_id` rentContractId,d.receive_pay deposit,case when br.late_pay_time is null then 0 else
  76. FLOOR(DATEDIFF(now(),br.late_pay_time)*br.late_pay_ratio/10000*br.owe) end latePayPrice,
  77. (select max(period) from wx_bill_rent where id=br.id) allPeriod,d.`status` depositStatus
  78. from wx_bill_rent br left join wx_merchant m on br.merchant_id=m.id
  79. left join wx_shop s on br.shop_id=s.id
  80. left join wx_rent_contract r on br.rent_contract_id=r.id
  81. left join wx_bill_rent_deposit d on br.rent_contract_id=d.rent_contract_id and br.merchant_id=d.merchant_id
  82. <where>
  83. <if test=" null != id ">and br.`id` = #{id}</if>
  84. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  85. <if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if>
  86. <if test=" null != tenantId ">and br.`tenant_id` = #{tenantId}</if>
  87. <if test=" null != status ">and br.`status` = #{status}</if>
  88. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  89. <if test=" null != starttime and null!=endtime ">and br.`receive_date` between #{starttime} and #{endtime}</if>
  90. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  91. </where>
  92. order by id desc
  93. </select>
  94. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  95. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_rent
  96. where tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate}
  97. group by tenant_id
  98. </select>
  99. <update id="updateNotPaidStatus" parameterType="hashmap">
  100. update wx_bill_rent set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  101. where tenant_id=#{tenantId} and status!=#{paid} and DATEDIFF(now(),receive_date)>0
  102. </update>
  103. <update id="updateWaitPayStatus" parameterType="hashmap">
  104. update wx_bill_rent set status=#{waitPay} where id in(
  105. select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent br
  106. left join wx_rent_contract rc on br.rent_contract_id=rc.id
  107. where br.tenant_id=#{tenantId} and br.status!=#{paid} and now() &lt; br.receive_date
  108. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  109. </update>
  110. </mapper>