Quellcode durchsuchen

Merge branch 'sowon' into develop

sowon4187 vor 5 Jahren
Ursprung
Commit
3f1b7b5c6c

+ 10 - 0
src/main/java/com/style24/front/biz/dao/TsfCouponDao.java

@@ -88,6 +88,16 @@ public interface TsfCouponDao {
 	 */
 	Coupon getCouponDetailInfo(int cpnId);
 	
+	/**
+	 * 마이페이지 등급쿠폰 다운가능 쿠폰 정보 조회
+	 * 
+	 * @param coupon
+	 * @return Collection<Coupon>
+	 * @author sowon
+	 * @since 2021.03.24
+	 */
+	Collection<Coupon> getPlanCouponInfo(Coupon coupon);
+	
 	
 	
 }

+ 40 - 0
src/main/java/com/style24/front/biz/service/TsfCouponService.java

@@ -421,4 +421,44 @@ public class TsfCouponService {
 	}
 	
 	
+	/**
+	 * 기획전 쿠폰 다운 처리
+	 *
+	 * @param coupon
+	 * @return Collection<Coupon>
+	 * @author card007
+	 * @since 2021.02.25
+	 */
+	@Transactional("shopTxnManager")
+	public int getPlanCouponInfo(Coupon coupon) {
+		int count = 0;
+
+		Collection<Coupon> couponList = couponDao.getPlanCouponInfo(coupon);
+
+		for (Coupon tmpCoupon : couponList) {
+			//int downloadCnt = tmpCoupon.getDownloadCnt();
+			for (int i = 0; i < couponList.size(); i++) {
+				if(couponList.iterator().next().getOwnCoupon()==0) {
+					CustCoupon custCoupon = new CustCoupon();
+					custCoupon.setCustNo(tmpCoupon.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());
+
+					coreCouponDao.saveCouponCustPub(custCoupon);
+
+					count++;
+
+				}
+			}
+		}
+
+		return count;
+	}
+
+	
 }

+ 19 - 0
src/main/java/com/style24/front/biz/service/TsfPlanningService.java

@@ -10,11 +10,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import com.style24.core.support.env.TscConstants;
 import com.style24.front.biz.dao.TsfPlanningDao;
 import com.style24.front.support.env.TsfConstants;
 import com.style24.front.support.security.session.TsfSession;
 import com.style24.persistence.domain.Cate4Srch;
 import com.style24.persistence.domain.Coupon;
+import com.style24.persistence.domain.Goods;
 import com.style24.persistence.domain.Login;
 import com.style24.persistence.domain.Plan;
 import com.style24.persistence.domain.Point;
