소스 검색

Merge branch 'master' of http://106.246.249.162:13000/orderqueen/oqpo-api

dwkim 2 년 전
부모
커밋
cc112e5c67

BIN
lib/easypay_java_client18(utf-8).jar


+ 9 - 0
pom.xml

@@ -13,6 +13,15 @@
13 13
         <maven.compiler.source>1.8</maven.compiler.source>
14 14
     </properties>
15 15
   	<dependencies>
16
+
17
+		<dependency>
18
+			<groupId>com.kicc</groupId>
19
+			<artifactId>easypay-client</artifactId>
20
+			<version>1.0</version>
21
+			<scope>system</scope>
22
+			<systemPath>${basedir}/lib/easypay_java_client18(utf-8).jar</systemPath>
23
+		</dependency>
24
+
16 25
   		<dependency>
17 26
 	   		<groupId>org.springframework.boot</groupId>
18 27
 	   		<artifactId>spring-boot-starter-web</artifactId>

+ 387 - 0
src/main/java/com/oqpo/api/service/loanmng/EasypayPaymentService.java

@@ -0,0 +1,387 @@
1
+package com.oqpo.api.service.loanmng;
2
+
3
+
4
+import com.kicc.EasyPayClient;
5
+import com.oqpo.api.exception.GlobalException;
6
+import com.oqpo.api.mapper.loanmng.UnpaidMngMapper;
7
+import com.oqpo.api.service.CommonService;
8
+import com.oqpo.api.util.StringUtil;
9
+import com.oqpo.api.web.dto.request.loanmng.EasypayPaymentRequest;
10
+import com.oqpo.api.web.dto.response.loanmng.EasypayPaymentResponse;
11
+import lombok.extern.slf4j.Slf4j;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.beans.factory.annotation.Value;
14
+import org.springframework.stereotype.Service;
15
+import org.springframework.transaction.annotation.Transactional;
16
+
17
+import javax.servlet.http.HttpServletRequest;
18
+
19
+@Service
20
+@Slf4j
21
+public class EasypayPaymentService extends CommonService {
22
+
23
+    @Autowired
24
+    private UnpaidMngMapper unpaidMngMapper;
25
+
26
+    @Value("${kicc.gateway}")
27
+    private String kiccGatewayUrl;
28
+    @Value("${kicc.cert_dir}")
29
+    private String kiccCertFile;
30
+    @Value("${kicc.log_dir}")
31
+    private String kiccLogDir;
32
+
33
+    /* 결제 요청 */
34
+    @Transactional
35
+    public EasypayPaymentResponse requestPayment(String userId, HttpServletRequest request, EasypayPaymentRequest easypayPaymentRequest) throws Exception {
36
+        try {
37
+            /* -------------------------------------------------------------------------- */
38
+            /* ::: 처리구분 설정                                                          */
39
+            /* -------------------------------------------------------------------------- */
40
+            final String TRAN_CD_NOR_PAYMENT = "00101000"; // 승인(일반, 에스크로)
41
+            final String TRAN_CD_NOR_MGR = "00201000"; // 변경(일반, 에스크로)
42
+            @SuppressWarnings("unused") final String TRAN_CD_NOR_MALL = "00201030"; // 셀러(다중정산)
43
+
44
+            /* -------------------------------------------------------------------------- */
45
+            /* ::: 지불정보 설정                                                          */
46
+            /* -------------------------------------------------------------------------- */
47
+            final String GW_URL = (String) kiccGatewayUrl; // GatewayURL
48
+            final String GW_PORT = "80"; // 포트번호(변경불가)
49
+
50
+            /* -------------------------------------------------------------------------- */
51
+            /* ::: 지불 데이터 셋업 (업체에 맞게 수정)                                    */
52
+            /* -------------------------------------------------------------------------- */
53
+            /* ※ 주의 ※                                                                 */
54
+            /* cert_file 변수 설정                                                        */
55
+            /* - pg_cert.pem 파일이 있는 디렉토리의  절대 경로 설정                       */
56
+            /* log_dir 변수 설정                                                          */
57
+            /* - log 디렉토리 설정                                                        */
58
+            /* log_level 변수 설정                                                        */
59
+            /* - log 레벨 설정 (1 to 99(높을수록 상세))                                   */
60
+            /* -------------------------------------------------------------------------- */
61
+            final String CERT_FILE = (String) kiccCertFile;
62
+            final String LOG_DIR = (String) kiccLogDir;
63
+            final int LOG_LEVEL = 1;
64
+
65
+            /* -------------------------------------------------------------------------- */
66
+            /* ::: 승인요청 정보 설정                                                     */
67
+            /* -------------------------------------------------------------------------- */
68
+            // [헤더]
69
+            String tr_cd = ""; // [필수]결제창요청구분
70
+            String trace_no = ""; // [필수]추적번호
71
+            String order_no = ""; // [필수]가맹점주문번호
72
+            String mall_id = ""; // [필수]가맹점ID
73
+            // [공통]
74
+            String encrypt_data = ""; // [필수]암호화전문
75
+            String sessionkey = ""; // [필수]세션키
76
+
77
+            if (!StringUtil.isEmpty(easypayPaymentRequest.getSp_tr_cd())) {
78
+                // [헤더]
79
+                tr_cd = StringUtil.null2str(easypayPaymentRequest.getSp_tr_cd()); // [필수]결제창요청구분
80
+                trace_no = StringUtil.null2str(easypayPaymentRequest.getSp_trace_no()); // [필수]추적번호
81
+                order_no = StringUtil.null2str(easypayPaymentRequest.getSp_order_no()); // [필수]가맹점주문번호
82
+                mall_id = StringUtil.null2str(easypayPaymentRequest.getSp_mall_id()); // [필수]가맹점ID
83
+                // [공통]
84
+                encrypt_data = StringUtil.null2str(easypayPaymentRequest.getSp_encrypt_data()); // [필수]암호화전문
85
+                sessionkey = StringUtil.null2str(easypayPaymentRequest.getSp_sessionkey()); // [필수]세션키
86
+            } else {
87
+                // [헤더]
88
+                tr_cd = StringUtil.null2str(easypayPaymentRequest.getEP_tr_cd()); // [필수]결제창요청구분
89
+                trace_no = StringUtil.null2str(easypayPaymentRequest.getEP_trace_no()); // [필수]추적번호
90
+                order_no = StringUtil.null2str(easypayPaymentRequest.getEP_order_no()); // [필수]가맹점주문번호
91
+                mall_id = StringUtil.null2str(easypayPaymentRequest.getEP_mall_id()); // [필수]가맹점ID
92
+                // [공통]
93
+                encrypt_data = StringUtil.null2str(easypayPaymentRequest.getEP_encrypt_data()); // [필수]암호화전문
94
+                sessionkey = StringUtil.null2str(easypayPaymentRequest.getEP_sessionkey()); // [필수]세션키
95
+            }
96
+
97
+            /* -------------------------------------------------------------------------- */
98
+            /* ::: 변경관리 정보 설정                                                     */
99
+            /* -------------------------------------------------------------------------- */
100
+            String mgr_txtype = StringUtil.null2str(easypayPaymentRequest.getMgr_txtype()); // [필수]거래구분
101
+            String mgr_subtype = StringUtil.null2str(easypayPaymentRequest.getMgr_subtype()); // [선택]변경세부구분
102
+            String org_cno = StringUtil.null2str(easypayPaymentRequest.getOrg_cno()); // [필수]원거래고유번호
103
+            String mgr_amt = StringUtil.null2str(easypayPaymentRequest.getMgr_amt()); // [선택]금액
104
+            String mgr_rem_amt = StringUtil.null2str(easypayPaymentRequest.getMgr_rem_amt()); // [선택]부분취소잔액
105
+            String mgr_bank_cd = StringUtil.null2str(easypayPaymentRequest.getMgr_bank_cd()); // [선택]환불계좌은행코드
106
+            String mgr_account = StringUtil.null2str(easypayPaymentRequest.getMgr_account()); // [선택]환불계좌번호
107
+            String mgr_depositor = StringUtil.null2str(easypayPaymentRequest.getMgr_depositor()); // [선택]환불계좌예금주명
108
+
109
+            /* -------------------------------------------------------------------------- */
110
+            /* ::: 전문                                                                   */
111
+            /* -------------------------------------------------------------------------- */
112
+            // String mgr_data    = "";     // 변경정보
113
+            // String mall_data   = "";     // 요청전문
114
+
115
+            /* -------------------------------------------------------------------------- */
116
+            /* ::: 결제 결과                                                              */
117
+            /* -------------------------------------------------------------------------- */
118
+            String bDBProc = "";     //가맹점DB처리성공여부
119
+            String res_cd = "";     //응답코드
120
+            String res_msg = "";     //응답메시지
121
+            String r_cno = "";     //PG거래번호
122
+            String r_amount = "";     //총 결제금액
123
+            String r_order_no = "";     //주문번호
124
+            String r_auth_no = "";     //승인번호
125
+            String r_tran_date = "";     //승인일시
126
+            String r_escrow_yn = "";     //에스크로 사용유무
127
+            String r_complex_yn = "";     //복합결제 유무
128
+            String r_stat_cd = "";     //상태코드
129
+            String r_stat_msg = "";     //상태메시지
130
+            String r_pay_type = "";     //결제수단
131
+            String r_mall_id = "";     //가맹점 Mall ID
132
+            String r_card_no = "";     //카드번호
133
+            String r_issuer_cd = "";     //발급사코드
134
+            String r_issuer_nm = "";     //발급사명
135
+            String r_acquirer_cd = "";     //매입사코드
136
+            String r_acquirer_nm = "";     //매입사명
137
+            String r_install_period = "";     //할부개월
138
+            String r_noint = "";     //무이자여부
139
+            String r_part_cancel_yn = "";     //부분취소 가능여부
140
+            String r_card_gubun = "";     //신용카드 종류
141
+            String r_card_biz_gubun = "";     //신용카드 구분
142
+            String r_cpon_flag = "";     //쿠폰사용유무
143
+            String r_bank_cd = "";     //은행코드
144
+            String r_bank_nm = "";     //은행명
145
+            String r_account_no = "";     //계좌번호
146
+            String r_deposit_nm = "";     //입금자명
147
+            String r_expire_date = "";     //계좌사용만료일
148
+            String r_cash_res_cd = "";     //현금영수증 결과코드
149
+            String r_cash_res_msg = "";     //현금영수증 결과메세지
150
+            String r_cash_auth_no = "";     //현금영수증 승인번호
151
+            String r_cash_tran_date = "";     //현금영수증 승인일시
152
+            String r_cash_issue_type = "";     //현금영수증발행용도
153
+            String r_cash_auth_type = "";     //인증구분
154
+            String r_cash_auth_value = "";     //인증번호
155
+            String r_auth_id = "";     //PhoneID
156
+            String r_billid = "";     //인증번호
157
+            String r_mobile_no = "";     //휴대폰번호
158
+            String r_mob_ansim_yn = "";     //안심결제 사용유무
159
+            String r_ars_no = "";     //전화번호
160
+            String r_cp_cd = "";     //포인트사/쿠폰사
161
+            String r_cpon_auth_no = "";     //쿠폰승인번호
162
+            String r_cpon_tran_date = "";     //쿠폰승인일시
163
+            String r_cpon_no = "";     //쿠폰번호
164
+            String r_remain_cpon = "";     //쿠폰잔액
165
+            String r_used_cpon = "";     //쿠폰 사용금액
166
+            String r_rem_amt = "";     //잔액
167
+            String r_bk_pay_yn = "";     //장바구니 결제여부
168
+            String r_canc_acq_date = "";     //매입취소일시
169
+            String r_canc_date = "";     //취소일시
170
+            String r_refund_date = "";     //환불예정일시
171
+
172
+            /* -------------------------------------------------------------------------- */
173
+            /* ::: EasyPayClient 인스턴스 생성 [변경불가 !!].                             */
174
+            /* -------------------------------------------------------------------------- */
175
+            EasyPayClient easyPayClient = new EasyPayClient();
176
+            easyPayClient.easypay_setenv_init(GW_URL, GW_PORT, CERT_FILE, LOG_DIR, LOG_LEVEL);
177
+            easyPayClient.easypay_reqdata_init();
178
+
179
+            /* -------------------------------------------------------------------------- */
180
+            /* ::: 승인요청(플러그인 암호화 전문 설정)                                    */
181
+            /* -------------------------------------------------------------------------- */
182
+            if (TRAN_CD_NOR_PAYMENT.equals(tr_cd)) {
183
+
184
+                // 승인요청 전문 설정
185
+                easyPayClient.easypay_set_trace_no(trace_no);
186
+                easyPayClient.easypay_encdata_set(encrypt_data, sessionkey);
187
+            }
188
+            /* -------------------------------------------------------------------------- */
189
+            /* ::: 변경관리 요청                                                          */
190
+            /* -------------------------------------------------------------------------- */
191
+            else if (TRAN_CD_NOR_MGR.equals(tr_cd)) {
192
+
193
+                int easypay_mgr_data_item;
194
+                easypay_mgr_data_item = easyPayClient.easypay_item("mgr_data");
195
+
196
+                easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_txtype", mgr_txtype);          // [필수]거래구분
197
+                easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_subtype", mgr_subtype);          // [선택]변경세부구분
198
+                easyPayClient.easypay_deli_us(easypay_mgr_data_item, "org_cno", org_cno);          // [필수]원거래고유번호
199
+                easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_amt", mgr_amt);          // [선택]금액
200
+                easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_rem_amt", mgr_rem_amt);          // [선택]부분취소 잔액
201
+                easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_bank_cd", mgr_bank_cd);          // [선택]환불계좌 은행코드
202
+                easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_account", mgr_account);          // [선택]환불계좌 번호
203
+                easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_depositor", mgr_depositor);          // [선택]환불계좌 예금주명
204
+                easyPayClient.easypay_deli_us(easypay_mgr_data_item, "req_ip", request.getRemoteAddr());// [필수]요청자 IP
205
+            }
206
+            /* -------------------------------------------------------------------------- */
207
+            /* ::: 실행                                                                   */
208
+            /* -------------------------------------------------------------------------- */
209
+            if (tr_cd.length() > 0) {
210
+                easyPayClient.easypay_run(mall_id, tr_cd, order_no);
211
+
212
+                res_cd = easyPayClient.res_cd;
213
+                res_msg = easyPayClient.res_msg;
214
+            } else {
215
+                res_cd = "M114";
216
+                res_msg = "연동 오류|tr_cd값이 설정되지 않았습니다.";
217
+            }
218
+
219
+            /* -------------------------------------------------------------------------- */
220
+            /* ::: 결과 처리                                                              */
221
+            /* -------------------------------------------------------------------------- */
222
+
223
+            r_cno = easyPayClient.easypay_get_res("cno");     //PG거래번호
224
+            r_amount = easyPayClient.easypay_get_res("amount");     //총 결제금액
225
+            r_order_no = easyPayClient.easypay_get_res("order_no");     //주문번호
226
+            r_auth_no = easyPayClient.easypay_get_res("auth_no");     //승인번호
227
+            r_tran_date = easyPayClient.easypay_get_res("tran_date");     //승인일시
228
+            r_escrow_yn = easyPayClient.easypay_get_res("escrow_yn");     //에스크로 사용유무
229
+            r_complex_yn = easyPayClient.easypay_get_res("complex_yn");     //복합결제 유무
230
+            r_stat_cd = easyPayClient.easypay_get_res("stat_cd");     //상태코드
231
+            r_stat_msg = easyPayClient.easypay_get_res("stat_msg");     //상태메시지
232
+            r_pay_type = easyPayClient.easypay_get_res("pay_type");     //결제수단
233
+            r_mall_id = easyPayClient.easypay_get_res("mall_id");     //가맹점 Mall ID
234
+            r_card_no = easyPayClient.easypay_get_res("card_no");     //카드번호
235
+            r_issuer_cd = easyPayClient.easypay_get_res("issuer_cd");     //발급사코드
236
+            r_issuer_nm = easyPayClient.easypay_get_res("issuer_nm");     //발급사명
237
+            r_acquirer_cd = easyPayClient.easypay_get_res("acquirer_cd");     //매입사코드
238
+            r_acquirer_nm = easyPayClient.easypay_get_res("acquirer_nm");     //매입사명
239
+            r_install_period = easyPayClient.easypay_get_res("install_period");     //할부개월
240
+            r_noint = easyPayClient.easypay_get_res("noint");     //무이자여부
241
+            r_part_cancel_yn = easyPayClient.easypay_get_res("part_cancel_yn");     //부분취소 가능여부
242
+            r_card_gubun = easyPayClient.easypay_get_res("card_gubun");     //신용카드 종류
243
+            r_card_biz_gubun = easyPayClient.easypay_get_res("card_biz_gubun");     //신용카드 구분
244
+            r_cpon_flag = easyPayClient.easypay_get_res("cpon_flag");     //쿠폰사용유무
245
+            r_bank_cd = easyPayClient.easypay_get_res("bank_cd");     //은행코드
246
+            r_bank_nm = easyPayClient.easypay_get_res("bank_nm");     //은행명
247
+            r_account_no = easyPayClient.easypay_get_res("account_no");     //계좌번호
248
+            r_deposit_nm = easyPayClient.easypay_get_res("deposit_nm");     //입금자명
249
+            r_expire_date = easyPayClient.easypay_get_res("expire_date");     //계좌사용만료일
250
+            r_cash_res_cd = easyPayClient.easypay_get_res("cash_res_cd");     //현금영수증 결과코드
251
+            r_cash_res_msg = easyPayClient.easypay_get_res("cash_res_msg");     //현금영수증 결과메세지
252
+            r_cash_auth_no = easyPayClient.easypay_get_res("cash_auth_no");     //현금영수증 승인번호
253
+            r_cash_tran_date = easyPayClient.easypay_get_res("cash_tran_date");     //현금영수증 승인일시
254
+            r_cash_issue_type = easyPayClient.easypay_get_res("cash_issue_type");     //현금영수증발행용도
255
+            r_cash_auth_type = easyPayClient.easypay_get_res("cash_auth_type");     //인증구분
256
+            r_cash_auth_value = easyPayClient.easypay_get_res("cash_auth_value");     //인증번호
257
+            r_auth_id = easyPayClient.easypay_get_res("auth_id");     //PhoneID
258
+            r_billid = easyPayClient.easypay_get_res("billid");     //인증번호
259
+            r_mobile_no = easyPayClient.easypay_get_res("mobile_no");     //휴대폰번호
260
+            r_mob_ansim_yn = easyPayClient.easypay_get_res("mob_ansim_yn");     //안심결제 사용유무
261
+            r_ars_no = easyPayClient.easypay_get_res("ars_no");     //전화번호
262
+            r_cp_cd = easyPayClient.easypay_get_res("cp_cd");     //포인트사/쿠폰사
263
+            r_cpon_auth_no = easyPayClient.easypay_get_res("cpon_auth_no");     //쿠폰승인번호
264
+            r_cpon_tran_date = easyPayClient.easypay_get_res("cpon_tran_date");     //쿠폰승인일시
265
+            r_cpon_no = easyPayClient.easypay_get_res("cpon_no");     //쿠폰번호
266
+            r_remain_cpon = easyPayClient.easypay_get_res("remain_cpon");     //쿠폰잔액
267
+            r_used_cpon = easyPayClient.easypay_get_res("used_cpon");     //쿠폰 사용금액
268
+            r_rem_amt = easyPayClient.easypay_get_res("rem_amt");     //잔액
269
+            r_bk_pay_yn = easyPayClient.easypay_get_res("bk_pay_yn");     //장바구니 결제여부
270
+            r_canc_acq_date = easyPayClient.easypay_get_res("canc_acq_date");     //매입취소일시
271
+            r_canc_date = easyPayClient.easypay_get_res("canc_date");     //취소일시
272
+            r_refund_date = easyPayClient.easypay_get_res("refund_date");     //환불예정일시
273
+
274
+            /* -------------------------------------------------------------------------- */
275
+            /* ::: 가맹점 DB 처리                                                         */
276
+            /* -------------------------------------------------------------------------- */
277
+            /* 응답코드(res_cd)가 "0000" 이면 정상승인 입니다.                            */
278
+            /* r_amount가 주문DB의 금액과 다를 시 반드시 취소 요청을 하시기 바랍니다.     */
279
+            /* DB 처리 실패 시 취소 처리를 해주시기 바랍니다.                             */
280
+            /* -------------------------------------------------------------------------- */
281
+            log.info("[REQUEST_PAYMENT] res_cd : " + res_cd);
282
+            EasypayPaymentResponse easyResult = new EasypayPaymentResponse();
283
+            easyResult.setRes_cd(res_cd);
284
+            easyResult.setRes_msg(res_msg);
285
+            easyResult.setCno(r_cno);
286
+            easyResult.setAmount(r_amount);
287
+            easyResult.setOrder_no(r_order_no);
288
+            easyResult.setAuth_no(r_auth_no);
289
+            easyResult.setTran_date(r_tran_date);
290
+            easyResult.setEscrow_yn(r_escrow_yn);
291
+            easyResult.setComplex_yn(r_complex_yn);
292
+            easyResult.setStat_cd(r_stat_cd);
293
+            easyResult.setStat_msg(r_stat_msg);
294
+            easyResult.setPay_type(r_pay_type);
295
+            easyResult.setMall_id(r_mall_id);
296
+            easyResult.setCard_no(r_card_no);
297
+            easyResult.setIssuer_cd(r_issuer_cd);
298
+            easyResult.setIssuer_nm(r_issuer_nm);
299
+            easyResult.setAcquirer_cd(r_acquirer_cd);
300
+            easyResult.setAcquirer_nm(r_acquirer_nm);
301
+            easyResult.setInstall_period(r_install_period);
302
+            easyResult.setNoint(r_noint);
303
+            easyResult.setPart_cancel_yn(r_part_cancel_yn);
304
+            easyResult.setCard_gubun(r_card_gubun);
305
+            easyResult.setCard_biz_gubun(r_card_biz_gubun);
306
+            easyResult.setCpon_flag(r_cpon_flag);
307
+            easyResult.setBank_cd(r_bank_cd);
308
+            easyResult.setBank_nm(r_bank_nm);
309
+            easyResult.setAccount_no(r_account_no);
310
+            easyResult.setDeposit_nm(r_deposit_nm);
311
+            easyResult.setExpire_date(r_expire_date);
312
+            easyResult.setCash_res_cd(r_cash_res_cd);
313
+            easyResult.setCash_res_msg(r_cash_res_msg);
314
+            easyResult.setCash_auth_no(r_cash_auth_no);
315
+            easyResult.setCash_tran_date(r_cash_tran_date);
316
+            easyResult.setCash_issue_type(r_cash_issue_type);
317
+            easyResult.setCash_auth_type(r_cash_auth_type);
318
+            easyResult.setCash_auth_value(r_cash_auth_value);
319
+            easyResult.setAuth_id(r_auth_id);
320
+            easyResult.setBillid(r_billid);
321
+            easyResult.setMobile_no(r_mobile_no);
322
+            easyResult.setMob_ansim_yn(r_mob_ansim_yn);
323
+            easyResult.setArs_no(r_ars_no);
324
+            easyResult.setCp_cd(r_cp_cd);
325
+            easyResult.setCpon_auth_no(r_cpon_auth_no);
326
+            easyResult.setCpon_tran_date(r_cpon_tran_date);
327
+            easyResult.setCpon_no(r_cpon_no);
328
+            easyResult.setRemain_cpon(r_remain_cpon);
329
+            easyResult.setUsed_cpon(r_used_cpon);
330
+            easyResult.setRem_amt(r_rem_amt);
331
+            easyResult.setBk_pay_yn(r_bk_pay_yn);
332
+            easyResult.setCanc_acq_date(r_canc_acq_date);
333
+            easyResult.setCanc_date(r_canc_date);
334
+            easyResult.setRefund_date(r_refund_date);
335
+
336
+            if (res_cd.equals("0000")) {
337
+                bDBProc = "true"; // DB처리 성공 시 "true", 실패 시 "false"
338
+                try {
339
+                    // TbSaleHeaderModel saleHeader = (TbSaleHeaderModel) SessionUtil.getAttribute(SessionUtil.PAYMENT_CART);
340
+                    // saveEasypayResult(easyResult);
341
+                    // TODO 결과를 저장한다.
342
+                } catch (Exception e) {
343
+                    e.printStackTrace();
344
+                    bDBProc = "false";
345
+                }
346
+
347
+                if (bDBProc.equals("false")) {
348
+                    // 승인요청이 실패 시 아래 실행
349
+                    if (TRAN_CD_NOR_PAYMENT.equals(tr_cd)) {
350
+                        int easypay_mgr_data_item;
351
+
352
+                        easyPayClient.easypay_reqdata_init();
353
+
354
+                        tr_cd = TRAN_CD_NOR_MGR;
355
+                        easypay_mgr_data_item = easyPayClient.easypay_item("mgr_data");
356
+                        if (!r_escrow_yn.equals("Y")) {
357
+                            easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_txtype", "40");
358
+                        } else {
359
+                            easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_txtype", "61");
360
+                            easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_subtype", "ES02");
361
+                        }
362
+                        easyPayClient.easypay_deli_us(easypay_mgr_data_item, "org_cno", r_cno);
363
+                        easyPayClient.easypay_deli_us(easypay_mgr_data_item, "order_no", order_no);
364
+                        easyPayClient.easypay_deli_us(easypay_mgr_data_item, "req_ip", request.getRemoteAddr());
365
+                        easyPayClient.easypay_deli_us(easypay_mgr_data_item, "req_id", "MALL_R_TRANS");
366
+                        easyPayClient.easypay_deli_us(easypay_mgr_data_item, "mgr_msg", "DB 처리 실패로 망취소");
367
+
368
+                        easyPayClient.easypay_run(mall_id, tr_cd, order_no);
369
+
370
+                        res_cd = easyPayClient.res_cd;
371
+                        res_msg = easyPayClient.res_msg;
372
+                        r_cno = easyPayClient.easypay_get_res("cno"); // PG거래번호
373
+                        r_canc_date = easyPayClient.easypay_get_res("canc_date"); // 취소일시
374
+                    }
375
+                }
376
+            }
377
+            return easyResult;
378
+        } catch (GlobalException e) {
379
+            e.getStackTrace();
380
+            throw new GlobalException(e.getSystemMessageCode());
381
+        } catch (Exception e) {
382
+            e.getStackTrace();
383
+            throw new RuntimeException();
384
+        }
385
+    }
386
+
387
+}

