LoanState.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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
  7. , FN_STORE_NM(A.brand_id,A.store_id) AS store_nm
  8. , A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm
  9. , A.acct_cd, A.acct_no
  10. , A.loan_dvsn, FN_CODE_NM('LOAN_DVSN', A.loan_dvsn) AS loan_dvsn_nm
  11. , A.use_yn, FN_CODE_NM('USE_YN',A.use_yn) AS use_yn_nm
  12. , A.acct_bal -- 입금금액(잔액)
  13. , A.credt_limit_amt
  14. , A.chrge_limit_amt
  15. , A.credt_limit_use_yn
  16. , A.use_amt_total -- 시용한금액
  17. , A.tmp_rcv_acct_total
  18. , CASE WHEN A.loan_dvsn = 'LD01' THEN A.chrge_limit_amt
  19. WHEN A.loan_dvsn = 'LD02' THEN A.credt_limit_amt END AS limit_amt -- 한도금액
  20. , CASE WHEN A.loan_dvsn = 'LD01' THEN A.acct_bal + A.chrge_limit_amt - A.use_amt_total
  21. WHEN A.loan_dvsn = 'LD02' THEN A.acct_bal + A.credt_limit_amt - A.use_amt_total END AS posb_limit_amt -- 사용가능금액
  22. , DATE_FORMAT(A.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, A.sys_chg_id
  23. , FN_USER_NM(A.sys_chg_id) AS sys_chg_nm
  24. FROM loan_mgnt_base_info A
  25. WHERE 1 = 1
  26. <if test="sBrandId != null and sBrandId != ''">
  27. AND A.brand_id = #{sBrandId}
  28. </if>
  29. <if test="sStoreId != null and sStoreId != ''">
  30. AND A.store_id = #{sStoreId}
  31. </if>
  32. <if test="sLoanDvsn != null and sLoanDvsn != ''">
  33. AND A.loan_dvsn = #{sLoanDvsn}
  34. </if>
  35. <if test="sUseYn != null and sUseYn != ''">
  36. AND A.use_yn = #{sUseYn}
  37. </if>
  38. <choose>
  39. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  40. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  41. <if test="gridRequest.sord == 'asc'.toString()">
  42. ORDER BY A.sys_chg_dttm ASC
  43. </if>
  44. <if test="gridRequest.sord == 'desc'.toString()">
  45. ORDER BY A.sys_chg_dttm DESC
  46. </if>
  47. </if>
  48. </when>
  49. <otherwise>
  50. ORDER BY A.sys_chg_dttm ASC
  51. </otherwise>
  52. </choose>
  53. <if test="gridRequest.pagingYn == true">
  54. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  55. </if>
  56. </select>
  57. <select id="selectLoanStateGridCnt" resultType="int">
  58. /* LoanStateMapper.selectLoanStateGridCnt */
  59. SELECT COUNT(*)
  60. FROM loan_mgnt_base_info A
  61. WHERE 1 = 1
  62. <if test="sBrandId != null and sBrandId != ''">
  63. AND A.brand_id = #{sBrandId}
  64. </if>
  65. <if test="sStoreId != null and sStoreId != ''">
  66. AND A.store_id = #{sStoreId}
  67. </if>
  68. <if test="sLoanDvsn != null and sLoanDvsn != ''">
  69. AND A.loan_dvsn = #{sLoanDvsn}
  70. </if>
  71. <if test="sUseYn != null and sUseYn != ''">
  72. AND A.use_yn = #{sUseYn}
  73. </if>
  74. </select>
  75. <select id="selectLoanMgntBaseInfo" resultType="com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity">
  76. /* LoanStateMapper.selectLoanMgntBaseInfo */
  77. SELECT A.loan_mgnt_unq_no,
  78. A.store_id, FN_STORE_NM(A.brand_id, A.store_id) AS store_nm,
  79. A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
  80. A.acct_cd, A.acct_no, A.acct_bal, A.loan_dvsn, FN_CODE_NM('LOAN_DVSN', A.loan_dvsn) AS loan_dvsn_nm,
  81. A.credt_limit_amt, A.chrge_limit_amt, A.credt_limit_use_yn, A.use_amt_total, A.tmp_rcv_acct_total,
  82. A.use_yn, FN_CODE_NM('USE_YN', A.use_yn) AS use_yn_nm, A.loan_desc,
  83. DATE_FORMAT(A.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, A.sys_reg_id,
  84. 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
  85. FROM loan_mgnt_base_info A
  86. WHERE A.loan_mgnt_unq_no = #{loanMgntUnqNo}
  87. </select>
  88. <select id="selectLoanHistGridList" resultType="com.oqpo.api.entity.loanmng.LoanMgntDtlHstEntity">
  89. /* LoanStateMapper.selectLoanHistGridList */
  90. SELECT A.loan_mgnt_unq_no,
  91. 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,
  92. DATE_FORMAT(CONCAT(A.loan_reg_dt, A.loan_reg_tm), '%Y.%m.%d %H:%i:%s') AS loan_reg_dtm,
  93. A.dpst_pay_dvsn, FN_CODE_NM('DPST_PAY_DVSN', A.dpst_pay_dvsn) AS dpst_pay_dvsn_nm,
  94. A.trsc_amt,
  95. CASE WHEN A.dpst_pay_dvsn = 'D' THEN A.trsc_amt END AS dpst_amt,
  96. CASE WHEN A.dpst_pay_dvsn = 'P' THEN A.trsc_amt END AS paym_amt,
  97. A.trsc_bf_bal, A.trsc_af_bal, A.media_dvsn, FN_CODE_NM('MEDIA_DVSN', A.media_dvsn) AS media_dvsn_nm,
  98. 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
  99. FROM loan_mgnt_dtl_hst A
  100. WHERE A.loan_mgnt_unq_no = #{sLoanMgntUnqNo}
  101. <if test="sDpstPayDvsn != null and sDpstPayDvsn != ''">
  102. AND A.dpst_pay_dvsn = #{sDpstPayDvsn}
  103. </if>
  104. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != '' ">
  105. AND A.loan_reg_dt BETWEEN #{fromDt} AND #{toDt}
  106. </if>
  107. <choose>
  108. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  109. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  110. <if test="gridRequest.sord == 'asc'.toString()">
  111. ORDER BY A.loan_reg_dt ASC, A.loan_reg_tm ASC
  112. </if>
  113. <if test="gridRequest.sord == 'desc'.toString()">
  114. ORDER BY A.loan_reg_dt DESC, A.loan_reg_tm DESC
  115. </if>
  116. </if>
  117. </when>
  118. <otherwise>
  119. ORDER BY A.loan_reg_dt DESC, A.loan_reg_tm DESC
  120. </otherwise>
  121. </choose>
  122. <if test="gridRequest.pagingYn == true">
  123. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  124. </if>
  125. </select>
  126. <select id="selectLoanHistGridCnt" resultType="int">
  127. /* LoanStateMapper.selectLoanHistGridCnt */
  128. SELECT COUNT(*)
  129. FROM loan_mgnt_dtl_hst A
  130. WHERE A.loan_mgnt_unq_no = #{sLoanMgntUnqNo}
  131. <if test="sDpstPayDvsn != null and sDpstPayDvsn != ''">
  132. AND A.dpst_pay_dvsn = #{sDpstPayDvsn}
  133. </if>
  134. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != '' ">
  135. AND A.loan_reg_dt BETWEEN #{fromDt} AND #{toDt}
  136. </if>
  137. </select>
  138. <select id="selectLoanJobDataInfo" resultType="com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity">
  139. select loan_mgnt_unq_no, store_id, loan_dvsn, fn_code_nm('LOAN_DVSN', loan_dvsn) AS loan_dvsn_nm
  140. , nvl(case when loan_dvsn = 'LD01' then (acct_bal + tmp_rcv_acct_total - use_amt_total)
  141. when loan_dvsn = 'LD02' then (CREDT_LIMIT_AMT + acct_bal + tmp_rcv_acct_total - use_amt_total)
  142. else 0 end,0) as ord_use_amt
  143. from loan_mgnt_base_info
  144. where store_id = #{storeId}
  145. and use_yn = 'Y'
  146. </select>
  147. <update id="updateloanPchReqUseAmt">
  148. update loan_mgnt_base_info
  149. set use_amt_total = use_amt_total + #{ordPchReqAmt}
  150. where loan_mgnt_unq_no = #{loanMgntUnqNo}
  151. and store_id = #{storeId}
  152. </update>
  153. <update id="updateloanMinusPchReqUseAmt">
  154. update loan_mgnt_base_info
  155. set use_amt_total = use_amt_total - #{ordPchReqAmt}
  156. where loan_mgnt_unq_no = #{loanMgntUnqNo}
  157. and store_id = #{storeId}
  158. </update>
  159. <update id="updateloanMinusInstProc">
  160. update /* updateloanMinusInstProc */ loan_mgnt_base_info
  161. set use_amt_total = use_amt_total - #{useAmtTotal}
  162. where loan_mgnt_unq_no = #{loanMgntUnqNo}
  163. and store_id = #{storeId}
  164. </update>
  165. <update id="updateListLoanMinusProc" >
  166. /* updateListLoanMinusProc */
  167. <foreach collection="gridUpdateData" item="item" separator=";">
  168. update /* updateloanMinusInstProc */ loan_mgnt_base_info
  169. set use_amt_total = use_amt_total - #{item.useAmtTotal}
  170. , sys_chg_dttm = NOW()
  171. , sys_chg_id = #{userId}
  172. where loan_mgnt_unq_no = #{item.loanMgntUnqNo}
  173. and store_id = #{item.storeId}
  174. </foreach>
  175. </update>
  176. <update id="updateloanRtnacctBalAmt">
  177. update /* updateloanRtnacctBalAmt */ loan_mgnt_base_info
  178. set sys_chg_dttm = now()
  179. ,sys_chg_id = #{userId}
  180. ,acct_bal = acct_bal + #{entity.acctBal}
  181. where loan_mgnt_unq_no = #{entity.loanMgntUnqNo}
  182. and store_id = #{entity.storeId}
  183. </update>
  184. <select id="selectLoanRtnDataInfo" resultType="com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity">
  185. select loan_mgnt_unq_no, store_id, loan_dvsn, acct_bal
  186. from loan_mgnt_base_info
  187. where store_id = #{storeId}
  188. and use_yn = 'Y'
  189. </select>
  190. </mapper>