Browse Source

수정

수정
xyzp1539 5 năm trước cách đây
mục cha
commit
6f76e6c30e

+ 54 - 9
src/main/java/com/style24/admin/biz/dao/TsaCouponDao.java

@@ -87,15 +87,6 @@ public interface TsaCouponDao {
 	 */
     Coupon getCouponDetail(String cpnId);
 
-    /**
-     * 쿠폰 적용 대상 조회
-     * @param  cpnRefval
-     * @return  Coupon
-     * @author xyzp1539
-     * @since 2021-01-15
-     */
-	ArrayList<Coupon> getCouponRefvalList(Coupon cpnRefval);
-
 	/**
 	 * 쿠폰 발급개수 조회
 	 * @param  cpnId
@@ -104,4 +95,58 @@ public interface TsaCouponDao {
 	 * @since 2021-01-15
 	 */
 	int getCouponIssueCnt(String cpnId);
+
+	/**
+	 * 쿠폰 적용 대상 - 제외상품
+	 * @param  cpnRefval
+	 * @return Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	ArrayList<Coupon> getCouponRefvalExceptGoodsList(Coupon cpnRefval);
+
+	/**
+	 * 쿠폰 적용 대상 - 브랜드
+	 * @param cpnRefval
+	 * @return Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	ArrayList<Coupon> getCouponRefvalBrandList(Coupon cpnRefval);
+
+	/**
+	 * 쿠폰 적용 대상 - 카테고리
+	 * @param cpnRefval
+	 * @return Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	ArrayList<Coupon> getCouponRefvalCategoryList(Coupon cpnRefval);
+
+	/**
+	 * 쿠폰 적용 대상 - 적용/제외상품
+	 * @param  cpnRefval
+	 * @return Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	ArrayList<Coupon> getCouponRefvalGoodsList(Coupon cpnRefval);
+
+	/**
+	 * 쿠폰 적용 대상 - 공급처
+	 * @param cpnRefval
+	 * @return Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	ArrayList<Coupon> getCouponRefvalSupplyCompList(Coupon cpnRefval);
+
+	/**
+	 * 쿠폰 입점업쳅 분담율 조회
+	 * @param cpnId
+	 * @return  Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	ArrayList<Coupon> getCouponBurdenList(String cpnId);
 }

+ 81 - 14
src/main/java/com/style24/admin/biz/service/TsaCouponService.java

@@ -251,20 +251,6 @@ public class TsaCouponService {
 	 */
     public Coupon getCouponDetail(String cpnId) { return couponDao.getCouponDetail(cpnId);}
 
-    /**
-     * 쿠폰 적용 대상 조회
-     * @param cpnId , cpnTarget
-     * @return Coupon
-     * @author xyzp1539
-     * @since 2021-01-15
-     */
-	public ArrayList<Coupon> getCouponRefvalList(String cpnId , String cpnTarget) {
-		Coupon cpnRefval = new Coupon();
-		cpnRefval.setCpnId(cpnId);
-		cpnRefval.setCpnTarget(cpnTarget);	// 공급업체
-		return couponDao.getCouponRefvalList(cpnRefval);
-	}
-
 	/**
 	 * 쿠폰 발급 개수 조회
 	 * @param  cpnId
@@ -275,4 +261,85 @@ public class TsaCouponService {
 	public int getCouponIssueCnt(String cpnId) {
 		return couponDao.getCouponIssueCnt(cpnId);
 	}
+
+	/**
+	 * 쿠폰 적용 대상 - 제외상품
+	 * @param  cpnId
+	 * @return Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	public ArrayList<Coupon> getCouponRefvalExceptGoodsList(String cpnId ) {
+		Coupon cpnRefval = new Coupon();
+		cpnRefval.setCpnId(cpnId);
+		cpnRefval.setCpnTarget("G260_14");
+		return couponDao.getCouponRefvalExceptGoodsList(cpnRefval);
+	}
+
+	/**
+	 * 쿠폰 적용 대상 - 브랜드
+	 * @param cpnId
+	 * @return Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	public ArrayList<Coupon> getCouponRefvalBrandList(String cpnId ) {
+		Coupon cpnRefval = new Coupon();
+		cpnRefval.setCpnId(cpnId);
+		cpnRefval.setCpnTarget("G260_12");
+		return couponDao.getCouponRefvalBrandList(cpnRefval);
+	}
+
+	/**
+	 * 쿠폰 적용 대상 - 카테고리
+	 * @param cpnId
+	 * @return Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	public ArrayList<Coupon> getCouponRefvalCategoryList(String cpnId) {
+		Coupon cpnRefval = new Coupon();
+		cpnRefval.setCpnId(cpnId);
+		cpnRefval.setCpnTarget("G260_11");
+		return couponDao.getCouponRefvalCategoryList(cpnRefval);
+	}
+
+	/**
+	 * 쿠폰 적용 대상 - 적용상품
+	 * @param  cpnId
+	 * @return Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	public ArrayList<Coupon> getCouponRefvalGoodsList(String cpnId , String cpnTarget) {
+		Coupon cpnRefval = new Coupon();
+		cpnRefval.setCpnId(cpnId);
+		cpnRefval.setCpnTarget(cpnTarget);
+		return couponDao.getCouponRefvalGoodsList(cpnRefval);
+	}
+
+	/**
+	 * 쿠폰 적용 대상 - 공급처
+	 * @param cpnId
+	 * @return Coupon
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	public ArrayList<Coupon> getCouponRefvalSupplyCompList(String cpnId) {
+		Coupon cpnRefval = new Coupon();
+		cpnRefval.setCpnId(cpnId);
+		cpnRefval.setCpnTarget("G260_30");
+		return couponDao.getCouponRefvalSupplyCompList(cpnRefval);
+	}
+
+	/**
+	 * 쿠폰 입점업체 분담율 조회
+	 * @param  
+	 * @return 
+	 * @author xyzp1539
+	 * @since 2021-01-18
+	 */
+	public ArrayList<Coupon> getCouponBurdenList(String cpnId) {
+		return couponDao.getCouponBurdenList(cpnId);
+	}
 }

+ 11 - 6
src/main/java/com/style24/admin/biz/web/TsaMarketingController.java

@@ -286,20 +286,25 @@ public class TsaMarketingController extends TsaBaseController {
 			// 쿠폰상세조회
 			mav.addObject("cpnDetail" , couponService.getCouponDetail(cpnId));
 			// 쿠폰적용대상 - 공급업체 조회
-			mav.addObject("cpnDtlRefvalSupplyCompList" , couponService.getCouponRefvalList(cpnId , "G260_13"));
+			mav.addObject("cpnDtlRefvalSupplyCompList" , couponService.getCouponRefvalSupplyCompList(cpnId));
 			// 쿠폰적용대상 - 적용상품 조회
-			mav.addObject("cpnDtlRefvalApplyGoodsList" , couponService.getCouponRefvalList(cpnId , "G260_10"));
+			mav.addObject("cpnDtlRefvalApplyGoodsList" , couponService.getCouponRefvalGoodsList(cpnId , "G260_10"));
 			// 쿠폰적용대상 - 카테고리 조회
-			mav.addObject("cpnDtlRefvalCateList" , couponService.getCouponRefvalList(cpnId , "G260_11"));
+			mav.addObject("cpnDtlRefvalCateList" , couponService.getCouponRefvalCategoryList(cpnId));
 			// 쿠폰적용대상 - 브랜드 조회
-			mav.addObject("cpnDtlRefvalBrandList" , couponService.getCouponRefvalList(cpnId , "G260_12"));
+			mav.addObject("cpnDtlRefvalBrandList" , couponService.getCouponRefvalBrandList(cpnId));
 			// 쿠폰적용대상 - 제외상품 조회
-			mav.addObject("cpnDtlRefvalExceptGoodsList" , couponService.getCouponRefvalList(cpnId , "G260_14"));
+			mav.addObject("cpnDtlRefvalExceptGoodsList" , couponService.getCouponRefvalGoodsList(cpnId , "G260_14"));
+			// 쿠폰 입점업체분담율 조회
+			mav.addObject("cpnDtlBurdenList" , couponService.getCouponBurdenList(cpnId));
 		}
 