+ 23 - 0
src/main/java/com/oqpo/api/service/sttlmng/SttlStateService.java

@@ -2,14 +2,19 @@ package com.oqpo.api.service.sttlmng;
2 2
 
3 3
 
4 4
 import com.oqpo.api.entity.settmng.StlMgntBaseInfoEntity;
5
+import com.oqpo.api.enums.SttlStCd;
6
+import com.oqpo.api.mapper.sttlmng.SttlReqMapper;
5 7
 import com.oqpo.api.mapper.sttlmng.SttlStateMapper;
6 8
 import com.oqpo.api.service.CommonService;
9
+import com.oqpo.api.util.DateUtil;
7 10
 import com.oqpo.api.web.dto.request.GridRequest;
11
+import com.oqpo.api.web.dto.request.sttlmng.SttlConfirmRequest;
8 12
 import com.oqpo.api.web.dto.response.GridResponse;
9 13
 import com.oqpo.api.web.dto.response.sttlmng.SttlStateGridResponse;
10 14
 import lombok.extern.slf4j.Slf4j;
11 15
 import org.springframework.beans.factory.annotation.Autowired;
12 16
 import org.springframework.stereotype.Service;
17
+import org.springframework.transaction.annotation.Transactional;
13 18
 
14 19
 import java.util.List;
