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.
 
 
 
 
 

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