Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 

311 Zeilen
16 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="status" jdbcType="INTEGER" property="status"/>
  16. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  17. <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
  18. <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
  19. <result column="is_preview" jdbcType="INTEGER" property="isPreview"/>
  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="last_owe_call_time" jdbcType="TIMESTAMP" property="lastOweCallTime"/>
  40. <result column="last_owe_call_user" jdbcType="VARCHAR" property="lastOweCallUser"/>
  41. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
  42. </resultMap>
  43. <sql id="allColumns">
  44. `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`last_owe_call_user`,
  45. `createtime`,`expired_day`,`status`,`apply_status`,`apply_pay_img`,`apply_update_time`,`is_del`,`is_preview`,`need_pay`,
  46. `last_owe_call_time`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,`late_pay_ratio`,`late_pay_time`,
  47. `late_pay_price`,`period`,`shop_info`,`pay_way`,`late_pay_status`,starttime,endtime,freeze,service_charge_pay,manage_fee_type
  48. </sql>
  49. <sql id="dynamicWhereConditions">
  50. where 1=1
  51. <if test=" null != id ">and `id` = #{id}</if>
  52. <if test=" null != tenantId and '' != tenantId">
  53. and `tenant_id` = #{tenantId}
  54. </if>
  55. <if test=" null != parentTenantId and '' != parentTenantId">
  56. and `parent_tenant_id` = #{parentTenantId}
  57. </if>
  58. <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
  59. <if test=" null != receivePay ">and `receive_pay` = #{receivePay}</if>
  60. <if test=" null != pay ">and `pay` = #{pay}</if>
  61. <if test=" null != receiveDate ">and `receive_date` = #{receiveDate}</if>
  62. <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
  63. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  64. <if test=" null != expiredDay ">and `expired_day` = #{expiredDay}</if>
  65. <if test=" null != status ">and `status` = #{status}</if>
  66. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  67. <if test=" null != isPreview ">and `is_preview` = #{isPreview}</if>
  68. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  69. <if test=" null != needPay ">and `need_pay` = #{needPay}</if>
  70. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  71. <if test=" null != userId ">and `user_id` = #{userId}</if>
  72. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  73. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  74. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  75. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  76. <if test=" null != latePayStatus ">and `late_pay_status` = #{latePayStatus}</if>
  77. <if test=" null != manageFeeType ">and `manage_fee_type` = #{manageFeeType}</if>
  78. <if test=" 1 == notifyed ">and (`last_owe_call_time` is not null and `receive_pay` - `pay` &gt; 0 and status not in (3,6,7) )</if>
  79. <if test=" null != merchantIds ">
  80. and merchant_id in
  81. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  82. #{midItem}
  83. </foreach>
  84. </if>
  85. <if test=" null != statusList ">
  86. and status in
  87. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  88. #{stItem}
  89. </foreach>
  90. </if>
  91. <if test=" null != ids ">
  92. and id in
  93. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  94. #{idItem}
  95. </foreach>
  96. </if>
  97. <if test=" null != sortColumns">order by ${sortColumns}</if>
  98. </sql>
  99. <select id="findList" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
  100. select
  101. <include refid="allColumns"/>
  102. from wx_bill_rent_manage
  103. <include refid="dynamicWhereConditions"/>
  104. </select>
  105. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  106. select
  107. <include refid="allColumns"/>
  108. from wx_bill_rent_manage
  109. where id = #{id} and `tenant_id` = #{tenantId}
  110. </select>
  111. <sql id="queryBillManageListConditions">
  112. <where>
  113. br.`is_preview` = 0
  114. <if test=" null != id ">and br.`id` = #{id}</if>
  115. <if test=" null != tenantId and '' != tenantId"> and br.`tenant_id` = #{tenantId}</if>
  116. <if test=" null != parentTenantId and '' != parentTenantId">and br.`parent_tenant_id` = #{parentTenantId}</if>
  117. <if test=" null != freeze ">and br.`freeze` = #{freeze}</if>
  118. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  119. <if test=" null != status ">and br.`status` = #{status}</if>
  120. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  121. <if test=" null != id ">and br.`id` = #{id}</if>
  122. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  123. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  124. <if test=" null != rentContractId ">and br.`rent_contract_id` = #{rentContractId}</if>
  125. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  126. <if test=" null != latePayStatus ">and br.`late_pay_status` = #{latePayStatus}</if>
  127. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  128. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  129. <if test=" null != month and '' != month">
  130. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  131. </if>
  132. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  133. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` &gt; 0 and br.status not in (3,6,7))
  134. </if>
  135. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  136. and (br.`starttime` &gt; #{oweBillLastTime} and br.`starttime` &lt;= #{nearBillLastTime} and br.status not in (3,6,7))
  137. </if>
  138. <if test=" null != manageFeeType ">and br.`manage_fee_type` = #{manageFeeType}</if>
  139. <if test=" null != hasMerchant ">and br.`merchant_id` is not null</if>
  140. <if test=" 1 == notifyed ">and (br.`last_owe_call_time` is not null and br.`receive_pay` - br.`pay` &gt; 0 and br.status not in (3,6,7) )</if>
  141. <if test=" null != merchantIds ">
  142. and br.merchant_id in
  143. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  144. #{midItem}
  145. </foreach>
  146. </if>
  147. <if test=" null != statusList ">
  148. and br.status in
  149. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  150. #{stItem}
  151. </foreach>
  152. </if>
  153. </where>
  154. </sql>
  155. <select id="queryBillManageList" parameterType="com.iformall.domain.po.WxBillRentManage" resultMap="BaseResultMap">
  156. select br.`id`,br.`tenant_id`,br.`parent_tenant_id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`,
  157. br.`status`,br.`need_pay`,br.`late_pay_time`,br.`period`,br.`rent_contract_id`,br.`last_owe_call_time`,br.`last_owe_call_user`,
  158. br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,
  159. br.late_pay_price,br.shop_info,br.pay_way,br.late_pay_status,br.starttime,br.endtime,
  160. br.freeze,br.service_charge_pay,br.manage_fee_type,br.`late_pay_ratio`
  161. from wx_bill_rent_manage br
  162. <include refid="queryBillManageListConditions"/>
  163. <if test=" null != sortColumns">order by ${sortColumns}</if>
  164. <if test="null != limitStart and null != limitEnd">
  165. limit #{limitStart},#{limitEnd}
  166. </if>
  167. </select>
  168. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  169. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  170. <result column="paid" jdbcType="VARCHAR" property="paid" />
  171. <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
  172. <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
  173. </resultMap>
  174. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillRentManage" resultMap="SumBaseResultMap">
  175. select
  176. sum(CAST(br.receive_pay AS DECIMAL(20,2))) receive_pay ,
  177. sum(CAST(br.pay AS DECIMAL(20,2))) paid ,
  178. min(starttime) min_date,
  179. max(endtime) max_date
  180. from wx_bill_rent_manage br
  181. <include refid="queryBillManageListConditions"/>
  182. </select>
  183. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillRentManage" resultType="Long">
  184. select distinct merchant_id from wx_bill_rent_manage br
  185. <include refid="queryBillManageListConditions"/>
  186. </select>
  187. <select id="queryRentContractIds" parameterType="com.iformall.domain.po.WxBillRentManage" resultType="Long">
  188. select distinct br.`rent_contract_id` from wx_bill_rent_manage br
  189. <include refid="queryBillManageListConditions"/>
  190. </select>
  191. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  192. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  193. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  194. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  195. </resultMap>
  196. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillRentManage" resultMap="HotNotifyBaseResultMap">
  197. select count(1) total_count , sum(CAST(br.`receive_pay` AS DECIMAL(20,2)) - CAST(br.`pay` AS DECIMAL(20,2))) total_money,MIN(br.starttime) min_begin_time from wx_bill_rent_manage br
  198. <include refid="queryBillManageListConditions"/>
  199. </select>
  200. <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
  201. <result column="bill_type" jdbcType="INTEGER" property="billType"/>
  202. <result column="bill_type_name" jdbcType="VARCHAR" property="billTypeName" />
  203. <result column="bill_id" jdbcType="BIGINT" property="billId" />
  204. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  205. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  206. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  207. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  208. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  209. </resultMap>
  210. <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxBillRentManage" resultMap="NotifyResultMap">
  211. select #{billType} bill_type,#{billTypeName} bill_type_name,br.id as bill_id, br.starttime,br.endtime,br.receive_pay,br.pay,br.merchant_id from wx_bill_rent_manage br
  212. <include refid="queryBillManageListConditions"/>
  213. </select>
  214. <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxBillRentManage">
  215. update wx_bill_rent_manage set is_preview = #{isPreview} where rent_contract_id = #{rentContractId}
  216. </update>
  217. <select id="queryPayInfoTotal" resultType="hashmap" parameterType="hashmap">
  218. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_rent_manage
  219. where status!=6
  220. <if test=" null != tenantId and '' != tenantId">
  221. and `tenant_id` = #{tenantId}
  222. </if>
  223. <if test=" null != parentTenantId and '' != parentTenantId">
  224. and `parent_tenant_id` = #{parentTenantId}
  225. </if>
  226. <if test=" null != startTime ">
  227. and receive_date &gt;= #{startdate}
  228. </if>
  229. <if test=" null != endTime">
  230. and receive_date &lt; #{enddate}
  231. </if>
  232. </select>
  233. <update id="updateNotPaidStatus" parameterType="hashmap">
  234. update wx_bill_rent_manage b set b.status=#{notPaid},b.expired_day=
  235. DATEDIFF(now(), b.receive_date)
  236. where b.status!=#{paid} and b.status!=6 and
  237. DATEDIFF(now(), b.receive_date) >0
  238. <if test=" null != tenantId and '' != tenantId">
  239. and b.`tenant_id` = #{tenantId}
  240. </if>
  241. <if test=" null != parentTenantId and '' != parentTenantId">
  242. and b.`parent_tenant_id` = #{parentTenantId}
  243. </if>
  244. </update>
  245. <update id="updateWaitPayStatus" parameterType="hashmap">
  246. update wx_bill_rent_manage set status=#{waitPay} where id in(
  247. select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent_manage br
  248. left join wx_rent_contract rc on br.rent_contract_id=rc.id
  249. where br.status!=#{paid}
  250. <if test=" null != tenantId and '' != tenantId">
  251. and br.`tenant_id` = #{tenantId}
  252. </if>
  253. <if test=" null != parentTenantId and '' != parentTenantId">
  254. and br.`parent_tenant_id` = #{parentTenantId}
  255. </if>
  256. and br.status!=6 and now() &lt; br.receive_date
  257. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  258. </update>
  259. <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxBillRentManage">
  260. delete from wx_bill_rent_manage where rent_contract_id = #{rentContractId} and manage_fee_type = #{manageFeeType}
  261. <if test=" null != isPreview ">and `is_preview` = #{isPreview}</if>
  262. </delete>
  263. <select id="oweBillCount" parameterType="java.lang.Long" resultType="java.lang.Long">
  264. select count(br.id) from wx_bill_rent_manage br,wx_rent_contract c where c.id = br.rent_contract_id
  265. and br.status = 1 and c.id = #{contractId}
  266. </select>
  267. <insert id="insertBills" parameterType="HashMap">
  268. INSERT INTO wx_bill_rent_manage (id,tenant_id,parent_tenant_id,
  269. rent_contract_id, receive_pay, pay, receive_date, pay_date, createtime, expired_day,
  270. status, is_del, need_pay, merchant_id, user_id, shop_id, updatetime, starttime, endtime,
  271. rent_shop_type, late_pay_ratio, late_pay_time, late_pay_price, period, shop_info,
  272. pay_way, late_pay_status, service_charge_pay,manage_fee_type)
  273. VALUES
  274. <foreach collection="list" item="item" index="index" separator=",">
  275. (
  276. #{item.id},#{item.tenantId},#{item.parentTenantId},
  277. #{item.rentContractId},#{item.receivePay},#{item.pay},#{item.receiveDate},#{item.payDate},#{item.createtime},
  278. #{item.expiredDay},#{item.status},#{item.isDel},#{item.needPay},#{item.merchantId},
  279. #{item.userId},#{item.shopId},#{item.updatetime},#{item.starttime},#{item.endtime},#{item.rentShopType},
  280. #{item.latePayRatio},#{item.latePayTime},#{item.latePayPrice},#{item.period},#{item.shopInfo},
  281. #{item.payWay},#{item.latePayStatus},#{item.serviceChargePay},#{item.manageFeeType}
  282. )
  283. </foreach>
  284. </insert>
  285. <delete id = "deleteById" parameterType="HashMap">
  286. delete from wx_bill_rent_manage where id = #{id} and tenant_id = #{tenantId}
  287. </delete>
  288. </mapper>