15 20
 import java.util.stream.Collectors;
@@ -21,6 +26,9 @@ public class SttlStateService extends CommonService {
21 26
     @Autowired
22 27
     private SttlStateMapper sttlStateMapper;
23 28
 
29
+    @Autowired
30
+    private SttlReqMapper sttlReqMapper;
31
+
24 32
     /*
25 33
       정산요청 그리드 리스트 조회
26 34
      */
@@ -59,4 +67,19 @@ public class SttlStateService extends CommonService {
59 67
         return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
60 68
     }
61 69
 
70
+    /* 정산완료  */
71
+    @Transactional
72
+    public void endSttl(String userId, SttlConfirmRequest sttlConfirmRequest) throws Exception {
73
+        // 정산기본정보 조회
74
+        StlMgntBaseInfoEntity entity = sttlReqMapper.selectStlMgntBaseInfo(sttlConfirmRequest.getSttlMgntUnqNo());
75
+
76
+        // 정산관리기본정보 - 정산상태코드 변경
77
+        StlMgntBaseInfoEntity infoEntity = new StlMgntBaseInfoEntity();
78
+        infoEntity.setSttlMgntUnqNo(sttlConfirmRequest.getSttlMgntUnqNo());
79
+        infoEntity.setSttlStCd(SttlStCd.STTL_CONFIRM.getCd());
80
+        infoEntity.setSttlDt(DateUtil.getCurrentDate());
81
+        infoEntity.setSttlAmt(entity.getSttlReqAmt()); // 정산요청금액을 정산금액으로 지정한다.
82
+        sttlReqMapper.updateStlMgntBaseInfo4SttlConfirm(userId, infoEntity);
83
+    }
84
+
62 85
 }