@@ -35,6 +37,9 @@ public class TsfPlanningService {
 	@Autowired
 	private TsfPlanningDao planningDao;
 	
+	@Autowired
+	private TsfCouponService couponService;
+	
 	/**
 	 * 기획전 카테고리 1deth 조회
 	 *
@@ -182,6 +187,20 @@ public class TsfPlanningService {
 	public Collection<Plan> getPlanGoods1Info(Plan plan) {
 		return planningDao.getPlanGoods1Info(plan);
 	}
+	
+	/**
+	 * 상품 쿠폰 다운 처리
+	 *
+	 * @param coupon
+	 * @return 
+	 * @author sowon
+	 * @since 2021.03.24
+	 */
+	@Transactional("shopTxnManager")
+	public int getPlanCouponDownInfo(Coupon coupon) {
+		return couponService.getPlanCouponInfo(coupon);
+	}
+
 
 
 	/**

+ 49 - 4
src/main/java/com/style24/front/biz/web/TsfPlanningController.java

@@ -14,21 +14,21 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.servlet.ModelAndView;
 
 import com.gagaframework.web.parameter.GagaMap;
-import com.gagaframework.web.rest.server.GagaResponse;
+import com.gagaframework.web.rest.server.GagaResponseStatus;
+import com.style24.core.biz.service.TscCustomerService;
 import com.style24.core.support.env.TscConstants;
 import com.style24.core.support.message.TscMessageByLocale;
+import com.style24.front.biz.service.TsfCouponService;
 import com.style24.front.biz.service.TsfPlanningService;
 import com.style24.front.support.controller.TsfBaseController;
-import com.style24.front.support.env.TsfConstants;
 import com.style24.front.support.security.session.TsfSession;
 import com.style24.persistence.domain.Cate4Srch;
 import com.style24.persistence.domain.Coupon;
 import com.style24.persistence.domain.Customer;
-import com.style24.persistence.domain.Order;
+import com.style24.persistence.domain.Goods;
 import com.style24.persistence.domain.Plan;
 import com.style24.persistence.domain.Review;
 
@@ -51,6 +51,9 @@ public class TsfPlanningController extends TsfBaseController {
 	@Autowired
 	private TsfPlanningService planningService;
 	
+	@Autowired
+	private TscCustomerService coreCustomerService;
+	
 	/**
 	 * 기획전 메인 화면
 	 * 
@@ -186,6 +189,48 @@ public class TsfPlanningController extends TsfBaseController {
 		mav.setViewName(super.getDeviceViewName("planning/PlanningDetailForm"));
 		return mav;
 	}
+	
+	/**
+	 * 기획전 쿠폰 다운로드. 고객이 상품쿠폰 다운로드 시 발급됨.
+	 *
+	 * @param params
+	 * @return
+	 * @throws Exception
+	 * @author sowon
+	 * @since 2021. 3. 24.
+	 */
+	@PostMapping(value = "/coupon/download")
+	@ResponseBody
+	public GagaMap createPlanCoupon(@RequestBody Coupon coupon) throws Exception {
+
+		GagaMap result = new GagaMap();
+
+		// 고객정보 조회
+		Customer customer = new Customer();
+		customer.setSiteCd(TscConstants.Site.STYLE24.value());
+		customer.setCustNo(TsfSession.getInfo().getCustNo());
+		customer.setCustStat(TscConstants.CustStat.ACTIVE.value());
+		customer = coreCustomerService.getCustomerInfo(customer);
+
+		// 고객정보 설정
+		coupon.setCustGb(customer.getCustGb());
+		coupon.setCustGrade(customer.getCustGrade());
+		coupon.setCustNo(customer.getCustNo());
+		// 등급쿠폰 다운 처리
+		int count = planningService.getPlanCouponDownInfo(coupon);
+
+		result.set("status", GagaResponseStatus.SUCCESS.getCode());
+
+		if (count == 0) {
+			result.set("message", message.getMessage("COUPON_0002"));
+		} else {
+			result.set("message", message.getMessage("COUPON_0001", new Object[] {count}));
+		}
+
+		return result;
+	}
+
+	
 	/**
 	 * 이벤트 메인 화면
 	 * 

+ 66 - 1
src/main/java/com/style24/persistence/mybatis/shop/TsfCoupon.xml

@@ -235,7 +235,7 @@
 		                     , FN_GET_BENEFIT_PRICE(#{frontGb},G.GOODS_CD, G.CURR_PRICE,#{custGb}) AS CURR_PRICE
 		                FROM   TB_GOODS G
 		                     , TB_COUPON CP
-		                WHERE  G.GOODS_CD = #{goodsCd}
+		                WHERE G.GOODS_CD = #{goodsCd}
 		                <if test="cpnId != null and cpnId != ''">
 		                AND    CP.CPN_ID = #{cpnId}
 		                </if>
@@ -585,4 +585,69 @@
 		 AND A.CPN_ID = #{cpnId}
 	</select>
 	
+	<!-- 기획전 다운가능 쿠폰 정보 조회 -->
+	<select id="getPlanCouponInfo" parameterType="Coupon" resultType="Coupon">
+		/* TsfCoupon.getPlanCouponInfo */
+		SELECT Z.CUST_NO
+		     , Z.CPN_ID
+		     , Z.AVAIL_STDT
+		     , Z.AVAIL_EDDT
+		     , Z.END_ALIM_YN
+		     , Z.DOWNLOAD_CNT
+		     , Z.OWN_COUPON
+		  FROM (SELECT A.*
+					 , CASE WHEN A.CNT <![CDATA[<=]]> 0 THEN 0
+							WHEN A.CNT > (A.DN_ABLE_CNT * A.ONE_PUB_QTY) THEN (A.DN_ABLE_CNT * A.ONE_PUB_QTY)
+							ELSE A.CNT
+						END AS DOWNLOAD_CNT
+				  FROM (SELECT #{custNo} AS CUST_NO
+							 , C.CPN_ID
+							 , C.CPN_NM
+							 , C.CUST_PUB_LIMIT_QTY
+							 , C.ONE_PUB_QTY
+							 , IF(C.PD_GB = 'P', C.AVAIL_STDT, NOW()) AS AVAIL_STDT
+							 , IF(C.PD_GB = 'P', C.AVAIL_EDDT, CONCAT(CURRENT_DATE + INTERVAL C.AVAIL_DAYS DAY, ' 23:59:59')) AS AVAIL_EDDT
+				             , C.END_ALIM_YN
+							 , IFNULL(CC.CPN_CNT, 0) AS DN_CNT
+				             , IF(C.CUST_PUB_LIMIT_QTY = 0 OR C.CUST_PUB_LIMIT_QTY - CC.CPN_CNT > 0, 1, 0) AS DN_ABLE_CNT
+				             , IF(C.TOT_PUB_LIMIT_QTY > 0, C.TOT_PUB_LIMIT_QTY - CC2.CPN_CNT, 99999) AS CNT
+				             , (SELECT COUNT(*) FROM TB_CUST_COUPON TCC WHERE CPN_ID = #{cpnId} AND CUST_NO = #{custNo}) AS OWN_COUPON
+						  FROM TB_COUPON C
+						 INNER JOIN TB_COUPON_CUST_GBN CCGB
+							ON C.CPN_ID = CCGB.CPN_ID
+						   AND CCGB.USABLE_CUST_GB = #{custGb}
+						 INNER JOIN TB_COUPON_CUST_GRADE CCGR
+							ON C.CPN_ID = CCGR.CPN_ID
+						   AND CCGR.USABLE_CUST_GRADE = #{custGrade}
+						  LEFT OUTER JOIN (SELECT CPN_ID
+												, CUST_NO
+												, COUNT(*) AS CPN_CNT
+											 FROM TB_CUST_COUPON
+											GROUP BY CPN_ID, CUST_NO) CC
+							ON C.CPN_ID = CC.CPN_ID
+						   AND CC.CUST_NO = #{custNo}
+						  LEFT OUTER JOIN (SELECT CPN_ID
+												, COUNT(*) AS CPN_CNT
+											 FROM TB_CUST_COUPON
+											GROUP BY CPN_ID) CC2
+							ON C.CPN_ID = CC2.CPN_ID
+						 WHERE C.DOWN_ABL_YN = 'N'
+						    AND C.CPN_ID IN (
+						       					SELECT PCI.ITEM_VAL 
+						       					FROM TB_PLAN_CONTENTS_ITEM PCI 
+						       					WHERE PCI.ITEM_VAL = #{cpnId}
+						       				)
+						   AND NOW() BETWEEN C.DOWN_STDT AND C.DOWN_EDDT
+						   AND C.CPN_STAT = 'G232_11'  -- 진행
+						   AND CASE WHEN C.TOT_PUB_LIMIT_QTY = 0 THEN 1
+									WHEN C.TOT_PUB_LIMIT_QTY - CC2.CPN_CNT > 0 THEN 1
+									ELSE 0
+								END = 1
+						   AND IF(C.NEW_CUST_YN = 'Y', (SELECT COUNT(*) FROM TB_CUSTOMER WHERE CUST_NO = #{custNo} AND REG_DT BETWEEN C.CUST_JOIN_STDT AND C.CUST_JOIN_EDDT), 1) = 1
+						   AND IF(C.FIRST_ORD_YN = 'Y', (SELECT COUNT(*) FROM TB_ORDER WHERE CUST_NO = #{custNo} AND ORD_DT BETWEEN C.BUY_STDT AND C.BUY_EDDT), 0) = 0
+						) A
+				) Z
+		 <!-- WHERE Z.DOWNLOAD_CNT <![CDATA[>=]]> 0 -->
+	
+	</select>
 </mapper>

+ 0 - 3
src/main/webapp/WEB-INF/views/web/mypage/MypageCouponDetailPopWeb.html

@@ -36,21 +36,18 @@
                		</th:block>
                 </p>
                 
-                
                 <p><strong>카테고리</strong>
                 	<th:block th:each="CateData, CateStat : ${cpnDtlRefvalCateList}">
                 		[[${CateData.cateNm}]],
                 	</th:block>
                 </p>
                 
-                
                 <p><strong>상품</strong>
                 	<th:block th:each="GoodsData, GoodsStat : ${cpnDtlRefvalApplyGoodsList}">
                 		[[${GoodsData.goodsNm}]],
                 	</th:block>
                 </p>
                 
-                
                 <p><strong>제외상품</strong>
                 	<th:block th:each="ExceptData, ExceptStat : ${cpnDtlRefvalExceptGoodsList}">
                 		[[${ExceptData.goodsNm}]],

+ 39 - 3
src/main/webapp/WEB-INF/views/web/planning/PlanningDetailFormWeb.html

@@ -212,6 +212,8 @@
 				</th:block>
 			</div>
 		</div>
+		
+	<div class="modal fade dp_coupon_pop"  id="coupon_modal_02" tabindex="-1" role="dialog"	aria-labelledby="PopupBasicLabel" aria-hidden="true"></div>
 		<!-- // container -->
 <script th:inline="javascript">
 let review = [[${reviewInfo}]];
@@ -327,8 +329,7 @@ if(coupon != null || coupon != ''){
 		html += '						</p>';
 		html += '					</div>';
 		if (coupon[i].couponStat == '쿠폰받기') {
-			html += '					<button type="button"';
-			html += '						class="btn btn_dark btn_block btn_coupon_down">';  /* btn_coupon_done */
+			html += '					<button type="button" id="coupon_" class="btn btn_dark btn_block btn_coupon_down" onclick="fnPlanCouponDown('+coupon[i].cpnId+')">';  /* btn_coupon_done */
 			html += '						<span>쿠폰받기</span>';								/* 받기완료  */
 			html += '					</button>';			
 		}else{
@@ -527,9 +528,44 @@ if(goods2 != null || goods2 != ''){
 		
 }
 
+//사용안내 모달
+var useInfoCoupon = function (id) {
+	 $.ajax( {
+		type		: "GET",
+		url 		: '/mypage/coupon/detailPop?cpnId='+ id,
+		dataType 	: 'html',
+		success 	: function(result) {
+			if (result != null) {
+				$("#coupon_modal_02").html(result);
+				$("#coupon_modal_02").modal("show");
+			}
+		}
+	});
+	
+	return false; 
+}
+
+// 쿠폰 다운로드
+	var fnPlanCouponDown = function(obj){
+	
+		if (!cfCheckLogin()) {
+			cfnGoToPage(_PAGE_LOGIN);
+			return false;
+		}
+		
+		let cpnId = obj;
+		gagajf.ajaxJsonSubmit(_PAGE_PLANNING_CPN_DOWNLOAD, JSON.stringify({cpnId: cpnId}), fnPlanCouponCallBack);
+	}
+	
+	// 쿠폰다운로드 콜백
+	var fnPlanCouponCallBack = function(result){
+		
+		// 화면 전환 필요		
+	}
+
 //세번째 자리 콤마찍기 (숫자만 포함, 소수점자리 구분)
 function comma(num){
-return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+	return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
 }
 
 

+ 1 - 0
src/main/webapp/ux/style24_link.js

@@ -73,6 +73,7 @@ const _PAGE_WISHLIST_DEL = _frontUrl + "/mypage/wish/list/delete";				// 위시
 //== 기획전 ==/
 const _PAGE_PLANNING_MAIN = _frontUrl + "/planning/main/form"; 					// 기획전 메인
 const _PAGE_PLANNING_DETAIL = _frontUrl + "/planning/detail/form";				// 기획전 상세
+const _PAGE_PLANNING_CPN_DOWNLOAD = "/planning/coupon/download";			    // 상품쿠폰다운로드
 
 //== 핫딜==/
 const _PAGE_SOCIAL_MAIN = _frontUrl + "/social/main/form";						// 소설(핫딜) 메인