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ů.
 
 
 
 
 

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