+ 56 - 0
src/main/java/com/oqpo/api/web/controller/loanmng/EasypayPaymentController.java

@@ -0,0 +1,56 @@
1
+package com.oqpo.api.web.controller.loanmng;
2
+
3
+import com.oqpo.api.enums.SystemMessageCode;
4
+import com.oqpo.api.service.loanmng.EasypayPaymentService;
5
+import com.oqpo.api.service.loanmng.UnpaidMngService;
6
+import com.oqpo.api.web.dto.request.loanmng.EasypayPaymentRequest;
7
+import com.oqpo.api.web.dto.request.loanmng.ReqDsptRequest;
8
+import com.oqpo.api.web.dto.request.loanmng.StlDtlGridRequest;
9
+import com.oqpo.api.web.dto.request.loanmng.UnpaidMngGridRequest;
10
+import com.oqpo.api.web.dto.response.GridResponse;
11
+import com.oqpo.api.web.dto.response.SaveResponse;
12
+import com.oqpo.api.web.dto.response.loanmng.UnpaidMngInfoResponse;
13
+import io.swagger.annotations.Api;
14
+import io.swagger.annotations.ApiImplicitParam;
15
+import io.swagger.annotations.ApiImplicitParams;
16
+import io.swagger.annotations.ApiOperation;
17
+import lombok.extern.slf4j.Slf4j;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.http.ResponseEntity;
20
+import org.springframework.web.bind.annotation.*;
21
+import springfox.documentation.annotations.ApiIgnore;
22
+
23
+import javax.servlet.http.HttpServletRequest;
24
+import javax.validation.Valid;
25
+
26
+@Slf4j
27
+@RestController
28
+@RequestMapping("/api/easypay/payment")
29
+@Api(tags = {"이지페이 결제 (EasypayPaymentController)"})
30
+public class EasypayPaymentController {
31
+
32
+    @Autowired
33
+    private EasypayPaymentService easypayPaymentService;
34
+
35
+    /**
36
+     * 설명 : 이지페이 결제 요청
37
+     *
38
+     * @param userId
39
+     * @param easypayPaymentRequest
40
+     * @return SaveResponse
41
+     * @throws Exception
42
+     */
43
+    @ApiImplicitParams({
44
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
45
+    })
46
+    @ApiOperation(value = "이지페이 결제 요청")
47
+    @PostMapping("/request")
48
+    public ResponseEntity<SaveResponse> request(@ApiIgnore String userId, HttpServletRequest request,
49
+                                                @RequestBody @Valid EasypayPaymentRequest easypayPaymentRequest) throws Exception {
50
+
51
+        easypayPaymentService.requestPayment(userId, request, easypayPaymentRequest);
52
+
53
+        return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
54
+    }
55
+
56
+}

