LoanState.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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.oqpo.api.mapper.loanmng.LoanStateMapper">
  4. <select id="selectLoanStateGridList" resultType="com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity">
  5. /* LoanStateMapper.selectLoanStateGridList */
  6. SELECT A.loan_mgnt_unq_no, A.store_id, FN_STORE_NM(A.brand_id, A.store_id) AS store_nm,
  7. A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm, A.acct_cd, A.acct_no, A.acct_bal,
  8. A.loan_dvsn, FN_CODE_NM('LOAN_DVSN', A.loan_dvsn) AS loan_dvsn_nm, A.credt_limit_amt,
  9. A.chrge_limit_amt, A.credt_limit_use_yn, A.use_amt_total, A.tmp_rcv_acct_total,
  10. A.use_yn, FN_CODE_NM('USE_YN', A.use_yn) AS use_yn_nm,
  11. CASE WHEN A.loan_dvsn = 'LD01' THEN A.chrge_limit_amt WHEN A.loan_dvsn = 'LD02' THEN A.credt_limit_amt END AS limit_amt,
  12. CASE
  13. WHEN A.loan_dvsn = 'LD01' THEN A.chrge_limit_amt - A.use_amt_total
  14. WHEN A.loan_dvsn = 'LD02' THEN A.credt_limit_amt - A.use_amt_total
  15. END AS posb_limit_amt,
  16. DATE_FORMAT(A.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, A.sys_chg_id, FN_USER_NM(A.sys_chg_id) AS sys_chg_nm
  17. FROM loan_mgnt_base_info A
  18. WHERE 1 = 1
  19. <if test="sBrandId != null and sBrandId != ''">
  20. AND A.brand_id = #{sBrandId}
  21. </if>
  22. <if test="sStoreId != null and sStoreId != ''">
  23. AND A.store_id = #{sStoreId}
  24. </if>
  25. <if test="sLoanDvsn != null and sLoanDvsn != ''">
  26. AND A.loan_dvsn = #{sLoanDvsn}
  27. </if>
  28. <if test="sUseYn != null and sUseYn != ''">
  29. AND A.use_yn = #{sUseYn}
  30. </if>
  31. <choose>
  32. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  33. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  34. <if test="gridRequest.sord == 'asc'.toString()">
  35. ORDER BY A.loan_mgnt_unq_no ASC
  36. </if>
  37. <if test="gridRequest.sord == 'desc'.toString()">
  38. ORDER BY A.loan_mgnt_unq_no DESC
  39. </if>
  40. </if>
  41. </when>
  42. <otherwise>
  43. ORDER BY A.loan_mgnt_unq_no ASC
  44. </otherwise>
  45. </choose>
  46. <if test="gridRequest.pagingYn == true">
  47. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  48. </if>
  49. </select>
  50. <select id="selectLoanStateGridCnt" resultType="int">
  51. /* LoanStateMapper.selectLoanStateGridCnt */
  52. SELECT COUNT(*)
  53. FROM loan_mgnt_base_info A
  54. WHERE 1 = 1
  55. <if test="sBrandId != null and sBrandId != ''">
  56. AND A.brand_id = #{sBrandId}
  57. </if>
  58. <if test="sStoreId != null and sStoreId != ''">
  59. AND A.store_id = #{sStoreId}
  60. </if>
  61. <if test="sLoanDvsn != null and sLoanDvsn != ''">
  62. AND A.loan_dvsn = #{sLoanDvsn}
  63. </if>
  64. <if test="sUseYn != null and sUseYn != ''">
  65. AND A.use_yn = #{sUseYn}
  66. </if>
  67. </select>
  68. <select id="selectLoanMgntBaseInfo" resultType="com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity">
  69. /* LoanStateMapper.selectLoanMgntBaseInfo */
  70. SELECT A.loan_mgnt_unq_no,
  71. A.store_id, FN_STORE_NM(A.brand_id, A.store_id) AS store_nm,
  72. A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
  73. A.acct_cd, A.acct_no, A.acct_bal, A.loan_dvsn, FN_CODE_NM('LOAN_DVSN', A.loan_dvsn) AS loan_dvsn_nm,
  74. A.credt_limit_amt, A.chrge_limit_amt, A.credt_limit_use_yn, A.use_amt_total, A.tmp_rcv_acct_total,
  75. A.use_yn, FN_CODE_NM('USE_YN', A.use_yn) AS use_yn_nm, A.loan_desc,
  76. DATE_FORMAT(A.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, A.sys_reg_id,
  77. DATE_FORMAT(A.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, A.sys_chg_id, FN_USER_NM(A.sys_chg_id) AS sys_chg_nm
  78. FROM loan_mgnt_base_info A
  79. WHERE A.loan_mgnt_unq_no = #{loanMgntUnqNo}
  80. </select>
  81. <select id="selectLoanHistGridList" resultType="com.oqpo.api.entity.loanmng.LoanMgntDtlHstEntity">
  82. /* LoanStateMapper.selectLoanHistGridList */
  83. SELECT A.loan_mgnt_unq_no,
  84. DATE_FORMAT(A.loan_reg_dt, '%Y.%m.%d') AS loan_reg_dt, TIME_FORMAT(A.loan_reg_tm, '%H:%i:%s') AS loan_reg_tm,
  85. A.dpst_pay_dvsn, FN_CODE_NM('DPST_PAY_DVSN', A.dpst_pay_dvsn) AS dpst_pay_dvsn_nm,
  86. A.trsc_amt,
  87. CASE WHEN A.dpst_pay_dvsn = 'D' THEN A.trsc_amt END AS dpst_amt,
  88. CASE WHEN A.dpst_pay_dvsn = 'P' THEN A.trsc_amt END AS paym_amt,
  89. A.trsc_bf_bal, A.trsc_af_bal, A.media_dvsn, FN_CODE_NM('MEDIA_DVSN', A.media_dvsn) AS media_dvsn_nm,
  90. A.rcv_acct_no, A.paym_acct_no, A.dpst_dt, A.dpst_nm, A.dpst_bnk_cd, A.dspt_mgnt_no, A.loan_desc
  91. FROM loan_mgnt_dtl_hst A
  92. WHERE A.loan_mgnt_unq_no = #{sLoanMgntUnqNo}
  93. <if test="sDpstPayDvsn != null and sDpstPayDvsn != ''">
  94. AND A.dpst_pay_dvsn = #{sDpstPayDvsn}
  95. </if>
  96. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != '' ">
  97. AND A.loan_reg_dt BETWEEN #{fromDt} AND #{toDt}
  98. </if>
  99. <choose>
  100. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  101. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  102. <if test="gridRequest.sord == 'asc'.toString()">
  103. ORDER BY A.loan_reg_dt ASC, A.loan_reg_tm ASC
  104. </if>
  105. <if test="gridRequest.sord == 'desc'.toString()">
  106. ORDER BY A.loan_reg_dt DESC, A.loan_reg_tm DESC
  107. </if>
  108. </if>
  109. </when>
  110. <otherwise>
  111. ORDER BY A.loan_reg_dt ASC, A.loan_reg_tm ASC
  112. </otherwise>
  113. </choose>
  114. <if test="gridRequest.pagingYn == true">
  115. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  116. </if>
  117. </select>
  118. <select id="selectLoanHistGridCnt" resultType="int">
  119. /* LoanStateMapper.selectLoanHistGridCnt */
  120. SELECT COUNT(*)
  121. FROM loan_mgnt_dtl_hst A
  122. WHERE A.loan_mgnt_unq_no = #{sLoanMgntUnqNo}
  123. <if test="sDpstPayDvsn != null and sDpstPayDvsn != ''">
  124. AND A.dpst_pay_dvsn = #{sDpstPayDvsn}
  125. </if>
  126. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != '' ">
  127. AND A.loan_reg_dt BETWEEN #{fromDt} AND #{toDt}
  128. </if>
  129. </select>
  130. <select id="selectLoanJobDataInfo" resultType="com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity">
  131. select loan_mgnt_unq_no, store_id, loan_dvsn, fn_code_nm('LOAN_DVSN', loan_dvsn) AS loan_dvsn_nm
  132. , nvl(case when loan_dvsn = 'LD01' then (acct_bal + tmp_rcv_acct_total - use_amt_total)
  133. when loan_dvsn = 'LD02' then (CREDT_LIMIT_AMT + acct_bal + tmp_rcv_acct_total - use_amt_total)
  134. else 0 end,0) as ord_use_amt
  135. from loan_mgnt_base_info
  136. where store_id = #{storeId}
  137. and use_yn = 'Y'
  138. </select>
  139. <update id="updateloanPchReqUseAmt">
  140. update loan_mgnt_base_info
  141. set use_amt_total = use_amt_total + #{ordPchReqAmt}
  142. where loan_mgnt_unq_no = #{loanMgntUnqNo}
  143. and store_id = #{storeId}
  144. </update>
  145. <update id="updateloanMinusPchReqUseAmt">
  146. update loan_mgnt_base_info
  147. set use_amt_total = use_amt_total - #{ordPchReqAmt}
  148. where loan_mgnt_unq_no = #{loanMgntUnqNo}
  149. and store_id = #{storeId}
  150. </update>
  151. </mapper>