TsfGiftcardService.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. package com.style24.front.biz.service;
  2. import java.util.Collection;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.stereotype.Service;
  5. import com.style24.front.biz.dao.TsfGiftcardDao;
  6. import com.style24.front.biz.thirdparty.Yes24Giftcard;
  7. import com.style24.front.support.security.session.TsfSession;
  8. import com.style24.persistence.domain.GiftCard;
  9. import com.style24.persistence.domain.Order;
  10. import lombok.extern.slf4j.Slf4j;
  11. /**
  12. * 상품권 Service
  13. *
  14. * @author gagamel
  15. * @since 2020. 12. 29
  16. */
  17. @Service
  18. @Slf4j
  19. public class TsfGiftcardService {
  20. @Autowired
  21. private TsfGiftcardDao giftcardDao;
  22. @Autowired
  23. private Yes24Giftcard yes24Gift;
  24. /**
  25. * 상품권정보 조회
  26. *
  27. * @param GiftCard
  28. * @author sowon
  29. * @since 2021. 3. 12
  30. */
  31. public GiftCard getGiftcardInfo(GiftCard giftcard) {
  32. // 고객번호 설정
  33. int custNo = TsfSession.getInfo().getCustNo();
  34. giftcard.setCustNo(custNo);
  35. return giftcardDao.getGiftcardInfo(giftcard);
  36. }
  37. /**
  38. * 상품권 사용 정보 조회
  39. *
  40. * @param GiftCard
  41. * @author sowon
  42. * @since 2021. 3. 12
  43. */
  44. public Collection<GiftCard> getGiftcardUseList(GiftCard giftcard) {
  45. // 고객번호 설정
  46. int custNo = TsfSession.getInfo().getCustNo();
  47. giftcard.setCustNo(custNo);
  48. giftcard.setMonthLength(giftcard.getMonth().length());
  49. return giftcardDao.getGiftcardUseList(giftcard);
  50. }
  51. /**
  52. * 상품권 보유 조회
  53. *
  54. * @param GiftCard
  55. * @author sowon
  56. * @since 2021. 3. 12
  57. */
  58. public Collection<GiftCard> getGiftcardOwnList(GiftCard giftcard) {
  59. // 고객번호 설정
  60. int custNo = TsfSession.getInfo().getCustNo();
  61. giftcard.setCustNo(custNo);
  62. return giftcardDao.getGiftcardOwnList(giftcard);
  63. }
  64. /**
  65. * 상품권 저장
  66. *
  67. * @param GiftCard
  68. * @author sowon
  69. * @throws Exception
  70. * @since 2021. 3. 15
  71. */
  72. public void createGiftcardUseConfirm(GiftCard giftcard) throws Exception {
  73. // 고객번호 설정
  74. int custNo = TsfSession.getInfo().getCustNo();
  75. String ip = TsfSession.getIpAddress();
  76. giftcard.setCustNo(custNo);
  77. giftcard.setRegNo(custNo);
  78. giftcard.setUpdNo(custNo);
  79. giftcard.setIpAddr(ip); // 아이피주소
  80. String pubNo = giftcard.getGfcdNo();
  81. String result =yes24Gift.soapDataTransfer(pubNo,ip,custNo);
  82. if (result.equals("01")) {
  83. giftcard.setResultVal(result); // 승인 결과 insert
  84. giftcardDao.saveGiftcardApi(giftcard);
  85. throw new IllegalArgumentException("존재하지 않는 상품권입니다.");
  86. } else if (result.equals("02")) {
  87. giftcard.setResultVal(result);
  88. giftcardDao.saveGiftcardApi(giftcard);
  89. throw new IllegalArgumentException("이미 등록된 상품권입니다.");
  90. } else if (result.equals("03")) {
  91. giftcard.setResultVal(result);
  92. giftcardDao.saveGiftcardApi(giftcard);
  93. throw new IllegalArgumentException("삭제된 상품권입니다.");
  94. } else if (result.equals("04")) {
  95. giftcard.setResultVal(result);
  96. giftcardDao.saveGiftcardApi(giftcard);
  97. throw new IllegalArgumentException("기간이 만료된 상품권입니다.");
  98. } else if (result.equals("99")) {
  99. giftcard.setResultVal(result);
  100. giftcardDao.saveGiftcardApi(giftcard);
  101. throw new IllegalArgumentException("시스템 오류입니다.");
  102. } else{
  103. giftcard.setResultVal("00");
  104. giftcardDao.saveGiftcardApi(giftcard);
  105. // 성공일 경우 tb_cust_giftcard insert
  106. String[] param = result.split("[|]");
  107. // [2021-04-01, 오전, 12:00:00]
  108. String[] param2 = param[2].split(" ");
  109. String[] param3 = param[3].split(" ");
  110. giftcard.setChgGfcdAmt(Integer.parseInt(param[1])); // 승인금액
  111. giftcard.setRmGfcdAmt(Integer.parseInt(param[1])); // 승인금액
  112. giftcard.setUseStDate(param2[0]);
  113. giftcard.setUseExpDate(param3[0]);
  114. giftcardDao.createGiftcardUseConfirm(giftcard);
  115. int custGfcdSq = giftcardDao.getCustGiftCardSq(pubNo);
  116. giftcard.setCustGfcdSq(custGfcdSq);
  117. giftcard.setOccurGb("G074_11");
  118. giftcard.setOccurDtlDesc("상품권등록");
  119. giftcard.setGfcdAmt(Integer.parseInt(param[1]));
  120. giftcardDao.createCustGiftcardHistory(giftcard);
  121. }
  122. }
  123. /**
  124. * 상품권 최근 12개월 년 월
  125. *
  126. * @param GiftCard
  127. * @author sowon
  128. * @since 2021. 3. 30
  129. */
  130. public Collection<GiftCard> getRecentlyDate(){
  131. return giftcardDao.getRecentlyDate();
  132. }
  133. /**
  134. * 상품권 KCP 현금영수증 신청 정보 조회
  135. *
  136. * @param GiftCard
  137. * @return GiftCard
  138. * @author card007
  139. * @since 2021. 04. 25
  140. */
  141. public GiftCard getCashReceiptsInfo(GiftCard giftCard) {
  142. return giftcardDao.getCashReceiptsInfo(giftCard);
  143. }
  144. /**
  145. * 상품권 KCP 현금영수증 신청 여부 조회
  146. *
  147. * @param GiftCard
  148. * @return GiftCard
  149. * @author card007
  150. * @since 2021. 04. 25
  151. */
  152. public GiftCard getCashReceiptsRequestInfo(Order order) {
  153. return giftcardDao.getCashReceiptsRequestInfo(order);
  154. }
  155. }