Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

245 linhas
12 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.WxBillRentManageMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillRentManage">
  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="INTEGER" property="expiredDay"/>
  15. <result column="owe" jdbcType="VARCHAR" property="owe"/>
  16. <result column="status" jdbcType="INTEGER" property="status"/>
  17. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  18. <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
  19. <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
  20. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  21. <result column="need_pay" jdbcType="VARCHAR" property="needPay"/>
  22. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  23. <result column="user_id" jdbcType="BIGINT" property="userId"/>
  24. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  25. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
  26. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  27. <result column="late_pay_ratio" jdbcType="INTEGER" property="latePayRatio"/>
  28. <result column="late_pay_time" jdbcType="TIMESTAMP" property="latePayTime"/>
  29. <result column="late_pay_price" jdbcType="VARCHAR" property="latePayPrice"/>
  30. <result column="period" jdbcType="INTEGER" property="period"/>
  31. <result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/>
  32. <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
  33. <result column="late_pay_status" jdbcType="INTEGER" property="latePayStatus"/>
  34. <result column="starttime" property="starttime"/>
  35. <result column="endtime" property="endtime"/>
  36. <result column="freeze" property="freeze"/>
  37. <result column="service_charge_pay" property="serviceChargePay"/>
  38. <result column="manage_fee_type" jdbcType="INTEGER" property="manageFeeType"/>
  39. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
  40. </resultMap>
  41. <sql id="allColumns">
  42. `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,
  43. `createtime`,`expired_day`,`owe`,`status`,`apply_status`,`apply_pay_img`,`apply_update_time`,`is_del`,`need_pay`,
  44. `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,
  45. `period`,`shop_info`,`pay_way`,`late_pay_status`,starttime,endtime,freeze,service_charge_pay,manage_fee_type
  46. </sql>
  47. <sql id="dynamicWhereConditions">
  48. where 1=1
  49. <if test=" null != id ">and `id` = #{id}</if>
  50. <if test=" null != tenantId and '' != tenantId">
  51. and `tenant_id` = #{tenantId}
  52. </if>
  53. <if test=" null != parentTenantId and '' != parentTenantId">
  54. and `parent_tenant_id` = #{parentTenantId}
  55. </if>
  56. <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
  57. <if test=" null != receivePay ">and `receive_pay` = #{receivePay}</if>
  58. <if test=" null != pay ">and `pay` = #{pay}</if>
  59. <if test=" null != receiveDate ">and `receive_date` = #{receiveDate}</if>
  60. <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
  61. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  62. <if test=" null != expiredDay ">and `expired_day` = #{expiredDay}</if>
  63. <if test=" null != owe ">and `owe` = #{owe}</if>
  64. <if test=" null != status ">and `status` = #{status}</if>
  65. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  66. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  67. <if test=" null != needPay ">and `need_pay` = #{needPay}</if>
  68. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  69. <if test=" null != userId ">and `user_id` = #{userId}</if>
  70. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  71. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  72. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  73. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  74. <if test=" null != latePayStatus ">and `late_pay_status` = #{latePayStatus}</if>
  75. <if test=" null != manageFeeType ">and `manage_fee_type` = #{manageFeeType}</if>
  76. <if test=" null != merchantIds ">
  77. and merchant_id in
  78. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  79. #{midItem}
  80. </foreach>
  81. </if>
  82. <if test=" null != ids ">
  83. and id in
  84. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  85. #{idItem}
  86. </foreach>
  87. </if>
  88. <if test=" null != sortColumns">order by ${sortColumns}</if>
  89. </sql>
  90. <select id="findList" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
  91. select
  92. <include refid="allColumns"/>
  93. from wx_bill_rent_manage
  94. <include refid="dynamicWhereConditions"/>
  95. </select>
  96. <sql id="queryBillManageListConditions">
  97. <where>
  98. 1 = 1
  99. <if test=" null != id ">and br.`id` = #{id}</if>
  100. <if test=" null != tenantId and '' != tenantId"> and br.`tenant_id` = #{tenantId}</if>
  101. <if test=" null != parentTenantId and '' != parentTenantId">and br.`parent_tenant_id` = #{parentTenantId}</if>
  102. <if test=" null != freeze ">and br.`freeze` = #{freeze}</if>
  103. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  104. <if test=" null != status ">and br.`status` = #{status}</if>
  105. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  106. <if test=" null != id ">and br.`id` = #{id}</if>
  107. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  108. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  109. <if test=" null != rentContractId ">and br.`rent_contract_id` = #{rentContractId}</if>
  110. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  111. <if test=" null != latePayStatus ">and br.`late_pay_status` = #{latePayStatus}</if>
  112. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  113. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  114. <if test=" null != month and '' != month">
  115. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  116. </if>
  117. <if test=" 1 == onlyOwe">and br.`owe` &gt; 0</if>
  118. <if test=" null != manageFeeType ">and br.`manage_fee_type` = #{manageFeeType}</if>
  119. <if test=" null != hasMerchant ">and br.`merchant_id` is not null</if>
  120. <if test=" null != merchantIds ">
  121. and br.merchant_id in
  122. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  123. #{midItem}
  124. </foreach>
  125. </if>
  126. </where>
  127. </sql>
  128. <select id="queryBillManageList" parameterType="com.iformall.domain.po.WxBillRentManage" resultMap="BaseResultMap">
  129. select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`,
  130. case when br.status=1 then br.owe else 0 end owe,br.`status`,br.`need_pay`,br.`late_pay_time`,br.`period`,br.`rent_contract_id`,
  131. br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,
  132. br.late_pay_price,br.shop_info,br.pay_way,br.late_pay_status,br.starttime,br.endtime,
  133. br.freeze,br.service_charge_pay,br.manage_fee_type,br.`late_pay_ratio`
  134. from wx_bill_rent_manage br
  135. <include refid="queryBillManageListConditions"/>
  136. <if test=" null != sortColumns">order by ${sortColumns}</if>
  137. <if test="null != limitStart and null != limitEnd">
  138. limit #{limitStart},#{limitEnd}
  139. </if>
  140. </select>
  141. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  142. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  143. <result column="paid" jdbcType="VARCHAR" property="paid" />
  144. <result column="owe" jdbcType="VARCHAR" property="owe"/>
  145. </resultMap>
  146. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillRentManage" resultMap="SumBaseResultMap">
  147. select sum(br.receive_pay) receive_pay , sum(br.pay) paid, sum(br.owe) owe from wx_bill_rent_manage br
  148. <include refid="queryBillManageListConditions"/>
  149. </select>
  150. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillRentManage" resultType="Long">
  151. select distinct merchant_id from wx_bill_rent_manage br
  152. <include refid="queryBillManageListConditions"/>
  153. </select>
  154. <select id="queryRentContractIds" parameterType="com.iformall.domain.po.WxBillRentManage" resultType="Long">
  155. select distinct br.`rent_contract_id` from wx_bill_rent_manage br
  156. <include refid="queryBillManageListConditions"/>
  157. </select>
  158. <select id="queryPayInfoTotal" resultType="hashmap" parameterType="hashmap">
  159. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_rent_manage
  160. where status!=6
  161. <if test=" null != tenantId and '' != tenantId">
  162. and `tenant_id` = #{tenantId}
  163. </if>
  164. <if test=" null != parentTenantId and '' != parentTenantId">
  165. and `parent_tenant_id` = #{parentTenantId}
  166. </if>
  167. <if test=" null != startTime ">
  168. and receive_date &gt;= #{startdate}
  169. </if>
  170. <if test=" null != endTime">
  171. and receive_date &lt; #{enddate}
  172. </if>
  173. </select>
  174. <update id="updateNotPaidStatus" parameterType="hashmap">
  175. update wx_bill_rent_manage b set b.status=#{notPaid},b.expired_day=
  176. DATEDIFF(now(), b.receive_date)
  177. where b.status!=#{paid} and b.status!=6 and
  178. DATEDIFF(now(), b.receive_date) >0
  179. <if test=" null != tenantId and '' != tenantId">
  180. and b.`tenant_id` = #{tenantId}
  181. </if>
  182. <if test=" null != parentTenantId and '' != parentTenantId">
  183. and b.`parent_tenant_id` = #{parentTenantId}
  184. </if>
  185. </update>
  186. <update id="updateWaitPayStatus" parameterType="hashmap">
  187. update wx_bill_rent_manage set status=#{waitPay} where id in(
  188. select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent_manage br
  189. left join wx_rent_contract rc on br.rent_contract_id=rc.id
  190. where br.status!=#{paid}
  191. <if test=" null != tenantId and '' != tenantId">
  192. and br.`tenant_id` = #{tenantId}
  193. </if>
  194. <if test=" null != parentTenantId and '' != parentTenantId">
  195. and br.`parent_tenant_id` = #{parentTenantId}
  196. </if>
  197. and br.status!=6 and now() &lt; br.receive_date
  198. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  199. </update>
  200. <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxBillRentManage">
  201. delete from wx_bill_rent_manage where rent_contract_id = #{rentContractId} and manage_fee_type = #{manageFeeType}
  202. </delete>
  203. <select id="oweBillCount" parameterType="java.lang.Long" resultType="java.lang.Long">
  204. select count(br.id) from wx_bill_rent_manage br,wx_rent_contract c where c.id = br.rent_contract_id
  205. and br.status = 1 and c.id = #{contractId}
  206. </select>
  207. <insert id="insertBills" parameterType="java.util.List">
  208. INSERT INTO wx_bill_rent_manage (id,tenant_id,parent_tenant_id,
  209. rent_contract_id, receive_pay, pay, receive_date, pay_date, createtime, expired_day,
  210. owe, status, is_del, need_pay, merchant_id, user_id, shop_id, updatetime, starttime, endtime,
  211. rent_shop_type, late_pay_ratio, late_pay_time, late_pay_price, period, shop_info,
  212. pay_way, late_pay_status, service_charge_pay,manage_fee_type)
  213. VALUES
  214. <foreach collection="list" item="item" index="index" separator=",">
  215. (
  216. #{item.id},#{item.tenantId},#{item.parentTenantId},
  217. #{item.rentContractId},#{item.receivePay},#{item.pay},#{item.receiveDate},#{item.payDate},#{item.createtime},
  218. #{item.expiredDay},#{item.owe},#{item.status},#{item.isDel},#{item.needPay},#{item.merchantId},
  219. #{item.userId},#{item.shopId},#{item.updatetime},#{item.starttime},#{item.endtime},#{item.rentShopType},
  220. #{item.latePayRatio},#{item.latePayTime},#{item.latePayPrice},#{item.period},#{item.shopInfo},
  221. #{item.payWay},#{item.latePayStatus},#{item.serviceChargePay},#{item.manageFeeType}
  222. )
  223. </foreach>
  224. </insert>
  225. </mapper>