+ 22 - 0
src/main/java/com/oqpo/api/web/controller/sttlmng/SttlStateController.java

@@ -1,8 +1,11 @@
1 1
 package com.oqpo.api.web.controller.sttlmng;
2 2
 
3
+import com.oqpo.api.enums.SystemMessageCode;
3 4
 import com.oqpo.api.service.sttlmng.SttlStateService;
5
+import com.oqpo.api.web.dto.request.sttlmng.SttlConfirmRequest;
4 6
 import com.oqpo.api.web.dto.request.sttlmng.SttlStateGridRequest;
5 7
 import com.oqpo.api.web.dto.response.GridResponse;
8
+import com.oqpo.api.web.dto.response.SaveResponse;
6 9
 import io.swagger.annotations.Api;
7 10
 import io.swagger.annotations.ApiImplicitParam;
8 11
 import io.swagger.annotations.ApiImplicitParams;
@@ -11,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
11 14
 import org.springframework.beans.factory.annotation.Autowired;
12 15
 import org.springframework.http.ResponseEntity;
13 16
 import org.springframework.web.bind.annotation.*;
17
+import springfox.documentation.annotations.ApiIgnore;
14 18
 
15 19
 import javax.validation.Valid;
16 20
 
@@ -41,4 +45,22 @@ public class SttlStateController {
41 45
                 sttlStateGridRequest.getFromDt(), sttlStateGridRequest.getToDt(), sttlStateGridRequest.toDTO(sttlStateGridRequest)));
