RecPayMapper.xml 19 KB

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