No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

148 líneas
7.9 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.WxBillPropertyMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillProperty">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="property_contract_id" jdbcType="INTEGER" property="propertyContractId" />
  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="INTEGER" 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="INTEGER" property="merchantId" />
  19. <result column="user_id" jdbcType="INTEGER" property="userId" />
  20. <result column="shop_id" jdbcType="INTEGER" 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. <result column="is_preview" property="isPreview"/>
  29. </resultMap>
  30. <sql id="allColumns">
  31. `id`,`property_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,
  32. `createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`,
  33. `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,
  34. `revenue`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,`period`,`is_preview`
  35. </sql>
  36. <sql id="dynamicWhereConditions">
  37. where 1=1
  38. <if test=" null != id "> and `id` = #{id} </if>
  39. <if test=" null != propertyContractId "> and `property_contract_id` = #{propertyContractId} </if>
  40. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  41. <if test=" null != pay "> and `pay` = #{pay} </if>
  42. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  43. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  44. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  45. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
  46. <if test=" null != tenantId "> and `tenant_id` = #{tenantId} </if>
  47. <if test=" null != owe "> and `owe` = #{owe} </if>
  48. <if test=" null != status "> and `status` = #{status} </if>
  49. <if test=" null != isDel "> and `is_del` = #{isDel} </if>
  50. <if test=" null != needPay "> and `need_pay` = #{needPay} </if>
  51. <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
  52. <if test=" null != userId "> and `user_id` = #{userId} </if>
  53. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  54. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  55. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  56. <if test=" null == isPreview ">and is_preview = 0</if>
  57. <if test=" null != isPreview ">and is_preview = #{isPreview}</if>
  58. <if test=" null != ids ">
  59. and id in
  60. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  61. #{idItem}
  62. </foreach>
  63. </if>
  64. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  65. </sql>
  66. <select id="findList" parameterType="com.iformall.domain.po.WxBillProperty" resultMap="BaseResultMap">
  67. select <include refid="allColumns" /> from wx_bill_property
  68. <include refid="dynamicWhereConditions" />
  69. </select>
  70. <select id="queryBillPropertyList" parameterType="com.iformall.domain.po.WxBillProperty" resultType="hashmap">
  71. select br.`id`,br.`receive_pay` receivePay,br.`pay`,br.`receive_date` receiveDate,
  72. br.`pay_date` payDate,br.`createtime`,br.`expired_day` expiredDay,br.`owe`,br.`status`,
  73. br.`need_pay` needPay,m.`name` merchantName,s.shop_number shopNumber,br.`updatetime`,
  74. br.`merchant_id` merchantId,br.`rent_shop_type` rentShopType,br.`period`,
  75. br.`revenue`,br.`late_pay_ratio` latePayRatio,br.`late_pay_time` latePayTime,
  76. br.`property_contract_id` propertyContractId,d.receive_pay deposit,case when br.late_pay_time is null then 0
  77. else
  78. FLOOR(DATEDIFF(now(),br.late_pay_time)*br.late_pay_ratio/10000*br.owe) end latePayPrice,
  79. (select max(period) from wx_bill_property where id=br.id) allPeriod,d.`status` depositStatus
  80. from wx_bill_property br left join wx_merchant m on br.merchant_id=m.id
  81. left join wx_shop s on br.shop_id=s.id
  82. left join wx_bill_property_deposit d on br.property_contract_id=d.property_contract_id
  83. <where>
  84. is_preview = 0
  85. <if test=" null != id ">and br.`id` = #{id}</if>
  86. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  87. <if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if>
  88. <if test=" null != tenantId ">and br.`tenant_id` = #{tenantId}</if>
  89. <if test=" null != status ">and br.`status` = #{status}</if>
  90. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  91. <if test=" null != starttime and null!=endtime ">and br.`receive_date` between #{starttime} and #{endtime}</if>
  92. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  93. </where>
  94. order by id desc
  95. </select>
  96. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  97. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property
  98. where tenant_id=#{tenantId} and date_format(receive_date,'%Y-%m')=#{receiveDate} and is_preview = 0
  99. group by tenant_id
  100. </select>
  101. <update id="updateNotPaidStatus" parameterType="hashmap">
  102. update wx_bill_property set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  103. where tenant_id=#{tenantId} and status!=#{paid} and DATEDIFF(now(),receive_date)>0
  104. </update>
  105. <update id="updateWaitPayStatus" parameterType="hashmap">
  106. update wx_bill_property set status=#{waitPay} where id in(
  107. select a.id from (select br.id,rc.receive_period,br.property_contract_id,br.receive_date from wx_bill_property br
  108. left join wx_property_contract rc on br.property_contract_id=rc.id
  109. where br.tenant_id=#{tenantId} and br.status!=#{paid} and now() &lt; br.receive_date
  110. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  111. </update>
  112. <update id="updateInvalidStatus" parameterType="com.iformall.domain.po.WxBillProperty">
  113. update wx_bill_property set status = 6 where property_contract_id = #{propertyContractId}
  114. and status = 4
  115. </update>
  116. <update id="updateInvalidStatusByRent" parameterType="com.iformall.domain.po.WxRentContract">
  117. update wx_bill_property set status = 6 where property_contract_id in
  118. (select id from wx_property_contract where rent_contract_id = #{id})
  119. and status = 4
  120. </update>
  121. <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxPropertyContract">
  122. delete from wx_bill_property where property_contract_id = #{id}
  123. </delete>
  124. <update id="update" parameterType="com.iformall.domain.po.WxBillProperty">
  125. update wx_bill_property set receive_pay = #{receivePay} where id = #{id}
  126. </update>
  127. <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxBillRent">
  128. update wx_bill_rent set is_preview = #{isPreview} where rent_contract_id = #{rentContractId}
  129. </update>
  130. </mapper>