42 46
     }
43 47
 
48
+    /**
49
+     * 설명 : 정산완료
50
+     *
51
+     * @param userId
52
+     * @param sttlConfirmRequest
53
+     * @return SaveResponse
54
+     * @throws Exception
55
+     */
56
+    @ApiImplicitParams({
57
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
58
+    })
59
+    @ApiOperation(value = "정산완료")
60
+    @PostMapping("/sttl-end")
61
+    public ResponseEntity<SaveResponse> confirmSttl(@ApiIgnore String userId, @RequestBody @Valid SttlConfirmRequest sttlConfirmRequest) throws Exception {
62
+        sttlStateService.endSttl(userId, sttlConfirmRequest);
63
+        return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
64
+    }
65
+
44 66
 }

+ 56 - 0
src/main/java/com/oqpo/api/web/dto/request/loanmng/EasypayPaymentRequest.java

@@ -0,0 +1,56 @@
1
+package com.oqpo.api.web.dto.request.loanmng;
2
+
3
+import io.swagger.annotations.ApiModelProperty;
4
+import lombok.Data;
5
+
6
+@Data
7
+public class EasypayPaymentRequest {
8
+
9
+    @ApiModelProperty(value = "결제창 요청구분", required = true)
10
+    private String EP_tr_cd;
11
+    @ApiModelProperty(value = "추적번호", required = true)
12
+    private String EP_trace_no;
13
+    @ApiModelProperty(value = "가맹점 주문번호", required = true)
14
+    private String EP_order_no;
15
+    @ApiModelProperty(value = "가맹점 ID", required = true)
16
+    private String EP_mall_id;
17
+    @ApiModelProperty(value = "암호화 전문", required = true)
18
+    private String EP_encrypt_data;
19
+    @ApiModelProperty(value = "세션키", required = true)
20
+    private String EP_sessionkey;
21
+    @ApiModelProperty(value = "거래구분", required = true)
22
+    private String mgr_txtype;
23
+    @ApiModelProperty(value = "변경세부구분", required = false)
24
+    private String mgr_subtype;
25
+    @ApiModelProperty(value = "원거래고유번호", required = true)
26
+    private String org_cno;
27
+    @ApiModelProperty(value = "금액", required = false)
28
+    private String mgr_amt;
29
+    @ApiModelProperty(value = "부분취소 잔액", required = false)
30
+    private String mgr_rem_amt;
31
+    @ApiModelProperty(value = "환불계좌 은행코드", required = false)
32
+    private String mgr_bank_cd;
33
+    @ApiModelProperty(value = "환불계좌 번호", required = false)
34
+    private String mgr_account;
35
+    @ApiModelProperty(value = "환불계좌 예금주명", required = false)
36
+    private String mgr_depositor;
37
+    @ApiModelProperty(value = "요청자 ID", required = false)
38
+    private String req_id;
39
+
40
+    @ApiModelProperty(value = "원거래번호", required = true)
41
+    private String org_payment_no;
42
+
43
+    @ApiModelProperty(value = "결제창 요청구분(모바일)", required = true)
44
+    private String sp_tr_cd;
45
+    @ApiModelProperty(value = "추적번호(모바일)", required = true)
46
+    private String sp_trace_no;
47
+    @ApiModelProperty(value = "가맹점 주문번호(모바일)", required = true)
48
+    private String sp_order_no;
49
+    @ApiModelProperty(value = "가맹점 ID(모바일)", required = true)
50
+    private String sp_mall_id;
51
+    @ApiModelProperty(value = "암호화 전문(모바일)", required = true)
52
+    private String sp_encrypt_data;
53
+    @ApiModelProperty(value = "세션키(모바일)", required = true)
54
+    private String sp_sessionkey;
55
+
56
+}

