| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- package com.style24.front.biz.service;
- import java.util.Collection;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.style24.front.biz.dao.TsfGiftcardDao;
- import com.style24.front.biz.thirdparty.Yes24Giftcard;
- import com.style24.front.support.security.session.TsfSession;
- import com.style24.persistence.domain.GiftCard;
- import com.style24.persistence.domain.Order;
- import lombok.extern.slf4j.Slf4j;
- /**
- * 상품권 Service
- *
- * @author gagamel
- * @since 2020. 12. 29
- */
- @Service
- @Slf4j
- public class TsfGiftcardService {
- @Autowired
- private TsfGiftcardDao giftcardDao;
- @Autowired
- private Yes24Giftcard yes24Gift;
- /**
- * 상품권정보 조회
- *
- * @param GiftCard
- * @author sowon
- * @since 2021. 3. 12
- */
- public GiftCard getGiftcardInfo(GiftCard giftcard) {
- // 고객번호 설정
- int custNo = TsfSession.getInfo().getCustNo();
- giftcard.setCustNo(custNo);
- return giftcardDao.getGiftcardInfo(giftcard);
- }
- /**
- * 상품권 사용 정보 조회
- *
- * @param GiftCard
- * @author sowon
- * @since 2021. 3. 12
- */
- public Collection<GiftCard> getGiftcardUseList(GiftCard giftcard) {
- // 고객번호 설정
- int custNo = TsfSession.getInfo().getCustNo();
- giftcard.setCustNo(custNo);
- giftcard.setMonthLength(giftcard.getMonth().length());
- return giftcardDao.getGiftcardUseList(giftcard);
- }
- /**
- * 상품권 보유 조회
- *
- * @param GiftCard
- * @author sowon
- * @since 2021. 3. 12
- */
- public Collection<GiftCard> getGiftcardOwnList(GiftCard giftcard) {
- // 고객번호 설정
- int custNo = TsfSession.getInfo().getCustNo();
- giftcard.setCustNo(custNo);
- return giftcardDao.getGiftcardOwnList(giftcard);
- }
- /**
- * 상품권 저장
- *
- * @param GiftCard
- * @author sowon
- * @throws Exception
- * @since 2021. 3. 15
- */
- public void createGiftcardUseConfirm(GiftCard giftcard) throws Exception {
- // 고객번호 설정
- int custNo = TsfSession.getInfo().getCustNo();
- String ip = TsfSession.getIpAddress();
- giftcard.setCustNo(custNo);
- giftcard.setRegNo(custNo);
- giftcard.setUpdNo(custNo);
- giftcard.setIpAddr(ip); // 아이피주소
-
-
- String pubNo = giftcard.getGfcdNo();
- String result =yes24Gift.soapDataTransfer(pubNo,ip,custNo);
- if (result.equals("01")) {
- giftcard.setResultVal(result); // 승인 결과 insert
- giftcardDao.saveGiftcardApi(giftcard);
- throw new IllegalArgumentException("존재하지 않는 상품권입니다.");
- } else if (result.equals("02")) {
- giftcard.setResultVal(result);
- giftcardDao.saveGiftcardApi(giftcard);
- throw new IllegalArgumentException("이미 등록된 상품권입니다.");
- } else if (result.equals("03")) {
- giftcard.setResultVal(result);
- giftcardDao.saveGiftcardApi(giftcard);
- throw new IllegalArgumentException("삭제된 상품권입니다.");
- } else if (result.equals("04")) {
- giftcard.setResultVal(result);
- giftcardDao.saveGiftcardApi(giftcard);
- throw new IllegalArgumentException("기간이 만료된 상품권입니다.");
- } else if (result.equals("99")) {
- giftcard.setResultVal(result);
- giftcardDao.saveGiftcardApi(giftcard);
- throw new IllegalArgumentException("시스템 오류입니다.");
- } else{
-
- giftcard.setResultVal("00");
- giftcardDao.saveGiftcardApi(giftcard);
-
- // 성공일 경우 tb_cust_giftcard insert
- String[] param = result.split("[|]");
- // [2021-04-01, 오전, 12:00:00]
- String[] param2 = param[2].split(" ");
- String[] param3 = param[3].split(" ");
-
- giftcard.setChgGfcdAmt(Integer.parseInt(param[1])); // 승인금액
- giftcard.setRmGfcdAmt(Integer.parseInt(param[1])); // 승인금액
- giftcard.setUseStDate(param2[0]);
- giftcard.setUseExpDate(param3[0]);
- giftcardDao.createGiftcardUseConfirm(giftcard);
-
- int custGfcdSq = giftcardDao.getCustGiftCardSq(pubNo);
- giftcard.setCustGfcdSq(custGfcdSq);
- giftcard.setOccurGb("G074_11");
- giftcard.setOccurDtlDesc("상품권등록");
- giftcard.setGfcdAmt(Integer.parseInt(param[1]));
-
- giftcardDao.createCustGiftcardHistory(giftcard);
-
- }
- }
-
- /**
- * 상품권 최근 12개월 년 월
- *
- * @param GiftCard
- * @author sowon
- * @since 2021. 3. 30
- */
- public Collection<GiftCard> getRecentlyDate(){
- return giftcardDao.getRecentlyDate();
- }
- /**
- * 상품권 KCP 현금영수증 신청 정보 조회
- *
- * @param GiftCard
- * @return GiftCard
- * @author card007
- * @since 2021. 04. 25
- */
- public GiftCard getCashReceiptsInfo(GiftCard giftCard) {
- return giftcardDao.getCashReceiptsInfo(giftCard);
- }
- /**
- * 상품권 KCP 현금영수증 신청 여부 조회
- *
- * @param GiftCard
- * @return GiftCard
- * @author card007
- * @since 2021. 04. 25
- */
- public GiftCard getCashReceiptsRequestInfo(Order order) {
- return giftcardDao.getCashReceiptsRequestInfo(order);
- }
- }
|