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

460 řádky
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="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. <result column="fees_type" jdbcType="INTEGER" property="feesType"/>
  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`,`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`,`fees_type`
  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 != payWay ">and `pay_way` = #{payWay}</if>
  67. <if test=" null != status ">and `status` = #{status}</if>
  68. <if test=" null != feesType ">and `fees_type` = #{feesType}</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 fees_type = 2 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 (`receive_date` &lt;= #{oweBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') &gt; 0 and fees_type = 1)
  92. </if>
  93. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  94. and (`receive_date` &gt; #{oweBillLastTime} and `receive_date` &lt;= #{nearBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') &gt; 0 and fees_type = 1)
  95. </if>
  96. <if test=" null != needPayStartDay">
  97. and (`receive_date` &lt;= #{needPayStartDay} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') &gt; 0 and fees_type = 1)
  98. </if>
  99. <if test=" null != needPayNoDays">
  100. and ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') &gt; 0 and fees_type = 1)
  101. </if>
  102. <if test=" null != toPayMerchant">
  103. and (
  104. ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') &lt; 0 and fees_type = 1)
  105. or
  106. ( `pay` - IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') &gt; 0 and fees_type = 2)
  107. )
  108. </if>
  109. <if test=" 1 == notifyed ">
  110. and (`last_owe_call_time` is not null and `receive_pay` - `pay`- IFNULL(`set_off`,'0') &gt; 0 )
  111. </if>
  112. <if test=" 1 == hasParentBillId ">and `parent_bill_id` is not null</if>
  113. <if test=" 0 == hasParentBillId ">and `parent_bill_id` is null</if>
  114. <if test=" null != energyReadingCalcuteId ">and `energy_reading_calcuteId` = #{energyReadingCalcuteId}</if>
  115. <if test=" null != energyReadingId ">and `energy_reading_id` = #{energyReadingId}</if>
  116. <if test=" null != cusName and '' != cusName">
  117. and ( cus_name like concat('%',#{cusName},'%')
  118. <if test=" null != cusNameShopIdList ">
  119. or `shop_id` in
  120. <foreach collection="cusNameShopIdList" index="index" item="cusShopidItem" open="(" separator="," close=")">
  121. #{cusShopidItem}
  122. </foreach>
  123. </if>
  124. )
  125. </if>
  126. <if test=" null != shopIdList ">
  127. and `shop_id` in
  128. <foreach collection="shopIdList" index="index" item="shopidItem" open="(" separator="," close=")">
  129. #{shopidItem}
  130. </foreach>
  131. </if>
  132. <if test=" null != energyFeesIds ">
  133. and `energy_fees_id` in
  134. <foreach collection="energyFeesIds" index="index" item="eidItem" open="(" separator="," close=")">
  135. #{eidItem}
  136. </foreach>
  137. </if>
  138. <if test=" null != rentContractIdList ">
  139. and `rent_contract_id` in
  140. <foreach collection="rentContractIdList" index="index" item="ridItem" open="(" separator="," close=")">
  141. #{ridItem}
  142. </foreach>
  143. </if>
  144. <if test=" null != propertyContractIds ">
  145. and property_contract_id in
  146. <foreach collection="propertyContractIds" index="index" item="pidItem" open="(" separator="," close=")">
  147. #{pidItem}
  148. </foreach>
  149. </if>
  150. <if test=" null != statusList ">
  151. and `status` in
  152. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  153. #{stItem}
  154. </foreach>
  155. </if>
  156. <if test=" null != notInIds ">
  157. and id not in
  158. <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
  159. #{nidItem}
  160. </foreach>
  161. </if>
  162. <if test=" null != ids ">
  163. and id in
  164. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  165. #{idItem}
  166. </foreach>
  167. </if>
  168. <if test=" null != sortColumns">order by ${sortColumns}</if>
  169. <if test="null != limitStart and null != limitEnd">
  170. limit #{limitStart},#{limitEnd}
  171. </if>
  172. </sql>
  173. <select id="findList" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  174. select
  175. <include refid="allColumns"/>
  176. from wx_all_bill
  177. <include refid="dynamicWhereConditions"/>
  178. </select>
  179. <select id="getShopIdList" parameterType="com.iformall.domain.po.WxAllBill" resultType="Long">
  180. select distinct shop_id
  181. from wx_all_bill
  182. <include refid="dynamicWhereConditions"/>
  183. </select>
  184. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  185. select
  186. <include refid="allColumns"/>
  187. from wx_all_bill where id = #{id} and `tenant_id` = #{tenantId}
  188. </select>
  189. <select id="queryBillRentContractIdList" parameterType="com.iformall.domain.po.WxAllBill" resultType="Long">
  190. select distinct rent_contract_id from wx_all_bill
  191. <include refid="dynamicWhereConditions"/>
  192. </select>
  193. <select id="getRemainAdvanceSum" parameterType="com.iformall.domain.po.WxAllBill" resultType="DECIMAL">
  194. 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)))
  195. from wx_all_bill
  196. <include refid="dynamicWhereConditions"/>
  197. </select>
  198. <select id="getMerchantAdvanceGroupSumList" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  199. select energy_fees_id, sum(CAST(pay AS DECIMAL(20,2))) pay , sum(CAST(ifnull(use_money,'0') AS DECIMAL(20,2))) use_money
  200. from wx_all_bill
  201. <include refid="dynamicWhereConditions"/>
  202. group by energy_fees_id
  203. </select>
  204. <select id="findContractSamePeriodSum" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  205. select
  206. sum(CAST(need_pay AS DECIMAL(20,2))) need_pay ,
  207. sum(CAST(receive_pay AS DECIMAL(20,2))) receive_pay ,
  208. sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2))) pay,
  209. sum(CAST(ifnull(set_off,'0') AS DECIMAL(20,2))) set_off,
  210. sum(CAST(ifnull(use_money,'0') AS DECIMAL(20,2))) use_money,
  211. sum(CAST(ifnull(return_pay,'0') AS DECIMAL(20,2))) return_pay,
  212. sum(CAST(ifnull(bussiness_manage_fee_need_pay,'0') AS DECIMAL(20,2))) bussiness_manage_fee_need_pay,
  213. sum(CAST(ifnull(operating_manage_fee_need_pay,'0') AS DECIMAL(20,2))) operating_manage_fee_need_pay,
  214. starttime,
  215. endtime,
  216. receive_date,
  217. virtual_compose_id
  218. from wx_all_bill
  219. <include refid="dynamicWhereConditions"/>
  220. group by starttime,endtime
  221. order by starttime asc
  222. </select>
  223. <select id="findContractFeesSamePeriodSum" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
  224. select
  225. sum(CAST(need_pay AS DECIMAL(20,2))) need_pay ,
  226. sum(CAST(receive_pay AS DECIMAL(20,2))) receive_pay ,
  227. sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2))) pay,
  228. sum(CAST(ifnull(set_off,'0') AS DECIMAL(20,2))) set_off,
  229. sum(CAST(ifnull(use_money,'0') AS DECIMAL(20,2))) use_money,
  230. sum(CAST(ifnull(return_pay,'0') AS DECIMAL(20,2))) return_pay,
  231. sum(CAST(ifnull(bussiness_manage_fee_need_pay,'0') AS DECIMAL(20,2))) bussiness_manage_fee_need_pay,
  232. sum(CAST(ifnull(operating_manage_fee_need_pay,'0') AS DECIMAL(20,2))) operating_manage_fee_need_pay,
  233. starttime,
  234. endtime,
  235. receive_date,
  236. virtual_compose_id,
  237. parent_virtual_compose_id,
  238. energy_fees_id
  239. from wx_all_bill
  240. <include refid="dynamicWhereConditions"/>
  241. group by energy_fees_id,starttime,endtime
  242. order by starttime asc
  243. </select>
  244. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  245. <result column="cut_off_pay" jdbcType="VARCHAR" property="cutOffPay"/>
  246. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  247. <result column="paid" jdbcType="VARCHAR" property="paid" />
  248. <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
  249. <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
  250. <result column="return_pay" jdbcType="VARCHAR" property="returnPay"/>
  251. <result column="set_off" jdbcType="VARCHAR" property="setOff"/>
  252. <result column="energy_fees_id" jdbcType="BIGINT" property="energyFeesId"/>
  253. </resultMap>
  254. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxAllBill" resultMap="SumBaseResultMap">
  255. select
  256. sum(CAST(need_pay AS DECIMAL(20,2))-CAST(receive_pay AS DECIMAL(20,2))) cut_off_pay ,
  257. sum(CAST(receive_pay AS DECIMAL(20,2))) receive_pay ,
  258. sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2))) paid,
  259. min(starttime) min_date,
  260. max(endtime) max_date,
  261. sum(CAST(ifnull(set_off,'0') AS DECIMAL(20,2))) set_off ,
  262. sum(CAST(ifnull(return_pay,'0') AS DECIMAL(20,2))) return_pay
  263. from wx_all_bill
  264. <include refid="dynamicWhereConditions"/>
  265. </select>
  266. <select id="getFeesBillSum" parameterType="com.iformall.domain.po.WxAllBill" resultMap="SumBaseResultMap">
  267. select
  268. energy_fees_id,
  269. sum(CAST(need_pay AS DECIMAL(20,2))-CAST(receive_pay AS DECIMAL(20,2))) cut_off_pay ,
  270. sum(CAST(receive_pay AS DECIMAL(20,2))) receive_pay ,
  271. sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2))) paid,
  272. min(starttime) min_date,
  273. max(endtime) max_date,
  274. sum(CAST(ifnull(set_off,'0') AS DECIMAL(20,2))) set_off ,
  275. sum(CAST(ifnull(return_pay,'0') AS DECIMAL(20,2))) return_pay
  276. from wx_all_bill
  277. <include refid="dynamicWhereConditions"/>
  278. group by energy_fees_id
  279. </select>
  280. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  281. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  282. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  283. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  284. <result column="energy_fees_id" jdbcType="INTEGER" property="energyFeesId"/>
  285. </resultMap>
  286. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxAllBill" resultMap="HotNotifyBaseResultMap">
  287. select
  288. energy_fees_id,
  289. count(1) total_count ,
  290. sum(CAST(`receive_pay` AS DECIMAL(20,2)) - CAST(`pay` AS DECIMAL(20,2)) - CAST(IFNULL(`set_off`,'0') AS DECIMAL(20,2))) as total_money,
  291. MIN(starttime) min_begin_time from wx_all_bill
  292. <include refid="dynamicWhereConditions"/>
  293. group by energy_fees_id
  294. </select>
  295. <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
  296. <result column="bill_id" jdbcType="BIGINT" property="billId" />
  297. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  298. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  299. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  300. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  301. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  302. </resultMap>
  303. <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxAllBill" resultMap="NotifyResultMap">
  304. select br.id as bill_id, br.starttime,br.endtime,br.receive_pay,br.pay,br.shop_id from wx_all_bill br
  305. <include refid="dynamicWhereConditions"/>
  306. </select>
  307. <delete id="deleteBillByContract" parameterType="com.iformall.domain.po.WxRentContract">
  308. delete from wx_all_bill where rent_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.historyReceivePay},#{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 (
  386. ( pay &lt;= 0 and IFNULL(`set_off`,'0') &lt;= 0 and IFNULL(`return_pay`,'0') &lt;= 0 and IFNULL(`use_money`,'0') &lt;= 0)
  387. or
  388. ( IFNULL(`set_off`,'0') &lt;= 0 and IFNULL(`return_pay`,'0') &lt;= 0 and IFNULL(`use_money`,'0') &lt;= 0)
  389. )
  390. </delete>
  391. <delete id = "deleteEnergyReadingBills" parameterType="HashMap">
  392. delete from wx_all_bill where energy_reading_calcuteId = #{energyReadingCalcuteId} and tenant_id = #{tenantId}
  393. 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
  394. </delete>
  395. <update id="updateContractCusName" parameterType="com.iformall.domain.po.WxAllBill">
  396. update wx_all_bill set cus_name = #{cusName} where cus_name is null
  397. <if test=" null != rentContractId">
  398. and rent_contract_id = #{rentContractId}
  399. </if>
  400. <if test=" null != propertyContractId">
  401. and property_contract_id = #{propertyContractId}
  402. </if>
  403. </update>
  404. <update id="transferCusName" parameterType="com.iformall.domain.po.WxAllBill">
  405. update wx_all_bill set cus_name = #{cusName} where tenant_id = #{tenantId}
  406. <if test=" null != rentContractId">
  407. and rent_contract_id = #{rentContractId}
  408. </if>
  409. <if test=" null != propertyContractId">
  410. and property_contract_id = #{propertyContractId}
  411. </if>
  412. and(
  413. <!-- 应收 -->
  414. (
  415. IFNULL(`pay`,'0') &lt;= 0
  416. or
  417. ( starttime &gt;= #{starttime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') &gt; 0 )
  418. or
  419. ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') &gt; 0 )
  420. )
  421. <!-- 应fu -->
  422. or (
  423. ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') &lt; 0 )
  424. or
  425. ( `pay` - IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') &gt; 0 )
  426. )
  427. )
  428. </update>
  429. </mapper>