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.
 
 
 
 
 

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