|
|
@@ -63,68 +63,109 @@ public class TsaCouponService {
|
|
|
couponDao.couponInsert(params);
|
|
|
|
|
|
Gson gson = new Gson();
|
|
|
+ Integer sequence;
|
|
|
// 적용대상 - 공급업체
|
|
|
Collection<Coupon> supplyCompList = gson.fromJson(params.getSupplyCompList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
for(Coupon supplyComp : supplyCompList) {
|
|
|
- Integer sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
+ sequence = null;
|
|
|
+ if(supplyComp.getCpnRefvalSq() != null && supplyComp.getCpnRefvalSq() > 0){
|
|
|
+ sequence = supplyComp.getCpnRefvalSq();
|
|
|
+ } else {
|
|
|
+ sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
+ }
|
|
|
+
|
|
|
supplyComp.setCpnId(cpnId);
|
|
|
supplyComp.setCpnRefvalSq(sequence);
|
|
|
supplyComp.setCpnTarget("G260_13");
|
|
|
supplyComp.setRefVal(supplyComp.getSupplyCompCd());
|
|
|
+ supplyComp.setRegNo(TsaSession.getInfo().getUserNo());
|
|
|
+ supplyComp.setUpdNo(TsaSession.getInfo().getUserNo());
|
|
|
couponDao.saveCouponRefVal(supplyComp);
|
|
|
}
|
|
|
// 적용대상 - 브랜드
|
|
|
Collection<Coupon> brandList = gson.fromJson(params.getBrandList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
for(Coupon brand : brandList) {
|
|
|
- Integer sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
+ sequence = null;
|
|
|
+ if(brand.getCpnRefvalSq() != null && brand.getCpnRefvalSq() > 0){
|
|
|
+ sequence = brand.getCpnRefvalSq();
|
|
|
+ } else {
|
|
|
+ sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
+ }
|
|
|
+
|
|
|
brand.setCpnId(cpnId);
|
|
|
brand.setCpnRefvalSq(sequence);
|
|
|
brand.setCpnTarget("G260_12");
|
|
|
brand.setRefVal(brand.getBrandCd());
|
|
|
+ brand.setRegNo(TsaSession.getInfo().getUserNo());
|
|
|
+ brand.setUpdNo(TsaSession.getInfo().getUserNo());
|
|
|
+
|
|
|
couponDao.saveCouponRefVal(brand);
|
|
|
}
|
|
|
// 적용대상 - 적용상품
|
|
|
Collection<Coupon> applyGoodsList = gson.fromJson(params.getApplyGoodsList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
for(Coupon applyGoods : applyGoodsList ) {
|
|
|
- Integer sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
+ sequence = null;
|
|
|
+ if(applyGoods.getCpnRefvalSq() != null && applyGoods.getCpnRefvalSq() > 0){
|
|
|
+ sequence = applyGoods.getCpnRefvalSq();
|
|
|
+ } else {
|
|
|
+ sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
+ }
|
|
|
applyGoods.setCpnId(cpnId);
|
|
|
applyGoods.setCpnRefvalSq(sequence);
|
|
|
applyGoods.setCpnTarget("G260_10");
|
|
|
applyGoods.setRefVal(applyGoods.getGoodsCd());
|
|
|
+ applyGoods.setRegNo(TsaSession.getInfo().getUserNo());
|
|
|
+ applyGoods.setUpdNo(TsaSession.getInfo().getUserNo());
|
|
|
+
|
|
|
couponDao.saveCouponRefVal(applyGoods);
|
|
|
}
|
|
|
// 적용대상 - 카테고리
|
|
|
Collection<Coupon> cateList = gson.fromJson(params.getCateList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
for(Coupon cate : cateList ) {
|
|
|
- Integer sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
+ sequence = null;
|
|
|
+ if(cate.getCpnRefvalSq() != null && cate.getCpnRefvalSq() > 0){
|
|
|
+ sequence = cate.getCpnRefvalSq();
|
|
|
+ } else {
|
|
|
+ sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
+ }
|
|
|
cate.setCpnId(cpnId);
|
|
|
cate.setCpnRefvalSq(sequence);
|
|
|
cate.setCpnTarget("G260_11");
|
|
|
cate.setRefVal(cate.getCateNo());
|
|
|
cate.setRefFormalGb(cate.getFormalGb());
|
|
|
cate.setRefBrandCd(cate.getBrandCd()); // ag-grid 브랜드코드
|
|
|
+ cate.setRegNo(TsaSession.getInfo().getUserNo());
|
|
|
+ cate.setUpdNo(TsaSession.getInfo().getUserNo());
|
|
|
+
|
|
|
couponDao.saveCouponRefVal(cate);
|
|
|
}
|
|
|
// 적용대상 - 제외상품
|
|
|
Collection<Coupon> exceptGoodsList = gson.fromJson(params.getExceptGoodsList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
for(Coupon exceptGoods: exceptGoodsList ) {
|
|
|
- Integer sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
+ sequence = null;
|
|
|
+ if(exceptGoods.getCpnRefvalSq() != null && exceptGoods.getCpnRefvalSq() > 0){
|
|
|
+ sequence = exceptGoods.getCpnRefvalSq();
|
|
|
+ } else {
|
|
|
+ sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
+ }
|
|
|
exceptGoods.setCpnId(cpnId);
|
|
|
exceptGoods.setCpnRefvalSq(sequence);
|
|
|
exceptGoods.setCpnTarget("G260_14");
|
|
|
exceptGoods.setRefVal(exceptGoods.getGoodsCd());
|
|
|
+ exceptGoods.setRegNo(TsaSession.getInfo().getUserNo());
|
|
|
+ exceptGoods.setUpdNo(TsaSession.getInfo().getUserNo());
|
|
|
+
|
|
|
couponDao.saveCouponRefVal(exceptGoods);
|
|
|
}
|
|
|
// 입점업체분담율
|
|
|
Collection<Coupon> burdenList = gson.fromJson(params.getBurdenList() , new TypeToken<Collection<Coupon>>(){}.getType());
|
|
|
for(Coupon burden: burdenList ) {
|
|
|
- Integer sequence = commonService.getNextSequence("SEQ_COUPON_REFVAL");
|
|
|
burden.setCpnId(cpnId);
|
|
|
- burden.setCpnTarget("G260_10");
|
|
|
+ burden.setRegNo(TsaSession.getInfo().getUserNo());
|
|
|
+ burden.setUpdNo(TsaSession.getInfo().getUserNo());
|
|
|
+
|
|
|
couponDao.saveCouponBurden(burden);
|
|
|
}
|
|
|
- //checkCpnValidation(params);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -149,77 +190,6 @@ public class TsaCouponService {
|
|
|
return couponDao.getCouponListCnt(param);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 쿠폰 벨리데이션 체크
|
|
|
- * @param params
|
|
|
- * @author xyzp1539
|
|
|
- * @since 2021-01-12
|
|
|
- */
|
|
|
- public void checkCpnValidation(Coupon params) {
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- // 할인율이면 100% 초과 체크하기
|
|
|
- if(params.getDcWay() != null && params.getDcWay().equals("G240_11")) {
|
|
|
- if(params.getDcAval() > 100) {
|
|
|
- throw new IllegalStateException("모바일 앱 할인율은 100을 초과할수 없습니다.");
|
|
|
- } else if(params.getDcPval() > 100) {
|
|
|
- throw new IllegalStateException("PC할인율은 100을 초과할수 없습니다.");
|
|
|
- } else if(params.getDcMval() > 100) {
|
|
|
- throw new IllegalStateException("모바일 웹 100을 초과할수 없습니다.");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 기간/일수구분이 일수인 경우 날짜 체크
|
|
|
- if(params.getPdGb() != null && params.getPdGb().equals("D")) {
|
|
|
- try {
|
|
|
- Date date1 = format.parse(params.getAvailStdt());
|
|
|
- Date date2 = format.parse(params.getAvailEddt());
|
|
|
-
|
|
|
- log.info("checkCpnValidation params.getAvailEddt() : {}" , params.getAvailEddt());
|
|
|
- log.info("checkCpnValidation params.getAvailStdt : {}" , params.getAvailStdt());
|
|
|
- if(date2.before(date1)) {
|
|
|
- throw new IllegalStateException("유효기간 종료날짜가 시작날짜보다 작습니다.");
|
|
|
- }
|
|
|
- } catch (ParseException exception) {
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 직접다운로드인 경우 기간 체크
|
|
|
- if(params.getDnGb() != null && params.getDnGb().equals("G058_20")) {
|
|
|
- try {
|
|
|
- Date date1 = format.parse(params.getDownStdt());
|
|
|
- Date date2 = format.parse(params.getDownEddt());
|
|
|
-
|
|
|
- log.info("checkCpnValidation params.getDownStdt() : {}" , params.getDownStdt());
|
|
|
- log.info("checkCpnValidation params.getDownEddt : {}" , params.getDownEddt());
|
|
|
- if(date2.before(date1)) {
|
|
|
- throw new IllegalStateException("다운로드 종료날짜가 시작날짜보다 작습니다.");
|
|
|
- }
|
|
|
- } catch (ParseException exception) {
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 첫구매 적용하는 경우 날짜 체크
|
|
|
- if(params.getFirstYn() != null && params.getFirstYn().equals("Y")) {
|
|
|
- try {
|
|
|
- Date date1 = format.parse(params.getBuyStdt());
|
|
|
- Date date2 = format.parse(params.getBuyEddt());
|
|
|
-
|
|
|
- log.info("checkCpnValidation params.getBuyStdt() : {}" , params.getBuyStdt());
|
|
|
- log.info("checkCpnValidation params.getBuyEddt : {}" , params.getBuyEddt());
|
|
|
- if(date2.before(date1)) {
|
|
|
- throw new IllegalStateException("첫구매 종료날짜가 시작날짜보다 작습니다.");
|
|
|
- }
|
|
|
- } catch (ParseException exception) {
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 신규회원여부 적용하는 경우 날짜 체크
|
|
|
- if(params.getCustJoinYn() != null && params.getCustJoinYn().equals("Y")) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 쿠폰조회 목록
|
|
|
* @param coupon - 쿠폰 정보
|
|
|
@@ -342,4 +312,17 @@ public class TsaCouponService {
|
|
|
public ArrayList<Coupon> getCouponBurdenList(String cpnId) {
|
|
|
return couponDao.getCouponBurdenList(cpnId);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 쿠폰 적용대상 삭제
|
|
|
+ * @param coupon
|
|
|
+ * @return
|
|
|
+ * @author xyzp1539
|
|
|
+ * @since 2021-01-19
|
|
|
+ */
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public void updateCouponRefval(Coupon coupon) {
|
|
|
+ coupon.setUpdNo(TsaSession.getInfo().getUserNo());
|
|
|
+ couponDao.updateCouponRefval(coupon);
|
|
|
+ }
|
|
|
}
|