PayBaseCustomerandmeterrelaMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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.bz.smart_city.dao.pay.archives.PayBaseCustomerandmeterrelaMapper">
  4. <sql id="sqlColumns">
  5. </sql>
  6. <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  7. <!--@mbg.generated-->
  8. <id column="id" property="id" />
  9. <id column="metercode" property="metercode"/>
  10. <result column="remarks" property="remarks" />
  11. <result column="create_by" property="createBy" />
  12. <result column="update_by" property="updateBy" />
  13. <result column="customer_id" property="customerId" />
  14. </resultMap>
  15. <sql id="sqlJoins">
  16. </sql>
  17. <select id="queryDevice" resultMap="BaseResultMap" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  18. select id as "id",water_meter_no as "metercode" from sc_device LIMIT 1
  19. </select>
  20. <select id="findList" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  21. select
  22. customer.id as "id",
  23. customer.watermeter_id as "watermeterId",
  24. account.id as "accountId",
  25. account.accountnumber as "accountnumber",
  26. customer.office_id as "officeId",
  27. account.name as "name",
  28. account.telephone as "telephone",
  29. customer.metercode as "metercode",
  30. pro.name as "propertyName",
  31. account.address as "address",
  32. customer.opendate as "opendate",
  33. customer.businessstate as "businessstate",
  34. customer.calculateway as "calculateway",
  35. pro.id as "waterPropertyId"
  36. from pay_base_customerandmeterrela customer
  37. left join pay_base_account account on customer.account_id = account.id
  38. left join pay_base_waterproperty pro on pro.id = customer.waterproperty_id
  39. <where>
  40. <if test="id != null">
  41. and customer.id =#{id}
  42. </if>
  43. <if test="metercode != null">
  44. and customer.metercode =#{metercode}
  45. </if>
  46. <if test="siteId != null">
  47. and customer.site_id = #{siteId}
  48. </if>
  49. <if test="customerId != null">
  50. and customer.customer_id = #{customerId}
  51. </if>
  52. order by customer.create_date desc
  53. </where>
  54. </select>
  55. <select id="getAccountId" resultType="com.bz.smart_city.entity.pay.PayBaseAccount">
  56. select
  57. id as "id"
  58. from pay_base_account
  59. <where>
  60. <if test="siteId != null">
  61. and site_id = #{siteId}
  62. </if>
  63. <if test="customerId != null">
  64. and customer_id = #{customerId}
  65. </if>
  66. <if test="accountnumber">
  67. and accountnumber =#{accountnumber}
  68. </if>
  69. order by create_date desc
  70. </where>
  71. </select>
  72. <select id="getDeviceId" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela" >
  73. select
  74. id as "id"
  75. from sc_device
  76. <where>
  77. <!--<if test="siteId != null">
  78. and site_id = #{siteId}
  79. </if>-->
  80. <if test="customerId != null">
  81. and customer_id = #{customerId}
  82. </if>
  83. <if test="metercode != null">
  84. and metercode =#{metercode}
  85. </if>
  86. </where>
  87. limit 1
  88. </select>
  89. <select id="getWaterPropertyId" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  90. select id as "waterPropertyId"
  91. from pay_base_waterproperty
  92. <where>
  93. <if test="siteId != null">
  94. and site_id = #{siteId}
  95. </if>
  96. <if test="customerId != null">
  97. and customer_id = #{customerId}
  98. </if>
  99. <if test="name != null">
  100. and name =#{name}
  101. </if>
  102. order by create_date desc
  103. </where>
  104. </select>
  105. <insert id="insertList">
  106. INSERT INTO pay_base_customerandmeterrela
  107. (
  108. id,
  109. account_id,
  110. watermeter_id,
  111. accountname,
  112. accountnumber,
  113. metercode,
  114. businessstate,
  115. office_id,
  116. housetype,
  117. calculateway,
  118. customercategory,
  119. customergroup,
  120. fixedamount,
  121. vatno,
  122. bankaccount,
  123. invoicetitle,
  124. address,
  125. opendate,
  126. waterproperty_id,
  127. watertype,
  128. canceldate,
  129. create_by,
  130. create_date,
  131. update_by,
  132. update_date,
  133. remarks,
  134. del_flag,
  135. site_id,
  136. customer_id
  137. )
  138. values
  139. <foreach collection="customers" item="customer" index="index" separator=",">
  140. (
  141. #{customer.id,jdbcType=BIGINT},
  142. #{customer.accountId,jdbcType=BIGINT},
  143. #{customer.watermeterId,jdbcType=BIGINT},
  144. #{customer.accountname,jdbcType=VARCHAR},
  145. #{customer.accountnumber,jdbcType=VARCHAR},
  146. #{customer.metercode,jdbcType=VARCHAR},
  147. #{customer.businessstate,jdbcType=INTEGER},
  148. #{customer.officeId,jdbcType=BIGINT},
  149. #{customer.housetype,jdbcType=INTEGER},
  150. #{customer.calculateway,jdbcType=INTEGER},
  151. #{customer.customercategory,jdbcType=INTEGER},
  152. #{customer.customergroup,jdbcType=INTEGER},
  153. #{customer.fixedamount,jdbcType=VARCHAR},
  154. #{customer.vatno,jdbcType=VARCHAR},
  155. #{customer.bankaccount,jdbcType=VARCHAR},
  156. #{customer.invoicetitle,jdbcType=VARCHAR},
  157. #{customer.address,jdbcType=VARCHAR},
  158. #{customer.opendate,jdbcType=TIMESTAMP},
  159. #{customer.waterPropertyId,jdbcType=BIGINT},
  160. #{customer.watertype,jdbcType=INTEGER},
  161. #{customer.canceldate,jdbcType=TIMESTAMP},
  162. #{customer.createBy,jdbcType=VARCHAR},
  163. #{customer.createDate,jdbcType=TIMESTAMP},
  164. #{customer.updateBy,jdbcType=VARCHAR},
  165. #{customer.updateDate,jdbcType=TIMESTAMP},
  166. #{customer.remarks,jdbcType=VARCHAR},
  167. #{customer.delFlag,jdbcType=VARCHAR},
  168. #{customer.siteId,jdbcType=BIGINT},
  169. #{customer.customerId,jdbcType=BIGINT}
  170. )
  171. </foreach>
  172. </insert>
  173. <update id="update">
  174. update pay_base_customerandmeterrela
  175. <set>
  176. <if test="accountId != null">account_id =#{accountId},</if>
  177. <if test="watermeterId != null">watermeter_id =#{watermeterId},</if>
  178. <if test="accountname != null">accountname =#{accountname},</if>
  179. <if test="accountnumber != null">accountnumber =#{accountnumber},</if>
  180. <if test="metercode != null">metercode =#{metercode},</if>
  181. <if test="businessstate != null">businessstate =#{businessstate},</if>
  182. <if test="officeId != null">office_id =#{officeId},</if>
  183. <if test="housetype != null">housetype =#{housetype},</if>
  184. <if test="calculateway != null">calculateway =#{calculateway},</if>
  185. <if test="customercategory != null">customercategory =#{customercategory},</if>
  186. <if test="customergroup != null">customergroup =#{customergroup},</if>
  187. <if test="fixedamount != null">fixedamount =#{fixedamount},</if>
  188. <if test="vatno != null">vatno =#{vatno},</if>
  189. <if test="bankaccount != null">bankaccount =#{bankaccount},</if>
  190. <if test="address != null">address =#{address},</if>
  191. <if test="opendate != null">opendate =#{opendate},</if>
  192. <if test="waterPropertyId != null">waterproperty_id =#{waterPropertyId},</if>
  193. <if test="watertype != null">watertype =#{watertype},</if>
  194. <if test="canceldate != null">canceldate =#{canceldate},</if>
  195. <if test="updateBy != null">update_by =#{updateBy},</if>
  196. <if test="updateDate != null">update_date =#{updateDate},</if>
  197. </set>
  198. <where>
  199. <if test="id != null">id =#{id}</if>
  200. </where>
  201. </update>
  202. <select id="meterAllDebt" resultType="java.lang.Double">
  203. select ifnull(sum(debt),0) debt from pay_pay_receivable r where r.meter_id=#{meterid}
  204. </select>
  205. <select id="findByAccount" resultType="com.bz.smart_city.entity.pay.PayPayRechargeaccount">
  206. select
  207. rech.*
  208. from pay_pay_rechargeaccount rech
  209. <where>
  210. <if test="accountId != null">
  211. and rech.account_id =#{accountId}
  212. </if>
  213. order by rech.create_date desc
  214. </where>
  215. </select>
  216. <update id="updateCustomerState">
  217. update pay_base_customerandmeterrela set businessstate =#{state},update_by=#{updateBy},update_date =#{date},canceldate =#{date}
  218. where site_id =#{siteId} and customer_id =#{customerId} and id =#{id}
  219. </update>
  220. <update id="updateDeviceState">
  221. update sc_device set status =#{state},update_by=#{updateBy},date_update =#{date}
  222. where site_id =#{siteId} and customer_id =#{customerId} and metercode =#{metercode}
  223. </update>
  224. <select id="getAll" resultType="com.bz.smart_city.dto.pay.PayCustomerDto">
  225. select
  226. customer.fixedamount as "fixedamount",
  227. customer.id as "id",
  228. account.accountnumber as "accountnumber",
  229. account.name as "accountname",
  230. account.telephone as "telephone",
  231. customer.metercode as "metercode",
  232. device.water_meter_no as "metereleno",
  233. property.id as "waterPropertyId",
  234. property.name as "waterPropertyName",
  235. account.address as "address",
  236. customer.opendate as "opendate",
  237. customer.office_id as "officeId",
  238. account.email,
  239. customer.vatno,
  240. customer.businessstate as "businessstate",
  241. (select label from pay_sys_dict where type = '开户状态' and value = customer.businessstate and site_id = #{siteId} and customer_id =#{customerId}) as "businessName",
  242. customer.calculateway as "calculateway",
  243. (select label from pay_sys_dict where type = '结算方式' and value = customer.calculateway and site_id = #{siteId} and customer_id =#{customerId}) as "calculatewayName",
  244. account.idtype as "idtype",
  245. (select label from pay_sys_dict where type = '证件类型' and value = account.idtype and site_id = #{siteId} and customer_id =#{customerId}) as "idtypeName",
  246. account.idcardno as "idcardno",
  247. customer.housetype as "housetype",
  248. (select label from pay_sys_dict where type = '住房类型' and value = customer.housetype and site_id = #{siteId} and customer_id =#{customerId}) as "housetypeName",
  249. customer.customergroup as "customergroup",
  250. (select label from pay_sys_dict where type = '开户分组' and value = customer.customergroup and site_id = #{siteId} and customer_id =#{customerId}) as "customergroupName"
  251. from pay_base_customerandmeterrela customer
  252. left join sc_device device on customer.watermeter_id = device.id
  253. left join pay_base_account account on account.id = customer.account_id
  254. left join pay_base_waterproperty property on property.id = customer.waterproperty_id
  255. <where>
  256. <if test="siteId != null">
  257. and customer.site_id = #{siteId}
  258. </if>
  259. <if test="customerId != null">
  260. and customer.customer_id = #{customerId}
  261. </if>
  262. <if test="condition != null">
  263. and
  264. (
  265. account.accountnumber like concat('%',#{condition},'%')
  266. or account.name like concat('%',#{condition},'%')
  267. or customer.metercode like concat('%',#{condition},'%')
  268. or account.address like concat('%',#{condition},'%')
  269. or account.telephone like concat('%',#{condition},'%')
  270. or device.water_meter_no like concat('%',#{condition},'%')
  271. )
  272. </if>
  273. <if test="waterPropertyId != null">
  274. and property.id =#{waterPropertyId}
  275. </if>
  276. <if test="businessstate != null">
  277. and customer.businessstate =#{businessstate}
  278. </if>
  279. <if test="calculateway != null">
  280. and customer.calculateway =#{calculateway}
  281. </if>
  282. <if test="programItems != null and programItems.size() != 0">
  283. and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  284. <if test="item.dimensionId == 10">
  285. customer.office_id = #{item.dimensionValue}
  286. </if>
  287. </foreach>
  288. </if>
  289. order by customer.create_date desc
  290. </where>
  291. </select>
  292. <select id="getList" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  293. select
  294. account.accountnumber as "accountnumber",
  295. account.name as "accountname",
  296. account.telephone as "telephone",
  297. customer.metercode as "metercode",
  298. property.name as "propertyName",
  299. device.loc_desc as "address",
  300. customer.opendate as "opendate",
  301. customer.businessstate as "businessstate",
  302. customer.calculateway as "calculateway",
  303. device.water_meter_no as "metereleno"
  304. from pay_base_customerandmeterrela customer
  305. left join pay_base_account account on account.id = customer.account_id
  306. left join pay_base_waterproperty property on property.id = customer.waterproperty_id
  307. inner join sc_device device on device.metercode = customer.metercode
  308. <where>
  309. <if test="siteId != null">
  310. and customer.site_id = #{siteId}
  311. </if>
  312. <if test="customerId != null">
  313. and customer.customer_id = #{customerId}
  314. </if>
  315. <if test="condition != null">
  316. and
  317. (
  318. account.accountnumber like concat('%',#{condition},'%')
  319. or account.name like concat('%',#{condition},'%')
  320. or customer.metercode like concat('%',#{condition},'%')
  321. or account.address like concat('%',#{condition},'%')
  322. or account.telephone like concat('%',#{condition},'%')
  323. or device.water_meter_no like concat('%',#{condition},'%')
  324. )
  325. </if>
  326. <if test="waterPropertyId != null">
  327. and property.id =#{waterPropertyId}
  328. </if>
  329. <if test="businessstate != null">
  330. and customer.businessstate =#{businessstate}
  331. </if>
  332. <if test="calculateway != null">
  333. and customer.calculateway =#{calculateway}
  334. </if>
  335. order by customer.create_date desc
  336. </where>
  337. </select>
  338. <select id="queryNoOpenAccount" resultType="com.bz.smart_city.entity.pay.archives.DeviceListInfo">
  339. select
  340. account.accountnumber as "accountnumber"
  341. from pay_base_account account
  342. <where>
  343. <if test="siteId != null">
  344. and account.site_id = #{siteId}
  345. </if>
  346. <if test="customerId != null">
  347. and account.customer_id = #{customerId}
  348. </if>
  349. order by account.create_date desc
  350. </where>
  351. </select>
  352. <select id="selectAccountInfo" resultType="com.bz.smart_city.entity.pay.archives.MeterListInfo">
  353. select
  354. device.metercode as "metercode",
  355. sil.user_name as accountname,
  356. sil.user_phone as telephone,
  357. sil.id_card as idcardno
  358. from pay_base_account account
  359. inner join sc_device device on account.id = device.account_id
  360. inner join sc_install_list sil on sil.device_id = device.id
  361. <where>
  362. device.metercode not in(select metercode from pay_base_customerandmeterrela where businessstate = '1')
  363. <if test="accountnumber != null">
  364. and account.accountnumber =#{accountnumber}
  365. </if>
  366. <!-- <if test="siteId != null">
  367. and account.site_id = #{siteId}
  368. </if>-->
  369. <if test="customerId != null">
  370. and account.customer_id = #{customerId}
  371. </if>
  372. order by account.create_date desc
  373. </where>
  374. </select>
  375. <select id="selectAccountMeterInfo" resultType="com.bz.smart_city.entity.pay.archives.PayAccountInfo">
  376. select
  377. account.accountnumber as "accountnumber",
  378. account.calculateway as "calculateway",
  379. account.waterproperty_id as "waterPropertyId",
  380. account.address as installAddress,
  381. device.metercode as "metercode",
  382. sil.user_name as accountname,
  383. sil.user_phone as telephone,
  384. sil.id_card as idcardno,
  385. device.water_meter_no as "metereleno"
  386. from pay_base_account account
  387. inner join sc_device device on account.id = device.account_id
  388. inner join sc_install_list sil on sil.device_id = device.id
  389. <where>
  390. device.metercode not in(select metercode from pay_base_customerandmeterrela where businessstate = '1')
  391. <if test="metercode != null">
  392. and device.metercode like concat('%',#{metercode},'%')
  393. </if>
  394. <!--<if test="siteId != null">
  395. and account.site_id = #{siteId}
  396. </if>-->
  397. <if test="customerId != null">
  398. and account.customer_id = #{customerId}
  399. </if>
  400. order by account.create_date desc
  401. </where>
  402. </select>
  403. <select id="selectMeterElenoMeterInfo" resultType="com.bz.smart_city.entity.pay.archives.PayAccountInfo">
  404. select
  405. account.accountnumber as "accountnumber",
  406. account.calculateway as "calculateway",
  407. account.waterproperty_id as "waterPropertyId",
  408. account.address as installAddress,
  409. device.metercode as "metercode",
  410. sil.user_name as accountname,
  411. sil.user_phone as telephone,
  412. sil.id_card as idcardno,
  413. device.water_meter_no as "metereleno"
  414. from pay_base_account account
  415. inner join sc_device device on account.id = device.account_id
  416. inner join sc_install_list sil on sil.device_id = device.id
  417. <where>
  418. device.id not in(select watermeter_id from pay_base_customerandmeterrela where businessstate = '1')
  419. <if test="metereleno != null">
  420. and device.water_meter_no like concat('%',#{metereleno},'%')
  421. </if>
  422. <!--<if test="siteId != null">
  423. and account.site_id = #{siteId}
  424. </if>-->
  425. <if test="customerId != null">
  426. and account.customer_id = #{customerId}
  427. </if>
  428. order by account.create_date desc
  429. </where>
  430. </select>
  431. <select id="selectAccountWater" resultType="com.bz.smart_city.entity.pay.archives.CustomerListInfo">
  432. select
  433. accountnumber as "accountnumber",
  434. calculateway as "calculateway" ,
  435. account.address as installAddress,
  436. waterproperty_id as "waterPropertyId",
  437. device.water_meter_no as "metereleno"
  438. from pay_base_account account
  439. inner join sc_device device on account.id = device.account_id
  440. <where>
  441. and (account.accountnumber not in (select accountnumber from pay_base_customerandmeterrela where businessstate ='1' ))
  442. <if test="accountnumber != null">
  443. and account.accountnumber like concat('%',#{accountnumber},'%')
  444. </if>
  445. <if test="siteId != null">
  446. and account.site_id = #{siteId}
  447. </if>
  448. <if test="customerId != null">
  449. and account.customer_id = #{customerId}
  450. </if>
  451. order by account.create_date desc
  452. </where>
  453. </select>
  454. <select id="queryMetercode" resultType="com.bz.smart_city.entity.pay.archives.MeterListInfo">
  455. select
  456. metercode from sc_device deivce
  457. <where>
  458. deivce.metercode not in (select metercode from pay_base_customerandmeterrela) and deivce.metercode is not null
  459. <!--<if test="siteId != null">
  460. and site_id = #{siteId}
  461. </if>-->
  462. <if test="customerId != null">
  463. and customer_id = #{customerId}
  464. </if>
  465. order by date_create desc
  466. </where>
  467. </select>
  468. <update id="updateAccountInfo">
  469. update pay_base_account set name=#{accountname},idtype =#{idtype},idcardno=#{idcardno},telephone=#{telephone},update_by=#{updateBy},update_date =#{date}
  470. where site_id =#{siteId} and customer_id =#{customerId} and accountnumber =#{accountnumber}
  471. </update>
  472. <update id="updateCustomerInfo">
  473. update pay_base_customerandmeterrela set accountname=#{accountname},housetype =#{housetype} ,office_id =#{officeId},customergroup =#{customergroup},update_by=#{updateBy},update_date =#{date}
  474. where site_id =#{siteId} and customer_id =#{customerId} and accountnumber =#{accountnumber} and metercode =#{metercode}
  475. </update>
  476. <update id="updateBaseAccountInfo">
  477. update pay_base_account set address =#{address} ,telephone =#{telephone},idtype =#{idtype},idcardno=#{idcardno}
  478. where site_id =#{siteId} and customer_id =#{customerId} and accountnumber =#{accountnumber};
  479. </update>
  480. <select id="queryWaterUserdStateCount" resultType="java.lang.Integer">
  481. select count(1) from pay_amount_waterusedamount t
  482. inner join pay_base_closingaccountinfo c on t.year = c.year and t.month = c.month
  483. where t.state = 1 and c.state = 0 and t.watermeter_id = #{id}
  484. </select>
  485. <select id="get" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  486. select
  487. a.id,
  488. a.account_id AS "accountId",
  489. a.watermeter_id AS "watermeterId",
  490. a.accountname,
  491. a.accountnumber,
  492. a.metercode,
  493. a.businessstate,
  494. a.office_id AS "officeId",
  495. a.housetype,
  496. a.calculateway,
  497. a.customercategory,
  498. a.customergroup,
  499. a.fixedamount,
  500. a.vatno,
  501. a.bankaccount,
  502. a.invoicetitle,
  503. a.address,
  504. a.opendate,
  505. a.waterproperty_id AS "waterpropertyId",
  506. a.watertype,
  507. a.canceldate,
  508. a.create_by AS "createBy",
  509. a.create_date AS "createDate",
  510. a.update_by AS "updateBy",
  511. a.update_date AS "updateDate",
  512. a.remarks AS "remarks",
  513. a.del_flag AS "delFlag",
  514. a.site_id as "siteId",
  515. a.customer_id as "customerId"
  516. from pay_base_customerandmeterrela a
  517. <where>
  518. a.id =#{id}
  519. </where>
  520. </select>
  521. <update id="updateMeterInstallOpen">
  522. update sc_install_list set is_accepted =#{isAccepted},date_update=#{date},update_by =#{updateBy} where device_id =#{id}
  523. </update>
  524. <select id="getOfficeId" resultType="com.bz.smart_city.entity.Organization">
  525. select id from sc_organization where site_id =#{siteId} and name =#{name}
  526. </select>
  527. <update id="updateRechargeAccountState">
  528. update pay_pay_rechargeaccount set businessstate ='2',update_by=#{updateBy},update_date =#{date}
  529. where site_id =#{siteId} and customer_id =#{customerId} and account_id =#{id}
  530. </update>
  531. <update id="updateAccountState">
  532. update pay_base_account set state =#{state},update_by=#{updateBy},update_date =#{date}
  533. where site_id =#{siteId} and customer_id =#{customerId} and id =#{id}
  534. </update>
  535. <select id="getResetLadderList" resultType="com.bz.smart_city.dto.pay.PayBaseCustomerandmeterrelaDto">
  536. SELECT
  537. a.waterproperty_id as waterpropertyId,
  538. a.account_id as accountId,
  539. pro.laddertype as laddertype
  540. FROM pay_base_customerandmeterrela a
  541. inner join pay_base_account ac on ac.id = a.account_id
  542. left join pay_base_waterproperty pro on pro.id = a.waterproperty_id
  543. WHERE (pro.laddertype=1 or pro.laddertype=2)
  544. and ac.resetaccumulatedtondate &lt;= now()
  545. and a.businessstate=1
  546. and a.site_id = #{siteId}
  547. and a.customer_id = #{customerId}
  548. </select>
  549. <select id="queryCustomerInfo" resultType="java.lang.Integer">
  550. select
  551. count(1)
  552. from pay_base_customerandmeterrela
  553. where site_id =#{siteId} and customer_id =#{customerId} and accountnumber =#{accountnumber} and metercode =#{metercode}
  554. </select>
  555. <select id="queryCancelInfo" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  556. select
  557. a.id,
  558. a.account_id AS "accountId",
  559. a.watermeter_id AS "watermeterId",
  560. a.accountname,
  561. a.accountnumber,
  562. a.metercode,
  563. a.businessstate,
  564. a.office_id AS "officeId",
  565. a.housetype,
  566. a.calculateway,
  567. a.customercategory,
  568. a.customergroup,
  569. a.fixedamount,
  570. a.vatno,
  571. a.bankaccount,
  572. a.invoicetitle,
  573. a.address,
  574. a.opendate,
  575. a.waterproperty_id AS "waterpropertyId",
  576. a.watertype,
  577. a.canceldate,
  578. a.create_by AS "createBy",
  579. a.create_date AS "createDate",
  580. a.update_by AS "updateBy",
  581. a.update_date AS "updateDate",
  582. a.remarks AS "remarks",
  583. a.del_flag AS "delFlag",
  584. a.site_id as "siteId",
  585. a.customer_id as "customerId"
  586. from pay_base_customerandmeterrela a
  587. <where>
  588. <if test="siteId != null">
  589. and a.site_id =#{siteId}
  590. </if>
  591. <if test="customerId != null">
  592. and a.customer_id =#{customerId}
  593. </if>
  594. <if test="accountnumber != null">
  595. and a.accountnumber =#{accountnumber}
  596. </if>
  597. <if test="metercode != null">
  598. and a.metercode =#{metercode}
  599. </if>
  600. </where>
  601. </select>
  602. <select id="queryMeterState" resultType="java.lang.Integer">
  603. select is_accepted as "isAccepted" from sc_install_list where account_id =#{accountId} and customer_id =#{customerId}
  604. </select>
  605. <select id="getParentOfficeId" resultType="com.bz.smart_city.entity.Organization">
  606. select id from sc_organization where site_id =#{siteId} and parent_id =#{id} and name =#{name}
  607. </select>
  608. <select id="findAccountByAccountNumber" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  609. select
  610. account.id as "accountId",
  611. account.accountnumber as "accountnumber",
  612. account.name as "accountname",
  613. customer.invoicetitle as "invoicetitle",
  614. account.telephone as "telephone",
  615. account.address as "address",
  616. customer.vatno as "vatno",
  617. customer.bankaccount as "bankaccount",
  618. account.email as "email"
  619. from pay_base_customerandmeterrela customer
  620. left join pay_base_account account on customer.account_id = account.id
  621. <where>
  622. <if test="siteId != null">
  623. and customer.site_id = #{siteId}
  624. </if>
  625. <if test="customerId != null">
  626. and customer.customer_id = #{customerId}
  627. </if>
  628. <if test="accountnumber != null and accountnumber != ''">
  629. and customer.accountnumber = #{accountnumber}
  630. </if>
  631. </where>
  632. limit 1
  633. </select>
  634. </mapper>