|
|
@@ -57,19 +57,55 @@ public class TsfCouponService {
|
|
|
* @since 2021. 02. 16
|
|
|
*/
|
|
|
public Coupon serialCpnApplyInfo(Coupon param) {
|
|
|
- Coupon cpn = couponDao.getSearchSerialCpnInfo(param);
|
|
|
- if(cpn != null && cpn.getCpnId() > 0) {
|
|
|
- // 다운로드 받을 수 있는 쿠폰이 있음
|
|
|
+ // TODO 로그인 정보 입력
|
|
|
+ param.setCustNo(1000006);
|
|
|
+ param.setRegNo(1000006);
|
|
|
+ param.setUpdNo(1000006);
|
|
|
+ param.setFrontGb(TsfSession.getFrontGb());
|
|
|
+
|
|
|
+ // 시리얼키의 쿠폰이 다운로드 가능한지 확인
|
|
|
+ Coupon cpn = couponDao.getSearchSerialCpnInfo(param); // >> 여기서 쿠폰 정보 다 빼내야함.
|
|
|
|
|
|
+
|
|
|
+ // 다운로드 받을 수 있는 쿠폰이 있으면
|
|
|
+ if(cpn != null && cpn.getCpnId() > 0) {
|
|
|
+ // 다운 받을 수 있는 쿠폰ID를 내가 받은 이력이 있는지 확인
|
|
|
+ cpn.setCustNo(param.getCustNo());
|
|
|
+ Coupon myCpn = couponDao.getSerialCpnUseInfo(cpn);
|
|
|
+
|
|
|
+ // 다운로드 받은 쿠폰이 있는 경우
|
|
|
+ if(myCpn != null && myCpn.getCpnId() > 0) {
|
|
|
+ // 이미 다운 받았고, 사용 한 쿠폰이 있을 경우 종료
|
|
|
+ if(!StringUtils.isEmpty(myCpn.getUsedDt())) {
|
|
|
+ cpn.setResult("해당 쿠폰은 이미 사용하신 쿠폰입니다.");
|
|
|
+ } else {
|
|
|
+ cpn.setResult("지급 받으신 쿠폰 사용 기한이 지났습니다.");
|
|
|
+ }
|
|
|
+ return cpn;
|
|
|
+ } else {
|
|
|
+ /* 다운받지 않은 경우 (tb_cust_coupon insert) */
|
|
|
+ // 랜덤쿠폰 할당 및 쿠폰 지급
|
|
|
+ cpn.setRegNo(param.getRegNo());
|
|
|
+ cpn.setUpdNo(param.getUpdNo());
|
|
|
+ updateGiveRandomCpnInfo(cpn);
|
|
|
+ }
|
|
|
} else {
|
|
|
// 다운로드 받을 수 있는 쿠폰이 존재하지 않음.
|
|
|
-
|
|
|
+ cpn.setResult("해당 쿠폰은 존재하지 않습니다.");
|
|
|
+ return cpn;
|
|
|
}
|
|
|
|
|
|
+ // 장바구니쿠폰 토탈 할인 금액 계산
|
|
|
+ cpn.setDcAmt(getCartCpnApplyTotalAmt(param));
|
|
|
+ cpn.setResult("SUCCESS");
|
|
|
+
|
|
|
+ log.info("CHECK INFO >> {} / {}", cpn.getDcAmt(), cpn.getResult());
|
|
|
|
|
|
+ return cpn;
|
|
|
|
|
|
|
|
|
|
|
|
+/*
|
|
|
// 시리얼 쿠폰 지급 및 사용 내역 조회
|
|
|
Coupon useSerial = getSerialCpnUseInfo(param);
|
|
|
if(useSerial == null) { useSerial = new Coupon(); }
|
|
|
@@ -95,25 +131,17 @@ public class TsfCouponService {
|
|
|
if(coupon == null) {
|
|
|
useSerial.setResult("해당 쿠폰은 존재하지 않습니다.");
|
|
|
return useSerial;
|
|
|
- } else if (!"Y".equals(coupon.getDownCanGb())) {
|
|
|
+ } *//*else if (!"Y".equals(coupon.getDownCanGb())) {
|
|
|
useSerial.setResult("해당 쿠폰은 사용 할 수 없습니다.");
|
|
|
return useSerial;
|
|
|
- } else {
|
|
|
+ }*//* else {
|
|
|
// 랜덤쿠폰 할당 및 쿠폰 지급
|
|
|
coupon.setCustNo(useSerial.getCustNo());
|
|
|
coupon.setRegNo(useSerial.getRegNo());
|
|
|
coupon.setUpdNo(useSerial.getUpdNo());
|
|
|
updateGiveRandomCpnInfo(coupon);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // 장바구니쿠폰 토탈 할인 금액 계산
|
|
|
- coupon.setDcAmt(getCartCpnApplyTotalAmt(useSerial));
|
|
|
- coupon.setResult("SUCCESS");
|
|
|
-
|
|
|
- log.info("CHECK INFO >> {} / {}", coupon.getDcAmt(), coupon.getResult());
|
|
|
-
|
|
|
- return coupon;
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
// 장바구니쿠폰 토탈 할인 금액 계산
|
|
|
@@ -140,7 +168,6 @@ public class TsfCouponService {
|
|
|
buyLimitAmt = info.getBuyLimitAmt(); // 최대할인율과 최소주문금액은 한 쿠폰에 값이 동일
|
|
|
if(TscConstants.DcWay.RATE.value().equals(info.getDcWay())) { // 할인방식이 할인율이면 각 상품별 할인금액을 따로 계산해야함
|
|
|
int dcAmt = (int) (info.getCurrPrice() * (info.getDcVal() / 100.0)); // 해당상품 할인금
|
|
|
- info.setCartCpnDcAmt(dcAmt);
|
|
|
totDcAmt = totDcAmt + dcAmt; // 적용 상품 총 할인금액
|
|
|
} else { // 할인 방식이 금액일 경우
|
|
|
totDcAmt = info.getDcVal();
|
|
|
@@ -175,6 +202,7 @@ public class TsfCouponService {
|
|
|
custCoupon.setPubReason("G068_60"); // 쿠폰 발행사유 (랜덤쿠폰등록)
|
|
|
custCoupon.setPubReasonDtl(param.getRdCpnNm() + " 쿠폰 등록");
|
|
|
|
|
|
+ // 트랜잭션을 묶기 위해 dao 직접 호출
|
|
|
coreCouponDao.updateGiveRandomCoupon(custCoupon); // 랜덤쿠폰 CUST_NO UPDATE
|
|
|
coreCouponDao.saveCouponCustPub(custCoupon); // 랜덤쿠폰 고객 지급
|
|
|
}
|