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.
 
 
 
 
 

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