+ 60 - 0
src/main/java/com/oqpo/api/web/dto/response/loanmng/EasypayPaymentResponse.java

@@ -0,0 +1,60 @@
1
+package com.oqpo.api.web.dto.response.loanmng;
2
+
3
+import lombok.Data;
4
+
5
+@Data
6
+public class EasypayPaymentResponse {
7
+	private String res_cd;
8
+	private String res_msg;
9
+	private String cno;
10
+	private String amount;
11
+	private String order_no;
12
+	private String auth_no;
13
+	private String tran_date;
14
+	private String escrow_yn;
15
+	private String complex_yn;
16
+	private String stat_cd;
17
+	private String stat_msg;
18
+	private String pay_type;
19
+	private String mall_id;
20
+	private String memb_id;
21
+	private String card_no;
22
+	private String issuer_cd;
23
+	private String issuer_nm;
24
+	private String acquirer_cd;
25
+	private String acquirer_nm;
26
+	private String install_period;
27
+	private String noint;
28
+	private String part_cancel_yn;
29
+	private String card_gubun;
30
+	private String card_biz_gubun;
31
+	private String cpon_flag;
32
+	private String bank_cd;
33
+	private String bank_nm;
34
+	private String account_no;
35
+	private String deposit_nm;
36
+	private String expire_date;
37
+	private String cash_res_cd;
38
+	private String cash_res_msg;
39
+	private String cash_auth_no;
40
+	private String cash_tran_date;
41
+	private String cash_issue_type;
42
+	private String cash_auth_type;
43
+	private String cash_auth_value;
44
+	private String auth_id;
45
+	private String billid;
46
+	private String mobile_no;
47
+	private String mob_ansim_yn;
48
+	private String ars_no;
49
+	private String cp_cd;
50
+	private String cpon_auth_no;
51
+	private String cpon_tran_date;
52
+	private String cpon_no;
53
+	private String remain_cpon;
54
+	private String used_cpon;
55
+	private String rem_amt;
56
+	private String bk_pay_yn;
57
+	private String canc_acq_date;
58
+	private String canc_date;
59
+	private String refund_date;
60
+}

