RecPayMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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, remarks, annex_paths, biznis_type, biznis_id, biznis_no, flg_lock, make_staff, make_time, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
  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. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  34. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  35. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  36. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  37. <result column="op_app_code" property="opAppCode"/>
  38. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  39. <result column="op_db_user" property="opDbUser"/>
  40. </resultMap>
  41. <!-- Response查询映射结果 -->
  42. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mac.RecPayResponse">
  43. <id column="rp_id" property="rpId"/>
  44. <result column="rp_no" property="rpNo"/>
  45. <result column="rp_type" property="rpType"/>
  46. <result column="object_id" property="objectId" typeHandler="UuidTypeHandler"/>
  47. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  48. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  49. <result column="sum_amt_rec" property="sumAmtRec"/>
  50. <result column="sum_amt_pay" property="sumAmtPay"/>
  51. <result column="sum_amt_receivable_handle" property="sumAmtReceivableHandle"/>
  52. <result column="sum_amt_payable_handle" property="sumAmtPayableHandle"/>
  53. <result column="sum_waive_amt" property="sumWaiveAmt"/>
  54. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  55. <result column="remarks" property="remarks"/>
  56. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  57. <result column="biznis_type" property="biznisType"/>
  58. <result column="biznis_id" property="biznisId" typeHandler="UuidTypeHandler"/>
  59. <result column="biznis_no" property="biznisNo"/>
  60. <result column="flg_lock" property="flgLock"/>
  61. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  62. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  63. <result column="flg_valid" property="flgValid"/>
  64. <result column="cp_id" property="cpId"/>
  65. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  66. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  67. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  68. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  69. <result column="op_app_code" property="opAppCode"/>
  70. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  71. <result column="op_db_user" property="opDbUser"/>
  72. </resultMap>
  73. <!-- 通用条件列 -->
  74. <sql id="Condition">
  75. <where>
  76. <if test="rpNo != null and rpNo != ''">
  77. AND t.rp_no LIKE concat('%',my_ex.likequery(#{rpNo}),'%')
  78. </if>
  79. <if test="rpType != null and rpType != ''">
  80. AND t.rp_type = #{rpType}
  81. </if>
  82. <if test="objectId != null and objectId != ''">
  83. AND t.object_id = #{objectId}
  84. </if>
  85. <if test="orgId != null and orgId != ''">
  86. AND t.org_id = #{orgId}
  87. </if>
  88. <if test="staffId != null and staffId != ''">
  89. AND t.staff_id = #{staffId}
  90. </if>
  91. <if test="sumAmtRec != null">
  92. AND t.sum_amt_rec = #{sumAmtRec}
  93. </if>
  94. <if test="sumAmtPay != null">
  95. AND t.sum_amt_pay = #{sumAmtPay}
  96. </if>
  97. <if test="sumAmtReceivableHandle != null">
  98. AND t.sum_amt_receivable_handle = #{sumAmtReceivableHandle}
  99. </if>
  100. <if test="sumAmtPayableHandle != null">
  101. AND t.sum_amt_payable_handle = #{sumAmtPayableHandle}
  102. </if>
  103. <if test="sumWaiveAmt != null">
  104. AND t.sum_waive_amt = #{sumWaiveAmt}
  105. </if>
  106. <if test="accDate != null">
  107. AND t.acc_date = #{accDate}
  108. </if>
  109. <if test="remarks != null and remarks != ''">
  110. AND t.remarks = #{remarks}
  111. </if>
  112. <if test="annexPaths != null and annexPaths != ''">
  113. AND t.annex_paths = #{annexPaths}
  114. </if>
  115. <if test="biznisType != null and biznisType != ''">
  116. AND t.biznis_type = #{biznisType}
  117. </if>
  118. <if test="biznisId != null and biznisId != ''">
  119. AND t.biznis_id = #{biznisId}
  120. </if>
  121. <if test="biznisNo != null and biznisNo != ''">
  122. AND t.biznis_no = #{biznisNo}
  123. </if>
  124. <if test="flgLock != null">
  125. AND t.flg_lock = #{flgLock}
  126. </if>
  127. <if test="makeStaff != null and makeStaff != ''">
  128. AND t.make_staff = #{makeStaff}
  129. </if>
  130. <if test="makeTime != null">
  131. AND t.make_time = #{makeTime}
  132. </if>
  133. <if test="cpId != null">
  134. AND t.cp_id = #{cpId}
  135. </if>
  136. <if test="cusPhone != null and cusPhone != ''">
  137. AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
  138. </if>
  139. <if test="cusName != null and cusName != ''">
  140. AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
  141. </if>
  142. <if test="orgIdList != null and orgIdList.size() > 0">
  143. AND t.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
  144. </if>
  145. <if test="staffIdList != null and staffIdList.size() > 0">
  146. AND t.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
  147. </if>
  148. <if test="makeTimeStart != null and makeTimeEnd != null">
  149. AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  150. AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  151. </if>
  152. <if test="flgValidList != null and flgValidList.size()>0">
  153. AND t.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  154. </if>
  155. </where>
  156. </sql>
  157. <sql id="idsForeach">
  158. <!-- 根据主键rpId批量操作 -->
  159. WHERE rp_id in
  160. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  161. #{item}
  162. </foreach>
  163. </sql>
  164. <!-- 查询表t_mac_rec_pay,(条件查询+分页)列表 -->
  165. <select id="selectByCond" resultMap="BaseResultMapResponse">
  166. select t.rp_id,
  167. t.rp_no,
  168. t.rp_type,
  169. sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "rpTypeName",
  170. t.object_id,
  171. tmc.cus_code as "cusCode",
  172. tmc.cus_name as "cusName",
  173. tmc.cus_phone as "cusPhone",
  174. tmc.address_full as "addressFull",
  175. t.org_id,
  176. tmo.org_name as "orgName",
  177. t.staff_id,
  178. tms.staff_name as "staffName",
  179. t.sum_amt_rec,
  180. t.sum_amt_pay,
  181. t.sum_amt_receivable_handle,
  182. t.sum_amt_payable_handle,
  183. t.sum_waive_amt,
  184. t.acc_date,
  185. t.remarks,
  186. t.annex_paths,
  187. t.biznis_type,
  188. t.biznis_id,
  189. t.biznis_no,
  190. t.flg_lock,
  191. t.make_staff,
  192. makestaff.staff_name as "makeStaffName",
  193. t.make_time,
  194. t.flg_valid,
  195. t.cp_id
  196. from dkic_b.t_mac_rec_pay as t
  197. left join dkic_b.t_mst_customer tmc
  198. on tmc.cus_id = t.object_id and t.rp_type in ('收付款类型-收款', '收付款类型-退收款')
  199. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.rp_type
  200. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  201. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  202. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  203. <include refid="Condition"/>
  204. order by t.op_create_time desc
  205. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  206. limit #{end} offset #{start}
  207. </if>
  208. </select>
  209. <!-- 查询表t_mac_rec_pay,(条件查询)个数 -->
  210. <select id="countByCond" resultType="Long">
  211. SELECT
  212. count(1)
  213. FROM dkic_b.t_mac_rec_pay as t
  214. LEFT JOIN dkic_b.t_mst_customer tmc
  215. ON tmc.cus_id = t.object_id and t.rp_type = '收付款类型-收款'
  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. tma.receipt,
  251. tma.receipt_lock as "receiptLock",
  252. tma.contract_assets as "contractAssets",
  253. tma.receivable,
  254. tma.receivable_handle as "receivableHandle",
  255. tma.receivable_waive as "receivableWaive",
  256. tma.receivable_residue as "receivableResidue",
  257. tma.receipt_residue as "receiptResidue"
  258. from dkic_b.t_mac_rec_pay as t
  259. left join dkic_b.t_mst_customer tmc
  260. on tmc.cus_id = t.object_id and t.rp_type in ('收付款类型-收款', '收付款类型-退收款')
  261. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.rp_type
  262. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  263. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  264. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  265. left join dkic_b.t_mac_account as tma on tma.object_id = t.object_id and tma.object_type = '对象类型-客户'
  266. WHERE t.rp_id = #{id}::uuid
  267. </select>
  268. <!-- 根据主键锁定表t_mac_rec_pay的一行数据 -->
  269. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  270. SELECT
  271. <include refid="Base_Column_List"/>
  272. FROM dkic_b.t_mac_rec_pay
  273. WHERE rp_id = #{id}::uuid
  274. for update
  275. </select>
  276. <!-- 根据主键锁定表t_mac_rec_pay的多行数据 -->
  277. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  278. SELECT
  279. <include refid="Base_Column_List"/>
  280. FROM dkic_b.t_mac_rec_pay
  281. <include refid="idsForeach"/>
  282. for update
  283. </select>
  284. <insert id="insertBatch">
  285. insert into dkic_b.t_mac_rec_pay
  286. (
  287. <trim suffixOverrides=",">
  288. rp_no,
  289. rp_type,
  290. object_id,
  291. org_id,
  292. staff_id,
  293. sum_amt_rec,
  294. sum_amt_pay,
  295. sum_amt_receivable_handle,
  296. sum_amt_payable_handle,
  297. sum_waive_amt,
  298. acc_date,
  299. remarks,
  300. annex_paths,
  301. biznis_type,
  302. biznis_id,
  303. biznis_no,
  304. flg_lock,
  305. make_staff,
  306. make_time,
  307. cp_id,
  308. op_app_code,
  309. </trim>
  310. )
  311. values
  312. <foreach collection="list" index="index" item="item" separator=",">
  313. (
  314. <trim suffixOverrides=",">
  315. #{item.rpNo},
  316. #{item.rpType},
  317. #{item.objectId}::uuid,
  318. #{item.orgId}::uuid,
  319. #{item.staffId}::uuid,
  320. #{item.sumAmtRec},
  321. #{item.sumAmtPay},
  322. #{item.sumAmtReceivableHandle},
  323. #{item.sumAmtPayableHandle},
  324. #{item.sumWaiveAmt},
  325. #{item.accDate},
  326. #{item.remarks},
  327. #{item.annexPaths},
  328. #{item.biznisType},
  329. #{item.biznisId}::uuid,
  330. #{item.biznisNo},
  331. #{item.flgLock},
  332. #{item.makeStaff}::uuid,
  333. #{item.makeTime},
  334. #{item.cpId},
  335. #{item.opAppCode},
  336. </trim>
  337. )
  338. </foreach>
  339. </insert>
  340. </mapper>