+		//issueCnt = 3;
+
 		mav.addObject("mode" , mode);
+		mav.addObject("issueCnt" , issueCnt);
 
-		mav.setViewName("marketing/CouponCreatePopupForm");
+		mav.setViewName("marketing/CouponPopupForm");
 		return mav;
 	}
 

+ 73 - 17
src/main/java/com/style24/persistence/mybatis/shop/TsaCoupon.xml

@@ -367,28 +367,84 @@
     	 WHERE CPN_ID = #{value}
 	</select>
 
-	<!-- 쿠폰 적용 대상 조회-->
-	<select id="getCouponRefvalList" parameterType="Coupon" resultType="Coupon">
-		/* TsaCoupon.getCouponRefvalList */
-		SELECT CPN_REFVAL_SQ
-			 , CPN_ID
-			 , CPN_TYPE
-			 , CPN_TARGET
-			 , REF_VAL
-			 , REF_FORMAL_GB
-			 , REF_BRAND_CD
-			 , DEL_YN
-		  FROM TB_COUPON_REFVAL
-		 WHERE CPN_ID = #{cpnId}
-		   AND CPN_TARGET = #{cpnTarget}
-	</select>
-
 	<!-- 쿠폰 발급 개수 조회 -->
 	<select id="getCouponIssueCnt" parameterType="String" resultType="int">
 		/* TsaCoupon.getCouponIssueCnt*/
 		SELECT COUNT(1)
-		  FROM tb_cust_coupon
+		  FROM TB_CUST_COUPON
 		 WHERE CPN_ID = #{cpnId}
 	</select>
 
+	<!-- 쿠폰 적용대상 조회 - 제외/적용 상품 -->
+	<select id="getCouponRefvalGoodsList" parameterType="Coupon" resultType="Coupon">
+		/* TsaCoupon.getCouponRefvalGoodsList */
+		SELECT FN_GET_CODE_NM('G073',B.GOODS_GB) AS GOODS_GB
+			 , B.GOODS_CD
+			 , B.GOODS_NM
+			 , C.BRAND_ENM
+			 , A.CPN_REFVAL_SQ
+		  FROM TB_COUPON_REFVAL A
+		 INNER JOIN TB_GOODS B ON A.REF_VAL = B.GOODS_CD
+		 INNER JOIN TB_BRAND C ON B.BRAND_CD = C.BRAND_CD
+		 WHERE A.CPN_ID = #{cpnId}
+		   AND A.CPN_TARGET = #{cpnTarget}
+		 ORDER BY A.CPN_REFVAL_SQ DESC
+	</select>
+
+	<!-- 쿠폰 적용대상 조회 - 브랜드 -->
+	<select id="getCouponRefvalBrandList" parameterType="Coupon" resultType="Coupon">
+		/* TsaCoupon.getCouponRefvalExceptGoodsList */
+		SELECT B.BRAND_CD
+			 , B.BRAND_ENM
+		     , C.SUPPLY_COMP_NM
+			 , A.CPN_REFVAL_SQ
+		  FROM TB_COUPON_REFVAL A
+		 INNER JOIN TB_BRAND B ON A.REF_VAL = B.BRAND_CD
+		 INNER JOIN TB_SUPPLY_COMPANY C ON B.SUPPLY_COMP_CD = C.SUPPLY_COMP_CD
+		 WHERE A.CPN_ID = #{cpnId}
+		   AND A.CPN_TARGET = #{cpnTarget}
+		 ORDER BY A.CPN_REFVAL_SQ DESC
+	</select>
+
+	<!-- 쿠폰적용대상 - 카테고리 조회 -->
+	<select id="getCouponRefvalCategoryList" parameterType="Coupon" resultType="Coupon">
+		/* TsaCoupon.getCouponRefvalCategoryList */
+		SELECT B.CATE_GB
+			 , A.REF_VAL AS CATE_CD
+			 , B.FULL_CATE_NM 					AS CATE_NM
+			 , B.SITE_CD
+			 , A.REF_FORMAL_GB					AS FORMAL_GB
+		     , A.REF_BRAND_CD					AS BRAND_CD
+			 , A.CPN_REFVAL_SQ
+		  FROM TB_COUPON_REFVAL A
+		 INNER JOIN TB_CATE_4SRCH B ON A.REF_VAL = B.LEAF_CATE_NO
+		 WHERE A.CPN_ID = #{cpnId}
+		   AND A.CPN_TARGET = #{cpnTarget}
+		 ORDER BY A.CPN_REFVAL_SQ DESC
+	</select>
+
+	<!-- 쿠폰 적용대상 - 공급처 조회 -->
+	<select id="getCouponRefvalSupplyCompList" parameterType="Coupon" resultType="Coupon">
+		/* TsaCoupon.getCouponRefvalSupplyCompList */
+		SELECT B.SUPPLY_COMP_CD
+			 , B.SUPPLY_COMP_NM
+			 , A.CPN_REFVAL_SQ
+		  FROM TB_COUPON_REFVAL A
+		 INNER JOIN TB_SUPPLY_COMPANY B ON A.REF_VAL = B.SUPPLY_COMP_CD
+		 WHERE A.CPN_ID = #{cpnId}
+		   AND A.CPN_TARGET = #{cpnTarget}
+		 ORDER BY A.CPN_REFVAL_SQ DESC
+	</select>
+
+	<!-- 쿠폰 입점업체 분담율 조회-->
+	<select id="getCouponBurdenList" parameterType="String" resultType="Coupon">
+		/* TsaCoupon.getCouponBurdenList */
+		SELECT SUPPLY_COMP_CD
+			 , BURDEN_RATE
+			 , DEL_YN
+			 , CPN_ID
+		  FROM TB_COUPON_BURDEN
+		 WHERE CPN_ID = #{value}
+	</select>
+
 </mapper>

+ 0 - 11
src/main/webapp/WEB-INF/views/marketing/CouponListForm.html

@@ -215,17 +215,6 @@
 			cfnCouponCreatePopup('');
 		}
 
