RecPayMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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 t.rp_type = tdk1.kind_code
  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. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  205. limit #{end} offset #{start}
  206. </if>
  207. </select>
  208. <!-- 查询表t_mac_rec_pay,(条件查询)个数 -->
  209. <select id="countByCond" resultType="Long">
  210. SELECT
  211. count(1)
  212. FROM dkic_b.t_mac_rec_pay as t
  213. LEFT JOIN dkic_b.t_mst_customer tmc
  214. ON tmc.cus_id = t.object_id and t.rp_type = '收付款类型-收款'
  215. <include refid="Condition"/>
  216. </select>
  217. <!-- 根据主键查询表t_mac_rec_pay的一行数据 -->
  218. <select id="selectById" resultMap="BaseResultMap">
  219. SELECT
  220. <include refid="Base_Column_List"/>
  221. FROM t_mac_rec_pay
  222. WHERE rp_id = #{rpId}::uuid
  223. </select>
  224. <!-- 根据主键锁定表t_mac_rec_pay的一行数据 -->
  225. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  226. SELECT
  227. <include refid="Base_Column_List"/>
  228. FROM t_mac_rec_pay
  229. WHERE rp_id = #{id}::uuid
  230. for update
  231. </select>
  232. <!-- 根据主键锁定表t_mac_rec_pay的多行数据 -->
  233. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  234. SELECT
  235. <include refid="Base_Column_List"/>
  236. FROM t_mac_rec_pay
  237. <include refid="idsForeach"/>
  238. for update
  239. </select>
  240. <insert id="insertBatch">
  241. insert into t_mac_rec_pay
  242. (
  243. <trim suffixOverrides=",">
  244. rp_no,
  245. rp_type,
  246. object_id,
  247. org_id,
  248. staff_id,
  249. sum_amt_rec,
  250. sum_amt_pay,
  251. sum_amt_receivable_handle,
  252. sum_amt_payable_handle,
  253. sum_waive_amt,
  254. acc_date,
  255. remarks,
  256. annex_paths,
  257. biznis_type,
  258. biznis_id,
  259. biznis_no,
  260. flg_lock,
  261. make_staff,
  262. make_time,
  263. cp_id,
  264. op_app_code,
  265. </trim>
  266. )
  267. values
  268. <foreach collection="list" index="index" item="item" separator=",">
  269. (
  270. <trim suffixOverrides=",">
  271. #{item.rpNo},
  272. #{item.rpType},
  273. #{item.objectId}::uuid,
  274. #{item.orgId}::uuid,
  275. #{item.staffId}::uuid,
  276. #{item.sumAmtRec},
  277. #{item.sumAmtPay},
  278. #{item.sumAmtReceivableHandle},
  279. #{item.sumAmtPayableHandle},
  280. #{item.sumWaiveAmt},
  281. #{item.accDate},
  282. #{item.remarks},
  283. #{item.annexPaths},
  284. #{item.biznisType},
  285. #{item.biznisId}::uuid,
  286. #{item.biznisNo},
  287. #{item.flgLock},
  288. #{item.makeStaff}::uuid,
  289. #{item.makeTime},
  290. #{item.cpId},
  291. #{item.opAppCode},
  292. </trim>
  293. )
  294. </foreach>
  295. </insert>
  296. </mapper>