RecPayMapper.xml 17 KB

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