-		// Row Click
-		/*
-        gridOptions.onCellClicked = function(event) {
-            var goodsCd = event.data.goodsCd;
-            if (event.colDef.field == "freeGiftName"){
-                // 수ㅜ정 필요
-                // cfnOpenGoodsDetailPopup('U',goodsCd);
-            }
-        }
-        */
-
 		// 초기화 클릭시
 		$('#btnInit').on('click', function() {
 			$('#searchForm')[0].reset();

+ 318 - 162
src/main/webapp/WEB-INF/views/marketing/CouponCreatePopupForm.html → src/main/webapp/WEB-INF/views/marketing/CouponPopupForm.html

@@ -3,7 +3,7 @@
 	  xmlns:th="http://www.thymeleaf.org">
 <!--
  *******************************************************************************
- * @source  : CouponCreatePopupForm.html
+ * @source  : CouponCreatePopup.html
  * @desc    : 쿠폰 등록 팝업 화면
  *============================================================================
  * ISTYLE24
@@ -21,7 +21,7 @@
 			<button type="button" class="close" onclick="uifnPopupClose('CouponCreatePopup')"><i class="fa fa-times"></i></button>
 		</div>
 		<div class="panelContent">
-			<form id="couponCreateForm" name="couponCreateForm" th:action="@{'/marketing/coupon/save'}" >
+			<form id="CouponCreatePopup" name="CouponCreatePopup" th:action="@{'/marketing/coupon/save'}" >
 				<input type="hidden" name="supplyCompList" id="supplyCompList">
 				<input type="hidden" name="brandList" id="brandList">
 				<input type="hidden" name="applyGoodsList" id="applyGoodsList">
@@ -51,12 +51,8 @@
 										<th>쿠폰번호<em class="required" title="필수"></em></th>
 										<td colspan="5">
 											<input type="hidden" name="copyCpnId" maxlength="50" value="">
-											<input type="text" name="cpnId" maxlength="50"  th:if="${mode == 'U'}" th:value="${cpnDetail.cpnId}" disabled="true" style="width:70%;" readonly="readonly" placeholder="자동생성" data-valid-name="쿠폰번호">
-											<input type="text" name="cpnId" maxlength="50"  th:unless="${mode == 'U'}" value="" style="width:70%;" disabled="true" placeholder="자동생성" data-valid-name="쿠폰번호">
-											<label class="chkBox checked" onclick="clickCreateChk(this);" th:if="${mode == 'U'}" readonly="readonly">
-												<input type="checkbox" name="cpnCreateType" value="true" class="type-check" checked />쿠폰번호 자동생성
-											</label>
-											<label class="chkBox checked" onclick="clickCreateChk(this);" th:unless="${mode == 'U'}">
+											<input type="text" name="cpnId" id="cpnId" maxlength="50"  style="width:70%;" disabled="true" readonly="readonly" placeholder="자동생성" data-valid-name="쿠폰번호">
+											<label class="chkBox checked" onclick="clickCreateChk(this);">
 												<input type="checkbox" name="cpnCreateType" value="true" class="type-check" checked />쿠폰번호 자동생성
 											</label>
 										</td>
@@ -243,12 +239,16 @@
 									</tr>
 									<tr>
 										<th>신규회원여부<em class="required" title="필수"></em></th>
-										<td colspan="5">
+										<td>
 											<select name="custJoinYn" id="custJoinYn" onchange="custJoinYnChange(this)" required="required" data-valid-name="신규회원여부">
 												<option value="Y">Y</option>
 												<option value="N" selected="selected">N</option>
 											</select>
 										</td>
+										<th>총발행제한수량<em class="required" title="필수"></em></th>
+										<td>
+											<input type="text" class="w200" name="totPubLimitQty" id="totPubLimitQty" value="0" required="required" data-valid-name="총발행제한수량" data-valid-type="numeric" style="text-align: right;">개<span class="cRed" id="totPubLimitQtySpan"> *제한없음</span>
+										</td>
 									</tr>
 									<tr>
 										<th class="custJoinDateTr">신규회원기간시작일시<em class="required" title="필수"></em></th>
@@ -274,18 +274,10 @@
 										</td>
 									</tr>
 									<tr>
-										<th>총발행제한수량<em class="required" title="필수"></em></th>
-										<td>
-											<input type="text" class="w200" name="totPubLimitQty" id="totPubLimitQty" value="0" required="required" data-valid-name="총발행제한수량" data-valid-type="numeric" style="text-align: right;">개<span class="cRed" id="totPubLimitQtySpan"> *제한없음</span>
-										</td>
 										<th>1인당발행제한수량<em class="required" title="필수"></em></th>
 										<td>
 											<input type="text" class="w200" name="custPubLimitQty" id="custPubLimitQty" value="0" required="required" data-valid-name="1인당발행제한수량" data-valid-type="numeric" style="text-align: right;">개<span class="cRed" id="custPubLimitQtySpan"> *제한없음</span>
 										</td>
-									</tr>
-									<tr>
-										<th>최소주문금액<em class="required" title="필수"></em></th>
-										<td><input type="text" class="w200" name="minBuyAmt" id="minBuyAmt" value="0" required="required" data-valid-name="최소주문금액" data-valid-type="numeric" style="text-align: right;">원<span class="cRed" id="minBuyAmtSpan"> *제한없음</span></td>
 										<th>1회발행수량<em class="required" title="필수"></em></th>
 										<td><input type="text" class="w200" name="onePubQty" id="onePubQty" value="1" required="required" data-valid-name="1회발행수량" data-valid-type="numeric" style="text-align: right;">개</td>
 									</tr>
@@ -310,10 +302,8 @@
 												<option th:if="${cpnStatList}" th:each="oneData , status : ${cpnStatList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
 											</select>
 										</td>
-									</tr>
-									<tr class="payTypeTr" style="display: none;">
-										<th>결제수단<em class="required" title="필수"></em></th>
-										<td>
+										<th class="payTypeTr" style="display: none;">결제수단<em class="required" title="필수"></em></th>
+										<td class="payTypeTr" style="display: none;">
 											<select name="payType" id="payType" data-valid-name="결제수단">
 												<option value="">[전체]</option>
 												<option th:if="${payTypeList}" th:each="oneData , status : ${payTypeList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
@@ -322,7 +312,8 @@
 									</tr>
 								</table>
 								<div class="mdPopBtnB aR">
-									<button type="button" class="btn btn-info btn-lg" onclick="fnCouponCreate();">등록</button>
+									<button type="button" class="btn btn-info btn-lg" onclick="fnCouponCreate();" th:if="${mode == 'N'}">등록</button>
+									<button type="button" class="btn btn-info btn-lg" onclick="fnCouponUpdate();" th:if="${mode == 'U'}">수정</button>
 								</div>
 							</div>
 						</li>
@@ -448,6 +439,7 @@
 	var cpnDtlRefvalCateList = [[${cpnDtlRefvalCateList}]];
 	var cpnDtlRefvalBrandList = [[${cpnDtlRefvalBrandList}]];
 	var cpnDtlRefvalExceptGoodsList = [[${cpnDtlRefvalExceptGoodsList}]];
+	var issueCnt = [[${issueCnt}]];
 
 	// 공통코드 리스트
 	var ibSupplyComList = gagajf.convertToArray([[${ibSupplyCompList}]]);
@@ -473,14 +465,16 @@
 			cellEditorParams: { values: gagaAgGrid.extractValues(delYnList) },
 			valueFormatter: function (params) { return gagaAgGrid.lookupValue(delYnList, params.value); },
 			valueParser: function (params) { return gagaAgGrid.lookupKey(delYnList, params.newValue); }
-		}
+		} ,
+		{ headerName: "쿠폰번호"  , field: "cpnId" , width: 120 , cellClass: 'text-center' , hide:true}
 	];
 
 	// ag-grid 공급처 컬럼
 	var supplyColumnDefs = [
 		{width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
 		{ headerName : "공급업체코드" , field: "supplyCompCd" , width:150, cellClass: 'text-center'} ,
-		{ headerName: "공급업체명" , field: "supplyCompNm" , width:150, cellClass: 'text-center'}
+		{ headerName: "공급업체명" , field: "supplyCompNm" , width:150, cellClass: 'text-center'},
+		{ headerName: "쿠폰대상일련번호"  , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
 	];
 
 	// ag-grid 브랜드 컬럼
@@ -489,6 +483,7 @@
 		{ headerName : "브랜드ID" , field: "brandCd" , width: 120, cellClass : 'text-center'} ,
 		{ headerName : "브랜드명" , field: "brandEnm" , width: 120, cellClass: 'text-center'} ,
 		{ headerName : "공급업체명", field: "supplyCompNm" , width: 150, cellClass: 'text-center' } ,
+		{ headerName: "쿠폰대상일련번호"  , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
 	];
 
 	// ag-grid 적용상품 컬럼
@@ -497,6 +492,7 @@
 		{ headerName: "상품구분" , field: "goodsGb" , width: 100, cellClass: 'text-center'} ,
 		{ headerName: "Product ID" , field: "goodsCd" , width: 120, cellClass: 'text-center'},
 		{ headerName: "상품명"  , field: "goodsNm" , width: 120 , cellClass: 'text-center'} ,
+		{ headerName: "쿠폰대상일련번호"  , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
 	];
 
 	// ag-grid 카테고리 컬럼
@@ -522,12 +518,13 @@
 			valueFormatter: function (params) { return gagaAgGrid.lookupValue(formalGbList, params.value); },
 			valueParser: function (params) { return gagaAgGrid.lookupKey(formalGbList, params.newValue); }
 		},
-		{ headerName: "브랜드명" , field:"brandCd" , width:150, cellClass: "text-center",
+		{ headerName: "브랜드명" , field:"brandCd" , width:150, cellClass: "text-center", required: true ,
 			editable: true, cellEditor: 'agRichSelectCellEditor',
 			cellEditorParams: { values: gagaAgGrid.extractValues(selfBrandList) },
 			valueFormatter: function (params) { return gagaAgGrid.lookupValue(selfBrandList, params.value); },
 			valueParser: function (params) { return gagaAgGrid.lookupKey(selfBrandList, params.newValue); }
-		}
+		},
+		{ headerName: "쿠폰대상일련번호"  , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
 	];
 
 	// ag-grid 제외상품 컬럼
@@ -536,6 +533,7 @@
 		{ headerName: "상품구분" , field: "goodsGb" , width: 100, cellClass: 'text-center'} ,
 		{ headerName: "Product ID" , field: "goodsCd" , width: 120, cellClass: 'text-center'},
 		{ headerName: "상품명"  , field: "goodsNm" , width: 120 , cellClass: 'text-center'} ,
+		{ headerName: "쿠폰대상일련번호"  , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
 	];
 
 	var inComGridOptions = gagaAgGrid.getGridOptions(columnDefs);
@@ -560,20 +558,59 @@
 		setReqValue();
 
 		// 필수값 validation 체크
-		if (!gagajf.validation('#couponCreateForm')) {
+		if (!gagajf.validation('#CouponCreatePopup')) {
 			return false;
 		}
 
+		checkValidation();
+
+		mcxDialog.confirm('저장하시겠습니까?' , {
+			cancelBtnText:"취소",
+			sureBtnText:"확인",
+			sureBtnClick: function () {
+				gagajf.ajaxFormSubmit($('#CouponCreatePopup').prop('action'), '#CouponCreatePopup', function() {
+					uifnPopupClose('CouponCreatePopup');
+					$('#btnSearch').trigger('click');
+				});
+			}
+		});
+	}
+
+	// 쿠폰 수정 시
+	function fnCouponUpdate(){
+		// 필수값들 셋팅
+		setReqValue();
+
+		// 필수값 validation 체크
+		if (!gagajf.validation('#CouponCreatePopup')) {
+			return false;
+		}
+
+		checkValidation();
+
+		mcxDialog.confirm('수정하시겠습니까?' , {
+			cancelBtnText:"취소",
+			sureBtnText:"확인",
+			sureBtnClick: function () {
+				gagajf.ajaxFormSubmit($('#CouponCreatePopup').prop('action'), '#CouponCreatePopup', function() {
+					uifnPopupClose('CouponCreatePopup');
+					$('#btnSearch').trigger('click');
+				});
+			}
+		});
+	}
+
+	function checkValidation(){
 		//신규가입 지급한다면 validation 체크
 		if( $('#custJoinYn option:selected').val() == "Y" ){
-			var fromDate = $('#couponCreateForm input[name=custJoinStdt]').val();
-			var toDate = $('#couponCreateForm input[name=custJoinEddt]').val();
+			var fromDate = $('#CouponCreatePopup input[name=custJoinStdt]').val();
+			var toDate = $('#CouponCreatePopup input[name=custJoinEddt]').val();
 
 			if (gagajf.isNull(fromDate) || gagajf.isNull(toDate)) {
 				mcxDialog.alertC("신규가입기간 시작일자와 종료일자를 입력하세요.", {
 					sureBtnText: "확인",
 					sureBtnClick: function() {
-						$('#couponCreateForm input[name=custJoinStdt]').focus();
+						$('#CouponCreatePopup input[name=custJoinStdt]').focus();
 					}
 				});
 				return false;
@@ -583,7 +620,7 @@
 				mcxDialog.alertC("등록 시작일자는 종료일자 보다 클 수 없습니다.", {
 					sureBtnText: "확인",
 					sureBtnClick: function() {
-						$('#couponCreateForm input[name=custJoinEddt]').focus();
+						$('#CouponCreatePopup input[name=custJoinEddt]').focus();
 					}
 				});
 				return false;
@@ -592,14 +629,14 @@
 
 		// 첫구매 지급하면 validation 체크
 		if( $('#firstYn option:selected').val() == "Y" ){
-			var fromDate = $('#couponCreateForm input[name=buyStdt]').val();
-			var toDate = $('#couponCreateForm input[name=buyEddt]').val();
+			var fromDate = $('#CouponCreatePopup input[name=buyStdt]').val();
+			var toDate = $('#CouponCreatePopup input[name=buyEddt]').val();
 
 			if (gagajf.isNull(fromDate) || gagajf.isNull(toDate)) {
 				mcxDialog.alertC("신규가입기간 시작일자와 종료일자를 입력하세요.", {
 					sureBtnText: "확인",
 					sureBtnClick: function() {
-						$('#couponCreateForm input[name=buyStdt]').focus();
+						$('#CouponCreatePopup input[name=buyStdt]').focus();
 					}
 				});
 				return false;
@@ -609,7 +646,7 @@
 				mcxDialog.alertC("등록 시작일자는 종료일자 보다 클 수 없습니다.", {
 					sureBtnText: "확인",
 					sureBtnClick: function() {
-						$('#couponCreateForm input[name=buyEddt]').focus();
+						$('#CouponCreatePopup input[name=buyEddt]').focus();
 					}
 				});
 				return false;
@@ -632,22 +669,15 @@
 				return false;
 			}
 		}
-
-		mcxDialog.confirm('저장하시겠습니까?' , {
-			cancelBtnText:"취소",
-			sureBtnText:"확인",
-			sureBtnClick: function () {
-				gagajf.ajaxFormSubmit($('#couponCreateForm').prop('action'), '#couponCreateForm', function() {
-					uifnPopupClose('CouponCreatePopup');
-					$('#btnSearch').trigger('click');
-				});
-			}
-		});
 	}
 
 	// 할인방식 변경
-	$("#couponCreateForm input[name=rdoDcWay]").bind('click change', function () {
+	$("#CouponCreatePopup input[name=rdoDcWay]").bind('click change', function () {
 		var radioValue = $(this).val();
+		//발급이력이있으면 수정안됨
+		if(issueCnt > 0 ) {
+			return false;
+		}
 
 		if(radioValue == 'G240_10') {
 			$('#dcPvalSpan').text("원");
@@ -661,9 +691,12 @@
 	});
 
 	// 쿠폰 상태 변경
-	$("#couponCreateForm input[name=rdoCpnType]").bind('click change', function () {
+	$("#CouponCreatePopup input[name=rdoCpnType]").bind('click change', function () {
 		var radioValue = $(this).val();
 
+		if(mode == "U") {
+			radioValue = cpnDetail.cpnType;
+		}
 		// 상품쿠폰 선택시 적용범위 개별로 변경 나머진 전체
 		if(radioValue == 'G230_11') {
 			$("input:radio[name='rdoApplyScope']:radio[value='I']").prop('checked', true);
@@ -674,13 +707,13 @@
 		// 주문서 쿠폰 선택시 결제수단 노출
 		if(radioValue == 'G230_20') {
 			$('.payTypeTr').css('display' , '');
-			$('#couponCreateForm #payType').attr('required' , true);
+			$('#CouponCreatePopup #payType').attr('required' , true);
 		} else {
 			$('.payTypeTr').css('display' , 'none');
-			$('#couponCreateForm #payType').attr('required' , false );
+			$('#CouponCreatePopup #payType').attr('required' , false );
 		}
 
-		$('#couponCreateForm #cpnType').val(radioValue);
+		$('#CouponCreatePopup #cpnType').val(radioValue);
 	});
 
 	// 적용대상 - 브랜드 추가 버튼시
@@ -820,25 +853,29 @@
 		var selectVal = $(pThis).val();
 
 		if(typeof selectVal == "undefined") {
-			selectVal = "P";
+			if(mode == "U") {
+				selectVal = cpnDetail.pdGb;
+			} else {
+				selectVal = "P";
+			}
 		}
 
 		if(selectVal == "P") {
 			$('.availDateTr').css('display' , '');
 			$('.availDayTr').css('display' , 'none');
-			$('#couponCreateForm #availDays').attr('required' , false);
-			$('#couponCreateForm #availStDay').attr('required' , true);
-			$('#couponCreateForm #availEdDay').attr('required' , true);
-			$('#couponCreateForm #availStdt').attr('required' , true);
-			$('#couponCreateForm #availEddt').attr('required' , true);
+			$('#CouponCreatePopup #availDays').attr('required' , false);
+			$('#CouponCreatePopup #availStDay').attr('required' , true);
+			$('#CouponCreatePopup #availEdDay').attr('required' , true);
+			$('#CouponCreatePopup #availStdt').attr('required' , true);
+			$('#CouponCreatePopup #availEddt').attr('required' , true);
 		} else {
 			$('.availDateTr').css('display' , 'none');
 			$('.availDayTr').css('display' , '');
-			$('#couponCreateForm #availDays').attr('required' , true);
-			$('#couponCreateForm #availStDay').attr('required' , false);
-			$('#couponCreateForm #availEdDay').attr('required' , false);
-			$('#couponCreateForm #availStdt').attr('required' , false);
-			$('#couponCreateForm #availEddt').attr('required' , false);
+			$('#CouponCreatePopup #availDays').attr('required' , true);
+			$('#CouponCreatePopup #availStDay').attr('required' , false);
+			$('#CouponCreatePopup #availEdDay').attr('required' , false);
+			$('#CouponCreatePopup #availStdt').attr('required' , false);
+			$('#CouponCreatePopup #availEddt').attr('required' , false);
 		}
 	}
 
@@ -847,7 +884,11 @@
 		var selectVal = $(pThis).val();
 
 		if(typeof selectVal == "undefined") {
-			selectVal = "N";
+			if(mode == "U") {
+				selectVal = cpnDetail.firstYn;
+			} else {
+				selectVal = "N";
+			}
 		}
 
 		if(selectVal == "Y" ) {
@@ -866,7 +907,11 @@
 		var selectVal = $(pThis).val();
 
 		if(typeof selectVal == "undefined") {
-			selectVal = "N";
+			if(mode == "U") {
+				selectVal = cpnDetail.custJoinYn;
+			} else {
+				selectVal = "N";
+			}
 		}
 
 		if(selectVal == "Y" ) {
@@ -888,93 +933,95 @@
 
 	// 쿠폰번호 자동생성 클릭시
 	function clickCreateChk(){
-		var flag = $('#couponCreateForm input[name=cpnCreateType]').prop("checked");
+		var flag = $('#CouponCreatePopup input[name=cpnCreateType]').prop("checked");
+		// 발급받은 이력이 있으면 수정 안됨
+		if(issueCnt > 0 ) {
+			return false;
+		}
 
 		if(!flag) {
-			$("#couponCreateForm input[name=cpnId]").prop("disabled", true);
-			$("#couponCreateForm input[name=cpnId]").attr("required", false);
-			$("#couponCreateForm input[name=cpnId]").attr("placeholder", "자동생성");
-			$('#couponCreateForm input[name=cpnCreateType]').prop("checked" , false);
+			$("#CouponCreatePopup input[name=cpnId]").prop("disabled", true);
+			$("#CouponCreatePopup input[name=cpnId]").attr("required", false);
+			$("#CouponCreatePopup input[name=cpnId]").attr("readonly", true);
+			$("#CouponCreatePopup input[name=cpnId]").attr("placeholder", "자동생성");
+			$('#CouponCreatePopup input[name=cpnCreateType]').prop("checked" , false);
 		} else{
-			$("#couponCreateForm input[name=cpnId]").prop("disabled", false);
-			$("#couponCreateForm input[name=cpnId]").attr("required", true);
-			$("#couponCreateForm input[name=cpnId]").attr("placeholder", "");
-			$('#couponCreateForm input[name=cpnCreateType]').prop("checked" , true);
+			$("#CouponCreatePopup input[name=cpnId]").prop("disabled", false);
+			$("#CouponCreatePopup input[name=cpnId]").attr("required", true);
+			$("#CouponCreatePopup input[name=cpnId]").attr("placeholder", "");
+			$("#CouponCreatePopup input[name=cpnId]").attr("readonly", false);
+			$('#CouponCreatePopup input[name=cpnCreateType]').prop("checked" , true);
 		}
 	}
 
 	// 전송시 값 세팅
 	function setReqValue(){
 		// 쿠폰유형값 세팅
-		$('#couponCreateForm #cpnType').val($('#couponCreateForm input:radio[name="rdoCpnType"]:checked').val());
+		$('#CouponCreatePopup #cpnType').val($('#CouponCreatePopup input:radio[name="rdoCpnType"]:checked').val());
 		// 할인방식값 세팅
-		$('#couponCreateForm #dcWay').val($('#couponCreateForm input:radio[name="rdoDcWay"]:checked').val());
+		$('#CouponCreatePopup #dcWay').val($('#CouponCreatePopup input:radio[name="rdoDcWay"]:checked').val());
 		// 적용범위값 세팅
-		$('#couponCreateForm #applyScope').val($('#couponCreateForm input:radio[name="rdoApplyScope"]:checked').val());
+		$('#CouponCreatePopup #applyScope').val($('#CouponCreatePopup input:radio[name="rdoApplyScope"]:checked').val());
 		// 다운로드기간 세팅
-		$('#couponCreateForm #downStdt').val($('#couponCreateForm #downStDay').val() + " " + $('#couponCreateForm #downStHH').val() + ":" + $('#couponCreateForm #downStMM').val() + ":00");
-		$('#couponCreateForm #downEddt').val($('#couponCreateForm #downEdDay').val() + " " + $('#couponCreateForm #downEdHH').val() + ":" + $('#couponCreateForm #downEdMM').val() + ":59");
+		$('#CouponCreatePopup #downStdt').val($('#CouponCreatePopup #downStDay').val() + " " + $('#CouponCreatePopup #downStHH').val() + ":" + $('#CouponCreatePopup #downStMM').val() + ":00");
+		$('#CouponCreatePopup #downEddt').val($('#CouponCreatePopup #downEdDay').val() + " " + $('#CouponCreatePopup #downEdHH').val() + ":" + $('#CouponCreatePopup #downEdMM').val() + ":59");
 		// 유효기간 세팅
-		$('#couponCreateForm #availStdt').val($('#couponCreateForm #availStDay').val() + " " + $('#couponCreateForm #availStHH').val() + ":" + $('#couponCreateForm #availStMM').val() + ":00");
-		$('#couponCreateForm #availEddt').val($('#couponCreateForm #availEdDay').val() + " " + $('#couponCreateForm #availEdHH').val() + ":" + $('#couponCreateForm #availEdMM').val() + ":59");
+		$('#CouponCreatePopup #availStdt').val($('#CouponCreatePopup #availStDay').val() + " " + $('#CouponCreatePopup #availStHH').val() + ":" + $('#CouponCreatePopup #availStMM').val() + ":00");
+		$('#CouponCreatePopup #availEddt').val($('#CouponCreatePopup #availEdDay').val() + " " + $('#CouponCreatePopup #availEdHH').val() + ":" + $('#CouponCreatePopup #availEdMM').val() + ":59");
 		// 첫구매기간세팅
-		$('#couponCreateForm #buyStdt').val($('#couponCreateForm #buyStDay').val() + " " + $('#couponCreateForm #buyStHH').val() + ":" + $('#couponCreateForm #buyStMM').val() + ":00");
-		$('#couponCreateForm #buyEddt').val($('#couponCreateForm #buyEdDay').val() + " " + $('#couponCreateForm #buyEdHH').val() + ":" + $('#couponCreateForm #buyEdMM').val() + ":59");
+		$('#CouponCreatePopup #buyStdt').val($('#CouponCreatePopup #buyStDay').val() + " " + $('#CouponCreatePopup #buyStHH').val() + ":" + $('#CouponCreatePopup #buyStMM').val() + ":00");
+		$('#CouponCreatePopup #buyEddt').val($('#CouponCreatePopup #buyEdDay').val() + " " + $('#CouponCreatePopup #buyEdHH').val() + ":" + $('#CouponCreatePopup #buyEdMM').val() + ":59");
 		// 신규회원기간 세팅
-		$('#couponCreateForm #custJoinStdt').val($('#couponCreateForm #custJoinStDay').val() + " " + $('#couponCreateForm #custJoinStHH').val() + ":" + $('#couponCreateForm #custJoinStMM').val() + ":00");
-		$('#couponCreateForm #custJoinEddt').val($('#couponCreateForm #custJoinEdDay').val() + " " + $('#couponCreateForm #custJoinEdHH').val() + ":" + $('#couponCreateForm #custJoinEdMM').val() + ":59");
+		$('#CouponCreatePopup #custJoinStdt').val($('#CouponCreatePopup #custJoinStDay').val() + " " + $('#CouponCreatePopup #custJoinStHH').val() + ":" + $('#CouponCreatePopup #custJoinStMM').val() + ":00");
+		$('#CouponCreatePopup #custJoinEddt').val($('#CouponCreatePopup #custJoinEdDay').val() + " " + $('#CouponCreatePopup #custJoinEdHH').val() + ":" + $('#CouponCreatePopup #custJoinEdMM').val() + ":59");
 		// 적용대상 - 공급처 그리드 전체값 세팅
 		var supplyAllData = gagaAgGrid.getAllRowData(supplyGridOptions);
 		var jsonSupplyCompData = JSON.stringify(supplyAllData);
-		$('#couponCreateForm #supplyCompList').val(jsonSupplyCompData);
+		$('#CouponCreatePopup #supplyCompList').val(jsonSupplyCompData);
 		// 적용대상 - 브랜드 그리드 전체값 세팅
 		var brandAllData = gagaAgGrid.getAllRowData(brandGridOptions);
 		var jsonBrandData = JSON.stringify(brandAllData);
-		$('#couponCreateForm #brandList').val(jsonBrandData);
+		$('#CouponCreatePopup #brandList').val(jsonBrandData);
 		// // 적용대상 - 카테고리 그리드 전체값 세팅
 		var cateAllData = gagaAgGrid.getAllRowData(cateGridOptions);
 		var jsonCateData = JSON.stringify(cateAllData);
-		$('#couponCreateForm #cateList').val(jsonCateData);
+		$('#CouponCreatePopup #cateList').val(jsonCateData);
 		// 적용대상 - 적용상품 그리드 전체값 세팅
 		var goodsAllData = gagaAgGrid.getAllRowData(goodsGridOptions);
 		var jsonGoodsData = JSON.stringify(goodsAllData);
-		$('#couponCreateForm #applyGoodsList').val(jsonGoodsData);
+		$('#CouponCreatePopup #applyGoodsList').val(jsonGoodsData);
 		// 적용대상 - 제외상품 그리드 전체값 세팅
 		var exceptGoodsAllData = gagaAgGrid.getAllRowData(excepGoodsGridOptions);
 		var jsonExceptGoodsData = JSON.stringify(exceptGoodsAllData);
-		$('#couponCreateForm #excepGoodsList').val(jsonExceptGoodsData);
+		$('#CouponCreatePopup #excepGoodsList').val(jsonExceptGoodsData);
 		// 입점업체분담율 그리드 전체값 세팅
 		var inCompBurdenAllData = gagaAgGrid.getAllRowData(inComGridOptions);
 		var jsonInCompBurdenData = JSON.stringify(inCompBurdenAllData);
-		$('#couponCreateForm #burdenList').val(jsonInCompBurdenData);
+		$('#CouponCreatePopup #burdenList').val(jsonInCompBurdenData);
 
 	}
 
-	$(document).ready(function() {
-		pdGbChange();
-		firstYnChange();
-		custJoinYnChange();
-
+	$(document).ready(function() { debugger;
 		gagaAgGrid.createGrid('inComGridList', inComGridOptions);
-		gagaAgGrid.createGrid('brandGridList' , brandGridOptions);
-		gagaAgGrid.createGrid('cateGridList' , cateGridOptions);
-		gagaAgGrid.createGrid('supplyGridList' , supplyGridOptions);
-		gagaAgGrid.createGrid('goodsGridList' , goodsGridOptions);
-		gagaAgGrid.createGrid('excepGoodsGridList' , excepGoodsGridOptions);
+		gagaAgGrid.createGrid('brandGridList', brandGridOptions);
+		gagaAgGrid.createGrid('cateGridList', cateGridOptions);
+		gagaAgGrid.createGrid('supplyGridList', supplyGridOptions);
+		gagaAgGrid.createGrid('goodsGridList', goodsGridOptions);
+		gagaAgGrid.createGrid('excepGoodsGridList', excepGoodsGridOptions);
 
 		// 초기화시 데이터 세팅
-		if(mode == "N") {
-			$('input[name=rdoCpnType]').eq(0).attr("checked" , true);
-			$('input[name=rdoDcWay]').eq(0).attr("checked" , true);
-			$('input[name=rdoApplyScope]').eq(0).attr("checked" , true)
-			$('#couponCreateForm #availEdHH option:last').attr("selected" , "selected");
-			$('#couponCreateForm #availEdMM option:last').attr("selected" , "selected");
-			$('#downEdHH option:last').attr("selected" , "selected");
-			$('#downEdMM option:last').attr("selected" , "selected");
-			$('#custJoinEdHH option:last').attr("selected" , "selected");
-			$('#custJoinEdMM option:last').attr("selected" , "selected");
-			$('#buyEdHH option:last').attr("selected" , "selected");
-			$('#buyEdMM option:last').attr("selected" , "selected");
+		if (mode == "N") {
+			$('input[name=rdoCpnType]').eq(0).attr("checked", true);
+			$('input[name=rdoDcWay]').eq(0).attr("checked", true);
+			$('input[name=rdoApplyScope]').eq(0).attr("checked", true)
+			$('#CouponCreatePopup #availEdHH option:last').attr("selected", "selected");
+			$('#CouponCreatePopup #availEdMM option:last').attr("selected", "selected");
+			$('#downEdHH option:last').attr("selected", "selected");
+			$('#downEdMM option:last').attr("selected", "selected");
+			$('#custJoinEdHH option:last').attr("selected", "selected");
+			$('#custJoinEdMM option:last').attr("selected", "selected");
+			$('#buyEdHH option:last').attr("selected", "selected");
+			$('#buyEdMM option:last').attr("selected", "selected");
 		} else {
 			// 수정모드시 그리드 세팅
 			inComGridOptions.api.setRowData(cpnDtlRefvalSupplyCompList);
@@ -984,69 +1031,178 @@
 			brandGridOptions.api.setRowData(cpnDtlRefvalBrandList);
 			cateGridOptions.api.setRowData(cpnDtlRefvalCateList);
 			// 기본정보 세팅
-			$("#couponCreateForm input:radio[name='rdoDcWay']:radio[value=" + cpnDetail.dcWay +"]").prop('checked' , true);
-			$("#couponCreateForm input:radio[name='rdoCpnType']:radio[value=" + cpnDetail.cpnType +"]").prop('checked' , true);
-			$("#couponCreateForm input:radio[name='rdoApplyScope']:radio[value=" + cpnDetail.applyScope +"]").prop('checked' , true);
-			$("#couponCreateForm input[name='dcPval']").val(cpnDetail.dcPval);
-			$("#couponCreateForm input[name='dcMval']").val(cpnDetail.dcMval);
-			$("#couponCreateForm input[name='dcAval']").val(cpnDetail.dcAval);
-			$("#couponCreateForm input[name='maxDcAmt']").val(cpnDetail.maxDcAmt);
-			$("#couponCreateForm input[name='totPubLimitQty']").val(cpnDetail.totPubLimitQty);
-			$("#couponCreateForm input[name='custPubLimitQty']").val(cpnDetail.custPubLimitQty);
-			$("#couponCreateForm input[name='onePubQty']").val(cpnDetail.onePubQty);
-			$("#couponCreateForm #usableCustGb").val(cpnDetail.usableCustGb).prop("selected" , true);
-			$("#couponCreateForm #usableCustGrade").val(cpnDetail.usableCustGrade).prop("selected" , true);
-			$("#couponCreateForm #endAlimYn").val(cpnDetail.endAlimYn).prop("selected" , true);
-			$("#couponCreateForm #firstYn").val(cpnDetail.firstYn).prop("selected" , true);
-			$("#couponCreateForm #reissuance").val(cpnDetail.reissuance).prop("selected" , true);
-			$("#couponCreateForm #dnGb").val(cpnDetail.dnGb).prop("selected" , true);
-			$("#couponCreateForm #cpnStat").val(cpnDetail.cpnStat).prop("selected" , true);
-			$("#couponCreateForm #custJoinYn").val(cpnDetail.custJoinYn).prop("selected" , true);
-			$("#couponCreateForm #pdGb").val(cpnDetail.pdGb).prop("selected" , true);
-			$("#couponCreateForm #cpnNm").val(cpnDetail.cpnNm);
-
-
-
-
+			$("#CouponCreatePopup input:radio[name='rdoDcWay']:radio[value=" + cpnDetail.dcWay + "]").prop('checked', true);
+			$("#CouponCreatePopup input:radio[name='rdoCpnType']:radio[value=" + cpnDetail.cpnType + "]").prop('checked', true);
+			$("#CouponCreatePopup input:radio[name='rdoApplyScope']:radio[value=" + cpnDetail.applyScope + "]").prop('checked', true);
+			$("#CouponCreatePopup #dcPval").val(cpnDetail.dcPval.addComma());
+			$("#CouponCreatePopup #dcMval").val(cpnDetail.dcMval.addComma());
+			$("#CouponCreatePopup #dcAval").val(cpnDetail.dcAval.addComma());
+			$("#CouponCreatePopup #maxDcAmt").val(cpnDetail.maxDcAmt.addComma());
+			$("#CouponCreatePopup #totPubLimitQty").val(cpnDetail.totPubLimitQty.addComma());
+			$("#CouponCreatePopup #custPubLimitQty").val(cpnDetail.custPubLimitQty.addComma());
+			$("#CouponCreatePopup #onePubQty").val(cpnDetail.onePubQty.addComma());
+			$("#CouponCreatePopup #usableCustGb").val(cpnDetail.usableCustGb).prop("selected", true);
+			$("#CouponCreatePopup #usableCustGrade").val(cpnDetail.usableCustGrade).prop("selected", true);
+			$("#CouponCreatePopup #endAlimYn").val(cpnDetail.endAlimYn).prop("selected", true);
+			$("#CouponCreatePopup #firstYn").val(cpnDetail.firstYn).prop("selected", true);
+			$("#CouponCreatePopup #reissuance").val(cpnDetail.reissuance).prop("selected", true);
+			$("#CouponCreatePopup #dnGb").val(cpnDetail.dnGb).prop("selected", true);
+			$("#CouponCreatePopup #cpnStat").val(cpnDetail.cpnStat).prop("selected", true);
+			$("#CouponCreatePopup #custJoinYn").val(cpnDetail.custJoinYn).prop("selected", true);
+			$("#CouponCreatePopup #pdGb").val(cpnDetail.pdGb).prop("selected", true);
+			$("#CouponCreatePopup #siteCd").val(cpnDetail.siteCd).prop("selected", true);
+			$("#CouponCreatePopup #cpnNm").val(cpnDetail.cpnNm);
+			$("#CouponCreatePopup #downYn").val(cpnDetail.downYn);
+			$("#CouponCreatePopup #buyLimitAmt").val(cpnDetail.buyLimitAmt.addComma());
+			$("#CouponCreatePopup #cpnId").val(cpnDetail.cpnId);
+			// 만약 쿠폰 발급한 내역이 있으면 쿠폰수정못하게 readonly , disabled 속성 추가
+			if (issueCnt > 0) {
+				$("#CouponCreatePopup #usableCustGb").attr('readonly', true);
+				$("#CouponCreatePopup #usableCustGb").attr('disabled', true);
+				$("#CouponCreatePopup #usableCustGrade").attr('readonly', true);
+				$("#CouponCreatePopup #usableCustGrade").attr('disabled', true);
+				$("#CouponCreatePopup #endAlimYn").attr('readonly', true);
+				$("#CouponCreatePopup #endAlimYn").attr('disabled', true);
+				$("#CouponCreatePopup #firstYn").attr('readonly', true);
+				$("#CouponCreatePopup #firstYn").attr('disabled', true);
+				$("#CouponCreatePopup #reissuance").attr('readonly', true);
+				$("#CouponCreatePopup #reissuance").attr('disabled', true);
+				$("#CouponCreatePopup #dnGb").attr('readonly', true);
+				$("#CouponCreatePopup #dnGb").attr('disabled', true);
+				$("#CouponCreatePopup #custJoinYn").attr('readonly', true);
+				$("#CouponCreatePopup #custJoinYn").attr('disabled', true);
+				$("#CouponCreatePopup #pdGb").attr('readonly', true);
+				$("#CouponCreatePopup #pdGb").attr('disabled', true);
+				$("#CouponCreatePopup #downYn").attr('readonly', true);
+				$("#CouponCreatePopup #downYn").attr('disabled', true);
+				$("#CouponCreatePopup #siteCd").attr('readonly', true);
+				$("#CouponCreatePopup #siteCd").attr('disabled', true);
+				$("#CouponCreatePopup #cpnNm").attr('readonly', true);
+				$("#CouponCreatePopup #cpnNm").attr('disabled', true);
+				$("#CouponCreatePopup #dcPval").attr('readonly', true);
+				$("#CouponCreatePopup #dcPval").attr('disabled', true);
+				$("#CouponCreatePopup #dcMval").attr('readonly', true);
+				$("#CouponCreatePopup #dcMval").attr('disabled', true);
+				$("#CouponCreatePopup #dcAval").attr('readonly', true);
+				$("#CouponCreatePopup #dcAval").attr('disabled', true);
+				$("#CouponCreatePopup #maxDcAmt").attr('readonly', true);
+				$("#CouponCreatePopup #maxDcAmt").attr('disabled', true);
+				$("#CouponCreatePopup #totPubLimitQty").attr('readonly', true);
+				$("#CouponCreatePopup #totPubLimitQty").attr('disabled', true);
+				$("#CouponCreatePopup #custPubLimitQty").attr('readonly', true);
+				$("#CouponCreatePopup #custPubLimitQty").attr('disabled', true);
+				$("#CouponCreatePopup #onePubQty").attr('readonly', true);
+				$("#CouponCreatePopup #onePubQty").attr('disabled', true);
+				$("#CouponCreatePopup #downStDay").attr('readonly', true);
+				$("#CouponCreatePopup #downStDay").attr('disabled', true);
+				$("#CouponCreatePopup #downStHH").attr('readonly', true);
+				$("#CouponCreatePopup #downStHH").attr('disabled', true);
+				$("#CouponCreatePopup #downStMM").attr('readonly', true);
+				$("#CouponCreatePopup #downStMM").attr('disabled', true);
+				$("#CouponCreatePopup #buyLimitAmt").attr('readonly', true);
+				$("#CouponCreatePopup input:radio[name='rdoDcWay']").attr('readonly', true);
+				$("#CouponCreatePopup input:radio[name='rdoCpnType']").attr('readonly', true);
+				$("#CouponCreatePopup input:radio[name='rdoApplyScope']").attr('readonly', true);
+				$("#CouponCreatePopup .rdoBtn").css('cursor', 'auto');
+				$("#CouponCreatePopup #cpnId").attr('readonly', true);
+				$("#CouponCreatePopup #cpnId").attr('disabled', true);
+				$("#CouponCreatePopup input:checkbox[name='cpnCreateType']").attr('readonly', true);
+				$("#CouponCreatePopup input:checkbox[name='cpnCreateType']").attr('disabled', true);
+				$("#CouponCreatePopup input:checkbox[name=cpnCreateType]").attr('checked', true);
+				$("#CouponCreatePopup input:checkbox[name=cpnCreateType]").parent().addClass('checked');
+			}
 			// 다운로드기간 세팅
-			splitDate("start" , cpnDetail.downStdt , "down");
-			splitDate("end" , cpnDetail.downEddt , "down");
+			splitDate("start", cpnDetail.downStdt, "down");
+			splitDate("end", cpnDetail.downEddt, "down");
 			// 유효기간이 날짜인경우 날짜 세팅
-			if(cpnDetail.pdGb == "P") {
-				splitDate("start" , cpnDetail.availStdt , "avail");
-				splitDate("end" , cpnDetail.availEddt , "avail");
+			if (cpnDetail.pdGb == "P") {
+				splitDate("start", cpnDetail.availStdt, "avail");
+				splitDate("end", cpnDetail.availEddt, "avail");
+				$("#CouponCreatePopup #availStDay").attr('readonly', true);
+				$("#CouponCreatePopup #availStDay").attr('disabled', true);
+				$("#CouponCreatePopup #availStHH").attr('readonly', true);
+				$("#CouponCreatePopup #availStHH").attr('disabled', true);
+				$("#CouponCreatePopup #availStMM").attr('readonly', true);
+				$("#CouponCreatePopup #availStMM").attr('disabled', true);
 			} else {
-				$("#couponCreateForm #availDays").val(cpnDetail.availDays);
+				$("#CouponCreatePopup #availDays").val(cpnDetail.availDays);
 			}
 			// 첫구매여부 적용하는 경우 날짜 세팅
-			if(cpnDetail.firstYn == "Y") {
-				splitDate("start" , cpnDetail.buyStdt , "buy");
-				splitDate("end" , cpnDetail.buyEddt , "buy");
+			if (cpnDetail.firstYn == "Y") {
+				splitDate("start", cpnDetail.buyStdt, "buy");
+				splitDate("end", cpnDetail.buyEddt, "buy");
+				$("#CouponCreatePopup #buyStDay").attr('readonly', true);
+				$("#CouponCreatePopup #buyStDay").attr('disabled', true);
+				$("#CouponCreatePopup #buyStHH").attr('readonly', true);
+				$("#CouponCreatePopup #buyStHH").attr('disabled', true);
+				$("#CouponCreatePopup #buyStMM").attr('readonly', true);
+				$("#CouponCreatePopup #buyStMM").attr('disabled', true);
 			}
 			// 신규회원여부 적용하는 경우 날짜 세팅
-			if(cpnDetail.custJoinYn == "Y") {
-				splitDate("start" , cpnDetail.custJoinStdt , "custJoin");
-				splitDate("end" , cpnDetail.custJoinEddt , "custJoin");
+			if (cpnDetail.custJoinYn == "Y") {
+				splitDate("start", cpnDetail.custJoinStdt, "custJoin");
+				splitDate("end", cpnDetail.custJoinEddt, "custJoin");
+				$("#CouponCreatePopup #custJoinStDay").attr('readonly', true);
+				$("#CouponCreatePopup #custJoinStDay").attr('disabled', true);
+				$("#CouponCreatePopup #custJoinStHH").attr('readonly', true);
+				$("#CouponCreatePopup #custJoinStHH").attr('disabled', true);
+				$("#CouponCreatePopup #custJoinStMM").attr('readonly', true);
+				$("#CouponCreatePopup #custJoinStMM").attr('disabled', true);
 			}
 		}
+		pdGbChange();
+		firstYnChange();
+		custJoinYnChange();
+	});
 
-		// 날짜분리 ( 시작/종료날짜구분(start , end) , 날짜String , 적용타켓대상 )
-		function splitDate(stedGb , date , targetGb ){
-			var str = date;
-			var dateStr = str.split(' ');
-			var timeArr = dateStr[1].split(':');
+	// 날짜분리 ( 시작/종료날짜구분(start , end) , 날짜String , 적용타대상 )
+	function splitDate(stedGb , date , targetGb ){
+		var str = date;
+		var dateStr = str.split(' ');
+		var timeArr = dateStr[1].split(':');
 
-			if(stedGb == "start") {
-				$("#couponCreateForm #"+targetGb+"StDay").val(dateStr[0]);
-				$("#couponCreateForm #"+targetGb+"StHH").val(timeArr[0]);
-				$("#couponCreateForm #"+targetGb+"StMM").val(timeArr[1]);
-			} else {
-				$("#couponCreateForm #"+targetGb+"EdDay").val(dateStr[0]);
-				$("#couponCreateForm #"+targetGb+"EdHH").val(timeArr[0]);
-				$("#couponCreateForm #"+targetGb+"EdMM").val(timeArr[1]);
-			}
+		if(stedGb == "start") {
+			$("#CouponCreatePopup #"+targetGb+"StDay").val(dateStr[0]);
+			$("#CouponCreatePopup #"+targetGb+"StHH").val(timeArr[0]);
+			$("#CouponCreatePopup #"+targetGb+"StMM").val(timeArr[1]);
+		} else {
+			$("#CouponCreatePopup #"+targetGb+"EdDay").val(dateStr[0]);
+			$("#CouponCreatePopup #"+targetGb+"EdHH").val(timeArr[0]);
+			$("#CouponCreatePopup #"+targetGb+"EdMM").val(timeArr[1]);
 		}
+	}
+
+	$("input[name=totPubLimitQty],input[name=custPubLimitQty],input[name=buyLimitAmt],input[name=onePubQty]").change(function(){
+		if($(this).val() == "0"){
+			$("#"+$(this).attr("name")+"Span").html("*제한없음");
+		}else{
+			$("#"+$(this).attr("name")+"Span").html("");
+		}
+		$("#"+$(this).attr("name")+"Span").css("color", "red");
 	});
+	setTimeout(function(){
+		$("input[name=totPubLimitQty],input[name=custPubLimitQty],input[name=buyLimitAmt],input[name=onePubQty]").change();
+	}, 1);
+
+	function setComma(formId, pBoolean){
+		setTimeout(function(){
+			//숫자타입 콤마 찍어주기
+			$("#"+formId+" [data-valid-type=numeric]").each(function(){
+				$(this).change(function(){
+					if(pBoolean){
+						$(this).val($(this).val().addComma());
+					}else{
+						$(this).val($(this).val().removeComma());
+					}
+				});
+				if(pBoolean){
+					$(this).val($(this).val().addComma());
+				}else{
+					$(this).val($(this).val().removeComma());
+				}
+			});
+		}, 300);
+	}
 
 	/*]]>*/
 </script>