RecPayMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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.dk.mdm.mapper.mac.RecPayMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. rp_id, rp_no, rp_type, object_id, org_id, staff_id, sum_amt_rec, sum_amt_pay, sum_amt_receivable_handle, sum_amt_payable_handle, sum_waive_amt, acc_date, annex_paths, remarks, biznis_type, biznis_id, biznis_no, flg_lock, make_staff, make_time, flg_valid, cp_id
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mac.RecPay">
  11. <id column="rp_id" property="rpId"/>
  12. <result column="rp_no" property="rpNo"/>
  13. <result column="rp_type" property="rpType"/>
  14. <result column="object_id" property="objectId" typeHandler="UuidTypeHandler"/>
  15. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  16. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  17. <result column="sum_amt_rec" property="sumAmtRec"/>
  18. <result column="sum_amt_pay" property="sumAmtPay"/>
  19. <result column="sum_amt_receivable_handle" property="sumAmtReceivableHandle"/>
  20. <result column="sum_amt_payable_handle" property="sumAmtPayableHandle"/>
  21. <result column="sum_waive_amt" property="sumWaiveAmt"/>
  22. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  23. <result column="remarks" property="remarks"/>
  24. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  25. <result column="biznis_type" property="biznisType"/>
  26. <result column="biznis_id" property="biznisId" typeHandler="UuidTypeHandler"/>
  27. <result column="biznis_no" property="biznisNo"/>
  28. <result column="flg_lock" property="flgLock"/>
  29. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  30. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  31. <result column="flg_valid" property="flgValid"/>
  32. <result column="cp_id" property="cpId"/>
  33. </resultMap>
  34. <!-- Response查询映射结果 -->
  35. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mac.RecPayResponse">
  36. <id column="rp_id" property="rpId"/>
  37. <result column="rp_no" property="rpNo"/>
  38. <result column="rp_type" property="rpType"/>
  39. <result column="object_id" property="objectId" typeHandler="UuidTypeHandler"/>
  40. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  41. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  42. <result column="sum_amt_rec" property="sumAmtRec"/>
  43. <result column="sum_amt_pay" property="sumAmtPay"/>
  44. <result column="sum_amt_receivable_handle" property="sumAmtReceivableHandle"/>
  45. <result column="sum_amt_payable_handle" property="sumAmtPayableHandle"/>
  46. <result column="sum_waive_amt" property="sumWaiveAmt"/>
  47. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  48. <result column="remarks" property="remarks"/>
  49. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  50. <result column="biznis_type" property="biznisType"/>
  51. <result column="biznis_id" property="biznisId" typeHandler="UuidTypeHandler"/>
  52. <result column="biznis_no" property="biznisNo"/>
  53. <result column="flg_lock" property="flgLock"/>
  54. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  55. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  56. <result column="flg_valid" property="flgValid"/>
  57. <result column="cp_id" property="cpId"/>
  58. <result column="receivable_residue" property="receivableResidue"/>
  59. <result column="receipt_residue" property="receiptResidue"/>
  60. <result column="payable_residue" property="payableResidue"/>
  61. <result column="payment_residue" property="paymentResidue"/>
  62. </resultMap>
  63. <!-- 通用条件列 -->
  64. <sql id="Condition">
  65. <if test="rpNo != null and rpNo != ''">
  66. AND t.rp_no LIKE concat('%',my_ex.likequery(#{rpNo}),'%')
  67. </if>
  68. <if test="rpType != null and rpType != ''">
  69. AND t.rp_type = #{rpType}
  70. </if>
  71. <if test="objectId != null and objectId != ''">
  72. AND t.object_id = #{objectId}::uuid
  73. </if>
  74. <if test="orgId != null and orgId != ''">
  75. AND t.org_id = #{orgId}::uuid
  76. </if>
  77. <if test="staffId != null and staffId != ''">
  78. AND t.staff_id = #{staffId}::uuid
  79. </if>
  80. <if test="sumAmtRec != null">
  81. AND t.sum_amt_rec = #{sumAmtRec}
  82. </if>
  83. <if test="sumAmtPay != null">
  84. AND t.sum_amt_pay = #{sumAmtPay}
  85. </if>
  86. <if test="sumAmtReceivableHandle != null">
  87. AND t.sum_amt_receivable_handle = #{sumAmtReceivableHandle}
  88. </if>
  89. <if test="sumAmtPayableHandle != null">
  90. AND t.sum_amt_payable_handle = #{sumAmtPayableHandle}
  91. </if>
  92. <if test="sumWaiveAmt != null">
  93. AND t.sum_waive_amt = #{sumWaiveAmt}
  94. </if>
  95. <if test="accDate != null">
  96. AND t.acc_date = #{accDate}
  97. </if>
  98. <if test="remarks != null and remarks != ''">
  99. AND t.remarks = #{remarks}
  100. </if>
  101. <if test="annexPaths != null and annexPaths != ''">
  102. AND t.annex_paths = #{annexPaths}
  103. </if>
  104. <if test="biznisType != null and biznisType != ''">
  105. AND t.biznis_type = #{biznisType}
  106. </if>
  107. <if test="biznisId != null and biznisId != ''">
  108. AND t.biznis_id = #{biznisId}::uuid
  109. </if>
  110. <if test="biznisNo != null and biznisNo != ''">
  111. AND t.biznis_no = #{biznisNo}
  112. </if>
  113. <if test="flgLock != null">
  114. AND t.flg_lock = #{flgLock}
  115. </if>
  116. <if test="makeStaff != null and makeStaff != ''">
  117. AND t.make_staff = #{makeStaff}
  118. </if>
  119. <if test="makeTime != null">
  120. AND t.make_time = #{makeTime}
  121. </if>
  122. <if test="cpId != null">
  123. AND t.cp_id = #{cpId}
  124. </if>
  125. <if test="cusPhone != null and cusPhone != ''">
  126. AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
  127. </if>
  128. <if test="cusName != null and cusName != ''">
  129. AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
  130. </if>
  131. <if test="orgIdList != null and orgIdList.size() > 0">
  132. AND t.org_id =any(#{orgIdList, typeHandler=UuidListTypeHandler})
  133. </if>
  134. <if test="staffIdList != null and staffIdList.size() > 0">
  135. AND t.staff_id =any(#{staffIdList, typeHandler=UuidListTypeHandler})
  136. </if>
  137. <if test="makeTimeStart != null and makeTimeEnd != null">
  138. AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  139. AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  140. </if>
  141. <if test="flgValidList != null and flgValidList.size()>0">
  142. AND t.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  143. </if>
  144. <if test="supName != null and supName != ''">
  145. AND tmp.sup_name LIKE concat('%',my_ex.likequery(#{supName}),'%')
  146. </if>
  147. <if test="staffName != null and staffName != ''">
  148. AND tms.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
  149. </if>
  150. <if test="orgName != null and orgName != ''">
  151. AND tmo.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
  152. </if>
  153. </sql>
  154. <sql id="idsForeach">
  155. <!-- 根据主键rpId批量操作 -->
  156. WHERE rp_id in
  157. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  158. #{item}
  159. </foreach>
  160. </sql>
  161. <!-- 查询表t_mac_rec_pay,(条件查询+分页)列表 -->
  162. <select id="selectByCond" resultMap="BaseResultMapResponse">
  163. select t.rp_id,
  164. t.rp_no,
  165. t.rp_type,
  166. sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "rpTypeName",
  167. t.object_id,
  168. tmc.cus_code as "cusCode",
  169. tmc.cus_name as "cusName",
  170. tmc.cus_phone as "cusPhone",
  171. tmc.address_full as "addressFull",
  172. t.org_id,
  173. tmo.org_name as "orgName",
  174. t.staff_id,
  175. tms.staff_name as "staffName",
  176. t.sum_amt_rec,
  177. t.sum_amt_pay,
  178. t.sum_amt_receivable_handle,
  179. t.sum_amt_payable_handle,
  180. t.sum_waive_amt,
  181. t.acc_date,
  182. t.remarks,
  183. t.annex_paths,
  184. t.biznis_type,
  185. t.biznis_id,
  186. t.biznis_no,
  187. t.flg_lock,
  188. t.make_staff,
  189. makestaff.staff_name as "makeStaffName",
  190. t.make_time,
  191. t.flg_valid,
  192. t.cp_id,
  193. tma.receivable_residue,
  194. tma.receipt_residue
  195. from dkic_b.t_mac_rec_pay as t
  196. left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.object_id
  197. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.rp_type
  198. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  199. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  200. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  201. LEFT JOIN dkic_b.t_mac_account tma on tma.object_id = t.object_id and tma.object_type in ('对象类型-客户')
  202. where t.rp_type in ('收付款类型-收款', '收付款类型-退收款')
  203. <include refid="Condition"/>
  204. <if test="searchText !=null and searchText != ''">
  205. AND (
  206. t.rp_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  207. or tmc.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  208. or tmc.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  209. or tmo.org_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  210. or tms.staff_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  211. )
  212. </if>
  213. order by t.op_create_time desc
  214. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  215. limit #{end} offset #{start}
  216. </if>
  217. </select>
  218. <!-- 查询表t_mac_rec_pay,(条件查询)个数 -->
  219. <select id="countByCond" resultType="Long">
  220. SELECT count(1)
  221. from dkic_b.t_mac_rec_pay as t
  222. left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.object_id
  223. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.rp_type
  224. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  225. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  226. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  227. where t.rp_type in ('收付款类型-收款', '收付款类型-退收款')
  228. <include refid="Condition"/>
  229. <if test="searchText !=null and searchText != ''">
  230. AND (
  231. t.rp_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  232. or tmc.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  233. or tmc.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  234. or tmo.org_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  235. or tms.staff_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  236. )
  237. </if>
  238. </select>
  239. <!-- 根据主键查询表t_mac_rec_pay的一行数据 -->
  240. <select id="selectById" resultMap="BaseResultMapResponse">
  241. select t.rp_id,
  242. t.rp_no,
  243. t.rp_type,
  244. sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "rpTypeName",
  245. t.object_id,
  246. tmc.cus_code as "cusCode",
  247. tmc.cus_name as "cusName",
  248. tmc.cus_phone as "cusPhone",
  249. tmc.address_full as "addressFull",
  250. t.org_id,
  251. tmo.org_name as "orgName",
  252. t.staff_id,
  253. tms.staff_name as "staffName",
  254. t.sum_amt_rec,
  255. t.sum_amt_pay,
  256. t.sum_amt_receivable_handle,
  257. t.sum_amt_payable_handle,
  258. t.sum_waive_amt,
  259. t.acc_date,
  260. t.remarks,
  261. t.annex_paths,
  262. t.biznis_type,
  263. t.biznis_id,
  264. t.biznis_no,
  265. t.flg_lock,
  266. t.make_staff,
  267. makestaff.staff_name as "makeStaffName",
  268. t.make_time,
  269. t.flg_valid,
  270. t.cp_id
  271. from dkic_b.t_mac_rec_pay as t
  272. left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.object_id
  273. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.rp_type
  274. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  275. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  276. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  277. where t.rp_type in ('收付款类型-收款', '收付款类型-退收款')
  278. and t.rp_id = #{id}::uuid
  279. </select>
  280. <!-- 根据主键锁定表t_mac_rec_pay的一行数据 -->
  281. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  282. SELECT
  283. <include refid="Base_Column_List"/>
  284. FROM dkic_b.t_mac_rec_pay
  285. WHERE flg_valid
  286. and rp_id = #{id}::uuid
  287. for update
  288. </select>
  289. <!-- 根据主键锁定表t_mac_rec_pay的一行数据 -->
  290. <select id="selectByBiznisIdForUpdate" resultMap="BaseResultMap">
  291. SELECT
  292. <include refid="Base_Column_List"/>
  293. FROM dkic_b.t_mac_rec_pay
  294. WHERE flg_valid
  295. and biznis_id = #{id}::uuid
  296. for update
  297. </select>
  298. <!-- 根据主键锁定表t_mac_rec_pay的一行数据 -->
  299. <select id="selectByBiznisId" resultMap="BaseResultMap">
  300. SELECT
  301. <include refid="Base_Column_List"/>
  302. FROM dkic_b.t_mac_rec_pay
  303. WHERE flg_valid
  304. and biznis_id = #{id}::uuid
  305. </select>
  306. <!-- 根据主键锁定表t_mac_rec_pay的多行数据 -->
  307. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  308. SELECT
  309. <include refid="Base_Column_List"/>
  310. FROM dkic_b.t_mac_rec_pay
  311. <include refid="idsForeach"/>
  312. for update
  313. </select>
  314. <insert id="insertBatch">
  315. insert into dkic_b.t_mac_rec_pay
  316. (
  317. <trim suffixOverrides=",">
  318. rp_no,
  319. rp_type,
  320. object_id,
  321. org_id,
  322. staff_id,
  323. sum_amt_rec,
  324. sum_amt_pay,
  325. sum_amt_receivable_handle,
  326. sum_amt_payable_handle,
  327. sum_waive_amt,
  328. acc_date,
  329. remarks,
  330. annex_paths,
  331. biznis_type,
  332. biznis_id,
  333. biznis_no,
  334. flg_lock,
  335. make_staff,
  336. make_time,
  337. cp_id,
  338. op_app_code,
  339. </trim>
  340. )
  341. values
  342. <foreach collection="list" index="index" item="item" separator=",">
  343. (
  344. <trim suffixOverrides=",">
  345. #{item.rpNo},
  346. #{item.rpType},
  347. #{item.objectId}::uuid,
  348. #{item.orgId}::uuid,
  349. #{item.staffId}::uuid,
  350. #{item.sumAmtRec},
  351. #{item.sumAmtPay},
  352. #{item.sumAmtReceivableHandle},
  353. #{item.sumAmtPayableHandle},
  354. #{item.sumWaiveAmt},
  355. #{item.accDate},
  356. #{item.remarks},
  357. #{item.annexPaths},
  358. #{item.biznisType},
  359. #{item.biznisId}::uuid,
  360. #{item.biznisNo},
  361. #{item.flgLock},
  362. #{item.makeStaff}::uuid,
  363. #{item.makeTime},
  364. #{item.cpId},
  365. #{item.opAppCode},
  366. </trim>
  367. )
  368. </foreach>
  369. </insert>
  370. <!-- 查询表t_mac_rec_pay,(条件查询+分页)列表 -->
  371. <select id="selectPaymentByCond" resultMap="BaseResultMapResponse">
  372. select t.rp_id,
  373. t.rp_no,
  374. t.rp_type,
  375. sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "rpTypeName",
  376. t.object_id,
  377. tmp.sup_code as "supCode",
  378. tmp.sup_name as "supName",
  379. t.org_id,
  380. tmo.org_name as "orgName",
  381. t.staff_id,
  382. tms.staff_name as "staffName",
  383. t.sum_amt_rec,
  384. t.sum_amt_pay,
  385. t.sum_amt_receivable_handle,
  386. t.sum_amt_payable_handle,
  387. t.sum_waive_amt,
  388. t.acc_date,
  389. t.remarks,
  390. t.annex_paths,
  391. t.biznis_type,
  392. t.biznis_id,
  393. t.biznis_no,
  394. t.flg_lock,
  395. t.make_staff,
  396. makestaff.staff_name as "makeStaffName",
  397. t.make_time,
  398. t.flg_valid,
  399. t.cp_id,
  400. tma.payable_residue,
  401. tma.payment_residue
  402. from dkic_b.t_mac_rec_pay as t
  403. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.object_id
  404. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.rp_type
  405. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  406. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  407. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  408. LEFT JOIN dkic_b.t_mac_account tma on tma.object_id = t.object_id and tma.object_type in ('对象类型-供应商')
  409. where t.rp_type in ('收付款类型-付款', '收付款类型-退付款')
  410. <include refid="Condition"/>
  411. <if test="searchText !=null and searchText != ''">
  412. AND (
  413. t.rp_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  414. or tmo.org_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  415. or tmp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  416. or tms.staff_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  417. )
  418. </if>
  419. order by t.op_create_time desc
  420. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  421. limit #{end} offset #{start}
  422. </if>
  423. </select>
  424. <!-- 查询表t_mac_rec_pay,(条件查询)个数 -->
  425. <select id="countPaymentByCond" resultType="Long">
  426. SELECT count(1)
  427. from dkic_b.t_mac_rec_pay as t
  428. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.object_id
  429. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.rp_type
  430. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  431. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  432. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  433. where t.rp_type in ('收付款类型-付款', '收付款类型-退付款')
  434. <include refid="Condition"/>
  435. <if test="searchText !=null and searchText != ''">
  436. AND (
  437. t.rp_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  438. or tmo.org_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  439. or tmp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  440. or tms.staff_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  441. )
  442. </if>
  443. </select>
  444. </mapper>