Selaa lähdekoodia

상품쿠폰다운받기

eskim 5 vuotta sitten
vanhempi
commit
d7bfe607ca

+ 66 - 61
src/main/java/com/style24/front/biz/service/TsfCouponService.java

@@ -39,10 +39,10 @@ public class TsfCouponService {
 
 	@Autowired
 	private TscOrderService coreOrderService;
-	
+
 	@Autowired
 	private TsfOrderService orderService;
-	
+
 	@Autowired
 	private TsfCustomerService customerService;
 
@@ -65,9 +65,9 @@ public class TsfCouponService {
 	 * @since 2021. 02. 16
 	 */
 	public Coupon serialCpnApplyInfo(Coupon param) {
-		
+
 		// TODO 로그인 정보 입력
-		if(TsfSession.isLogin()) {
+		if (TsfSession.isLogin()) {
 			Login login = TsfSession.getInfo();
 			param.setCustNo(login.getCustNo());
 			param.setRegNo(login.getCustNo());
@@ -80,18 +80,18 @@ public class TsfCouponService {
 		Coupon cpn = couponDao.getSearchSerialCpnInfo(param);
 
 		// 다운로드 받을 수 있는 쿠폰이 있으면
-		if(cpn != null && cpn.getCpnId() > 0) {
+		if (cpn != null && cpn.getCpnId() > 0) {
 			// 다운 받을 수 있는 쿠폰ID를 내가 받은 이력이 있는지 확인
 			cpn.setCustNo(param.getCustNo());
 			Coupon myCpn = couponDao.getSerialCpnUseInfo(cpn);
 
 			// 다운로드 받은 쿠폰이 있는 경우
-			if(myCpn != null && myCpn.getCpnId() > 0) {
+			if (myCpn != null && myCpn.getCpnId() > 0) {
 				// 이미 다운 받았고, 사용 한 쿠폰이 있을 경우 종료
-				if(!StringUtils.isEmpty(myCpn.getUsedDt())) {
+				if (!StringUtils.isEmpty(myCpn.getUsedDt())) {
 					cpn.setResult("해당 쿠폰은 이미 사용하신 쿠폰입니다.");
 					return cpn;
-				} else if("N".equals(myCpn.getAvailYn())) {
+				} else if ("N".equals(myCpn.getAvailYn())) {
 					cpn.setResult("지급 받으신 쿠폰의 유효기간이 아닙니다.");
 					return cpn;
 				}
@@ -115,13 +115,12 @@ public class TsfCouponService {
 
 		// 2021.03.03 장바구니 시퀀스 없음 jsh77b 
 		// 장바구니쿠폰 토탈 할인 금액 계산
-		if (param.getCartSqArr() != null ) {
+		if (param.getCartSqArr() != null) {
 			param.setCpnId(cpn.getCpnId());
 			cpn.setDcAmt(getCartCpnApplyTotalAmt(param));
 		} else {
 			Order order = new Order();
-			
-			
+
 			/*
 			// 3. 할인구간정보조회
 			// 3.2 상품쿠폰, 장바구니쿠폰 목록 조회
@@ -136,15 +135,9 @@ public class TsfCouponService {
 			// 3.2.2 장바구니쿠폰기준 ---> 상품목록
 			cartCpnList = coreOrderService.getCartCpnApplyList(tmtbGoodsApplyList, cartCpnList);
 			*/
-			
-			
-			
-			
-			
+
 		}
-		
-		
-		
+
 		cpn.setResult("SUCCESS");
 
 		return cpn;
@@ -164,11 +157,11 @@ public class TsfCouponService {
 		int totCurrPrice = 0;
 		int maxDcAmt = 0;
 		int buyLimitAmt = 0;
-		if(param != null && param.getCartSqArr().length > 0) {
+		if (param != null && param.getCartSqArr().length > 0) {
 			Collection<Order> serialGoodsList = coreOrderService.getSerialCpnApplyGoodsList(order);
 			for (int i = 0; i < param.getCartSqArr().length; i++) {
 				for (Order cpnInfo : serialGoodsList) {
-					if("A".equals(cpnInfo.getApplyScope()) || param.getCartSqArr()[i] == cpnInfo.getCartSq()) {
+					if ("A".equals(cpnInfo.getApplyScope()) || param.getCartSqArr()[i] == cpnInfo.getCartSq()) {
 						cpnInfo.setCurrPrice(param.getCurrPrices()[i]);
 					}
 				}
@@ -187,7 +180,7 @@ public class TsfCouponService {
 				}
 			}
 
-			if(totCurrPrice < totDcAmt) {
+			if (totCurrPrice < totDcAmt) {
 				totDcAmt = totCurrPrice;
 			}
 
@@ -236,10 +229,10 @@ public class TsfCouponService {
 	@Transactional("shopTxnManager")
 	public int createCustGradeAllCoupon(Coupon coupon) {
 		int count = 0;
-		
+
 		Collection<Coupon> couponList = couponDao.getCustGradeCouponInfo(coupon);
-		
-		for(Coupon tmpCoupon : couponList) {
+
+		for (Coupon tmpCoupon : couponList) {
 			int downloadCnt = tmpCoupon.getDownloadCnt();
 			for (int i = 0; i < downloadCnt; i++) {
 				CustCoupon custCoupon = new CustCoupon();
@@ -257,7 +250,7 @@ public class TsfCouponService {
 				count++;
 			}
 		}
-		
+
 		return count;
 	}
 
@@ -282,7 +275,7 @@ public class TsfCouponService {
 			custCoupon.setRegNo(coupon.getCustNo());
 		}
 	}
-	
+
 	/**
 	 * 상품 쿠폰 조회
 	 * @param goods
@@ -293,7 +286,7 @@ public class TsfCouponService {
 	public Collection<Coupon> getGoodsCouponList(Goods goods) {
 		return couponDao.getGoodsCouponList(goods);
 	}
-	
+
 	/**
 	 * 상품 쿠폰 다운 처리
 	 *
@@ -303,78 +296,90 @@ public class TsfCouponService {
 	 * @since 2021.03.12
 	 */
 	@Transactional("shopTxnManager")
-	public int createGoodsCoupon(Goods goods) {
-		int result = 0;
+	public String createGoodsCoupon(Goods goods) {
+		String result = "SUCESS";
 		int downloadCnt = 1; 	// 쿠폰당 다운 받을수
-		
+
 		log.info("상품쿠폰 발급전 정보 goods {}", goods);
-		// 10: 발급가능 쿠폰없음, 20: 발급완료 쿠폰, 30: 발급받은 쿠폰
-		//죄송합니다. 쿠폰이 모두 소진되었습니다
-		//죄송합니다. 해당 쿠폰은 다운로드가 불가합니다.
-		
-		Collection<Coupon> goodsCouponList  = couponDao.getGoodsCouponList(goods);
+
+		Collection<Coupon> goodsCouponList = couponDao.getGoodsCouponList(goods);
 		if (goodsCouponList == null || goodsCouponList.isEmpty()) {
-			result = 10;
+			result = "ERROR_10";
 			return result;
 		}
-		
+
 		Coupon coupon = goodsCouponList.iterator().next();
 		log.info("상품쿠폰 쿠폰정보  coupon {}", coupon);
-		
+
+		// 발급수 확인 -- 필요없나?
+		if (coupon.getTotPubLimitQty() > 0) {
+			if (coupon.getTotPubLimitQty() <= coupon.getCustCouponCnt()) {
+				log.info("상품쿠폰 다운  skip: 쿠폰발급수 : {}, 회원발급수 : {}", coupon.getTotPubLimitQty(), coupon.getCustCouponCnt());
+				result = "ERROR_30";
+				return result;
+			}
+		}
+
 		// 회원정보 확인 - 발급등급,첫구매, 신규회원, 제휴링크
-		
+
 		// 회원등급 USABLE_CUST_GRADE
 		if (coupon.getUsableCustGrade().indexOf(goods.getCustGrade()) < 0) {
-			result = 10;
+			log.info("상품쿠폰 다운  skip: 쿠폰등급 : {}, 회원등급 : {}", coupon.getUsableCustGrade(), goods.getCustGrade());
+			result = "ERROR_20";
 			return result;
 		}
-		
+
 		// 첫구매여부 (Y:구매이력이없음 | N:구매이력있음) - 구매기간일자 해당기간에 구매이력이 없으면 다운로드 가능
 		if ("Y".equals(coupon.getFirstOrdYn())) {
 			int firstOrdcnt = orderService.getCustFirstOrderCount(coupon);
 			if (firstOrdcnt > 0) {
-				result = 10;
-				return result;	
+				log.info("상품쿠폰 다운  skip: 쿠폰첫구매정보 : {}, {} ~ {} ", coupon.getFirstOrdYn(), coupon.getBuyStdt(), coupon.getBuyEddt());
+				result = "ERROR_20";
+				return result;
 			}
 		}
-		
+
 		// 신규회원 NEW_CUST_YN
 		if ("Y".equals(coupon.getNewCustYn())) {
 			Customer customer = customerService.getCustomerFindByCustNo(goods.getCustNo());
-			if (customer == null || StringUtils.isEmpty(customer.getJoinDt()) ) {
-				result = 10;
-				return result;	
+			if (customer == null || StringUtils.isEmpty(customer.getJoinDt())) {
+				log.info("상품쿠폰 다운  skip: 쿠폰 신규회원정보 : {} 회원정보 없음", coupon.getCustNo());
+				result = "ERROR_20";
+				return result;
 			}
 			log.info("고객정보 customer {}", customer);
-			if (Integer.parseInt(customer.getJoinDt()) < Integer.parseInt(coupon.getCustJoinStdt()) || 
-				Integer.parseInt(customer.getJoinDt()) > Integer.parseInt(coupon.getCustJoinEddt()) ) {
-				result = 10;
-				return result;	
+			if (Integer.parseInt(customer.getJoinDt()) < Integer.parseInt(coupon.getCustJoinStdt()) ||
+				Integer.parseInt(customer.getJoinDt()) > Integer.parseInt(coupon.getCustJoinEddt())) {
+				log.info("상품쿠폰 다운  skip: 쿠폰 신규회원정보 : {}, {} ~ {} ", customer.getJoinDt(), coupon.getCustJoinStdt(), coupon.getCustJoinEddt());
+				result = "ERROR_20";
+				return result;
 			}
 		}
-		
+
 		// 제휴링크 나중에 확인하자!!!!!
-		
-		for(Coupon tmpCoupon : goodsCouponList) {
+
+		int count = 0;
+		for (Coupon tmpCoupon : goodsCouponList) {
 
 			for (int i = 0; i < downloadCnt; i++) {
 				CustCoupon custCoupon = new CustCoupon();
-				custCoupon.setCustNo(tmpCoupon.getCustNo());
+				custCoupon.setCustNo(TsfSession.getInfo().getCustNo());
 				custCoupon.setCpnId(tmpCoupon.getCpnId());
 				custCoupon.setAvailStdt(tmpCoupon.getAvailStdt());
 				custCoupon.setAvailEddt(tmpCoupon.getAvailEddt());
 				custCoupon.setPubReason(TscConstants.PubReason.DOWNLOAD.value());
 				custCoupon.setEndAlimSendYn("N");		// 알림 발송 여부(발송되면 Y)
-				custCoupon.setRegNo(tmpCoupon.getCustNo());
-				custCoupon.setUpdNo(tmpCoupon.getCustNo());
+				custCoupon.setRegNo(TsfSession.getInfo().getCustNo());
+				custCoupon.setUpdNo(TsfSession.getInfo().getCustNo());
 
 				log.info("상품쿠폰 고객 다운로드 custCoupon {}", custCoupon);
-				// coreCouponDao.saveCouponCustPub(custCoupon);
+				coreCouponDao.saveCouponCustPub(custCoupon);
 
-				result++;
+				count++;
 			}
 		}
-		
+		result = Integer.toString(count);	// 다운받은 쿠폰수
+
 		return result;
 	}
 }

+ 15 - 24
src/main/java/com/style24/front/biz/service/TsfGoodsService.java

@@ -41,7 +41,7 @@ public class TsfGoodsService {
 
 	@Autowired
 	private TsfGoodsDao goodsDao;
-	
+
 	@Autowired
 	private TsfCouponService couponService;
 
@@ -414,7 +414,7 @@ public class TsfGoodsService {
 	public GoodsSafeNo getGoodsSafeNo(Goods goods) {
 		return goodsDao.getGoodsSafeNo(goods);
 	}
-	
+
 	/**
 	 * 상품  배송안내정보
 	 * @param goodsCd
@@ -425,7 +425,7 @@ public class TsfGoodsService {
 	public Delivery getGoodsDeliveryInfo(String goodsCd) {
 		return goodsDao.getGoodsDeliveryInfo(goodsCd);
 	}
-	
+
 	/**
 	 * 상품 다다익선 목록
 	 * @param goods
@@ -436,7 +436,7 @@ public class TsfGoodsService {
 	public Collection<Goods> getTmtbGoodsList(Goods goods) {
 		return goodsDao.getTmtbGoodsList(goods);
 	}
-	
+
 	/**
 	 * 재입고 알림 미 알림 조회
 	 * @param goods
@@ -447,7 +447,7 @@ public class TsfGoodsService {
 	public ReinboundInform getNotReinboundInform(ReinboundInform reinboundInform) {
 		return goodsDao.getNotReinboundInform(reinboundInform);
 	}
-	
+
 	/**
 	 * 재입고알림 생성
 	 * @param goods
@@ -459,7 +459,7 @@ public class TsfGoodsService {
 	public void createReinboundInform(ReinboundInform reinboundInform) {
 		goodsDao.createReinboundInform(reinboundInform);
 	}
-	
+
 	/**
 	 * 재입고알림 수정
 	 * @param goods
@@ -471,7 +471,7 @@ public class TsfGoodsService {
 	public void updateReinboundInform(ReinboundInform reinboundInform) {
 		goodsDao.updateReinboundInform(reinboundInform);
 	}
-	
+
 	/**
 	 * 재입고 알림 신청 저장
 	 *
@@ -490,19 +490,19 @@ public class TsfGoodsService {
 		reinboundInform.setCustNo(TsfSession.getInfo().getCustNo());
 		reinboundInform.setRegNo(TsfSession.getInfo().getCustNo());
 		reinboundInform.setUpdNo(TsfSession.getInfo().getCustNo());
-		
+
 		// 미알림 조회
 		ReinboundInform tmpReinboundInform = goodsDao.getNotReinboundInform(reinboundInform);
-		
+
 		if (tmpReinboundInform == null || tmpReinboundInform.getRinbdInfoSq() <= 0) {
 			goodsDao.createReinboundInform(reinboundInform);
-		}else {
+		} else {
 			reinboundInform.setRinbdInfoSq(tmpReinboundInform.getRinbdInfoSq());
 			goodsDao.updateReinboundInform(reinboundInform);
 		}
 
 	}
-	
+
 	/**
 	 * 실측사이즈 조회
 	 *
@@ -514,7 +514,7 @@ public class TsfGoodsService {
 	public Collection<Measurement> getMeasurementList(Goods goods) {
 		return goodsDao.getMeasurementList(goods);
 	}
-	
+
 	/**
 	 * 사이즈 정보 조회
 	 *
@@ -526,7 +526,7 @@ public class TsfGoodsService {
 	public Collection<SizeInfo> getSizeInfoList(SizeInfo sizeInfo) {
 		return goodsDao.getSizeInfoList(sizeInfo);
 	}
-	
+
 	/**
 	 * 상품 쿠폰 다운 처리
 	 *
@@ -536,16 +536,7 @@ public class TsfGoodsService {
 	 * @since 2021.03.15
 	 */
 	@Transactional("shopTxnManager")
-	public int createGoodsCoupon(Goods goods) {
-		int count = 0;
-		
-		// 쿠폰발급
-		int result = couponService.createGoodsCoupon(goods);
-		
-		//리턴정보 확인
-		//죄송합니다. 쿠폰이 모두 소진되었습니다
-		//죄송합니다. 해당 쿠폰은 다운로드가 불가합니다.
-		
-		return count;
+	public String createGoodsCoupon(Goods goods) {
+		return couponService.createGoodsCoupon(goods);
 	}
 }

+ 65 - 52
src/main/java/com/style24/front/biz/web/TsfGoodsController.java

@@ -67,9 +67,9 @@ public class TsfGoodsController extends TsfBaseController {
 
 	@Autowired
 	private TscLookbookService coreLookbookService;
-	
+
 	@Autowired
-	private TsfCouponService couponService; 
+	private TsfCouponService couponService;
 
 	@Value("${has-ssl}")
 	private String hasSsl;
@@ -225,7 +225,7 @@ public class TsfGoodsController extends TsfBaseController {
 				mav.setViewName(super.getDeviceViewName("goods/GoodsDetailForm"));
 			}
 		}
-		
+
 		return mav;
 	}
 
@@ -242,9 +242,10 @@ public class TsfGoodsController extends TsfBaseController {
 		goods.setIsApp(TsfSession.getAttribute("isApp"));	//앱여부 true
 		goods.setSiteCd(TscConstants.Site.STYLE24.value());
 		goods.setAfLinkCd(TsfSession.getAttribute("afLinkCd"));
-//		goods.setSoldoutGoodsDisplayYn(envsetService.getSoldoutGoodsDisplayYn(TscConstants.Site.STYLE24.value())); // 품절상품노출여부
+		goods.setSoldoutGoodsDisplayYn(envsetService.getSoldoutGoodsDisplayYn(TscConstants.Site.STYLE24.value())); // 품절상품노출여부
 		goods.setPointUnit(envsetService.getPayUnit(TscConstants.Site.STYLE24.value())); // 10:원단위절사(int)
 		goods.setFloorUnit(envsetService.getPayUnit(TscConstants.Site.STYLE24.value()));
+
 		// 회원 구분
 		if (TsfSession.getInfo() != null) {
 			goods.setCustGb(TsfSession.getInfo().getCustGb());
@@ -413,17 +414,17 @@ public class TsfGoodsController extends TsfBaseController {
 		paramsGoods.setGoodsCd(goodsCd);
 		setGoods(paramsGoods);
 		Goods goods = goodsService.getGoodsInfo(paramsGoods);
-		
+
 		// 배송업체명, 반품비, 교환비, 주소
 		mav.addObject("deliveryInfo", goodsService.getGoodsDeliveryInfo(goodsCd));
-		
+
 		// 상품 기본정보
 		mav.addObject("goodsInfo", goods);
 
 		mav.setViewName(super.getDeviceViewName("goods/GoodsDeliveryForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 -  쿠폰 레이어
 	 * @return
@@ -443,7 +444,7 @@ public class TsfGoodsController extends TsfBaseController {
 		mav.addObject("goodsCouponList", couponService.getGoodsCouponList(paramsGoods));
 		// 상품 기본정보
 		mav.addObject("params", paramsGoods);
-		
+
 		//mav.addObject("goodsInfo", goods);
 
 		mav.setViewName(super.getDeviceViewName("goods/GoodsCouponForm"));
@@ -464,14 +465,14 @@ public class TsfGoodsController extends TsfBaseController {
 		paramsGoods.setGoodsCd(goodsCd);
 		setGoods(paramsGoods);
 		Goods goods = goodsService.getGoodsInfo(paramsGoods);
-		
+
 		// 상품 기본정보
 		mav.addObject("goodsInfo", goods);
 
 		mav.setViewName(super.getDeviceViewName("goods/GoodsShopBenefitForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 -  사이즈 레이어
 	 * @return
@@ -487,43 +488,43 @@ public class TsfGoodsController extends TsfBaseController {
 		paramsGoods.setColorCd(colorCd);
 		setGoods(paramsGoods);
 		Goods goods = goodsService.getGoodsInfo(paramsGoods);
-		
+
 		// 상품 기본정보
 		mav.addObject("goodsInfo", goods);
-		
+
 		// 실측 사이즈 정보 - 자사상품만
 		String typeCd = "";
 		String typeWith = "";
-		Collection<Measurement> measurementList= new ArrayList<Measurement>();
+		Collection<Measurement> measurementList = new ArrayList<Measurement>();
 		if ("Y".equals(goods.getSelfGoodsYn())) {
 			paramsGoods.setOptCd1(colorCd);
 			measurementList = goodsService.getMeasurementList(paramsGoods);
 			if (measurementList != null && !measurementList.isEmpty()) {
-				typeCd =  measurementList.iterator().next().getTypecd();
+				typeCd = measurementList.iterator().next().getTypecd();
 				if ("하의".equals(typeCd)) {
-					typeWith =  Integer.toString(((int)Math.floor(100 / 6)));
+					typeWith = Integer.toString(((int)Math.floor(100 / 6)));
 				}
 			}
 		}
-		
+
 		// 표준사이즈 - 공통
 		SizeInfo sizeInfo = new SizeInfo();
 		sizeInfo.setSizeGb("1"); 	// 사이즈구분정보 1:표준사이즈. 2:측정사이즈
 		sizeInfo.setSizeCate1Cd("00"); 	// 사이즈카테고리1 표준사이즈일경우   공통(00),자사브랜드코드)
 		Collection<SizeInfo> commonSizeInfoList = goodsService.getSizeInfoList(sizeInfo);
-		
+
 		// 표준사이즈 - 자사브랜드
-		Collection<SizeInfo> brandSizeInfoList =  new ArrayList<SizeInfo>();
+		Collection<SizeInfo> brandSizeInfoList = new ArrayList<SizeInfo>();
 		if ("Y".equals(goods.getSelfGoodsYn())) {
 			sizeInfo.setSizeCate1Cd(goods.getBrandCd());	// 자사브랜드코드(브랜드그룹코드아님)
 			brandSizeInfoList = goodsService.getSizeInfoList(sizeInfo);
 		}
-		
+
 		// 측정사이즈
 		sizeInfo.setSizeGb("2");
 		sizeInfo.setSizeCate1Cd("");
-		Collection<SizeInfo> measurementSizeInfoList = goodsService.getSizeInfoList(sizeInfo);		
-		
+		Collection<SizeInfo> measurementSizeInfoList = goodsService.getSizeInfoList(sizeInfo);
+
 		mav.addObject("measurementList", measurementList);
 		mav.addObject("typeCd", typeCd);
 		mav.addObject("typeWith", typeWith);
@@ -534,7 +535,7 @@ public class TsfGoodsController extends TsfBaseController {
 		mav.setViewName(super.getDeviceViewName("goods/GoodsSizeInfoForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 -  재입고 레이어
 	 * @return
@@ -550,17 +551,17 @@ public class TsfGoodsController extends TsfBaseController {
 		paramsGoods.setColorCd(colorCd);
 		setGoods(paramsGoods);
 		Goods goods = goodsService.getGoodsInfo(paramsGoods);
-		
+
 		// 상품 기본정보
 		mav.addObject("goodsInfo", goods);
-		
+
 		// 자사 일반상품- 옵션2(사이즈) 정보
 		mav.addObject("goodsOption2List", goodsService.getGoodsOption2List(paramsGoods));
 
 		mav.setViewName(super.getDeviceViewName("goods/GoodsInstockAlarmForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 -  재입고 등록
 	 * @return
@@ -574,7 +575,7 @@ public class TsfGoodsController extends TsfBaseController {
 		goodsService.saveGoodsInstockAlarmForm(reinboundInform);
 		return super.ok("재입고 알림 신청이 완료되었습니다. 재입고 시 알림톡이 발송됩니다.");
 	}
-	
+
 	/**
 	 * 상품상세 -  상품평 레이어
 	 * @return
@@ -589,14 +590,14 @@ public class TsfGoodsController extends TsfBaseController {
 		paramsGoods.setGoodsCd(goodsCd);
 		setGoods(paramsGoods);
 		Goods goods = goodsService.getGoodsInfo(paramsGoods);
-		
+
 		// 상품 기본정보
 		mav.addObject("goodsInfo", goods);
 
 		mav.setViewName(super.getDeviceViewName("goods/GoodsReviewForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 -  상품평 - 베스트 레이어
 	 * @return
@@ -611,14 +612,14 @@ public class TsfGoodsController extends TsfBaseController {
 		paramsGoods.setGoodsCd(goodsCd);
 		setGoods(paramsGoods);
 		Goods goods = goodsService.getGoodsInfo(paramsGoods);
-		
+
 		// 상품 기본정보
 		mav.addObject("goodsInfo", goods);
 
 		mav.setViewName(super.getDeviceViewName("goods/GoodsReviewBestForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 -  상품평 - 포토/영상 리스트 레이어
 	 * @return
@@ -633,14 +634,14 @@ public class TsfGoodsController extends TsfBaseController {
 		paramsGoods.setGoodsCd(goodsCd);
 		setGoods(paramsGoods);
 		Goods goods = goodsService.getGoodsInfo(paramsGoods);
-		
+
 		// 상품 기본정보
 		mav.addObject("goodsInfo", goods);
 
 		mav.setViewName(super.getDeviceViewName("goods/GoodsReviewPhotoForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 -  상품평 - 포토/영상 상세 레이어
 	 * @return
@@ -655,14 +656,14 @@ public class TsfGoodsController extends TsfBaseController {
 		paramsGoods.setGoodsCd(goodsCd);
 		setGoods(paramsGoods);
 		Goods goods = goodsService.getGoodsInfo(paramsGoods);
-		
+
 		// 상품 기본정보
 		mav.addObject("goodsInfo", goods);
 
 		mav.setViewName(super.getDeviceViewName("goods/GoodsReviewPhotoDetailForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 - 다다익선 상품
 	 * 
@@ -684,7 +685,7 @@ public class TsfGoodsController extends TsfBaseController {
 		mav.setViewName(super.getDeviceViewName("goods/GoodsOtherForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 - 함께본 상품
 	 * 
@@ -693,7 +694,7 @@ public class TsfGoodsController extends TsfBaseController {
 	 * @since 2021. 3. 8
 	 */
 	@PostMapping("/detail/together/frame")
-	public ModelAndView goodsTogetherForm(Goods goods) {  
+	public ModelAndView goodsTogetherForm(Goods goods) {
 
 		ModelAndView mav = new ModelAndView();
 		// 상품관련 기본값 설정(회원 등급, 앱, PC/모바일 등)
@@ -706,7 +707,7 @@ public class TsfGoodsController extends TsfBaseController {
 		mav.setViewName(super.getDeviceViewName("goods/GoodsOtherForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 - 추천 상품
 	 * 
@@ -715,7 +716,7 @@ public class TsfGoodsController extends TsfBaseController {
 	 * @since 2021. 3. 8
 	 */
 	@PostMapping("/detail/recommend/frame")
-	public ModelAndView goodsRecommendForm(Goods goods) {  
+	public ModelAndView goodsRecommendForm(Goods goods) {
 
 		ModelAndView mav = new ModelAndView();
 		// 상품관련 기본값 설정(회원 등급, 앱, PC/모바일 등)
@@ -728,7 +729,7 @@ public class TsfGoodsController extends TsfBaseController {
 		mav.setViewName(super.getDeviceViewName("goods/GoodsOtherForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 상품상세 - 비슷한 상품
 	 * 
@@ -737,7 +738,7 @@ public class TsfGoodsController extends TsfBaseController {
 	 * @since 2021. 3. 8
 	 */
 	@PostMapping("/detail/like/frame")
-	public ModelAndView goodsLikeForm(Goods goods) {  
+	public ModelAndView goodsLikeForm(Goods goods) {
 
 		ModelAndView mav = new ModelAndView();
 		// 상품관련 기본값 설정(회원 등급, 앱, PC/모바일 등)
@@ -750,7 +751,7 @@ public class TsfGoodsController extends TsfBaseController {
 		mav.setViewName(super.getDeviceViewName("goods/GoodsOtherForm"));
 		return mav;
 	}
-	
+
 	/**
 	 * 고객의 상품쿠폰 발급. 고객이 상품쿠폰 다운로드 시 발급됨.
 	 *
@@ -765,24 +766,36 @@ public class TsfGoodsController extends TsfBaseController {
 	public GagaMap createGoodsCoupon(@RequestBody Goods goods) throws Exception {
 
 		GagaMap result = new GagaMap();
-		
+
 		// 상품관련 기본값 설정(회원 등급, 앱, PC/모바일 등)
 		setGoods(goods);
 		log.info("createGoodsCoupon  goods {}", goods);
-		
-		int couponResult = goodsService.createGoodsCoupon(goods);
-		
-		//result.set("goodsCouponList", couponService.getGoodsCouponList(paramsGoods));
-		
+
+		// 쿠폰발급
+		// ERROR_10: 발급가능 쿠폰없음, 20: 발급완료 쿠폰, 30: 발급받은 쿠폰
+		//죄송합니다. 쿠폰이 모두 소진되었습니다
+		//죄송합니다. 해당 쿠폰은 다운로드가 불가합니다.
+		String couponResult = goodsService.createGoodsCoupon(goods);
+
 		result.set("status", GagaResponseStatus.SUCCESS.getCode());
-		
-		if (couponResult == 0) {
-			//result.set("message", message.getMessage("COUPON_0002"));
+
+		if ("ERROR_10".equals(couponResult)) {
+			result.set("message", "발급가능 쿠폰이 없습니다.");
+		} else if ("ERROR_20".equals(couponResult)) {
+			result.set("message", "죄송합니다. 해당 쿠폰은 다운로드가 불가합니다.");
+		} else if ("ERROR_30".equals(couponResult)) {
+			result.set("message", "죄송합니다. 쿠폰이 모두 소진되었습니다.");
 		} else {
-			//result.set("message", message.getMessage("COUPON_0001", new Object[] {couponResult}));
+			if (goods.getArrCpnId() != null || goods.getArrCpnId().length > 0) {
+				result.set("message", couponResult + "개 쿠폰이 발급되었습니다.");
+			} else {
+				result.set("message", "쿠폰이 발급되었습니다.");
+			}
+
 		}
 		result.set("status", "200");
-
+		result.set("params", goods);
+		result.set("goodsCouponList", couponService.getGoodsCouponList(goods));
 		return result;
 	}
 }

+ 2 - 0
src/main/java/com/style24/persistence/domain/Cate4Srch.java

@@ -37,4 +37,6 @@ public class Cate4Srch extends TscBaseDomain {
 
 	private Integer brandGroupNo;	// 브랜드그룹번호
 
+	private String soldoutGoodsDispYn;
+
 }

+ 4 - 1
src/main/java/com/style24/persistence/domain/Goods.java

@@ -1,5 +1,6 @@
 package com.style24.persistence.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.style24.persistence.TscBaseDomain;
 
 import lombok.Data;
@@ -135,7 +136,9 @@ public class Goods extends TscBaseDomain {
 	private String goodsTopDesc;		// 40:상위컨텐츠, 60:상위컨텐츠-모바일
 	private String goodsDownDesc;		// 50:하위컨텐츠, 70:하위컨텐츠-모바일
 	private String goodsDesc;			// 80:상품상세(as-is,입점)
-	
+
 	private String goodsOtherGb;		// tmtb:다다익선상품, together:함께본상품  recommmend:추천상품  like: 비슷한상품
 
+	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+	private int[] arrCpnId;				// 쿠폰
 }

+ 10 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsfCoupon.xml

@@ -143,6 +143,7 @@
 		     , A.CPN_ID
 		     , A.CPN_NM
 		     , A.CUST_PUB_LIMIT_QTY
+		     , A.TOT_PUB_LIMIT_QTY
 		     , A.BUY_LIMIT_AMT
 		     , A.MAX_DC_AMT
 		     , A.CPN_TYPE
@@ -167,6 +168,7 @@
 		       , DC_VAL
 		       , DC_WAY
 		       , CUST_PUB_LIMIT_QTY
+		       , TOT_PUB_LIMIT_QTY
 		       , BUY_LIMIT_AMT
 		       , MAX_DC_AMT
 		       , CPN_TYPE
@@ -189,6 +191,7 @@
 		             , CP.MAX_DC_AMT                                          -- 최대할인금액
 		             , CP.CURR_PRICE                                          -- 즉시쿠폰적용판매가
 		             , CP.CUST_PUB_LIMIT_QTY                                  -- 1인당 발급제한수량
+		             , CP.TOT_PUB_LIMIT_QTY                                   -- 총발행제한수량(0은 무제한)
 		             , CP.BUY_LIMIT_AMT                                       -- 구매제한금액
 		             , CP.CPN_TYPE                                            -- 쿠폰타입
 		             , CP.AVAIL_STDT                                          -- 유효시작일시
@@ -217,6 +220,7 @@
 		                     , CP.MAX_DC_AMT
 		                     , CP.BUY_LIMIT_AMT
 		                     , CP.CUST_PUB_LIMIT_QTY
+		                     , CP.TOT_PUB_LIMIT_QTY
 		                     , CP.CPN_TYPE
 		                     , CP.NEW_CUST_YN
 		                     , DATE_FORMAT(CP.CUST_JOIN_STDT, '%Y%m%d%H%i%S') AS CUST_JOIN_STDT
@@ -235,6 +239,12 @@
 		                <if test="cpnId != null and cpnId != ''">
 		                AND    CP.CPN_ID = #{cpnId}
 		                </if>
+		                <if test="arrCpnId != null and arrCpnId != ''">
+		                AND    CP.CPN_ID IN
+		                <foreach collection="arrCpnId" item="item" index="index"  open="(" close=")" separator=",">
+		                UPPER(#{item})
+		                </foreach>
+		                </if>
 		                AND    CP.SITE_CD = #{siteCd}
 		                AND    CP.CPN_STAT = 'G232_11'   -- 쿠폰인 진행중인 쿠폰만
 		                <![CDATA[

+ 84 - 11
src/main/webapp/WEB-INF/views/web/goods/GoodsCouponFormWeb.html

@@ -40,10 +40,10 @@
 								</p>
 							</div>
 							<th:block th:if="${goodsCoupon.custPubLimitQty > 0 and goodsCoupon.custPubLimitQty <= goodsCoupon.custCouponCnt}">
-							<button type="button" class="btn btn_dark btn_block btn_coupon_down"  disabled="disabled"><span>받기완료</span></button>
+							<button type="button" class="btn btn_dark btn_block btn_coupon_down"   disabled="disabled"><span>받기완료</span></button>
 							</th:block>
 							<th:block th:unless="${goodsCoupon.custPubLimitQty > 0 and goodsCoupon.custPubLimitQty <= goodsCoupon.custCouponCnt}">
-							<button type="button" class="btn btn_dark btn_block btn_coupon_down" th:attr="cpnId=${goodsCoupon.cpnId}" onclick="goodsCouponDown(this);"><span>쿠폰받기</span></button>
+							<button type="button" class="btn btn_dark btn_block btn_coupon_down" th:attr="cpnId=${goodsCoupon.cpnId}" th:id="${'coupon_'+goodsCoupon.cpnId}" onclick="jfGoodsCouponDown(this);"><span>쿠폰받기</span></button>
 							</th:block>
 						</div>
 					</li>
@@ -52,7 +52,7 @@
 		</form>	
 		</div>
 		<div class="modal-footer">
-			<button type="button" class="btn btn_primary btn_all_cpdown" onclick="goodsCouponDownAll();"><span>쿠폰 모두 받기</span></button>
+			<button type="button" class="btn btn_primary btn_all_cpdown" onclick="jfGoodsCouponDownAll();"><span>쿠폰 모두 받기</span></button>
 		</div>
 	</div>
 </div>
@@ -61,7 +61,7 @@
 /*<![CDATA[*/
 
 	// 쿠폰 다운로드
-	var goodsCouponDown = function(obj){
+	var jfGoodsCouponDown = function(obj){
 	
 		if (!cfCheckLogin()) {
 			cfnGoToPage(_PAGE_LOGIN);
@@ -72,27 +72,95 @@
 		var cpnId = $obj.attr('cpnId');
 		var goodsCd = $('#goodsCouponForm input[name=goodsCd]').val();
 		
-		 gagajf.ajaxJsonSubmit(_PAGE_GOODS_CPN_DOWNLOAD, JSON.stringify({goodsCd: goodsCd, cpnId: cpnId}), fnGoodsCouponCallBack);
+		 gagajf.ajaxJsonSubmit(_PAGE_GOODS_CPN_DOWNLOAD, JSON.stringify({goodsCd: goodsCd, cpnId: cpnId}), jfGoodsCouponCallBack);
 		 
 	//쿠폰이 발급되었습니다
 	//죄송합니다. 쿠폰이 모두 소진되었습니다
 	//죄송합니다. 해당 쿠폰은 다운로드가 불가합니다.
 	}
 	
+	// 쿠폰다운로드 콜백
+	var jfGoodsCouponCallBack = function(result){
+		if (result.status == "200"){
+			var cpnId = result.params.cpnId;
+			if (result.goodsCouponList == null) return;
+			var list = result.goodsCouponList;
+
+			list.forEach(function(coupon){
+				if (coupon.cpnId == cpnId){
+					if (Number(coupon.custPubLimitQty) > 0){
+						if (Number(coupon.custPubLimitQty) <= Number(coupon.custCouponCnt)){
+							$('#coupon_'+ coupon.cpnId).html('<span>받기완료</span>');
+							$('#coupon_'+ coupon.cpnId).attr('disabled', true);
+						}
+					}
+					if (Number(coupon.TotPubLimitQty) > 0){
+						if (Number(coupon.TotPubLimitQty) <= Number(coupon.CustCouponCnt)){
+							$('#coupon_'+ coupon.cpnId).html('<span>받기완료</span>');
+							$('#coupon_'+ coupon.cpnId).attr('disabled', true);
+						}
+					}
+				}
+			});
+		}
+		jfCouponCheck();
+	}
+	
+	
 	// 쿠폰 전체 다운로드
-	var goodsCouponDownAll = function(){
+	var jfGoodsCouponDownAll = function(){
 		//00개 쿠폰이 발급되었습니다.
+		var couponDownAbleYn = "N";
+		var arrCpnId = [];
+		$('.btn_coupon_down').each(function(){
+			if (!$(this).attr('disabled')){
+				couponDownAbleYn = "Y";
+				arrCpnId.push($(this).attr('cpnId'));
+			}
+		});	
+		
+		if ("N" == couponDownAbleYn){
+			mcxDialog.alert("다운 받을 쿠폰이 없습니다.");
+			return false;
+		}
+		var goodsCd = $('#goodsCouponForm input[name=goodsCd]').val();
+		gagajf.ajaxJsonSubmit(_PAGE_GOODS_CPN_DOWNLOAD, JSON.stringify({goodsCd: goodsCd, arrCpnId: arrCpnId}), jfGoodsCouponDownAllBack);
+		
 	}
 	
-	// 쿠폰다운로드 콜백
-	var fnGoodsCouponCallBack = function(result){
+	// 쿠폰 전체 다운로드 콜백
+	var jfGoodsCouponDownAllBack = function(result){
 		if (result.status == "200"){
-			mcxDialog.alert("쿠폰이 발급되었습니다.");
+			if (result.goodsCouponList == null) return;
+			var list = result.goodsCouponList;
+
+			list.forEach(function(coupon){
+				$('.btn_coupon_down').each(function(){
+					if (!$(this).attr('disabled')){
+						var cpnId = $(this).attr('cpnId');
+						if (coupon.cpnId == cpnId){
+							if (Number(coupon.custPubLimitQty) > 0){
+								if (Number(coupon.custPubLimitQty) <= Number(coupon.custCouponCnt)){
+									$('#coupon_'+ coupon.cpnId).html('<span>받기완료</span>');
+									$('#coupon_'+ coupon.cpnId).attr('disabled', true);
+								}
+							}
+							if (Number(coupon.TotPubLimitQty) > 0){
+								if (Number(coupon.TotPubLimitQty) <= Number(coupon.CustCouponCnt)){
+									$('#coupon_'+ coupon.cpnId).html('<span>받기완료</span>');
+									$('#coupon_'+ coupon.cpnId).attr('disabled', true);
+								}
+							}
+						}
+					}
+				});	
+			});
 		}
+		jfCouponCheck();
 	}
 	
-	$(document).ready(function() {
-		
+	
+	var jfCouponCheck = function(){
 		var couponDownAbleYn = "N";
 		$('.btn_coupon_down').each(function(){
 			if (!$(this).attr('disabled')){
@@ -105,6 +173,11 @@
 			$('.btn_all_cpdown').attr('disabled', true);
 			$('.btn_all_cpdown').find('span').text('쿠폰 모두 받기 완료');
 		}
+	}	
+	
+	$(document).ready(function() {
+		
+		jfCouponCheck();
 	});