You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

460 lines
23 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.WxAllBillMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxAllBill">
  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="shop_id" jdbcType="BIGINT" property="shopId"/>
  9. <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
  10. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  11. <result column="create_by_name" jdbcType="VARCHAR" property="createByName"/>
  12. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
  13. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  14. <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/>
  15. <result column="price_detail" jdbcType="VARCHAR" property="priceDetail"/>
  16. <result column="need_pay" jdbcType="VARCHAR" property="needPay"/>
  17. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  18. <result column="history_receive_pay" jdbcType="VARCHAR" property="historyReceivePay"/>
  19. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  20. <result column="bill_type" jdbcType="INTEGER" property="billType"/>
  21. <result column="pay_way" jdbcType="BIGINT" property="payWay"/>
  22. <result column="pay_date" jdbcType="TIMESTAMP" property="payDate"/>
  23. <result column="set_off" jdbcType="VARCHAR" property="setOff"/>
  24. <result column="use_money" jdbcType="VARCHAR" property="useMoney"/>
  25. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  26. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  27. <result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate"/>
  28. <result column="period" jdbcType="VARCHAR" property="period"/>
  29. <result column="status" jdbcType="INTEGER" property="status"/>
  30. <result column="energy_fees_id" jdbcType="BIGINT" property="energyFeesId"/>
  31. <result column="return_pay" jdbcType="VARCHAR" property="returnPay"/>
  32. <result column="bill_remark" jdbcType="VARCHAR" property="billRemark"/>
  33. <result column="last_owe_call_time" jdbcType="TIMESTAMP" property="lastOweCallTime"/>
  34. <result column="last_owe_call_user" jdbcType="VARCHAR" property="lastOweCallUser"/>
  35. <result column="bussiness_manage_fee_need_pay" jdbcType="VARCHAR" property="bussinessManageFeeNeedPay"/>
  36. <result column="operating_manage_fee_need_pay" jdbcType="VARCHAR" property="operatingManageFeeNeedPay"/>
  37. <result column="is_preview" jdbcType="INTEGER" property="isPreview"/>
  38. <result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/>
  39. <result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/>
  40. <result column="rent_contract_agile_fees_type" jdbcType="INTEGER" property="rentContractAgileFeesType"/>
  41. <result column="property_contract_id" jdbcType="BIGINT" property="propertyContractId"/>
  42. <result column="parent_bill_id" jdbcType="BIGINT" property="parentBillId"/>
  43. <result column="virtual_compose_id" jdbcType="BIGINT" property="virtualComposeId"/>
  44. <result column="parent_virtual_compose_id" jdbcType="BIGINT" property="parentVirtualComposeId"/>
  45. <result column="energy_reading_calcuteId" jdbcType="BIGINT" property="energyReadingCalcuteId" />
  46. <result column="energy_reading_id" jdbcType="BIGINT" property="energyReadingId" />
  47. <result column="extra_create_from" jdbcType="INTEGER" property="extraCreateFrom" />
  48. <result column="rent_area" jdbcType="VARCHAR" property="rentArea" />
  49. <result column="can_edit" jdbcType="INTEGER" property="canEdit" />
  50. <result column="cus_name" jdbcType="VARCHAR" property="cusName" />
  51. </resultMap>
  52. <sql id="allColumns">
  53. `id`,`tenant_id`,`parent_tenant_id`,`shop_id`,`createtime`,`create_by`,`create_by_name`,`updatetime`,`update_by`,`update_by_name`,
  54. `price_detail`,`need_pay`,`receive_pay`,`history_receive_pay`,`pay`,`bill_type`,`pay_way`,`pay_date`,`set_off`,`use_money`,`starttime`,`endtime`,`status`,`energy_fees_id`,
  55. `return_pay`,`bill_remark`,`last_owe_call_time`,`last_owe_call_user`,`bussiness_manage_fee_need_pay`,`operating_manage_fee_need_pay`,`receive_date`,`period`,
  56. `is_preview`,`shop_info`,`rent_contract_id`,`rent_contract_agile_fees_type`,`property_contract_id`,`parent_bill_id`,`virtual_compose_id`,`parent_virtual_compose_id`,
  57. `energy_reading_calcuteId`,`energy_reading_id`,`extra_create_from`,`rent_area`,`can_edit`,`cus_name`
  58. </sql>
  59. <sql id="dynamicWhereConditions">
  60. where `tenant_id` = #{tenantId}
  61. <if test=" null != id ">and `id` = #{id}</if>
  62. <if test=" null != parentTenantId and '' != parentTenantId"> and `parent_tenant_id` = #{parentTenantId}</if>
  63. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  64. <if test=" null != createBy ">and `create_by` = #{createBy}</if>
  65. <if test=" null != createByName and '' != createByName"> and `create_by_name` like concat('%',#{createByName},'%')</if>
  66. <if test=" null != billType ">and `bill_type` = #{billType}</if>
  67. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  68. <if test=" null != status ">and `status` = #{status}</if>
  69. <if test=" null != energyFeesId ">and `energy_fees_id` = #{energyFeesId}</if>
  70. <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
  71. <if test=" null != rentContractAgileFeesType ">and `rent_contract_agile_fees_type` = #{rentContractAgileFeesType}</if>
  72. <if test=" null != propertyContractId ">and `property_contract_id` = #{propertyContractId}</if>
  73. <if test=" null != parentBillId ">and `parent_bill_id` = #{parentBillId}</if>
  74. <if test=" null != virtualComposeId ">and `virtual_compose_id` = #{virtualComposeId}</if>
  75. <if test=" null != parentVirtualComposeId ">and `parent_virtual_compose_id` = #{parentVirtualComposeId}</if>
  76. <if test=" null != isPreview ">and `is_preview` = #{isPreview}</if>
  77. <if test=" null != starttime">and `starttime` &gt;= #{starttime}</if>
  78. <if test=" null != endtime">and `endtime` &lt;= #{endtime}</if>
  79. <if test=" null != receiveDate">and `receive_date` &lt;= #{receiveDate}</if>
  80. <if test=" null != starttimeEqual">and `starttime` = #{starttimeEqual}</if>
  81. <if test=" null != endtimeEqual">and `endtime` = #{endtimeEqual}</if>
  82. <if test=" null != extraCreateFrom">and `extra_create_from` = #{extraCreateFrom}</if>
  83. <if test=" null != noExtraCreateFrom">and `extra_create_from` is null</if>
  84. <if test=" null != advanceHasMoney">and bill_type = 6 and IFNULL(`pay`,'0') -IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') &gt; 0</if>
  85. <if test=" null != depositHasMoney">and IFNULL(`pay`,'0') - IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') &gt; 0 and bill_type in (13,21,5)</if>
  86. <if test=" null != canEdit">and `can_edit` = #{canEdit}</if>
  87. <if test=" null != month and '' != month">
  88. and date_format(starttime,'%Y-%m') &lt;= #{month} and date_format(endtime,'%Y-%m') &gt;= #{month}
  89. </if>
  90. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  91. and (
  92. (`receive_date` &lt;= #{oweBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') &gt; 0 and bill_type not in (13,21,5,7))
  93. or
  94. (`receive_date` &lt;= #{oweBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') &gt; 0 and bill_type in (13,21,5,7))
  95. )
  96. </if>
  97. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  98. and (
  99. (`receive_date` &gt; #{oweBillLastTime} and `receive_date` &lt;= #{nearBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') &gt; 0 and bill_type not in (13,21,5,7))
  100. or
  101. (`receive_date` &gt; #{oweBillLastTime} and `receive_date` &lt;= #{nearBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') &gt; 0 and bill_type in (13,21,5,7))
  102. )
  103. </if>
  104. <if test=" null != needPayStartDay">
  105. and (
  106. (`receive_date` &lt;= #{needPayStartDay} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') &gt; 0 and bill_type not in (13,21,5,7))
  107. or
  108. (`receive_date` &lt;= #{needPayStartDay} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') &gt; 0 and bill_type in (13,21,5,7))
  109. )
  110. </if>
  111. <if test=" null != needPayNoDays">
  112. and (
  113. ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') &gt; 0 and bill_type not in (13,21,5,6,7))
  114. or
  115. ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') &gt; 0 and bill_type in (13,21,5,6,7))
  116. )
  117. </if>
  118. <if test=" null != toPayMerchant">
  119. and (
  120. ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') &lt; 0 and bill_type not in (13,21,5,6,7))
  121. or
  122. ( `pay` - IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') &gt; 0 and bill_type in (13,21,5,7))
  123. )
  124. </if>
  125. <if test=" 1 == notifyed ">
  126. and (
  127. (`last_owe_call_time` is not null and `receive_pay` - `pay`- IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') &gt; 0 and bill_type not in (13,21,5,7))
  128. or
  129. (`last_owe_call_time` is not null and `receive_pay` - `pay`- IFNULL(`set_off`,'0') &gt; 0 and bill_type in (13,21,5,7))
  130. )
  131. </if>
  132. <if test=" 1 == hasParentBillId ">and `parent_bill_id` is not null</if>
  133. <if test=" 0 == hasParentBillId ">and `parent_bill_id` is null</if>
  134. <if test=" null != energyReadingCalcuteId ">and `energy_reading_calcuteId` = #{energyReadingCalcuteId}</if>
  135. <if test=" null != energyReadingId ">and `energy_reading_id` = #{energyReadingId}</if>
  136. <if test=" null != cusName and '' != cusName">
  137. and ( cus_name like concat('%',#{cusName},'%')
  138. <if test=" null != cusNameShopIdList ">
  139. or `shop_id` in
  140. <foreach collection="cusNameShopIdList" index="index" item="cusShopidItem" open="(" separator="," close=")">
  141. #{cusShopidItem}
  142. </foreach>
  143. </if>
  144. )
  145. </if>
  146. <if test=" null != shopIdList ">
  147. and `shop_id` in
  148. <foreach collection="shopIdList" index="index" item="shopidItem" open="(" separator="," close=")">
  149. #{shopidItem}
  150. </foreach>
  151. </if>
  152. <if test=" null != energyFeesIds ">
  153. and `energy_fees_id` in
  154. <foreach collection="energyFeesIds" index="index" item="eidItem" open="(" separator="," close=")">
  155. #{eidItem}
  156. </foreach>
  157. </if>
  158. <if test=" null != rentContractIdList ">
  159. and `rent_contract_id` in
  160. <foreach collection="rentContractIdList" index="index" item="ridItem" open="(" separator="," close=")">
  161. #{ridItem}
  162. </foreach>
  163. </if>
  164. <if test=" null != propertyContractIds ">
  165. and property_contract_id in
  166. <foreach collection="propertyContractIds" index="index" item="pidItem" open="(" separator="," close=")">
  167. #{pidItem}
  168. </foreach>
  169. </if>
  170. <if test=" null != statusList ">
  171. and `status` in
  172. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  173. #{stItem}
  174. </foreach>
  175. </if>
  176. <if test=" null != notInIds ">
  177. and id not in
  178. <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
  179. #{nidItem}
  180. </foreach>
  181. </if>
  182. <if test=" null != ids ">
  183. and id in
  184. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  185. #{idItem}
  186. </foreach>
  187. </if>
  188. <if test=" null != sortColumns">order by ${sortColumns}</if>
  189. <if test="null != limitStart and null != limitEnd">
  190. limit #{limitStart},#{limitEnd}
  191. </if>
  192. </sql>
  193. <select id="findList" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  194. select
  195. <include refid="allColumns"/>
  196. from wx_all_bill
  197. <include refid="dynamicWhereConditions"/>
  198. </select>
  199. <select id="getShopIdList" parameterType="com.iformall.domain.po.WxAllBill" resultType="Long">
  200. select distinct shop_id
  201. from wx_all_bill
  202. <include refid="dynamicWhereConditions"/>
  203. </select>
  204. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  205. select
  206. <include refid="allColumns"/>
  207. from wx_all_bill where id = #{id} and `tenant_id` = #{tenantId}
  208. </select>
  209. <select id="queryBillRentContractIdList" parameterType="com.iformall.domain.po.WxAllBill" resultType="Long">
  210. select distinct rent_contract_id from wx_all_bill
  211. <include refid="dynamicWhereConditions"/>
  212. </select>
  213. <select id="getRemainAdvanceSum" parameterType="com.iformall.domain.po.WxAllBill" resultType="DECIMAL">
  214. select sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2)) - CAST(ifnull(return_pay,'0') AS DECIMAL(20,2)) - CAST(ifnull(use_money,'0') AS DECIMAL(20,2)))
  215. from wx_all_bill
  216. <include refid="dynamicWhereConditions"/>
  217. </select>
  218. <select id="getMerchantAdvanceGroupSumList" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  219. select energy_fees_id, sum(CAST(pay AS DECIMAL(20,2))) pay , sum(CAST(ifnull(use_money,'0') AS DECIMAL(20,2))) use_money
  220. from wx_all_bill
  221. <include refid="dynamicWhereConditions"/>
  222. group by energy_fees_id
  223. </select>
  224. <select id="findContractSamePeriodSum" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  225. select
  226. sum(CAST(need_pay AS DECIMAL(20,2))) need_pay ,
  227. sum(CAST(receive_pay AS DECIMAL(20,2))) receive_pay ,
  228. sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2))) pay,
  229. sum(CAST(ifnull(set_off,'0') AS DECIMAL(20,2))) set_off,
  230. sum(CAST(ifnull(use_money,'0') AS DECIMAL(20,2))) use_money,
  231. sum(CAST(ifnull(return_pay,'0') AS DECIMAL(20,2))) return_pay,
  232. sum(CAST(ifnull(bussiness_manage_fee_need_pay,'0') AS DECIMAL(20,2))) bussiness_manage_fee_need_pay,
  233. sum(CAST(ifnull(operating_manage_fee_need_pay,'0') AS DECIMAL(20,2))) operating_manage_fee_need_pay,
  234. starttime,
  235. endtime,
  236. receive_date,
  237. virtual_compose_id
  238. from wx_all_bill
  239. <include refid="dynamicWhereConditions"/>
  240. group by starttime,endtime
  241. order by starttime asc
  242. </select>
  243. <select id="findContractFeesSamePeriodSum" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  244. select
  245. sum(CAST(need_pay AS DECIMAL(20,2))) need_pay ,
  246. sum(CAST(receive_pay AS DECIMAL(20,2))) receive_pay ,
  247. sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2))) pay,
  248. sum(CAST(ifnull(set_off,'0') AS DECIMAL(20,2))) set_off,
  249. sum(CAST(ifnull(use_money,'0') AS DECIMAL(20,2))) use_money,
  250. sum(CAST(ifnull(return_pay,'0') AS DECIMAL(20,2))) return_pay,
  251. sum(CAST(ifnull(bussiness_manage_fee_need_pay,'0') AS DECIMAL(20,2))) bussiness_manage_fee_need_pay,
  252. sum(CAST(ifnull(operating_manage_fee_need_pay,'0') AS DECIMAL(20,2))) operating_manage_fee_need_pay,
  253. starttime,
  254. endtime,
  255. receive_date,
  256. virtual_compose_id,
  257. parent_virtual_compose_id,
  258. energy_fees_id
  259. from wx_all_bill
  260. <include refid="dynamicWhereConditions"/>
  261. group by energy_fees_id,starttime,endtime
  262. order by starttime asc
  263. </select>
  264. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  265. <result column="cut_off_pay" jdbcType="VARCHAR" property="cutOffPay"/>
  266. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  267. <result column="paid" jdbcType="VARCHAR" property="paid" />
  268. <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
  269. <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
  270. <result column="return_pay" jdbcType="VARCHAR" property="returnPay"/>
  271. <result column="set_off" jdbcType="VARCHAR" property="setOff"/>
  272. <result column="energy_fees_id" jdbcType="BIGINT" property="energyFeesId"/>
  273. </resultMap>
  274. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxAllBill" resultMap="SumBaseResultMap">
  275. select
  276. sum(CAST(need_pay AS DECIMAL(20,2))-CAST(receive_pay AS DECIMAL(20,2))) cut_off_pay ,
  277. sum(CAST(receive_pay AS DECIMAL(20,2))) receive_pay ,
  278. sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2))) paid,
  279. min(starttime) min_date,
  280. max(endtime) max_date,
  281. sum(CAST(ifnull(set_off,'0') AS DECIMAL(20,2))) set_off ,
  282. sum(CAST(ifnull(return_pay,'0') AS DECIMAL(20,2))) return_pay
  283. from wx_all_bill
  284. <include refid="dynamicWhereConditions"/>
  285. </select>
  286. <select id="getFeesBillSum" parameterType="com.iformall.domain.po.WxAllBill" resultMap="SumBaseResultMap">
  287. select
  288. energy_fees_id,
  289. sum(CAST(need_pay AS DECIMAL(20,2))-CAST(receive_pay AS DECIMAL(20,2))) cut_off_pay ,
  290. sum(CAST(receive_pay AS DECIMAL(20,2))) receive_pay ,
  291. sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2))) paid,
  292. min(starttime) min_date,
  293. max(endtime) max_date,
  294. sum(CAST(ifnull(set_off,'0') AS DECIMAL(20,2))) set_off ,
  295. sum(CAST(ifnull(return_pay,'0') AS DECIMAL(20,2))) return_pay
  296. from wx_all_bill
  297. <include refid="dynamicWhereConditions"/>
  298. group by energy_fees_id
  299. </select>
  300. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  301. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  302. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  303. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  304. <result column="energy_fees_id" jdbcType="INTEGER" property="energyFeesId"/>
  305. </resultMap>
  306. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxAllBill" resultMap="HotNotifyBaseResultMap">
  307. select
  308. energy_fees_id,
  309. count(1) total_count ,
  310. case when bill_type in (13,21,5) then sum(CAST(`receive_pay` AS DECIMAL(20,2)) - CAST(`pay` AS DECIMAL(20,2)) - CAST(IFNULL(`set_off`,'0') AS DECIMAL(20,2)) )
  311. else sum(CAST(`receive_pay` AS DECIMAL(20,2)) - CAST(`pay` AS DECIMAL(20,2)) - CAST(IFNULL(`set_off`,'0') AS DECIMAL(20,2)) + CAST(IFNULL(`return_pay`,'0') AS DECIMAL(20,2)))
  312. end as total_money,
  313. MIN(starttime) min_begin_time from wx_all_bill
  314. <include refid="dynamicWhereConditions"/>
  315. group by energy_fees_id
  316. </select>
  317. <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
  318. <result column="bill_type" jdbcType="INTEGER" property="billType"/>
  319. <result column="bill_id" jdbcType="BIGINT" property="billId" />
  320. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  321. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  322. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  323. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  324. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  325. </resultMap>
  326. <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxAllBill" resultMap="NotifyResultMap">
  327. select bill_type,br.id as bill_id, br.starttime,br.endtime,br.receive_pay,br.pay,br.shop_id from wx_all_bill br
  328. <include refid="dynamicWhereConditions"/>
  329. </select>
  330. <delete id="deleteBillByContract" parameterType="com.iformall.domain.po.WxRentContract">
  331. delete from wx_all_bill where rent_contract_id = #{id}
  332. </delete>
  333. <delete id="deleteBillByPropertyContract" parameterType="com.iformall.domain.po.WxPropertyContract">
  334. delete from wx_all_bill where property_contract_id = #{id}
  335. </delete>
  336. <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxAllBill">
  337. delete from wx_all_bill where is_preview = 1
  338. <if test=" null != rentContractId">
  339. and rent_contract_id = #{rentContractId}
  340. </if>
  341. <if test=" null != propertyContractId">
  342. and property_contract_id = #{propertyContractId}
  343. </if>
  344. <if test=" null != rentContractAgileFeesType">
  345. and rent_contract_agile_fees_type = #{rentContractAgileFeesType}
  346. </if>
  347. <if test=" null != energyFeesId">
  348. and energy_fees_id = #{energyFeesId}
  349. </if>
  350. </delete>
  351. <delete id="deleteNoNeedPayBill" parameterType="com.iformall.domain.po.WxAllBill">
  352. delete from wx_all_bill where starttime &gt;= #{shopEndtime} and IFNULL(`pay`,'0') &lt;= 0 AND IFNULL(`set_off`,'0') &lt;= 0
  353. and IFNULL(`return_pay`,'0') &lt;= 0 and IFNULL(`use_money`,'0') &lt;= 0
  354. <if test=" null != rentContractId">
  355. and rent_contract_id = #{rentContractId}
  356. </if>
  357. <if test=" null != propertyContractId">
  358. and property_contract_id = #{propertyContractId}
  359. </if>
  360. </delete>
  361. <delete id="deleteByRentHuiSuan" parameterType="com.iformall.domain.po.WxAllBill">
  362. delete from wx_all_bill where rent_contract_id = #{rentContractId}
  363. and IFNULL(`pay`,'0') &lt;= 0 AND IFNULL(`set_off`,'0') &lt;= 0 and IFNULL(`return_pay`,'0') &lt;= 0 and IFNULL(`use_money`,'0') &lt;= 0
  364. and extra_create_from = #{extraCreateFrom} and `starttime` = #{starttimeEqual}
  365. </delete>
  366. <select id="countValidBillCountByRentHuiSuan" parameterType="com.iformall.domain.po.WxAllBill" resultType="Integer">
  367. select count(1) from wx_all_bill where rent_contract_id = #{rentContractId}
  368. and (IFNULL(`pay`,'0') &gt; 0 or IFNULL(`set_off`,'0') &gt; 0 or IFNULL(`return_pay`,'0') &gt; 0 or IFNULL(`use_money`,'0') &gt; 0)
  369. and extra_create_from = #{extraCreateFrom} and `starttime` = #{starttimeEqual}
  370. </select>
  371. <delete id="deleteByRentReveneuSales" parameterType="com.iformall.domain.po.WxAllBill">
  372. delete from wx_all_bill where extra_create_from = #{extraCreateFrom}
  373. and IFNULL(`pay`,'0') &lt;= 0 AND IFNULL(`set_off`,'0') &lt;= 0 and IFNULL(`return_pay`,'0') &lt;= 0 and IFNULL(`use_money`,'0') &lt;= 0
  374. and `starttime` = #{starttimeEqual}
  375. <if test=" null != rentContractId">
  376. and rent_contract_id = #{rentContractId}
  377. </if>
  378. <if test=" null != propertyContractId">
  379. and property_contract_id = #{propertyContractId}
  380. </if>
  381. </delete>
  382. <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxAllBill">
  383. update wx_all_bill set is_preview = #{isPreview}
  384. <if test=" null != rentContractId">
  385. where rent_contract_id = #{rentContractId}
  386. </if>
  387. <if test=" null != propertyContractId">
  388. where property_contract_id = #{propertyContractId}
  389. </if>
  390. </update>
  391. <insert id="insertBills" parameterType="HashMap">
  392. INSERT INTO wx_all_bill (
  393. <include refid="allColumns"/>
  394. )
  395. VALUES
  396. <foreach collection="list" item="item" index="index" separator=",">
  397. (
  398. #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.shopId},#{item.createtime},
  399. #{item.createBy},#{item.createByName},#{item.updatetime},#{item.updateBy},#{item.updateByName},#{item.priceDetail},
  400. #{item.needPay},#{item.receivePay},#{item.historyReceivePay},#{item.pay},#{item.billType},#{item.payWay},#{item.payDate},#{item.setOff},#{item.useMoney},
  401. #{item.starttime},#{item.endtime},#{item.status},#{item.energyFeesId},#{item.returnPay},#{item.billRemark},
  402. #{item.lastOweCallTime},#{item.lastOweCallUser},#{item.bussinessManageFeeNeedPay},#{item.operatingManageFeeNeedPay},
  403. #{item.receiveDate},#{item.period},#{item.isPreview},#{item.shopInfo},#{item.rentContractId},#{item.rentContractAgileFeesType},#{item.propertyContractId},
  404. #{item.parentBillId},#{item.virtualComposeId},#{item.parentVirtualComposeId},#{item.energyReadingCalcuteId},
  405. #{item.energyReadingId},#{item.extraCreateFrom},#{item.rentArea},#{item.canEdit},#{item.cusName}
  406. )
  407. </foreach>
  408. </insert>
  409. <delete id = "deleteById" parameterType="HashMap">
  410. delete from wx_all_bill where id = #{id} and tenant_id = #{tenantId}
  411. and (
  412. (bill_type != 7 and pay &lt;= 0 and IFNULL(`set_off`,'0') &lt;= 0 and IFNULL(`return_pay`,'0') &lt;= 0 and IFNULL(`use_money`,'0') &lt;= 0)
  413. or
  414. (bill_type = 7 and IFNULL(`set_off`,'0') &lt;= 0 and IFNULL(`return_pay`,'0') &lt;= 0 and IFNULL(`use_money`,'0') &lt;= 0)
  415. )
  416. </delete>
  417. <delete id = "deleteEnergyReadingBills" parameterType="HashMap">
  418. delete from wx_all_bill where energy_reading_calcuteId = #{energyReadingCalcuteId} and tenant_id = #{tenantId}
  419. and pay &lt;= 0 and IFNULL(`set_off`,'0') &lt;= 0 and IFNULL(`return_pay`,'0') &lt;= 0 and IFNULL(`use_money`,'0') &lt;= 0
  420. </delete>
  421. <update id="updateContractCusName" parameterType="com.iformall.domain.po.WxAllBill">
  422. update wx_all_bill set cus_name = #{cusName} where cus_name is null
  423. <if test=" null != rentContractId">
  424. and rent_contract_id = #{rentContractId}
  425. </if>
  426. <if test=" null != propertyContractId">
  427. and property_contract_id = #{propertyContractId}
  428. </if>
  429. </update>
  430. </mapper>