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.
 
 
 
 
 

188 líneas
10 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="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="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="BIGINT" 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="BIGINT" 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="BIGINT" property="latePayPrice"/>
  27. <result column="period" jdbcType="INTEGER" property="period"/>
  28. <result column="is_preview" property="isPreview"/>
  29. <result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/>
  30. <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
  31. <result column="late_pay_status" jdbcType="INTEGER" property="latePayStatus"/>
  32. <result column="comments" jdbcType="VARCHAR" property="comments"/>
  33. </resultMap>
  34. <sql id="allColumns">
  35. `id`,`property_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,
  36. `createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`,
  37. `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,
  38. `revenue`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,`period`,`is_preview`,`shop_info`,
  39. `pay_way`,`late_pay_status`,`comments`
  40. </sql>
  41. <sql id="dynamicWhereConditions">
  42. where 1=1
  43. <if test=" null != id "> and `id` = #{id} </if>
  44. <if test=" null != propertyContractId "> and `property_contract_id` = #{propertyContractId} </if>
  45. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  46. <if test=" null != pay "> and `pay` = #{pay} </if>
  47. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  48. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  49. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  50. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
  51. <if test=" null != tenantId "> and `tenant_id` = #{tenantId} </if>
  52. <if test=" null != owe "> and `owe` = #{owe} </if>
  53. <if test=" null != status "> and `status` = #{status} </if>
  54. <if test=" null != isDel "> and `is_del` = #{isDel} </if>
  55. <if test=" null != needPay "> and `need_pay` = #{needPay} </if>
  56. <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
  57. <if test=" null != userId "> and `user_id` = #{userId} </if>
  58. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  59. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  60. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  61. <if test=" null != isPreview ">and is_preview = #{isPreview}</if>
  62. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  63. <if test=" null != latePayStatus ">and `late_pay_status` = #{latePayStatus}</if>
  64. <if test=" null != ids ">
  65. and id in
  66. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  67. #{idItem}
  68. </foreach>
  69. </if>
  70. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  71. </sql>
  72. <select id="findList" parameterType="com.iformall.domain.po.WxBillProperty" resultMap="BaseResultMap">
  73. select <include refid="allColumns" /> from wx_bill_property
  74. <include refid="dynamicWhereConditions" />
  75. </select>
  76. <select id="queryBillPropertyList" parameterType="com.iformall.domain.po.WxBillProperty" resultType="hashmap">
  77. select br.`id`,br.`receive_pay` receivePay,
  78. case when br.status=1 then br.`pay` else 0 end pay
  79. ,br.`receive_date` receiveDate,
  80. br.`pay_date` payDate,br.`createtime`,br.`expired_day` expiredDay,
  81. case when br.status=1 then br.owe else 0 end owe
  82. ,br.`status`,
  83. br.`need_pay` needPay,m.`name` merchantName,s.shop_number shopNumber,br.`updatetime`,
  84. br.`merchant_id` merchantId,br.`rent_shop_type` rentShopType,br.`period`,
  85. br.`revenue`,br.`late_pay_ratio` latePayRatio,br.`late_pay_time` latePayTime,
  86. br.`property_contract_id` propertyContractId,d.receive_pay deposit,case when br.late_pay_status=2
  87. then (case when br.late_pay_time is null then 0
  88. else FLOOR(DATEDIFF(now(),br.late_pay_time)*br.late_pay_ratio/10000*br.owe)end)
  89. else br.late_pay_price end latePayPrice,
  90. (select max(period) from wx_bill_property where property_contract_id=br.property_contract_id)
  91. allPeriod,d.`status` depositStatus,br.`shop_info` shopInfo,br.pay_way payWay,br.late_pay_status latePayStatus,
  92. br.`comments`,br.starttime,br.endtime
  93. from wx_bill_property br left join wx_merchant m on br.merchant_id=m.id
  94. left join wx_shop s on br.shop_id=s.id
  95. left join wx_bill_property_deposit d on br.property_contract_id=d.property_contract_id
  96. <where>
  97. br.is_preview = 0
  98. <if test=" null != id ">and br.`id` = #{id}</if>
  99. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  100. <if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if>
  101. <if test=" null != tenantId ">and br.`tenant_id` = #{tenantId}</if>
  102. <if test=" null != status ">and br.`status` = #{status}</if>
  103. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  104. <if test=" null != starttime and null!=endtime ">and br.`receive_date` between #{starttime} and #{endtime}</if>
  105. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  106. <if test=" null != propertyContractId ">and br.`property_contract_id` = #{propertyContractId}</if>
  107. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  108. <if test=" null != latePayStatus ">and br.`late_pay_status` = #{latePayStatus}</if>
  109. <if test=" null != latePayStatus ">and br.`late_pay_status` = #{latePayStatus}</if>
  110. <if test=" null != depositStatus ">and d.`status` = #{depositStatus}</if>
  111. </where>
  112. <if test=" null != sortColumns">order by ${sortColumns}</if>
  113. </select>
  114. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  115. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property
  116. where tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate} and is_preview = 0
  117. group by tenant_id
  118. </select>
  119. <select id="queryPayInfoTotal" resultType="hashmap" parameterType="hashmap">
  120. select round(sum(receive_pay)/100,2) receivepay,round(sum(pay)/100,2) pay,tenant_id from wx_bill_property
  121. where tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate} and is_preview = 0
  122. </select>
  123. <select id="queryOweInfo" resultType="hashmap" parameterType="hashmap">
  124. select IFNULL(round(sum(owe)/100,2),0) owe,tenant_id from wx_bill_property
  125. where status = 1 and tenant_id=#{tenantId} and receive_date between #{startdate} and #{enddate} and is_preview = 0
  126. </select>
  127. <update id="updateNotPaidStatus" parameterType="hashmap">
  128. update wx_bill_property set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  129. where tenant_id=#{tenantId} and status!=#{paid} and status != 6 and DATEDIFF(now(),receive_date)>0
  130. </update>
  131. <update id="updateWaitPayStatus" parameterType="hashmap">
  132. update wx_bill_property set status=#{waitPay} where id in(
  133. select a.id from (select br.id,rc.receive_period,br.property_contract_id,br.receive_date from wx_bill_property br
  134. left join wx_property_contract rc on br.property_contract_id=rc.id
  135. where br.tenant_id=#{tenantId} and br.status!=#{paid} and br.status != 6 and now() &lt; br.receive_date
  136. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  137. </update>
  138. <update id="updateInvalidStatus" parameterType="com.iformall.domain.po.WxBillProperty">
  139. update wx_bill_property set status = 6 where property_contract_id = #{propertyContractId}
  140. and status in(4,2)
  141. </update>
  142. <update id="updateInvalidStatusByRent" parameterType="com.iformall.domain.po.WxRentContract">
  143. update wx_bill_property set status = 6 where property_contract_id in
  144. (select id from wx_property_contract where rent_contract_id = #{id})
  145. and status != 3
  146. </update>
  147. <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxPropertyContract">
  148. delete from wx_bill_property where property_contract_id = #{id}
  149. </delete>
  150. <update id="update" parameterType="com.iformall.domain.po.WxBillProperty">
  151. update wx_bill_property set updatetime = now()
  152. <if test=" null != receivePay ">,receive_pay = #{receivePay},owe=#{receivePay}</if>
  153. <if test=" null != comments ">,comments = #{comments}</if>
  154. <if test=" null != receiveDate ">,receive_date = #{receiveDate}</if>
  155. <if test="0 == receivePay or 0l == receivePay">,status = 3,pay_date=now()</if>
  156. where id = #{id}
  157. </update>
  158. <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxBillProperty">
  159. update wx_bill_property set is_preview = #{isPreview},merchant_id = #{merchantId}
  160. where property_contract_id = #{propertyContractId}
  161. </update>
  162. <select id="oweBillCount" parameterType="java.lang.Long" resultType="java.lang.Long">
  163. select count(br.id) from wx_bill_property br,wx_property_contract c
  164. where c.id = br.property_contract_id and br.status = 1 and c.id = #{contractId}
  165. </select>
  166. </mapper>