Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

484 řádky
24 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.WxBillRentMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillRent">
  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="expired_day" jdbcType="INTEGER" property="expiredDay"/>
  17. <result column="status" jdbcType="INTEGER" property="status"/>
  18. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  19. <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
  20. <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
  21. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  22. <result column="contract_need_pay" jdbcType="VARCHAR" property="contractNeedPay"/>
  23. <result column="rent_price_info" jdbcType="VARCHAR" property="rentPriceInfo"/>
  24. <result column="need_pay" jdbcType="VARCHAR" property="needPay"/>
  25. <result column="bussiness_manage_fee_need_pay" jdbcType="VARCHAR" property="bussinessManageFeeNeedPay"/>
  26. <result column="operating_manage_fee_need_pay" jdbcType="VARCHAR" property="operatingManageFeeNeedPay"/>
  27. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  28. <result column="user_id" jdbcType="BIGINT" property="userId"/>
  29. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  30. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
  31. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  32. <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/>
  33. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  34. <result column="revenue" jdbcType="VARCHAR" property="revenue"/>
  35. <result column="late_pay_ratio" jdbcType="INTEGER" property="latePayRatio"/>
  36. <result column="late_pay_time" jdbcType="TIMESTAMP" property="latePayTime"/>
  37. <result column="late_pay_price" jdbcType="VARCHAR" property="latePayPrice"/>
  38. <result column="period" jdbcType="INTEGER" property="period"/>
  39. <result column="is_preview" property="isPreview"/>
  40. <result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/>
  41. <result column="pay_way" jdbcType="BIGINT" property="payWay"/>
  42. <result column="late_pay_status" jdbcType="INTEGER" property="latePayStatus"/>
  43. <result column="comments" jdbcType="VARCHAR" property="comments"/>
  44. <result column="starttime" property="starttime"/>
  45. <result column="endtime" property="endtime"/>
  46. <result column="last_owe_call_time" jdbcType="TIMESTAMP" property="lastOweCallTime"/>
  47. <result column="last_owe_call_user" jdbcType="VARCHAR" property="lastOweCallUser"/>
  48. <result column="merchant_name" property="merchantName"/>
  49. <result column="deposit" property="deposit"/>
  50. <result column="deposit_status" property="depositStatus"/>
  51. <result column="rent_type" property="rentType"/>
  52. <result column="all_period" property="allPeriod"/>
  53. <result column="pay_ratio" property="payRatio"/>
  54. <result column="bus_discount_ratio" property="busDiscountRatio"/>
  55. <result column="late_pay_day" property="latePayDay"/>
  56. <result column="late_pay_ratio" property="latePayRatio"/>
  57. <result column="freeze" property="freeze"/>
  58. <result column="bus_discount_ratio" property="busDiscountRatio"/>
  59. <result column="join_rent_price" property="joinRentPrice"/>
  60. <result column="service_charge_pay" property="serviceChargePay"/>
  61. <result column="energy_fees_id" jdbcType="BIGINT" property="energyFeesId"/>
  62. <result column="set_off" jdbcType="VARCHAR" property="setOff"/>
  63. <result column="advance_id" jdbcType="BIGINT" property="advanceId"/>
  64. </resultMap>
  65. <sql id="allColumns">
  66. `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`create_by`,`create_by_name`,`update_by`,`update_by_name`,
  67. `createtime`,`expired_day`,`status`,`is_del`,`contract_need_pay`,`rent_price_info`,`need_pay`,`bussiness_manage_fee_need_pay`,`operating_manage_fee_need_pay`,
  68. `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,`apply_status`,`apply_pay_img`,`apply_update_time`,`last_owe_call_time`,
  69. `revenue`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,`period`,`is_preview`,`shop_info`,`last_owe_call_user`,`set_off`,`advance_id`,
  70. `pay_way`,`late_pay_status`,`comments`,starttime,endtime,bus_discount_ratio,freeze,join_rent_price,service_charge_pay,`energy_fees_id`
  71. </sql>
  72. <sql id="dynamicWhereConditions">
  73. where 1=1
  74. <if test=" null != id ">and `id` = #{id}</if>
  75. <if test=" null != tenantId and '' != tenantId">
  76. and `tenant_id` = #{tenantId}
  77. </if>
  78. <if test=" null != parentTenantId and '' != parentTenantId">
  79. and `parent_tenant_id` = #{parentTenantId}
  80. </if>
  81. <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
  82. <if test=" null != energyFeesId ">and `energy_fees_id` = #{energyFeesId}</if>
  83. <if test=" null != advanceId ">and `advance_id` = #{advanceId}</if>
  84. <if test=" null != receivePay ">and `receive_pay` = #{receivePay}</if>
  85. <if test=" null != pay ">and `pay` = #{pay}</if>
  86. <if test=" null != receiveDate ">and `receive_date` = #{receiveDate}</if>
  87. <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
  88. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  89. <if test=" null != expiredDay ">and `expired_day` = #{expiredDay}</if>
  90. <if test=" null != status ">and `status` = #{status}</if>
  91. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  92. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  93. <if test=" null != needPay ">and `need_pay` = #{needPay}</if>
  94. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  95. <if test=" null != userId ">and `user_id` = #{userId}</if>
  96. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  97. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  98. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  99. <if test=" null != isPreview ">and is_preview = #{isPreview}</if>
  100. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  101. <if test=" null != latePayStatus ">and `late_pay_status` = #{latePayStatus}</if>
  102. <if test=" null != starttime ">and `starttime` = #{starttime}</if>
  103. <if test=" null != endtime ">and `endtime` = #{endtime}</if>
  104. <if test=" null != endtimeBegin ">
  105. and endtime &gt;= #{endtimeBegin}
  106. </if>
  107. <if test=" null != endtimeEnd">
  108. and endtime &lt; #{endtimeEnd}
  109. </if>
  110. <if test=" 1 == notifyed ">and (`last_owe_call_time` is not null and `receive_pay` - `pay` - `set_off &gt; 0 and status not in (3,6,7) )</if>
  111. <if test=" null != statusList ">
  112. and status in
  113. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  114. #{stItem}
  115. </foreach>
  116. </if>
  117. <if test=" null != ids ">
  118. and id in
  119. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  120. #{idItem}
  121. </foreach>
  122. </if>
  123. <if test=" null != sortColumns">order by ${sortColumns}</if>
  124. </sql>
  125. <select id="findList" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
  126. select
  127. <include refid="allColumns"/>
  128. from wx_bill_rent
  129. <include refid="dynamicWhereConditions"/>
  130. </select>
  131. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  132. select
  133. <include refid="allColumns"/>
  134. from wx_bill_rent where id = #{id} and `tenant_id` = #{tenantId}
  135. </select>
  136. <sql id="queryBillRentListCondition">
  137. <where>
  138. br.is_preview = 0
  139. <if test=" null != id ">and br.`id` = #{id}</if>
  140. <if test=" null != tenantId and '' != tenantId"> and br.`tenant_id` = #{tenantId}</if>
  141. <if test=" null != parentTenantId and '' != parentTenantId">and br.`parent_tenant_id` = #{parentTenantId}</if>
  142. <if test=" null != freeze ">and br.`freeze` = #{freeze}</if>
  143. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  144. <if test=" null != status ">and br.`status` = #{status}</if>
  145. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  146. <if test=" null != id ">and br.`id` = #{id}</if>
  147. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  148. <if test=" null != advanceId ">and br.`advance_id` = #{advanceId}</if>
  149. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  150. <if test=" null != rentContractId ">and br.`rent_contract_id` = #{rentContractId}</if>
  151. <if test=" null != energyFeesId ">and br.`energy_fees_id` = #{energyFeesId}</if>
  152. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  153. <if test=" null != latePayStatus ">and br.`late_pay_status` = #{latePayStatus}</if>
  154. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  155. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  156. <if test=" null != month and '' != month">
  157. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  158. </if>
  159. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  160. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  161. </if>
  162. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  163. and (br.`starttime` &gt; #{oweBillLastTime} and br.`starttime` &lt;= #{nearBillLastTime} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  164. </if>
  165. <if test=" null != needPayStartDay">
  166. and (br.`starttime` &lt;= #{needPayStartDay} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  167. </if>
  168. <if test=" 1 == notifyed ">and (br.`last_owe_call_time` is not null and br.`receive_pay` - br.`pay`- br.`set_off` &gt; 0 and br.status not in (3,6,7) )</if>
  169. <if test=" null != rentContractIdList ">
  170. and br.`rent_contract_id` in
  171. <foreach collection="rentContractIdList" index="index" item="ridItem" open="(" separator="," close=")">
  172. #{ridItem}
  173. </foreach>
  174. </if>
  175. <if test=" null != merchantIdList ">
  176. and br.`merchant_id` in
  177. <foreach collection="merchantIdList" index="index" item="midItem" open="(" separator="," close=")">
  178. #{midItem}
  179. </foreach>
  180. </if>
  181. <if test=" null != statusList ">
  182. and br.`status` in
  183. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  184. #{stItem}
  185. </foreach>
  186. </if>
  187. </where>
  188. </sql>
  189. <select id="queryBillRentList" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
  190. 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`,br.`last_owe_call_user`,
  191. br.`status`,br.`contract_need_pay`,br.`rent_price_info`,br.`need_pay`,br.`bussiness_manage_fee_need_pay`,br.`operating_manage_fee_need_pay`,br.`last_owe_call_time`,
  192. br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,br.`revenue`,br.`late_pay_time`,br.`period`,br.`rent_contract_id`,
  193. br.late_pay_price,br.shop_info,br.pay_way,br.late_pay_status,br.`comments`,br.starttime,br.endtime,br.bus_discount_ratio,br.freeze,br.join_rent_price,br.service_charge_pay,
  194. br.`create_by`,br.`create_by_name`,br.`update_by`,br.`update_by_name`,br.`energy_fees_id`,br.`set_off`,br.`advance_id`
  195. from wx_bill_rent br
  196. <include refid="queryBillRentListCondition"/>
  197. <if test=" null != sortColumns">order by ${sortColumns}</if>
  198. <if test="null != limitStart and null != limitEnd">
  199. limit #{limitStart},#{limitEnd}
  200. </if>
  201. </select>
  202. <select id="queryBillRentContractIdList" parameterType="com.iformall.domain.po.WxBillRent" resultType="Long">
  203. select distinct rent_contract_id from wx_bill_rent br
  204. <include refid="queryBillRentListCondition"/>
  205. </select>
  206. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  207. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  208. <result column="paid" jdbcType="VARCHAR" property="paid" />
  209. <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
  210. <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
  211. <result column="service_pay" jdbcType="VARCHAR" property="servicePay"/>
  212. <result column="late_pay" jdbcType="VARCHAR" property="latePay"/>
  213. <result column="return_pay" jdbcType="VARCHAR" property="returnPay"/>
  214. </resultMap>
  215. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillRent" resultMap="SumBaseResultMap">
  216. select
  217. sum(CAST(br.receive_pay AS DECIMAL(20,2))) receive_pay ,
  218. sum(CAST(br.pay AS DECIMAL(20,2))) paid,
  219. min(starttime) min_date,
  220. max(endtime) max_date,
  221. sum(CAST(br.service_charge_pay AS DECIMAL(20,2))) service_pay ,
  222. sum(CAST(br.late_pay_price AS DECIMAL(20,2))) late_pay,
  223. '0' return_pay
  224. from wx_bill_rent br
  225. <include refid="queryBillRentListCondition"/>
  226. </select>
  227. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillRent" resultType="Long">
  228. select distinct merchant_id from wx_bill_rent br
  229. <include refid="queryBillRentListCondition"/>
  230. </select>
  231. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  232. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  233. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  234. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  235. </resultMap>
  236. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillRent" resultMap="HotNotifyBaseResultMap">
  237. select count(1) total_count , sum(CAST(br.`receive_pay` AS DECIMAL(20,2)) - CAST(br.`pay` AS DECIMAL(20,2)) - CAST(IFNULL(br.`set_off`,"0") AS DECIMAL(20,2))) total_money,MIN(br.starttime) min_begin_time from wx_bill_rent br
  238. <include refid="queryBillRentListCondition"/>
  239. </select>
  240. <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
  241. <result column="bill_type" jdbcType="INTEGER" property="billType"/>
  242. <result column="bill_type_name" jdbcType="VARCHAR" property="billTypeName" />
  243. <result column="bill_id" jdbcType="BIGINT" property="billId" />
  244. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  245. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  246. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  247. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  248. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  249. </resultMap>
  250. <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxBillRent" resultMap="NotifyResultMap">
  251. 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 br
  252. <include refid="queryBillRentListCondition"/>
  253. </select>
  254. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  255. select IFNULL(sum(CAST(receive_pay AS DECIMAL(20,2))),0) receivepay,IFNULL(sum(CAST(pay AS DECIMAL(20,2))),0) pay,tenant_id from wx_bill_rent
  256. where is_preview = 0
  257. and status!=6
  258. <if test=" null != tenantId and '' != tenantId">
  259. and `tenant_id` = #{tenantId}
  260. </if>
  261. <if test=" null != parentTenantId and '' != parentTenantId">
  262. and `parent_tenant_id` = #{parentTenantId}
  263. </if>
  264. <if test=" null != startTime ">
  265. and receive_date &gt;= #{startTime}
  266. </if>
  267. <if test=" null != endTime">
  268. and receive_date &lt; #{endTime}
  269. </if>
  270. </select>
  271. <select id="queryPayInfoTotal" resultType="hashmap" parameterType="hashmap">
  272. select IFNULL(sum(CAST(receive_pay AS DECIMAL(20,2))),0) receivepay,IFNULL(sum(CAST(pay AS DECIMAL(20,2))),0) pay,tenant_id from wx_bill_rent
  273. where is_preview = 0 and status!=6
  274. <if test=" null != tenantId and '' != tenantId">
  275. and `tenant_id` = #{tenantId}
  276. </if>
  277. <if test=" null != parentTenantId and '' != parentTenantId">
  278. and `parent_tenant_id` = #{parentTenantId}
  279. </if>
  280. <if test=" null != startTime ">
  281. and receive_date &gt;= #{startTime}
  282. </if>
  283. <if test=" null != endTime">
  284. and receive_date &lt; #{endTime}
  285. </if>
  286. </select>
  287. <select id="queryOweInfo" resultType="hashmap" parameterType="hashmap">
  288. select IFNULL(sum(receive_pay-pay),0) owe,tenant_id from wx_bill_rent
  289. where status = 1
  290. <if test=" null != tenantId and '' != tenantId">
  291. and `tenant_id` = #{tenantId}
  292. </if>
  293. <if test=" null != parentTenantId and '' != parentTenantId">
  294. and `parent_tenant_id` = #{parentTenantId}
  295. </if>
  296. and receive_date between #{startdate} and #{enddate} and is_preview = 0
  297. </select>
  298. <update id="updateNotPaidStatus" parameterType="hashmap">
  299. update wx_bill_rent b set b.status=#{notPaid},b.expired_day=
  300. DATEDIFF(now(), b.receive_date)
  301. where b.status!=#{paid} and b.status!=6 and
  302. DATEDIFF(now(), b.receive_date) >0
  303. <if test=" null != tenantId and '' != tenantId">
  304. and b.`tenant_id` = #{tenantId}
  305. </if>
  306. <if test=" null != parentTenantId and '' != parentTenantId">
  307. and b.`parent_tenant_id` = #{parentTenantId}
  308. </if>
  309. </update>
  310. <update id="updateWaitPayStatus" parameterType="hashmap">
  311. update wx_bill_rent set status=#{waitPay} where id in(
  312. select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent br
  313. left join wx_rent_contract rc on br.rent_contract_id=rc.id
  314. where br.status!=#{paid}
  315. <if test=" null != tenantId and '' != tenantId">
  316. and br.`tenant_id` = #{tenantId}
  317. </if>
  318. <if test=" null != parentTenantId and '' != parentTenantId">
  319. and br.`parent_tenant_id` = #{parentTenantId}
  320. </if>
  321. and br.status!=6 and now() &lt; br.receive_date
  322. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  323. </update>
  324. <update id="updateInvalidStatus" parameterType="com.iformall.domain.po.WxBillRent">
  325. update wx_bill_rent set status = 6 where rent_contract_id = #{rentContractId}
  326. and status != 3
  327. </update>
  328. <delete id="deleteBillByContract" parameterType="com.iformall.domain.po.WxRentContract">
  329. delete from wx_bill_rent where rent_contract_id = #{id}
  330. </delete>
  331. <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxBillRent">
  332. delete from wx_bill_rent where rent_contract_id = #{rentContractId}
  333. <if test=" null != isPreview "> and is_preview = #{isPreview}</if>
  334. </delete>
  335. <update id="updateForReceiverPay" parameterType="com.iformall.domain.po.WxBillRent">
  336. update wx_bill_rent set updatetime = now()
  337. <if test=" null != receivePay ">,receive_pay = #{receivePay}</if>
  338. <if test=" null != comments ">,comments = #{comments}</if>
  339. <if test=" null != receiveDate ">,receive_date = #{receiveDate}</if>
  340. <if test="0 == receivePay or 0l == receivePay">,status = 3,pay_date=now()</if>
  341. where id = #{id}
  342. </update>
  343. <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxBillRent">
  344. update wx_bill_rent set is_preview = #{isPreview},merchant_id = #{merchantId},need_pay = receive_pay
  345. where rent_contract_id = #{rentContractId}
  346. </update>
  347. <select id="oweBillCount" parameterType="java.lang.Long" resultType="java.lang.Long">
  348. select count(br.id) from wx_bill_rent br,wx_rent_contract c where c.id = br.rent_contract_id
  349. and br.status = 1 and c.id = #{contractId}
  350. </select>
  351. <insert id="insertBills" parameterType="HashMap">
  352. INSERT INTO wx_bill_rent (id,tenant_id,parent_tenant_id,
  353. rent_contract_id, receive_pay, pay, receive_date, pay_date, createtime, expired_day,create_by,create_by_name,update_by,update_by_name,
  354. status, is_del, contract_need_pay,rent_price_info,need_pay,bussiness_manage_fee_need_pay,operating_manage_fee_need_pay, merchant_id, user_id, shop_id, updatetime, starttime, endtime,
  355. rent_shop_type, revenue, late_pay_ratio, late_pay_time, late_pay_price, period, is_preview, shop_info,
  356. pay_way, late_pay_status, comments,service_charge_pay,energy_fees_id,advance_id)
  357. VALUES
  358. <foreach collection="list" item="item" index="index" separator=",">
  359. (
  360. #{item.id},#{item.tenantId},#{item.parentTenantId},
  361. #{item.rentContractId},#{item.receivePay},#{item.pay},#{item.receiveDate},#{item.payDate},#{item.createtime},#{item.expiredDay},#{item.createBy},#{item.createByName},#{item.updateBy},#{item.updateByName},
  362. #{item.status},#{item.isDel},#{item.contractNeedPay},#{item.rentPriceInfo},#{item.needPay},#{item.bussinessManageFeeNeedPay},#{item.operatingManageFeeNeedPay},#{item.merchantId},
  363. #{item.userId},#{item.shopId},#{item.updatetime},#{item.starttime},#{item.endtime},#{item.rentShopType},#{item.revenue},
  364. #{item.latePayRatio},#{item.latePayTime},#{item.latePayPrice},#{item.period},#{item.isPreview},#{item.shopInfo},
  365. #{item.payWay},#{item.latePayStatus},#{item.comments},#{item.serviceChargePay},#{item.energyFeesId},#{item.advanceId}
  366. )
  367. </foreach>
  368. </insert>
  369. <update id="updateBills" parameterType="java.util.List">
  370. <foreach collection="bills" item="item" index="index" open="" close="" separator=";">
  371. update wx_bill_rent
  372. <set>
  373. <if test=" null != item.receivePay ">updatetime = now(),receive_pay = #{item.receivePay},</if>
  374. <if test=" null != item.comments ">comments = #{item.comments},</if>
  375. <if test=" null != item.receiveDate ">receive_date = #{item.receiveDate},</if>
  376. <if test="0 == item.receivePay or 0l == item.receivePay">status = 3,pay_date=now()</if>
  377. </set>
  378. where id = #{item.id}
  379. </foreach>
  380. </update>
  381. <select id="selectBillOne" parameterType="com.iformall.domain.po.WxBillRent"
  382. resultType="com.iformall.domain.po.WxBillRent">
  383. select * from wx_bill_rent where merchant_id=#{merchantId}
  384. AND rent_shop_type = #{rentShopType} AND is_preview = #{isPreview}
  385. AND date_format(starttime,'%Y-%m-%d 00:00:00.0') = #{starttime} AND date_format(endtime,'%Y-%m-%d 00:00:00.0') = #{endtime}
  386. </select>
  387. <delete id = "deleteById" parameterType="HashMap">
  388. delete from wx_bill_rent where id = #{id} and tenant_id = #{tenantId}
  389. </delete>
  390. <!--
  391. <update id="insertBillAction">
  392. insert into wx_bill_action(id,user_name,`action`,bill_id,details,tenant_id,parent_tenant_id)
  393. select
  394. (select unix_timestamp(now()) + CEILING(RAND()*90000+10000) + CEILING(RAND()*90000+10000)+ CEILING(RAND()*90000+10000) ) id
  395. ,'系统端' user_name,7 `action`,b.id bill_id,
  396. CONCAT('系统计入',
  397. if(b.late_pay_price is null,
  398. round(
  399. c.late_pay_ratio * DATEDIFF(now(), date_add(b.receive_date,interval(c.late_pay_day) day)) /10000
  400. ,2)
  401. ,
  402. round(
  403. (c.late_pay_ratio) /10000
  404. ,2)
  405. )
  406. ,'元') details,b.tenant_id,b.parent_tenant_id
  407. from wx_bill_rent b left join wx_rent_contract c on(b.rent_contract_id=c.id)
  408. where c.late_pay_ratio >0
  409. and DATEDIFF(now(), date_add(b.receive_date,interval(c.late_pay_day) day)) >0
  410. and b.status!=3 and b.status!=6
  411. </update>
  412. <update id="autoAddLatePayPrice">
  413. update wx_bill_rent b set b.late_pay_price =
  414. if(b.late_pay_price is null,
  415. round(
  416. (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`)
  417. * DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_rent_contract where id = b.`rent_contract_id`) day)) /100
  418. ,2)
  419. ,
  420. b.late_pay_price +
  421. round(
  422. (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`) /100
  423. ,2)
  424. )
  425. where b.status!=3 and b.status!=6
  426. and (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`) > 0
  427. and DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_rent_contract where id = b.`rent_contract_id`) day)) >0;
  428. </update>
  429. <update id="updateServiceCharge" parameterType="com.iformall.domain.po.WxPayAccountBill">
  430. update wx_bill_rent set service_charge_pay=round(receive_pay*#{serviceChargeRate}/10000)
  431. where service_charge_pay=0
  432. <if test=" null != tenantId and '' != tenantId">
  433. and `tenant_id` = #{tenantId}
  434. </if>
  435. <if test=" null != parentTenantId and '' != parentTenantId">
  436. and `parent_tenant_id` = #{parentTenantId}
  437. </if>
  438. and status in(1,2,4)
  439. </update>-->
  440. <!-- <update id="updateOwe">
  441. update wx_bill_rent set owe = receive_pay + service_charge_pay + ifnull(late_pay_price,0) - pay where status in (1,2,4)
  442. </update> -->
  443. </mapper>