+ 10 - 0
src/main/resources-env/dev/application.yml

@@ -79,3 +79,13 @@ logging:
79 79
 
80 80
 log:
81 81
   path: /home/noorija/apps/oqpo/logs
82
+
83
+kicc:
84
+  javascript_url: http://testsp.easypay.co.kr/webpay/EasypayCard_Web.js
85
+  action:
86
+    web_url: https://testpg.easypay.co.kr/webpay/MainAction.do
87
+    mobile_url: https://testsp.easypay.co.kr/ep8/MainAction.do
88
+  gateway: testgw.easypay.co.kr
89
+  cert_dir: C:/kicc/easypay/cert
90
+  log_dir: C:/kicc/easypay/logs
91
+  test_mall_tid: T0010761

+ 10 - 0
src/main/resources-env/local/application.yml

@@ -80,3 +80,13 @@ logging:
80 80
 
81 81
 log:
82 82
   path: D:/dev/logs/oqpo
83
+
84
+kicc:
85
+  javascript_url: http://testsp.easypay.co.kr/webpay/EasypayCard_Web.js
86
+  action:
87
+    web_url: https://testpg.easypay.co.kr/webpay/MainAction.do
88
+    mobile_url: https://testsp.easypay.co.kr/ep8/MainAction.do
89
+  gateway: testgw.easypay.co.kr
90
+  cert_dir: C:/kicc/easypay/cert
91
+  log_dir: C:/kicc/easypay/logs
92
+  test_mall_tid: T0010761

+ 10 - 0
src/main/resources-env/qa/application.yml

@@ -79,3 +79,13 @@ logging:
79 79
 
80 80
 log:
81 81
   path: D:/dev/logs/noorikiosk
82
+
83
+kicc:
84
+  javascript_url: http://testsp.easypay.co.kr/webpay/EasypayCard_Web.js
85
+  action:
86
+    web_url: https://testpg.easypay.co.kr/webpay/MainAction.do
87
+    mobile_url: https://testsp.easypay.co.kr/ep8/MainAction.do
88
+  gateway: testgw.easypay.co.kr
89
+  cert_dir: C:/kicc/easypay/cert
90
+  log_dir: C:/kicc/easypay/logs
91
+  test_mall_tid: T0010761