|
@@ -6,6 +6,9 @@ import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -34,6 +37,9 @@ public class TsaCouponService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private TsaCommonService commonService;
|
|
private TsaCommonService commonService;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 쿠폰 저장
|
|
* 쿠폰 저장
|
|
|
* @param params
|
|
* @param params
|
|
@@ -44,68 +50,34 @@ public class TsaCouponService {
|
|
|
public void couponSave(Coupon params) {
|
|
public void couponSave(Coupon params) {
|
|
|
String cpnId = ""; // 쿠폰ID
|
|
String cpnId = ""; // 쿠폰ID
|
|
|
|
|
|
|
|
- params = applyTargetSetting(params);
|
|
|
|
|
-
|
|
|
|
|
params.setRegNo(TsaSession.getInfo().getUserNo());
|
|
params.setRegNo(TsaSession.getInfo().getUserNo());
|
|
|
params.setUpdNo(TsaSession.getInfo().getUserNo());
|
|
params.setUpdNo(TsaSession.getInfo().getUserNo());
|
|
|
|
|
|
|
|
// 자동생성이면 시퀀스 가져오기
|
|
// 자동생성이면 시퀀스 가져오기
|
|
|
- if (params.getCpnId() == null || params.getCpnId().equals("")) {
|
|
|
|
|
- int sequence = commonService.getNextSequence("SEQ_COUPON");
|
|
|
|
|
- cpnId = "CPN" + sequence;
|
|
|
|
|
|
|
+ /*if(StringUtils.isBlank(params.getCpnId())) {
|
|
|
|
|
+ Integer sequence = commonService.getNextSequence("SEQ_COUPON");
|
|
|
|
|
+ cpnId = "CPN"+sequence;
|
|
|
} else {
|
|
} else {
|
|
|
cpnId = params.getCpnId();
|
|
cpnId = params.getCpnId();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- log.info(">>>> CPNID : {}", cpnId);
|
|
|
|
|
params.setCpnId(cpnId);
|
|
params.setCpnId(cpnId);
|
|
|
|
|
|
|
|
couponDao.couponInsert(params);
|
|
couponDao.couponInsert(params);
|
|
|
|
|
+ */
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
|
|
|
- //checkCpnValidation(params);
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 쿠폰 적용대상 세팅
|
|
|
|
|
- public Coupon applyTargetSetting(Coupon params) {
|
|
|
|
|
- Collection<Coupon> cpnSupplyCompList = null;
|
|
|
|
|
- Collection<Coupon> cpnBrandList = null;
|
|
|
|
|
- Collection<Coupon> cpnApplyGoodsList = null;
|
|
|
|
|
- Collection<Coupon> cpnCateList = null;
|
|
|
|
|
- Collection<Coupon> cpnBurdenList = null;
|
|
|
|
|
- Collection<Coupon> cpnExcepGoodsList = null;
|
|
|
|
|
- ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- if (params.getSupplyCompList() != null) {
|
|
|
|
|
- cpnSupplyCompList = mapper.readValue(params.getSupplyCompList(), new TypeReference<Collection<Coupon>>() {
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- if (params.getBrandList() != null) {
|
|
|
|
|
- cpnBrandList = mapper.readValue(params.getBrandList(), new TypeReference<Collection<Coupon>>() {
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- if (params.getApplyGoodsList() != null) {
|
|
|
|
|
- cpnApplyGoodsList = mapper.readValue(params.getApplyGoodsList(), new TypeReference<Collection<Coupon>>() {
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- if (params.getCateList() != null) {
|
|
|
|
|
- cpnCateList = mapper.readValue(params.getCateList(), new TypeReference<Collection<Coupon>>() {
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- if (params.getBurdenList() != null) {
|
|
|
|
|
- cpnBurdenList = mapper.readValue(params.getBurdenList(), new TypeReference<Collection<Coupon>>() {
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- if (params.getCateList() != null) {
|
|
|
|
|
- cpnExcepGoodsList = mapper.readValue(params.getExceptGoodsList(), new TypeReference<Collection<Coupon>>() {
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
|
+ Collection<Coupon> supplyCompList = gson.fromJson(params.getSupplyCompList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
|
|
+ for(Coupon supplyComp : supplyCompList) {
|
|
|
|
|
+ // couponDao.couponRefValInsert(supplyComp);
|
|
|
}
|
|
}
|
|
|
|
|
+ Collection<Coupon> brandList = gson.fromJson(params.getBrandList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
|
|
+ Collection<Coupon> applyGoodsList = gson.fromJson(params.getApplyGoodsList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
|
|
+ Collection<Coupon> cateList = gson.fromJson(params.getCateList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
|
|
+ Collection<Coupon> exceptGoodsList = gson.fromJson(params.getExceptGoodsList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
|
|
+ Collection<Coupon> burdenList = gson.fromJson(params.getBurdenList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
|
|
+
|
|
|
|
|
+ //checkCpnValidation(params);
|
|
|
|
|
|
|
|
- return params;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -139,25 +111,25 @@ public class TsaCouponService {
|
|
|
public void checkCpnValidation(Coupon params) {
|
|
public void checkCpnValidation(Coupon params) {
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
// 할인율이면 100% 초과 체크하기
|
|
// 할인율이면 100% 초과 체크하기
|
|
|
- if (params.getDcWay() != null && params.getDcWay().equals("G240_11")) {
|
|
|
|
|
- if (params.getDcAval() > 100) {
|
|
|
|
|
|
|
+ if(params.getDcWay() != null && params.getDcWay().equals("G240_11")) {
|
|
|
|
|
+ if(params.getDcAval() > 100) {
|
|
|
throw new IllegalStateException("모바일 앱 할인율은 100을 초과할수 없습니다.");
|
|
throw new IllegalStateException("모바일 앱 할인율은 100을 초과할수 없습니다.");
|
|
|
- } else if (params.getDcPval() > 100) {
|
|
|
|
|
|
|
+ } else if(params.getDcPval() > 100) {
|
|
|
throw new IllegalStateException("PC할인율은 100을 초과할수 없습니다.");
|
|
throw new IllegalStateException("PC할인율은 100을 초과할수 없습니다.");
|
|
|
- } else if (params.getDcMval() > 100) {
|
|
|
|
|
|
|
+ } else if(params.getDcMval() > 100) {
|
|
|
throw new IllegalStateException("모바일 웹 100을 초과할수 없습니다.");
|
|
throw new IllegalStateException("모바일 웹 100을 초과할수 없습니다.");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 기간/일수구분이 일수인 경우 날짜 체크
|
|
// 기간/일수구분이 일수인 경우 날짜 체크
|
|
|
- if (params.getPdGb() != null && params.getPdGb().equals("D")) {
|
|
|
|
|
|
|
+ if(params.getPdGb() != null && params.getPdGb().equals("D")) {
|
|
|
try {
|
|
try {
|
|
|
Date date1 = format.parse(params.getAvailStdt());
|
|
Date date1 = format.parse(params.getAvailStdt());
|
|
|
Date date2 = format.parse(params.getAvailEddt());
|
|
Date date2 = format.parse(params.getAvailEddt());
|
|
|
|
|
|
|
|
- log.info("checkCpnValidation params.getAvailEddt() : {}", params.getAvailEddt());
|
|
|
|
|
- log.info("checkCpnValidation params.getAvailStdt : {}", params.getAvailStdt());
|
|
|
|
|
- if (date2.before(date1)) {
|
|
|
|
|
|
|
+ log.info("checkCpnValidation params.getAvailEddt() : {}" , params.getAvailEddt());
|
|
|
|
|
+ log.info("checkCpnValidation params.getAvailStdt : {}" , params.getAvailStdt());
|
|
|
|
|
+ if(date2.before(date1)) {
|
|
|
throw new IllegalStateException("유효기간 종료날짜가 시작날짜보다 작습니다.");
|
|
throw new IllegalStateException("유효기간 종료날짜가 시작날짜보다 작습니다.");
|
|
|
}
|
|
}
|
|
|
} catch (ParseException exception) {
|
|
} catch (ParseException exception) {
|
|
@@ -165,14 +137,14 @@ public class TsaCouponService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 직접다운로드인 경우 기간 체크
|
|
// 직접다운로드인 경우 기간 체크
|
|
|
- if (params.getDnGb() != null && params.getDnGb().equals("G058_20")) {
|
|
|
|
|
|
|
+ if(params.getDnGb() != null && params.getDnGb().equals("G058_20")) {
|
|
|
try {
|
|
try {
|
|
|
Date date1 = format.parse(params.getDownStdt());
|
|
Date date1 = format.parse(params.getDownStdt());
|
|
|
Date date2 = format.parse(params.getDownEddt());
|
|
Date date2 = format.parse(params.getDownEddt());
|
|
|
|
|
|
|
|
- log.info("checkCpnValidation params.getDownStdt() : {}", params.getDownStdt());
|
|
|
|
|
- log.info("checkCpnValidation params.getDownEddt : {}", params.getDownEddt());
|
|
|
|
|
- if (date2.before(date1)) {
|
|
|
|
|
|
|
+ log.info("checkCpnValidation params.getDownStdt() : {}" , params.getDownStdt());
|
|
|
|
|
+ log.info("checkCpnValidation params.getDownEddt : {}" , params.getDownEddt());
|
|
|
|
|
+ if(date2.before(date1)) {
|
|
|
throw new IllegalStateException("다운로드 종료날짜가 시작날짜보다 작습니다.");
|
|
throw new IllegalStateException("다운로드 종료날짜가 시작날짜보다 작습니다.");
|
|
|
}
|
|
}
|
|
|
} catch (ParseException exception) {
|
|
} catch (ParseException exception) {
|
|
@@ -180,14 +152,14 @@ public class TsaCouponService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 첫구매 적용하는 경우 날짜 체크
|
|
// 첫구매 적용하는 경우 날짜 체크
|
|
|
- if (params.getFirstYn() != null && params.getFirstYn().equals("Y")) {
|
|
|
|
|
|
|
+ if(params.getFirstYn() != null && params.getFirstYn().equals("Y")) {
|
|
|
try {
|
|
try {
|
|
|
Date date1 = format.parse(params.getBuyStdt());
|
|
Date date1 = format.parse(params.getBuyStdt());
|
|
|
Date date2 = format.parse(params.getBuyEddt());
|
|
Date date2 = format.parse(params.getBuyEddt());
|
|
|
|
|
|
|
|
- log.info("checkCpnValidation params.getBuyStdt() : {}", params.getBuyStdt());
|
|
|
|
|
- log.info("checkCpnValidation params.getBuyEddt : {}", params.getBuyEddt());
|
|
|
|
|
- if (date2.before(date1)) {
|
|
|
|
|
|
|
+ log.info("checkCpnValidation params.getBuyStdt() : {}" , params.getBuyStdt());
|
|
|
|
|
+ log.info("checkCpnValidation params.getBuyEddt : {}" , params.getBuyEddt());
|
|
|
|
|
+ if(date2.before(date1)) {
|
|
|
throw new IllegalStateException("첫구매 종료날짜가 시작날짜보다 작습니다.");
|
|
throw new IllegalStateException("첫구매 종료날짜가 시작날짜보다 작습니다.");
|
|
|
}
|
|
}
|
|
|
} catch (ParseException exception) {
|
|
} catch (ParseException exception) {
|
|
@@ -195,7 +167,7 @@ public class TsaCouponService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 신규회원여부 적용하는 경우 날짜 체크
|
|
// 신규회원여부 적용하는 경우 날짜 체크
|
|
|
- if (params.getCustJoinYn() != null && params.getCustJoinYn().equals("Y")) {
|
|
|
|
|
|
|
+ if(params.getCustJoinYn() != null && params.getCustJoinYn().equals("Y")) {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|