選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

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