فهرست منبع

수정

수정
xyzp1539 5 سال پیش
والد
کامیت
f6a3716380

+ 18 - 0
src/main/java/com/style24/admin/biz/dao/TsaCouponDao.java

@@ -166,4 +166,22 @@ public interface TsaCouponDao {
      * @since 2021-01-21
      */
 	void saveCouponCustPub(CustCoupon custPub);
+
+	/**
+	 * 특정 쿠폰 발급받은 고객 조회
+	 * @param  custCoupon
+	 * @return
+	 * @author xyzp1539
+	 * @since 2021-01-21
+	 */
+	ArrayList<CustCoupon> getCouponIssueCustList(CustCoupon custCoupon);
+
+	/**
+	 * 발급받은 쿠폰 유효기간 변경
+	 * @param
+	 * @return
+	 * @author xyzp1539
+	 * @since 2021-01-21
+	 */
+	void updateCustCouponAvailEddt(CustCoupon issueCust);
 }

+ 19 - 1
src/main/java/com/style24/admin/biz/service/TsaCouponService.java

@@ -46,7 +46,6 @@ public class TsaCouponService {
 	@Transactional("shopTxnManager")
 	public void saveCoupon(Coupon params) {
 		String cpnId = "";		// 쿠폰ID
-
 		params.setRegNo(TsaSession.getInfo().getUserNo());
 		params.setUpdNo(TsaSession.getInfo().getUserNo());
 
@@ -161,6 +160,25 @@ public class TsaCouponService {
 
 			couponDao.saveCouponBurden(burden);
 		}
+
+		// 수정모드이고 변경된 쿠폰상태가 대기 , 중지 인경우 고객이 발급받은 내용도 변경
+		if(!StringUtils.isBlank(params.getCpnId()) &&
+				(params.getCpnStat().equals("G232_10") || params.getCpnStat().equals("G232_12")) ) {
+
+			CustCoupon custCoupon = new CustCoupon();
+			custCoupon.setCpnId(params.getCpnId());
+			custCoupon.setUseYn("Y");
+			ArrayList<CustCoupon> custList = couponDao.getCouponIssueCustList(custCoupon);
+
+			if(custList != null && custList.size() > 0 ) {
+				for(CustCoupon issueCust : custList) {
+					issueCust.setAvailEddt(params.getAvailEddt());
+					issueCust.setUpdNo(TsaSession.getInfo().getUserNo());
+
+					couponDao.updateCustCouponAvailEddt(issueCust);
+				}
+			}
+		}
 	}
 
 	/**

+ 1 - 0
src/main/java/com/style24/persistence/domain/CustCoupon.java

@@ -22,6 +22,7 @@ public class CustCoupon extends TscBaseDomain {
     private String  pubReasonDtl;           // 발행사유상세
     private String  usedDt;                 // 사용된일시
     private String  endAlimSendYn;          // 만료알림발송여부
+    private String  useYn;                  // 사용여부
 
     // 그리드 컬럼
     private String  custList;

+ 83 - 23
src/main/java/com/style24/persistence/mybatis/shop/TsaCoupon.xml

@@ -20,6 +20,7 @@
 					 , PD_GB
 					 , AVAIL_STDT
 					 , AVAIL_EDDT
+				     , AVAIL_DAYS
 					 , FN_GET_USER_NM(REG_NO) AS REG_NM
 					 , REG_DT
 				  FROM TB_COUPON
@@ -118,16 +119,11 @@
 		  , DC_PVAL
 		  , DC_MVAL
 		  , DC_AVAL
+		  , MAX_DC_AMT
 		  , PD_GB
-		  <choose>
-			  <when test='pdGb != null and pdGb == "P"'>
 		  , AVAIL_STDT
 		  , AVAIL_EDDT
-			  </when>
-			  <when test='pdGb != null and pdGb == "D"'>
 		  , AVAIL_DAYS
-			  </when>
-		  </choose>
 		  , CUST_PUB_LIMIT_QTY
 		  , TOT_PUB_LIMIT_QTY
 		  , ONE_PUB_QTY
@@ -145,14 +141,10 @@
 		  , UPD_DT
 		  , FIRST_YN
 		  , DOWN_YN
-		  <if test='custJoinYn != null and custJoinYn == "Y"'>
 		  , CUST_JOIN_STDT
 		  , CUST_JOIN_EDDT
-		  </if>
-		  <if test='firstYn != null and firstYn == "Y"'>
 		  , BUY_STDT
 		  , BUY_EDDT
-		  </if>
 		  <if test='cpnType != null and cpnType == "G230_20"'>
 		  , PAY_TYPE
 		  </if>
@@ -162,6 +154,7 @@
 		  , #{cpnNm}
 		  , #{siteCd}
 		  , #{afLinkCd}
+		  , #{afLinkCd}
 		  , #{usableCustGb}
 		  , #{usableCustGrade}
 		  , #{cpnType}
@@ -170,13 +163,17 @@
 		  , #{dcPval}
 		  , #{dcMval}
 		  , #{dcAval}
+		  , #{maxDcAmt}
 		  , #{pdGb}
 		  <choose>
 			  <when test='pdGb != null and pdGb == "P"'>
 		  , DATE_FORMAT(#{availStdt} , '%Y-%m-%d %H:%i:%s')
 		  , DATE_FORMAT(#{availEddt} , '%Y-%m-%d %H:%i:%s')
+		  , null
 			  </when>
 			  <when test='pdGb != null and pdGb == "D"' >
+		  , null
+		  , null
 		  , #{availDays}
 			  </when>
 		  </choose>
@@ -197,14 +194,26 @@
 		  , now()
 		  , #{firstYn}
 		  , #{downYn}
-		  <if test='custJoinYn != null and custJoinYn == "Y"'>
+		  <choose>
+			  <when test='custJoinYn != null and custJoinYn == "Y"'>
 		  , DATE_FORMAT(#{custJoinStdt} , '%Y-%m-%d %H:%i:%s')
 		  , DATE_FORMAT(#{custJoinEddt} , '%Y-%m-%d %H:%i:%s')
-		  </if>
-		  <if test='firstYn != null and firstYn == "Y"'>
+			  </when>
+			  <when test='custJoinYn != null and custJoinYn == "N"'>
+		  , null
+		  , null
+			  </when>
+		  </choose>
+		  <choose>
+			  <when test='firstYn != null and firstYn == "Y"'>
 		  , DATE_FORMAT(#{buyStdt} , '%Y-%m-%d %H:%i:%s')
 		  , DATE_FORMAT(#{buyEddt} , '%Y-%m-%d %H:%i:%s')
-		  </if>
+			  </when>
+			  <when test='firstYn != null and firstYn == "N"'>
+		  , DATE_FORMAT(#{buyStdt} , '%Y-%m-%d %H:%i:%s')
+		  , DATE_FORMAT(#{buyEddt} , '%Y-%m-%d %H:%i:%s')
+			  </when>
+		  </choose>
 		  <if test='cpnType != null and cpnType == "G230_20"'>
 		  , #{payType}
 		  </if>
@@ -223,14 +232,23 @@
 		  , DC_AVAL = #{dcAval}
 		  , MAX_DC_AMT = #{maxDcAmt}
 		  , PD_GB = #{pdGb}
-		  , AVAIL_STDT = #{availStdt}
-		  , AVAIL_EDDT = #{availEddt}
-		  , AVAIL_DAYS = #{availDays}
+		<choose>
+			<when test='pdGb != null and pdGb == "P"'>
+		  , AVAIL_STDT = DATE_FORMAT(#{availStdt} , '%Y-%m-%d %H:%i:%s')
+		  , AVAIL_EDDT = DATE_FORMAT(#{availEddt} , '%Y-%m-%d %H:%i:%s')
+		  , AVAIL_DAYS = null
+			</when>
+			<when test='pdGb != null and pdGb == "D"' >
+		  , AVAIL_STDT = null
+		  , AVAIL_EDDT = null
+	   	  , AVAIL_DAYS = #{availDays}
+			</when>
+		</choose>
 		  , CUST_PUB_LIMIT_QTY = #{custPubLimitQty}
 		  , TOT_PUB_LIMIT_QTY = #{totPubLimitQty}
 		  , ONE_PUB_QTY = #{onePubQty}
-		  , DOWN_STDT = #{downStdt}
-		  , DOWN_EDDT = #{downEddt}
+		  , DOWN_STDT = DATE_FORMAT(#{downStdt} , '%Y-%m-%d %H:%i:%s')
+		  , DOWN_EDDT = DATE_FORMAT(#{downEddt} , '%Y-%m-%d %H:%i:%s')
 		  , BUY_LIMIT_AMT = #{buyLimitAmt}
 		  , PLAN_SQ = #{planSq}
 		  , REISSUANCE = #{reissuance}
@@ -240,10 +258,26 @@
 		  , UPD_DT = now()
 		  , FIRST_YN = #{firstYn}
 		  , DOWN_YN = #{downYn}
-		  , CUST_JOIN_STDT = #{custJoinStdt}
-		  , CUST_JOIN_EDDT = #{custJoinEddt}
-		  , BUY_STDT = #{buyStdt}
-		  , BUY_EDDT = #{buyEddt}
+		<choose>
+			<when test='custJoinYn != null and custJoinYn == "Y"'>
+		  , CUST_JOIN_STDT = DATE_FORMAT(#{custJoinStdt} , '%Y-%m-%d %H:%i:%s')
+		  , CUST_JOIN_EDDT = DATE_FORMAT(#{custJoinEddt} , '%Y-%m-%d %H:%i:%s')
+			</when>
+			<when test='custJoinYn != null and custJoinYn == "N"'>
+		  , CUST_JOIN_STDT = null
+		  , CUST_JOIN_EDDT = null
+			</when>
+		</choose>
+		<choose>
+			<when test='firstYn != null and firstYn == "Y"'>
+		  , BUY_STDT = DATE_FORMAT(#{buyStdt} , '%Y-%m-%d %H:%i:%s')
+		  , BUY_EDDT = DATE_FORMAT(#{buyEddt} , '%Y-%m-%d %H:%i:%s')
+			</when>
+			<when test='firstYn != null and firstYn == "N"'>
+		  , BUY_STDT = null
+		  , BUY_EDDT = null
+			</when>
+		</choose>
 		  , PAY_TYPE = #{payType}
 		  , CUST_JOIN_YN = #{custJoinYn}
 	</insert>
@@ -544,4 +578,30 @@
 		)
 	</insert>
 
+	<!-- 특정 쿠폰 발급받은 회원 조회-->
+	<select id="getCouponIssueCustList" parameterType="CustCoupon" resultType="CustCoupon">
+		/* TsaCoupon.getCouponIssueCustList */
+		SELECT CUST_CPN_SQ
+			 , CUST_NO
+			 , CPN_ID
+			 , AVAIL_STDT
+			 , AVAIL_EDDT
+		  FROM TB_CUST_COUPON
+		 WHERE CPN_ID = #{cpnId}
+		   AND USED_DT IS NOT NULL
+	</select>
+
+	<!-- 특정 쿠폰 발급받은 고객 유효기간 수정-->
+	<update id="updateCustCouponAvailEddt" parameterType="CustCoupon">
+		/* TsaCoupon.updateCustCouponAvailEddt */
+		UPDATE TB_CUST_COUPON
+		   SET AVAIL_EDDT = DATE_FORMAT(#{availEddt} , '%Y-%m-%d')
+			 , UPD_NO = #{updNo}
+			 , UPD_DT = now()
+		 WHERE CPN_ID = #{cpnId}
+		   AND USED_DT IS NOT NULL
+		   AND CUST_NO = #{custNo}
+		   AND CUST_CPN_SQ = #{custCpnSq}
+	</update>
+
 </mapper>

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

@@ -192,7 +192,7 @@
 			},
 			{headerName: "사용 수/발급 수 ", field: "useIssueCnt", width: 140, cellClass: 'text-center',
 				cellRenderer: function(params) {
-					return params.data.issueCnt.addComma() + "/" + params.data.useCnt.addComma();
+					return params.data.useCnt.addComma() + "/" + params.data.issueCnt.addComma();
 				}
 			},
 			{headerName: "기간/일수구분", field: "pdGb", width: 140, cellClass: 'text-center' ,

+ 36 - 21
src/main/webapp/WEB-INF/views/marketing/CouponPopupForm.html

@@ -604,7 +604,7 @@
 					return false;
 				}
 				checkValidation();
-
+				disable
 				$("#CouponForm input[name=cpnId]").prop("disabled", false);
 				$("#CouponForm input[name=cpnId]").attr("required", true);
 				$("#CouponForm input[name=cpnId]").attr("placeholder", "");
@@ -1163,8 +1163,14 @@
 		$('#CouponForm #downStdt').val($('#CouponForm #downStDay').val() + " " + $('#CouponForm #downStHH').val() + ":" + $('#CouponForm #downStMM').val() + ":00");
 		$('#CouponForm #downEddt').val($('#CouponForm #downEdDay').val() + " " + $('#CouponForm #downEdHH').val() + ":" + $('#CouponForm #downEdMM').val() + ":59");
 		// 유효기간 세팅
-		$('#CouponForm #availStdt').val($('#CouponForm #availStDay').val() + " " + $('#CouponForm #availStHH').val() + ":" + $('#CouponForm #availStMM').val() + ":00");
-		$('#CouponForm #availEddt').val($('#CouponForm #availEdDay').val() + " " + $('#CouponForm #availEdHH').val() + ":" + $('#CouponForm #availEdMM').val() + ":59");
+		if($("#CouponForm #pdGb").val() == 'P') {
+			$('#CouponForm #availStdt').val($('#CouponForm #availStDay').val() + " " + $('#CouponForm #availStHH').val() + ":" + $('#CouponForm #availStMM').val() + ":00");
+			$('#CouponForm #availEddt').val($('#CouponForm #availEdDay').val() + " " + $('#CouponForm #availEdHH').val() + ":" + $('#CouponForm #availEdMM').val() + ":59");
+			$('#CouponForm #availDays').val('');
+		} else {
+			$('#CouponForm #availStdt').val('');
+			$('#CouponForm #availEddt').val('');
+		}
 		// 첫구매기간세팅
 		$('#CouponForm #buyStdt').val($('#CouponForm #buyStDay').val() + " " + $('#CouponForm #buyStHH').val() + ":" + $('#CouponForm #buyStMM').val() + ":00");
 		$('#CouponForm #buyEddt').val($('#CouponForm #buyEdDay').val() + " " + $('#CouponForm #buyEdHH').val() + ":" + $('#CouponForm #buyEdMM').val() + ":59");
@@ -1326,36 +1332,45 @@
 			if (cpnDetail.pdGb == "P") {
 				splitDate("start", cpnDetail.availStdt, "avail");
 				splitDate("end", cpnDetail.availEddt, "avail");
-				$("#CouponForm #availStDay").attr('readonly', true);
-				$("#CouponForm #availStDay").attr('disabled', true);
-				$("#CouponForm #availStHH").attr('readonly', true);
-				$("#CouponForm #availStHH").attr('disabled', true);
-				$("#CouponForm #availStMM").attr('readonly', true);
-				$("#CouponForm #availStMM").attr('disabled', true);
+				if(issueCnt > 0) {
+					$("#CouponForm #availStDay").attr('readonly', true);
+					$("#CouponForm #availStDay").attr('disabled', true);
+					$("#CouponForm #availStHH").attr('readonly', true);
+					$("#CouponForm #availStHH").attr('disabled', true);
+					$("#CouponForm #availStMM").attr('readonly', true);
+					$("#CouponForm #availStMM").attr('disabled', true);
+				}
 			} else {
 				$("#CouponForm #availDays").val(cpnDetail.availDays);
+				$('#CouponForm #availEdHH option:last').attr("selected", "selected");
+				$('#CouponForm #availEdMM option:last').attr("selected", "selected");
+
 			}
 			// 첫구매여부 적용하는 경우 날짜 세팅
 			if (cpnDetail.firstYn == "Y") {
 				splitDate("start", cpnDetail.buyStdt, "buy");
 				splitDate("end", cpnDetail.buyEddt, "buy");
-				$("#CouponForm #buyStDay").attr('readonly', true);
-				$("#CouponForm #buyStDay").attr('disabled', true);
-				$("#CouponForm #buyStHH").attr('readonly', true);
-				$("#CouponForm #buyStHH").attr('disabled', true);
-				$("#CouponForm #buyStMM").attr('readonly', true);
-				$("#CouponForm #buyStMM").attr('disabled', true);
+				if(issueCnt > 0) {
+					$("#CouponForm #buyStDay").attr('readonly', true);
+					$("#CouponForm #buyStDay").attr('disabled', true);
+					$("#CouponForm #buyStHH").attr('readonly', true);
+					$("#CouponForm #buyStHH").attr('disabled', true);
+					$("#CouponForm #buyStMM").attr('readonly', true);
+					$("#CouponForm #buyStMM").attr('disabled', true);
+				}
 			}
 			// 신규회원여부 적용하는 경우 날짜 세팅
 			if (cpnDetail.custJoinYn == "Y") {
 				splitDate("start", cpnDetail.custJoinStdt, "custJoin");
 				splitDate("end", cpnDetail.custJoinEddt, "custJoin");
-				$("#CouponForm #custJoinStDay").attr('readonly', true);
-				$("#CouponForm #custJoinStDay").attr('disabled', true);
-				$("#CouponForm #custJoinStHH").attr('readonly', true);
-				$("#CouponForm #custJoinStHH").attr('disabled', true);
-				$("#CouponForm #custJoinStMM").attr('readonly', true);
-				$("#CouponForm #custJoinStMM").attr('disabled', true);
+				if(issueCnt > 0) {
+					$("#CouponForm #custJoinStDay").attr('readonly', true);
+					$("#CouponForm #custJoinStDay").attr('disabled', true);
+					$("#CouponForm #custJoinStHH").attr('readonly', true);
+					$("#CouponForm #custJoinStHH").attr('disabled', true);
+					$("#CouponForm #custJoinStMM").attr('readonly', true);
+					$("#CouponForm #custJoinStMM").attr('disabled', true);
+				}
 			}
 		}
 		// 기본세팅