|
|
@@ -1,10 +1,13 @@
|
|
|
package com.style24.admin.biz.service;
|
|
|
|
|
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.gagaframework.web.parameter.GagaMap;
|
|
|
import com.style24.admin.biz.dao.TsaGiftCardDao;
|
|
|
import com.style24.admin.support.security.session.TsaSession;
|
|
|
import com.style24.core.biz.thirdparty.Yes24Giftcard;
|
|
|
import com.style24.core.support.env.TscConstants;
|
|
|
+import com.style24.persistence.domain.Customer;
|
|
|
import com.style24.persistence.domain.GiftCard;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -26,9 +29,15 @@ public class TsaGiftCardService {
|
|
|
@Autowired
|
|
|
private TsaGiftCardDao giftCardDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TsaCustomerService customerService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private Yes24Giftcard yes24Giftcard;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ObjectMapper objectMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 상품권 대량 등록수
|
|
|
@@ -55,66 +64,84 @@ public class TsaGiftCardService {
|
|
|
/**
|
|
|
* 상품권 저장
|
|
|
*
|
|
|
- * @param giftCard - 상품권, 고객 정보
|
|
|
+ * @param gagaMap - 상품권, 고객 정보
|
|
|
* @author jsshin
|
|
|
* @throws Exception
|
|
|
* @since 2021. 5. 12
|
|
|
*/
|
|
|
@Transactional("shopTxnManager")
|
|
|
- public void saveGiftcardUseConfirm(GiftCard giftCard) throws Exception {
|
|
|
- // 고객번호 설정
|
|
|
+ public void saveGiftcardUseConfirm(GagaMap gagaMap) throws Exception {
|
|
|
Integer userNo = TsaSession.getInfo().getUserNo();
|
|
|
String ip = TsaSession.getIpAddress();
|
|
|
- giftCard.setRegNo(userNo);
|
|
|
- giftCard.setUpdNo(userNo);
|
|
|
- giftCard.setIpAddr(ip); // 아이피주소
|
|
|
-
|
|
|
- Integer custNo = giftCard.getCustNo();
|
|
|
- String pubNo = giftCard.getGfcdNo().trim();
|
|
|
- String result = yes24Giftcard.soapDataTransfer(pubNo, ip, custNo);
|
|
|
-
|
|
|
String resultMsg;
|
|
|
- if ("01".equals(result)) {
|
|
|
- giftCard.setResultVal(result); // 승인 결과 insert
|
|
|
- resultMsg = "존재하지 않는 상품권";
|
|
|
- } else if ("02".equals(result)) {
|
|
|
- giftCard.setResultVal(result);
|
|
|
- resultMsg = "이미 등록된 상품권";
|
|
|
- } else if ("03".equals(result)) {
|
|
|
- giftCard.setResultVal(result);
|
|
|
- resultMsg = "삭제된 상품권";
|
|
|
- } else if ("04".equals(result)) {
|
|
|
- giftCard.setResultVal(result);
|
|
|
- resultMsg = "기간이 만료된 상품권";
|
|
|
- } else if ("99".equals(result)) {
|
|
|
- giftCard.setResultVal(result);
|
|
|
- resultMsg = "시스템 오류";
|
|
|
+ GiftCard giftCard = objectMapper.convertValue(gagaMap, GiftCard.class);
|
|
|
+
|
|
|
+ // 1. 엑셀 내용 데이터 생성
|
|
|
+ giftCardDao.createGfcdBulkReg(giftCard);
|
|
|
+
|
|
|
+ // 2. 활동회원 확인
|
|
|
+ Customer customer = customerService.getCustomerInfoByCustId(giftCard.getCustId().trim());
|
|
|
+
|
|
|
+ // 3. 유효한 회원이면
|
|
|
+ if (customer != null) {
|
|
|
+ Integer custNo = customer.getCustNo();
|
|
|
+ String pubNo = giftCard.getGfcdNo().trim();
|
|
|
+ // 상품권 API 호출
|
|
|
+ String result = yes24Giftcard.soapDataTransfer(pubNo, ip, custNo);
|
|
|
+
|
|
|
+ giftCard.setCustNo(custNo);
|
|
|
+ giftCard.setRegNo(userNo);
|
|
|
+ giftCard.setUpdNo(userNo);
|
|
|
+ giftCard.setIpAddr(ip);
|
|
|
+
|
|
|
+ if ("01".equals(result)) {
|
|
|
+ giftCard.setResultVal(result);
|
|
|
+ resultMsg = "존재하지 않는 상품권";
|
|
|
+ } else if ("02".equals(result)) {
|
|
|
+ giftCard.setResultVal(result);
|
|
|
+ resultMsg = "이미 등록된 상품권";
|
|
|
+ } else if ("03".equals(result)) {
|
|
|
+ giftCard.setResultVal(result);
|
|
|
+ resultMsg = "삭제된 상품권";
|
|
|
+ } else if ("04".equals(result)) {
|
|
|
+ giftCard.setResultVal(result);
|
|
|
+ resultMsg = "기간이 만료된 상품권";
|
|
|
+ } else if ("99".equals(result)) {
|
|
|
+ giftCard.setResultVal(result);
|
|
|
+ resultMsg = "시스템 오류";
|
|
|
+ } else {
|
|
|
+ giftCard.setResultVal("00");
|
|
|
+ resultMsg = "상품권등록 성공";
|
|
|
+ }
|
|
|
+ // 상품권 API 이력 저장
|
|
|
+ giftCardDao.createGiftcardApi(giftCard);
|
|
|
+
|
|
|
+ // 성공일 경우
|
|
|
+ if ("00".equals(giftCard.getResultVal())) {
|
|
|
+ String[] param = result.split("[|]");
|
|
|
+ // [2021-04-01, 오전, 12:00:00]
|
|
|
+ String[] param2 = param[2].split(" ");
|
|
|
+ String[] param3 = param[3].split(" ");
|
|
|
+
|
|
|
+ // 고객 상품권 등록
|
|
|
+ giftCard.setGfcdNm("YES24상품권");
|
|
|
+ giftCard.setChgGfcdAmt(Integer.parseInt(param[1])); // 승인금액
|
|
|
+ giftCard.setRmGfcdAmt(Integer.parseInt(param[1])); // 승인금액
|
|
|
+ giftCard.setUseStDate(param2[0]);
|
|
|
+ giftCard.setUseExpDate(param3[0]);
|
|
|
+ giftCardDao.createGiftcardUseConfirm(giftCard);
|
|
|
+
|
|
|
+ // 고객 상품권 이력 등록
|
|
|
+ giftCard.setOccurGb(TscConstants.GiftCardOccurGb.REGISTER_GIFTCARD.value());
|
|
|
+ giftCard.setOccurDtlDesc("상품권등록");
|
|
|
+ giftCard.setGfcdAmt(Integer.parseInt(param[1]));
|
|
|
+ giftCardDao.createCustGiftcardHistory(giftCard);
|
|
|
+ }
|
|
|
} else {
|
|
|
- giftCard.setResultVal("00");
|
|
|
- resultMsg = "상품권등록 성공";
|
|
|
- }
|
|
|
- giftCard.setResultMsg(resultMsg);
|
|
|
- giftCardDao.createGiftcardApi(giftCard);
|
|
|
-
|
|
|
- // 성공일 경우
|
|
|
- if ("00".equals(giftCard.getResultVal())) {
|
|
|
- String[] param = result.split("[|]");
|
|
|
- // [2021-04-01, 오전, 12:00:00]
|
|
|
- String[] param2 = param[2].split(" ");
|
|
|
- String[] param3 = param[3].split(" ");
|
|
|
-
|
|
|
- giftCard.setGfcdNm("YES24상품권");
|
|
|
- giftCard.setChgGfcdAmt(Integer.parseInt(param[1])); // 승인금액
|
|
|
- giftCard.setRmGfcdAmt(Integer.parseInt(param[1])); // 승인금액
|
|
|
- giftCard.setUseStDate(param2[0]);
|
|
|
- giftCard.setUseExpDate(param3[0]);
|
|
|
- giftCardDao.createGiftcardUseConfirm(giftCard);
|
|
|
- giftCard.setOccurGb(TscConstants.GiftCardOccurGb.REGISTER_GIFTCARD.value());
|
|
|
- giftCard.setOccurDtlDesc("상품권등록");
|
|
|
- giftCard.setGfcdAmt(Integer.parseInt(param[1]));
|
|
|
- giftCardDao.createCustGiftcardHistory(giftCard);
|
|
|
+ resultMsg = "존재하지 않는 회원";
|
|
|
}
|
|
|
|
|
|
+ giftCard.setResultMsg(resultMsg);
|
|
|
giftCardDao.updateGfcdBulkReg(giftCard);
|
|
|
|
|
|
}
|