RecPayMapper.xml 16 KB

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