Selaa lähdekoodia

Merge branch 'develop' of http://112.172.147.34:4936/style24/style24.core into develop

jsshin 5 vuotta sitten
vanhempi
commit
1ba1c7ae11

+ 354 - 0
src/main/java/com/style24/core/biz/dao/TscCouponDao.java

@@ -0,0 +1,354 @@
+package com.style24.core.biz.dao;
+
+import com.style24.core.support.annotation.ShopDs;
+import com.style24.persistence.domain.*;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * 쿠폰 DAO
+ * @author bin2107
+ * @since  2021-02-09
+ */
+@ShopDs
+@Component
+public interface TscCouponDao {
+    /**
+     * 쿠폰 리스트 조회
+     * @param  param
+     * @return ArrayList<Coupon>
+     * @author xyzp1539
+     * @since 2020-12-22
+     */
+    ArrayList<Coupon> getCouponList(Coupon param);
+
+    /**
+     * 쿠폰 리스트 카운트 조회
+     * @param  param
+     * @return int
+     * @author xyzp1539
+     * @since 2020-12-22
+     */
+    int getCouponListCnt(Coupon param);
+
+    /**
+     * 쿠폰 발급개수 조회
+     * @param  cpnId
+     * @return int
+     * @author xyzp1539
+     * @since 2021-01-15
+     */
+    int getCouponIssueCnt(int cpnId);
+
+    /**
+     * 쿠폰 상세 조회
+     * @param  cpnId
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-15
+     */
+    Coupon getCouponDetail(int cpnId);
+
+    /**
+     * 쿠폰 적용 대상 - 공급처
+     * @param cpnRefval
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    ArrayList<CouponRefval> getCouponRefvalSupplyCompList(CouponRefval cpnRefval);
+
+    /**
+     * 쿠폰 적용 대상 - 적용/제외상품
+     * @param  cpnRefval
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    ArrayList<CouponRefval> getCouponRefvalGoodsList(CouponRefval cpnRefval);
+
+    /**
+     * 쿠폰 적용 대상 - 카테고리
+     * @param cpnRefval
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    ArrayList<CouponRefval> getCouponRefvalCategoryList(CouponRefval cpnRefval);
+
+    /**
+     * 쿠폰 적용 대상 - 브랜드
+     * @param cpnRefval
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    ArrayList<CouponRefval> getCouponRefvalBrandList(CouponRefval cpnRefval);
+
+    /**
+     * 쿠폰 입점업쳅 분담율 조회
+     * @param cpnId
+     * @return  Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    ArrayList<Coupon> getCouponBurdenList(int cpnId);
+
+    /**
+     * 동일 쿠폰명이 존재하는지 확인
+     * @param cpnId
+     * @author xodud1202
+     * @since 2021. 01. 26
+     */
+    ArrayList<CustCoupon> getRandomCouponInfo(int cpnId);
+
+    /**
+     * 쿠폰사용가능고객구분 조회
+     * @param cpnId
+     * @author bin2107
+     * @since 2021. 02. 02
+     */
+    ArrayList<Coupon> getCouponCustGbList(int cpnId);
+
+    /**
+     * 쿠폰사용가능고객등급 조회
+     * @param cpnId
+     * @author bin2107
+     * @since 2021. 02. 02
+     */
+    ArrayList<Coupon> getCouponCustGradeList(int cpnId);
+
+    /**
+     * 쿠폰사용가능결제수단 조회
+     * @param cpnId
+     * @author bin2107
+     * @since 2021. 02. 02
+     */
+    ArrayList<Coupon> getCouponPayTypeList(int cpnId);
+
+    /**
+     * 선착순쿠폰 조회
+     * @param cpnId
+     * @author bin2107
+     * @since 2021. 02. 05
+     */
+    ArrayList<Coupon> getLimitedTimeCouponList(int cpnId);
+
+    /**
+     * 쿠폰 마스터 수정
+     * @param
+     * @author bin2107
+     * @since 2021. 2. 5
+     */
+    void updateCouponMstInfo(Coupon coupon);
+
+    /**
+     * 쿠폰 회원 구분 수정
+     * @param
+     * @author bin2107
+     * @since 2021. 2. 5
+     */
+    void deleteCouponCustGubun(Coupon coupon);
+
+    /**
+     * 쿠폰 회원 등급 수정
+     * @param
+     * @author bin2107
+     * @since 2021. 2. 5
+     */
+    void deleteCouponCustGrade(Coupon coupon);
+
+    /**
+     * 쿠폰 회원 결제 수정
+     * @param
+     * @author bin2107
+     * @since 2021. 2. 5
+     */
+    void deleteCouponPayType(Coupon coupon);
+
+    /**
+     * 쿠폰 공급업체,브랜드,상품값 수정
+     * @param
+     * @author bin2107
+     * @since 2021. 2. 5
+     */
+    void deleteCouponRefVal(Coupon coupon);
+
+    /**
+     * 쿠폰  입점업체 분담율 수정
+     * @param
+     * @author bin2107
+     * @since 2021. 2. 5
+     */
+    void deleteCouponBurden(Coupon coupon);
+
+    /**
+     * 선착순 쿠폰 삭제
+     * @param
+     * @author bin2107
+     * @since 2021. 2. 5
+     */
+    void deleteLimitedTimeCoupon(Coupon coupon);
+
+    /**
+     * 쿠폰 등록
+     * @param params
+     * @author xyzp1539
+     * @since  2021-01-12
+     */
+    void couponInsert(Coupon params);
+
+    /**
+     * 쿠폰사용가능고객등급
+     * @param params
+     * @author bin2107
+     * @since 2021. 02. 02
+     */
+    void createCouponCustGubun(Coupon params);
+
+    /**
+     * 쿠폰사용가능고객등급
+     * @param params
+     * @author bin2107
+     * @since 2021. 02. 02
+     */
+    void createCouponCustGrade(Coupon params);
+
+    /**
+     * 쿠폰사용가능결제수단
+     * @param params
+     * @author bin2107
+     * @since 2021. 02. 02
+     */
+    void createCouponPayType(Coupon params);
+
+    /**
+     * 쿠폰 적용대상 등록
+     * @param supplyComp
+     * @author xyzp1539
+     * @since  2021-01-14
+     */
+    void saveCouponRefVal(CouponRefval supplyComp);
+
+    /**
+     * 쿠폰 입점업체 분담 등록
+     * @param burden
+     * @author xyzp1539
+     * @since  2021-01-14
+     */
+    void saveCouponBurden(CouponBurden burden);
+
+    /**
+     * 선착순 쿠폰 저장
+     * @param couponLimitedTime
+     * @author bin2107
+     * @since 2021. 02. 04
+     */
+    void createLimitedTimeCoupon(CouponLimitedTime couponLimitedTime);
+
+    /**
+     * 특정 쿠폰 발급받은 고객 조회
+     * @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);
+
+    /**
+     * 동일 쿠폰명이 같은 기간에 존재하는지 확인
+     * @param param
+     * @author xodud1202
+     * @since 2021. 01. 26
+     */
+    int getSerialOverlapCheck(Coupon param);
+
+    /**
+     * 난수, 시리얼 쿠폰 등록
+     * @param param
+     * @author xodud1202
+     * @since 2021. 01. 26
+     */
+    void createRandomCouponInfo(Coupon param);
+
+    /**
+     * 동일 쿠폰명이 존재하는지 확인
+     * @param param
+     * @author xodud1202
+     * @since 2021. 01. 27
+     */
+    int getRandomCouponNmCnt(String param);
+
+    /**
+     * 쿠폰 적용대상 삭제
+     * @param  couponRefval
+     * @return
+     * @author xyzp1539
+     * @since 2021-01-19
+     */
+    void updateCouponRefval(CouponRefval couponRefval);
+
+    /**
+     * 쿠폰 적용 대상 - 제외상품
+     * @param  cpnRefval
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    ArrayList<CouponRefval> getCouponRefvalExceptGoodsList(CouponRefval cpnRefval);
+
+    /**
+     * 고객 쿠폰 발행
+     * @param  custPub
+     * @return
+     * @author xyzp1539
+     * @since 2021-01-21
+     */
+    void saveCouponCustPub(CustCoupon custPub);
+
+    /**
+     * 쿠폰발급받은 회원리스트 팝업
+     * @param
+     * @return
+     * @author bin2107
+     * @since 2021-02-03
+     */
+    Collection<Coupon> getCpnPubCustList(int cpnId);
+
+    /**
+     * 선착순 쿠폰 삭제
+     * @param couponLimitedTime
+     * @author bin2107
+     * @since 2021. 02. 05
+     */
+    void updateLimitedTimeCouponList(CouponLimitedTime couponLimitedTime);
+
+    /**
+     * 쿠폰 상태 변경
+     * @param
+     * @author bin2107
+     * @since 2021. 2. 5
+     */
+    void updateCouponStat(Coupon coupon);
+
+    /**
+     * 쿠폰조회 목록
+     * @param coupon - 쿠폰 정보
+     * @return
+     * @author gagamel
+     * @since 2021. 1. 8
+     */
+    Collection<Coupon> getCouponRetrieveList(Coupon coupon);
+
+}

+ 489 - 0
src/main/java/com/style24/core/biz/service/TscCouponService.java

@@ -0,0 +1,489 @@
+package com.style24.core.biz.service;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.style24.core.biz.dao.TscCouponDao;
+import com.style24.core.support.env.TscConstants;
+import com.style24.core.support.message.TscMessageByLocale;
+import com.style24.persistence.domain.*;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Random;
+
+/**
+ * 쿠폰 Service
+ *
+ * @author bin2107
+ * @since 2021. 02. 09
+ */
+@Service
+@Slf4j
+public class TscCouponService {
+    @Autowired
+    private TscMessageByLocale message;
+
+    @Autowired
+    private TscCouponDao couponDao;
+
+    /**
+     * 쿠폰 리스트 조회
+     * @param  param
+     * @return ArrayList<Coupon>
+     * @author xyzp1539
+     * @since 2020-12-22
+     */
+    public ArrayList<Coupon> getCouponList(Coupon param) {
+        return couponDao.getCouponList(param);
+    }
+
+    /**
+     * 쿠폰리스트 카운트 조회
+     * @param  param
+     * @return int
+     * @author xyzp1539
+     * @since 2020-12-22
+     */
+    public int getCouponListCnt(Coupon param) {
+        return couponDao.getCouponListCnt(param);
+    }
+
+    /**
+     * 쿠폰 발급 개수 조회
+     * @param  cpnId
+     * @return  cnt
+     * @author xyzp1539
+     * @since 2021-01-15
+     */
+    public int getCouponIssueCnt(int cpnId) {
+        return couponDao.getCouponIssueCnt(cpnId);
+    }
+
+    /**
+     * 쿠폰 상세 조회
+     * @param  cpnId
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-15
+     */
+    public Coupon getCouponDetail(int cpnId) { return couponDao.getCouponDetail(cpnId);}
+
+    /**
+     * 쿠폰 적용 대상 - 공급처
+     * @param cpnId
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    public ArrayList<CouponRefval> getCouponRefvalSupplyCompList(int cpnId) {
+        CouponRefval cpnRefval = new CouponRefval();
+        cpnRefval.setCpnId(cpnId);
+        cpnRefval.setCpnTarget("G260_13");
+        return couponDao.getCouponRefvalSupplyCompList(cpnRefval);
+    }
+
+    /**
+     * 쿠폰 적용 대상 - 적용상품
+     * @param  cpnId
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    public ArrayList<CouponRefval> getCouponRefvalGoodsList(int cpnId , String cpnTarget) {
+        CouponRefval cpnRefval = new CouponRefval();
+        cpnRefval.setCpnId(cpnId);
+        cpnRefval.setCpnTarget(cpnTarget);
+        return couponDao.getCouponRefvalGoodsList(cpnRefval);
+    }
+
+    /**
+     * 쿠폰 적용 대상 - 카테고리
+     * @param cpnId
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    public ArrayList<CouponRefval> getCouponRefvalCategoryList(int cpnId) {
+        CouponRefval cpnRefval = new CouponRefval();
+        cpnRefval.setCpnId(cpnId);
+        cpnRefval.setCpnTarget("G260_11");
+        return couponDao.getCouponRefvalCategoryList(cpnRefval);
+    }
+
+    /**
+     * 쿠폰 적용 대상 - 브랜드
+     * @param cpnId
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    public ArrayList<CouponRefval> getCouponRefvalBrandList(int cpnId ) {
+        CouponRefval cpnRefval = new CouponRefval();
+        cpnRefval.setCpnId(cpnId);
+        cpnRefval.setCpnTarget("G260_12");
+        return couponDao.getCouponRefvalBrandList(cpnRefval);
+    }
+
+    /**
+     * 쿠폰 적용 대상 - 제외상품
+     * @param  cpnId
+     * @return Coupon
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    public ArrayList<CouponRefval> getCouponRefvalExceptGoodsList(int cpnId ) {
+        CouponRefval cpnRefval = new CouponRefval();
+        cpnRefval.setCpnId(cpnId);
+        cpnRefval.setCpnTarget("G260_14");
+        return couponDao.getCouponRefvalExceptGoodsList(cpnRefval);
+    }
+
+    /**
+     * 쿠폰 입점업체 분담율 조회
+     * @param
+     * @return
+     * @author xyzp1539
+     * @since 2021-01-18
+     */
+    public ArrayList<Coupon> getCouponBurdenList(int cpnId) {
+        return couponDao.getCouponBurdenList(cpnId);
+    }
+
+    /**
+     * 랜덤쿠폰 생성 리스트 조회
+     * @param
+     * @return
+     * @author xodud1202
+     * @since 2021-01-26
+     */
+    public ArrayList<CustCoupon> getRandomCouponInfo(int cpnId) {
+        return couponDao.getRandomCouponInfo(cpnId);
+    }
+
+    /**
+     * 쿠폰사용가능고객구분 조회
+     * @param
+     * @return
+     * @author bin2107
+     * @since 2021-02-02
+     */
+    public ArrayList<Coupon> getCouponCustGbList(int cpnId) {
+        return couponDao.getCouponCustGbList(cpnId);
+    }
+
+    /**
+     * 쿠폰사용가능고객등급 조회
+     * @param
+     * @return
+     * @author bin2107
+     * @since 2021-02-02
+     */
+    public ArrayList<Coupon> getCouponCustGradeList(int cpnId) {
+        return couponDao.getCouponCustGradeList(cpnId);
+    }
+
+    /**
+     * 쿠폰사용가능결제수단 조회
+     * @param
+     * @return
+     * @author bin2107
+     * @since 2021-02-02
+     */
+    public ArrayList<Coupon> getCouponPayTypeList(int cpnId) {
+        return couponDao.getCouponPayTypeList(cpnId);
+    }
+
+    /**
+     * 선착순쿠폰 조회
+     * @param
+     * @return
+     * @author bin2107
+     * @since 2021-02-05
+     */
+    public ArrayList<Coupon> getLimitedTimeCouponList(int cpnId) {
+        return couponDao.getLimitedTimeCouponList(cpnId);
+    }
+
+    /**
+     * 쿠폰 저장
+     * @param params
+     * @author xyzp1539
+     * @since  2021-01-11
+     */
+    @Transactional("shopTxnManager")
+    public String saveCoupon(Coupon params){
+        int cpnId = params.getCpnId();		// 쿠폰ID (신규생성인지 수정인지 구분하기 위해 params의 cpnId를 먼저 가져옴 > 쿠폰 생성시 cpnId를 저장하기때문임)
+
+        if(cpnId != 0) {    //수정모드일때
+            couponDao.updateCouponMstInfo(params);	// 쿠폰 마스터 수정
+            couponDao.deleteCouponCustGubun(params);	// 쿠폰 회원 구분 수정
+            couponDao.deleteCouponCustGrade(params);	// 쿠폰 회원 등급 수정
+            couponDao.deleteCouponPayType(params);	// 쿠폰 결제 수단 수정
+            couponDao.deleteCouponRefVal(params);	// 공급업체,브랜드,카테고리,상품 삭제
+            couponDao.deleteCouponBurden(params);	// 입점업체 분담율 삭제
+            couponDao.deleteLimitedTimeCoupon(params);	// 선착순 쿠폰 삭제
+        }else{	//등록모드일때
+            params.setCpnStat("G232_10");
+            couponDao.couponInsert(params);
+        }
+
+        for(int i=0; i<params.getUsableCustGbArr().length; i++){
+            params.setUsableCustGb(params.getUsableCustGbArr()[i]);
+            couponDao.createCouponCustGubun(params);
+        }
+
+        for(int i=0; i<params.getUsableCustGradeArr().length; i++){
+            params.setUsableCustGrade(params.getUsableCustGradeArr()[i]);
+            couponDao.createCouponCustGrade(params);
+        }
+
+        for(int i=0; i<params.getPayTypeArr().length; i++){
+            params.setPayType(params.getPayTypeArr()[i]);
+            couponDao.createCouponPayType(params);
+        }
+
+        // 공급업체 등록
+        for(CouponRefval compRefval : params.getSupplyCompList()){
+            compRefval.setCpnId(params.getCpnId());
+            compRefval.setCpnTarget("G260_13");
+            compRefval.setRefVal(compRefval.getSupplyCompCd());
+            compRefval.setCpnType(params.getCpnType());
+            compRefval.setRegNo(params.getRegNo());
+            compRefval.setUpdNo(params.getUpdNo());
+            couponDao.saveCouponRefVal(compRefval);
+        }
+
+        // 브랜드 등록
+        for(CouponRefval brandRefval : params.getBrandList()){
+            brandRefval.setCpnId(params.getCpnId());
+            brandRefval.setCpnTarget("G260_12");
+            brandRefval.setRefVal(brandRefval.getBrandCd());
+            brandRefval.setCpnType(params.getCpnType());
+            brandRefval.setRegNo(params.getRegNo());
+            brandRefval.setUpdNo(params.getUpdNo());
+            couponDao.saveCouponRefVal(brandRefval);
+        }
+
+        // 적용상품
+        for(CouponRefval applyGoodsRefval : params.getApplyGoodsList()){
+            applyGoodsRefval.setCpnId(params.getCpnId());
+            applyGoodsRefval.setCpnTarget("G260_10");
+            applyGoodsRefval.setRefVal(applyGoodsRefval.getGoodsCd());
+            applyGoodsRefval.setCpnType(params.getCpnType());
+            applyGoodsRefval.setRegNo(params.getRegNo());
+            applyGoodsRefval.setUpdNo(params.getUpdNo());
+            couponDao.saveCouponRefVal(applyGoodsRefval);
+        }
+
+        // 카테고리
+        for(CouponRefval cateRefval : params.getCateList()){
+            cateRefval.setCpnId(params.getCpnId());
+            cateRefval.setCpnTarget("G260_11");
+            cateRefval.setRefVal(cateRefval.getCateNo());
+            cateRefval.setFormalGb(cateRefval.getFormalGb());
+            cateRefval.setBrandCd(cateRefval.getBrandCd());
+            cateRefval.setCpnType(params.getCpnType());
+            cateRefval.setRegNo(params.getRegNo());
+            cateRefval.setUpdNo(params.getUpdNo());
+            couponDao.saveCouponRefVal(cateRefval);
+        }
+
+        // 제외상품
+        for(CouponRefval exceptGoodsRefval : params.getExceptGoodsList()){
+            exceptGoodsRefval.setCpnId(params.getCpnId());
+            exceptGoodsRefval.setCpnTarget("G260_14");
+            exceptGoodsRefval.setRefVal(exceptGoodsRefval.getGoodsCd());
+            exceptGoodsRefval.setCpnType(params.getCpnType());
+            exceptGoodsRefval.setRegNo(params.getRegNo());
+            exceptGoodsRefval.setUpdNo(params.getUpdNo());
+            couponDao.saveCouponRefVal(exceptGoodsRefval);
+        }
+
+        // 입점업체분담율
+        for(CouponBurden couponBurden : params.getBurdenList()){
+            couponBurden.setCpnId(params.getCpnId());
+            couponBurden.setRegNo(params.getRegNo());
+            couponBurden.setUpdNo(params.getUpdNo());
+            couponDao.saveCouponBurden(couponBurden);
+        }
+
+        // 선착순쿠폰
+        for(CouponLimitedTime couponLimitedTime : params.getLimitedTimeCpnList()){
+            couponLimitedTime.setCpnId(params.getCpnId());
+            couponLimitedTime.setRegNo(params.getRegNo());
+            couponLimitedTime.setUpdNo(params.getUpdNo());
+            couponDao.createLimitedTimeCoupon(couponLimitedTime);
+        }
+
+        // 수정모드이고 변경된 쿠폰상태가 대기 , 중지 인경우 고객이 발급받은 내용도 변경
+        if(cpnId != 0 &&
+                (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(params.getUpdNo());
+
+                    couponDao.updateCustCouponAvailEddt(issueCust);
+                }
+            }
+        }
+
+        // 시리얼 쿠폰 생성(최초 쿠폰 생성일 경우에만)
+        if(cpnId == 0 && params.getCpnType().equals(TscConstants.CpnType.PAY_CPN.value()) && params.getDcCdGb().equals(TscConstants.DcCdGb.SERIAL.value())) {
+            // 시리얼 쿠폰명이 동일한 쿠폰이 일정 겹치는 부분이 있는지 확인
+            int overlapCheck = couponDao.getSerialOverlapCheck(params);
+            if(overlapCheck < 1) {
+                for(int i = 0 ; i < params.getTotPubLimitQty() ; i++) {
+                    couponDao.createRandomCouponInfo(params);
+                }
+            } else {
+                throw new IllegalStateException("같은 시리얼명이 사용되는 쿠폰이 중복됩니다. 기간을 확인해주세요.");
+            }
+        } else if(cpnId == 0 && params.getCpnType().equals(TscConstants.CpnType.PAY_CPN.value()) && params.getDcCdGb().equals(TscConstants.DcCdGb.RANDOM.value())) {
+            Random random = new Random();
+            String prefixRandomCpn = "" + params.getCpnId();		// 랜덤 번호는 쿠폰번호 + 랜덤문자 = 12로 처리함
+            // 랜덤 문자 발급 수 만큼 진행
+            for(int j = 0 ; j < params.getTotPubLimitQty() ; j++) {
+                boolean chk = true;
+                while (chk) {
+                    // 대문자+소문자+숫자 조합 10자리 인증번호 생성
+                    StringBuilder sb = new StringBuilder();
+                    // 쿠폰번호 + 랜덤글자 = 12 글자만큼 생성
+                    for (int i = 0; i < 12 - prefixRandomCpn.length(); i++) {
+                        int index = random.nextInt(2);
+                        switch (index) {
+                            case 0:
+                                sb.append((char) (random.nextInt(26) + 65));
+                                break;
+                            case 1:
+                                sb.append(random.nextInt(10));
+                                break;
+                        }
+                    }
+
+                    // 인증번호 중복 체크
+                    int cnt = couponDao.getRandomCouponNmCnt(sb.toString());
+
+                    if (cnt == 0) {
+                        // 인증번호 설정
+                        params.setRdCpnNm(sb.substring(0, 4) + params.getCpnId() + sb.substring(4));
+                        couponDao.createRandomCouponInfo(params);
+                        chk = false;
+                    }
+                }
+            }
+        }
+
+        return "SUCCESS";
+    }
+
+    /**
+     * 쿠폰 적용대상 삭제
+     * @param   couponRefval
+     * @return
+     * @author xyzp1539
+     * @since 2021-01-19
+     */
+    @Transactional("shopTxnManager")
+    public void updateCouponRefval(CouponRefval couponRefval) {
+        couponDao.updateCouponRefval(couponRefval);
+    }
+
+    /**
+     * 고객 쿠폰
+     * @param
+     * @return
+     * @author xyzp1539
+     * @since 2021-01-21
+     */
+    @Transactional("shopTxnManager")
+    public void saveCouponCustPub(CustCoupon custCoupon) {
+        Gson gson = new Gson();
+
+        Collection<CustCoupon> custPubList = gson.fromJson(custCoupon.getCustList() , new TypeToken<Collection<CustCoupon>>(){}.getType());
+        for(CustCoupon custPub : custPubList ) {
+            custPub.setCpnId(custCoupon.getCpnId());
+            custPub.setAvailStdt(custCoupon.getAvailStdt());
+            custPub.setAvailEddt(custCoupon.getAvailEddt());
+            custPub.setPubReason(custCoupon.getPubReason());
+            custPub.setPubReasonDtl(custCoupon.getPubReasonDtl());
+            custPub.setEndAlimSendYn(custCoupon.getEndAlimSendYn());
+
+            couponDao.saveCouponCustPub(custPub);
+        }
+    }
+
+    /**
+     * 쿠폰발급받은 회원리스트 팝업
+     * @param
+     * @return
+     * @author bin2107
+     * @since 2021-02-03
+     */
+    public Collection<Coupon> getCpnPubCustList(int cpnId) {
+        return couponDao.getCpnPubCustList(cpnId);
+    }
+
+    /**
+     * 선착순쿠폰 삭제
+     *
+     * @param
+     * @return
+     * @author bin2107
+     * @since 2021. 2. 5
+     */
+    @Transactional("shopTxnManager")
+    public void updateLimitedTimeCouponList(CouponLimitedTime couponLimitedTime) {
+        if (couponLimitedTime == null || (couponLimitedTime.getArrLimitCpnId() == null && couponLimitedTime.getArrLimitCpnId().length <= 0)) {
+            throw new IllegalStateException(message.getMessage("FAIL_1001"));
+        }
+
+        if (couponLimitedTime.getArrLimitCpnId().length > 0) {
+            couponDao.updateLimitedTimeCouponList(couponLimitedTime);
+        }
+    }
+
+    /**
+     * 쿠폰 상태 변경
+     * @param
+     * @author bin2107
+     * @since 2021. 2. 5
+     */
+    @Transactional("shopTxnManager")
+    public void updateCouponStat(Coupon coupon) {
+        couponDao.updateCouponStat(coupon);
+    }
+
+    /**
+     * 쿠폰조회 목록
+     * @param coupon - 쿠폰 정보
+     * @return
+     * @author gagamel
+     * @since 2021. 1. 8
+     */
+    public Collection<Coupon> getCouponRetrieveList(Coupon coupon) {
+        return couponDao.getCouponRetrieveList(coupon);
+    }
+
+    /**
+     * 회원상세 - 쿠폰발급
+     * @param coupon - 쿠폰정보
+     * @author jsshin
+     * @since 2021. 1. 29
+     */
+    @Transactional("shopTxnManager")
+    public void saveCouponIssue(CustCoupon coupon) {
+        couponDao.saveCouponCustPub(coupon);
+    }
+
+}

+ 105 - 0
src/main/java/com/style24/persistence/domain/Coupon.java

@@ -0,0 +1,105 @@
+package com.style24.persistence.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.style24.persistence.TscBaseDomain;
+import com.style24.persistence.TscPageRequest;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 쿠폰 도메인
+ * @author xyzp1539
+ * @since 2020-12-21
+ */
+@SuppressWarnings("serial")
+@Data
+public class Coupon extends TscBaseDomain {
+
+    // TB_COUPON
+    private int    cpnId;					// 쿠폰ID
+    private String cpnNm;					// 쿠폰명
+    private String siteCd;					// 사이트코드(공통코드G000)
+    private String afLinkCd;				// 제휴링크코드
+    private String usableCustGb;			// 사용가능고객구분(공통코드G100)
+    private String usableCustGrade;		    // 사용가능고객등급(공통코드G110)
+    private String cpnType;				    // 쿠폰유형(공통코드G230)
+    private String applyScope;				// 적용범위(A:전체, I:개별). "I:개별"이고 쿠폰유형이 "20:장바구니쿠폰" 외 이면 TB_COUPON_REFVAL 참조
+    private String dcWay;					// 할인방식(공통코드G240)
+    private int    dcPval;					// 할인값(PC). 할인방식이 금액이면 할인금액, 율이면 할인율
+    private int    dcMval;					// 할인값(모바일). 할인방식이 금액이면 할인금액, 율이면 할인율
+    private int    dcAval;					// 할인값(모바일앱)
+    private int    maxDcAmt;				// 최고할인금액
+    private String pdGb;					// 기간/일수구분(P:기간, D:일수)
+    private String availStdt;				// 유효시작일시(기간/일수구분 "P:기간"일 때 사용됨)
+    private String availEddt;				// 유효종료일시(기간/일수구분 "P:기간"일 때 사용됨)
+    private int    availDays;				// 유효일수(기간/일수구분 "D:일수"일 때 사용됨)
+    private int    custPubLimitQty;		    // 고객당발행제한수량(0은 무제한)
+    private int    totPubLimitQty;			// 총발행제한수량(0은 무제한)
+    private int    onePubQty;				// 1회발행수량(기본은 1)
+    private String dnGb;					// 다운로드구분(공통코드G058)
+    private String downStdt;				// 다운로드시작일시
+    private String downEddt;			    // 다운로드종료일시
+    private int    buyLimitAmt;			    // 구매제한금액(0은 제한없음. 그 외는 00 이상 구매 시 사용)
+    private int    planSq;					// 기획전번호(쿠폰유형이 플러스쿠폰 일 때 사용 기획전번호)
+    private String reissuance;				// 쿠폰재발급여부(공통코드G231)
+    private String cpnStat;				    // 쿠폰상태(공통코드G232)
+    private String endAlimYn;				// 만료알림여부
+    private String firstOrdYn;				// 첫구매여부 (Y:구매이력이없음 | N:구매이력있음)
+    private String downAblYn;				// 다운로드가능여부(마이페이지, 상품상세) --> EP쿠폰, 난수쿠폰
+    private String custJoinStdt;			// 회원가입일자(FROM) 20200101 (신규회원여부의 판단을 가입일자로 설정함)
+    private String custJoinEddt;			// 회원가입일자(FROM) 20200101 (신규회원여부의 판단을 가입일자로 설정함)
+    private String buyStdt;				    // 회원가입일자(FROM) 20200101 (구매기간일자(FROM) (해당기간에 구매이력이 없으면 다운로드 가능))
+    private String buyEddt;				    // 구매기간일자(TO)
+    private int    issueCnt;				// 쿠폰발급개수
+    private int    useCnt;					// 쿠폰사용개수
+    private String payType;                 // 결제수단
+    private String newCustYn;              // 신규회원여부
+    private String afChannel;               // 제휴링크
+    private String dcCdGb;                  // 할인코드유형 (공통코드G233)
+    private String rdCpnNm;                 // 랜덤쿠폰 사용키 (시리얼명 or 난수)
+
+    private String custNo;
+    private String custNm;
+    private String custGbNm;
+    private String custGradeNm;
+    private String useYn;
+    private String usedDt;
+    private String pubReason;
+    private String pubReasonNm;
+    private String pubReasonDtl;
+
+    private Integer limitCpnId;         // 선착순쿠폰일련번호
+    private String delYn;
+
+    // 그리드 파라미터
+    List<CouponRefval> supplyCompList;          // 공급업체 리스트
+    List<CouponRefval> brandList;               // 브랜드 리스트
+    List<CouponRefval> applyGoodsList;          // 적용상품 리스트
+    List<CouponRefval> exceptGoodsList;         // 제외상품 리스트
+    List<CouponRefval> cateList;                // 카테고리 리스트
+    List<CouponBurden> burdenList;              // 업체 분담율 리스트
+
+    // TB_COUPON_BAN_GOODS
+    private int    cpnBanGoodsSq;           //  제외상품시퀀스
+
+    // 사용가능고객구분
+    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+    private String[] usableCustGbArr;
+
+    // 사용가능고객등급
+    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+    private String[] usableCustGradeArr;
+
+    // 결제수단
+    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+    private String[] payTypeArr;
+
+    List<CouponLimitedTime> limitedTimeCpnList; //선착순 쿠폰 리스트
+
+    // Pagination
+    private TscPageRequest pageable;
+    private int pageNo = 1;
+    private int pageSize = 50;
+    private int pageUnit = 10;
+}

+ 19 - 0
src/main/java/com/style24/persistence/domain/CouponBurden.java

@@ -0,0 +1,19 @@
+package com.style24.persistence.domain;
+
+import com.style24.persistence.TscBaseDomain;
+import lombok.Data;
+
+/**
+ * 쿠폰 적용대상 도메인
+ * @author xyzp1539
+ * @since 2021-01-20
+ */
+@SuppressWarnings("serial")
+@Data
+public class CouponBurden extends TscBaseDomain {
+    private int  cpnId;					// 쿠폰ID
+    private String  supplyCompCd;           // 공급업체코드
+    private Integer burdenRate;             // 업체분담율
+    private String  delYn;                  // 삭제여부
+    private String  supplyCompNm;           // 공급업체명
+}

+ 25 - 0
src/main/java/com/style24/persistence/domain/CouponLimitedTime.java

@@ -0,0 +1,25 @@
+package com.style24.persistence.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.style24.persistence.TscBaseDomain;
+import lombok.Data;
+
+/**
+ * 선착순 쿠폰 도메인
+ * @author bin2107
+ * @since 2021-02-04
+ */
+@SuppressWarnings("serial")
+@Data
+public class CouponLimitedTime extends TscBaseDomain {
+    private int     cpnId;				// 쿠폰ID
+    private Integer limitCpnId;         // 선착순쿠폰일련번호
+    private String  limitCpnNm;         // 선착순쿠폰명
+    private int     downLimitQty;       // 다운로드가능수량
+    private String  downStdt;           // 다운로드시작일시
+    private String  downEddt;           // 다운로드종료일시
+    private String  delYn;              // 삭제여부
+
+    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+    private String[] arrLimitCpnId;
+}

+ 41 - 0
src/main/java/com/style24/persistence/domain/CouponRefval.java

@@ -0,0 +1,41 @@
+package com.style24.persistence.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.style24.persistence.TscBaseDomain;
+import lombok.Data;
+
+/**
+ * 쿠폰 적용대상 도메인
+ * @author xyzp1539
+ * @since 2021-01-20
+ */
+@SuppressWarnings("serial")
+@Data
+public class CouponRefval extends TscBaseDomain {
+    private int  cpnId;					    // 쿠폰ID
+    private String  cpnTarget;              // 쿠폰대상구분(공통코드G260)
+    private String  refVal;                 // 관련값(쿠폰대상이 "10:상품"일 때는 상품코드, "20:브랜드"일 때는 브랜드코드, "30:카테고리"일 때는 카테고리코드, "40:제외상품"일 때는 상품코드)
+    private Integer cpnRefvalSq;            // 쿠폰대상일련번호
+    private String  refFormalGb;            // 정상/이월구분(G009). 쿠폰대상구분이 카테고리일 경우 사용
+    private String  refBrandCd;             // 브랜드코드. 쿠폰대상구분이 카테고리일 경우 사용
+    private String  cpnType;			    // 쿠폰유형(공통코드G230)
+    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+    private Integer[] cpnRefvalSqArr;       // 쿠폰적용대상시퀀스배열
+
+    // 그리드 컬럼들
+    private String  supplyCompCd;           // 공급업체코드
+    private Integer burdenRate;             // 업체분담율
+    private String  delYn;                  // 삭제여부
+    private String  supplyCompNm;           // 공급업체명
+    private String  brandCd;                // 브랜드코드
+    private String  brandEnm;               // 브랜드영문명
+    private String  goodsGb;                // 상품구분
+    private String  goodsCd;                // 상품코드
+    private String  goodsNm;                // 상품명
+    private String  cateNm;                 // 카테고리코드명
+    private String  cateNo;                 // 카테고리코드
+    private String  cateList;               // 카테고리 리스트
+    private String  formalGb;               // 이월정상구분
+    private String  siteCd;                 // 사이트코드
+    private String  cateGb;                 // 카테고리구분
+}

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

@@ -0,0 +1,32 @@
+package com.style24.persistence.domain;
+
+import com.style24.persistence.TscBaseDomain;
+import lombok.Data;
+
+/**
+ * 고객쿠폰 도메인
+ * @author xyzp1539
+ * @since 2020-12-21
+ */
+@SuppressWarnings("serial")
+@Data
+public class CustCoupon extends TscBaseDomain {
+    private Integer custCpnSq;              // 고객쿠폰일련번호
+    private Integer custNo;                 // 고객번호
+    private int     cpnId;                  // 쿠폰아이디
+    private String  availStdt;              // 유효시작일시
+    private String  availEddt;              // 유효종료일시
+    private String  pubReason;              // 발행사유(공통코드G250)
+    private String  pubReasonDtl;           // 발행사유상세
+    private String  usedDt;                 // 사용된일시
+    private String  endAlimSendYn;          // 만료알림발송여부
+    private String  useYn;                  // 사용여부
+    private String  rdCpnNm;                // 랜덤쿠폰 및 시리얼쿠폰 키
+    private String  custId;                 // 고객 아이디
+    private String  custNm;                 // 고객명
+
+    // 그리드 컬럼
+    private String  custList;
+    private String  cpnNm;                  // 쿠폰명
+    private Integer ordNo;                  // 주문번호
+}

+ 952 - 0
src/main/java/com/style24/persistence/mybatis/shop/TscCoupon.xml

@@ -0,0 +1,952 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.style24.core.biz.dao.TscCouponDao">
+    <!-- 쿠폰리스트 조회 -->
+    <select id="getCouponList" parameterType="Coupon" resultType="Coupon">
+        /* TscCoupon.getCouponList */
+        SELECT T.*
+        , COUNT(CUST_CPN_SQ) AS ISSUE_CNT
+        , COUNT(USED_DT) AS USE_CNT
+        FROM (
+        SELECT SITE_CD
+        , CPN_ID
+        , CPN_NM
+        , CPN_TYPE
+        , DC_WAY
+        , DC_PVAL
+        , DC_MVAL
+        , MAX_DC_AMT
+        , PD_GB
+        , AVAIL_STDT
+        , AVAIL_EDDT
+        , AVAIL_DAYS
+        , FN_GET_USER_NM(REG_NO) AS REG_NM
+        , REG_DT
+        FROM TB_COUPON
+        WHERE 1=1
+        <if test="siteCd != null and siteCd != ''">
+            AND SITE_CD = #{siteCd}
+        </if>
+        <if test="cpnId != null and cpnId != ''">
+            AND CPN_ID = #{cpnId}
+        </if>
+        <if test="cpnType != null and cpnType != ''">
+            AND CPN_TYPE = #{cpnType}
+        </if>
+        <if test="regNo != null and regNo != ''">
+            AND REG_NO = #{regNo}
+        </if>
+        <if test="dcWay != null and dcWay != ''">
+            AND DC_WAY = #{dcWay}
+        </if>
+        <if test="cpnNm != null and cpnNm != ''">
+            AND CPN_NM LIKE LOWER('%' || #{cpnNm} || '%')
+        </if>
+        <if test="pdGb != null and pdGb != ''">
+            AND PD_GB = #{pdGb}
+        </if>
+        <if test="availStdt != null and availStdt != '' and availEddt != null and availEddt != ''">
+            AND AVAIL_STDT >= DATE_FORMAT(#{availStdt} , '%Y-%m-%d')
+            AND AVAIL_EDDT <![CDATA[ <= ]]> DATE_FORMAT(#{availEddt} , '%Y-%m-%d')
+        </if>
+        ) T
+        LEFT OUTER JOIN TB_CUST_COUPON CC
+        ON T.CPN_ID = CC.CPN_ID
+        GROUP BY  T.SITE_CD
+        , T.CPN_ID
+        , T.CPN_NM
+        , T.CPN_TYPE
+        , T.DC_WAY
+        , T.DC_PVAL
+        , T.DC_MVAL
+        , T.MAX_DC_AMT
+        , T.PD_GB
+        , T.AVAIL_STDT
+        , T.AVAIL_EDDT
+        , T.REG_NM
+        , T.REG_DT
+        ORDER BY  T.REG_DT DESC
+    </select>
+
+    <!-- 쿠폰 리스트 카운트 조회-->
+    <select id="getCouponListCnt" parameterType="Coupon" resultType="int">
+        /* TscCoupon.getCouponListCnt */
+        SELECT COUNT(1)
+        FROM TB_COUPON
+        WHERE 1=1
+        <if test="siteCd != null and siteCd != ''">
+            AND SITE_CD = #{siteCd}
+        </if>
+        <if test="cpnId != null and cpnId != ''">
+            AND CPN_ID = #{cpnId}
+        </if>
+        <if test="cpnType != null and cpnType != ''">
+            AND CPN_TYPE = #{cpnType}
+        </if>
+        <if test="regNo != null and regNo != ''">
+            AND REG_NO = #{regNo}
+        </if>
+        <if test="dcWay != null and dcWay != ''">
+            AND DC_WAY = #{dcWay}
+        </if>
+        <if test="cpnNm != null and cpnNm != ''">
+            AND CPN_NM LIKE LOWER('%' || #{cpnNm} || '%')
+        </if>
+        <if test="pdGb != null and pdGb != ''">
+            AND PD_GB = #{pdGb}
+        </if>
+        <if test="availStdt != null and availStdt != '' and availEddt != null and availEddt != ''">
+            AND AVAIL_STDT >= DATE_FORMAT(#{availStdt} , '%Y-%m-%d')
+            AND AVAIL_EDDT <![CDATA[ <= ]]> DATE_FORMAT(#{availEddt} , '%Y-%m-%d')
+        </if>
+    </select>
+
+    <!-- 쿠폰 발급 개수 조회 -->
+    <select id="getCouponIssueCnt" parameterType="int" resultType="int">
+        /* TscCoupon.getCouponIssueCnt*/
+        SELECT COUNT(1)
+        FROM TB_CUST_COUPON
+        WHERE CPN_ID = #{cpnId}
+    </select>
+
+    <!-- 쿠폰 상세 조회-->
+    <select id="getCouponDetail" parameterType="int" resultType="Coupon">
+        /* TscCoupon.getCouponDetail */
+        SELECT B.CPN_ID
+        , B.CPN_NM
+        , B.SITE_CD
+        , B.AF_LINK_CD
+        , B.CPN_TYPE
+        , B.APPLY_SCOPE
+        , B.DC_WAY
+        , B.DC_PVAL
+        , B.DC_MVAL
+        , B.DC_AVAL
+        , B.MAX_DC_AMT
+        , B.PD_GB
+        , B.AVAIL_STDT
+        , B.AVAIL_EDDT
+        , B.AVAIL_DAYS
+        , B.CUST_PUB_LIMIT_QTY
+        , B.TOT_PUB_LIMIT_QTY
+        , B.ONE_PUB_QTY
+        , B.DN_GB
+        , B.DOWN_STDT
+        , B.DOWN_EDDT
+        , B.BUY_LIMIT_AMT
+        , B.PLAN_SQ
+        , B.REISSUANCE
+        , B.CPN_STAT
+        , B.END_ALIM_YN
+        , B.FIRST_ORD_YN
+        , B.DOWN_ABL_YN
+        , B.DC_CD_GB
+        , B.CUST_JOIN_STDT
+        , B.CUST_JOIN_EDDT
+        , B.BUY_STDT
+        , B.BUY_EDDT
+        , B.NEW_CUST_YN
+        , (SELECT AF_CHANNEL
+        FROM TB_AF_LINK A
+        WHERE A.AF_LINK_CD = B.AF_LINK_CD) AS AF_CHANNEL
+        , RC.RD_CPN_NM AS RD_CPN_NM
+        FROM TB_COUPON B
+        LEFT OUTER JOIN (SELECT CPN_ID
+        , RD_CPN_NM
+        FROM TB_RANDOM_COUPON
+        GROUP BY CPN_ID, RD_CPN_NM) RC
+        ON B.CPN_ID = RC.CPN_ID
+        AND B.DC_CD_GB = 'G233_10'		<!-- 시리얼 유형일 경우에만 랜덤쿠폰 검색 검색 -->
+        WHERE B.CPN_ID = #{value}
+    </select>
+
+    <!-- 쿠폰 적용대상 - 공급처 조회 -->
+    <select id="getCouponRefvalSupplyCompList" parameterType="CouponRefval" resultType="CouponRefval">
+        /* TscCoupon.getCouponRefvalSupplyCompList */
+        SELECT B.SUPPLY_COMP_CD
+             , B.SUPPLY_COMP_NM
+             , A.CPN_REFVAL_SQ
+             , A.DEL_YN
+        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}
+          AND A.DEL_YN = 'N'
+        ORDER BY A.CPN_REFVAL_SQ DESC
+    </select>
+
+    <!-- 쿠폰 적용대상 조회 - 제외/적용 상품 -->
+    <select id="getCouponRefvalGoodsList" parameterType="CouponRefval" resultType="CouponRefval">
+        /* TscCoupon.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
+             , A.DEL_YN
+        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}
+          AND A.DEL_YN = 'N'
+        ORDER BY A.CPN_REFVAL_SQ DESC
+    </select>
+
+    <!-- 쿠폰적용대상 - 카테고리 조회 -->
+    <select id="getCouponRefvalCategoryList" parameterType="CouponRefval" resultType="CouponRefval">
+        /* TscCoupon.getCouponRefvalCategoryList */
+        SELECT B.CATE_GB
+             , A.REF_VAL AS CATE_NO
+             , 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
+             , A.DEL_YN
+        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}
+          AND A.DEL_YN = 'N'
+        ORDER BY A.CPN_REFVAL_SQ DESC
+    </select>
+
+    <!-- 쿠폰 적용대상 조회 - 브랜드 -->
+    <select id="getCouponRefvalBrandList" parameterType="CouponRefval" resultType="CouponRefval">
+        /* TscCoupon.getCouponRefvalExceptGoodsList */
+        SELECT B.BRAND_CD
+             , B.BRAND_ENM
+             , A.CPN_REFVAL_SQ
+             , A.DEL_YN
+        FROM TB_COUPON_REFVAL A
+                 INNER JOIN TB_BRAND B ON A.REF_VAL = B.BRAND_CD
+        WHERE A.CPN_ID = #{cpnId}
+          AND A.CPN_TARGET = #{cpnTarget}
+          AND A.DEL_YN = 'N'
+        ORDER BY A.CPN_REFVAL_SQ DESC
+    </select>
+
+    <!-- 쿠폰 입점업체 분담율 조회-->
+    <select id="getCouponBurdenList" parameterType="int" resultType="CouponBurden">
+        /* TscCoupon.getCouponBurdenList */
+        SELECT SUPPLY_COMP_CD
+             , BURDEN_RATE
+             , DEL_YN
+             , CPN_ID
+        FROM TB_COUPON_BURDEN
+        WHERE CPN_ID = #{value}
+          AND DEL_YN = 'N'
+    </select>
+
+    <!-- 특정 쿠폰 발급받은 회원 조회-->
+    <select id="getRandomCouponInfo" parameterType="int" resultType="CustCoupon">
+        /* TscCoupon.getRandomCouponInfo */
+        SELECT RC.CPN_ID
+             , RC.RD_CPN_NM
+             , C.CUST_NO
+             , C.CUST_ID
+             , C.CUST_NM
+             , DATE_FORMAT(CC.REG_DT, '%Y-%m-%d %H:%i:%s') AS REG_DT
+             , DATE_FORMAT(CC.USED_DT, '%Y-%m-%d %H:%i:%s') AS USED_DT
+        FROM TB_RANDOM_COUPON RC
+                 LEFT OUTER JOIN TB_CUSTOMER C
+                                 ON RC.CUST_NO = C.CUST_NO
+                 LEFT OUTER JOIN TB_CUST_COUPON CC
+                                 ON RC.CPN_ID = CC.CPN_ID
+                                     AND C.CUST_NO = CC.CUST_NO
+        WHERE RC.CPN_ID = #{cpnId}
+    </select>
+
+    <!-- 쿠폰사용가능고객구분 조회-->
+    <select id="getCouponCustGbList" parameterType="int" resultType="Coupon">
+        /* TscCoupon.getCouponCustGbList */
+        SELECT CPN_ID
+             , USABLE_CUST_GB
+        FROM TB_COUPON_CUST_GBN
+        WHERE CPN_ID = #{cpnId}
+    </select>
+
+    <!-- 쿠폰사용가능고객등급 조회-->
+    <select id="getCouponCustGradeList" parameterType="int" resultType="Coupon">
+        /* TscCoupon.getCouponCustGradeList */
+        SELECT CPN_ID
+             , USABLE_CUST_GRADE
+        FROM TB_COUPON_CUST_GRADE
+        WHERE CPN_ID = #{cpnId}
+    </select>
+
+    <!-- 쿠폰사용가능결제수단 조회-->
+    <select id="getCouponPayTypeList" parameterType="int" resultType="Coupon">
+        /* TscCoupon.getCouponPayTypeList */
+        SELECT CPN_ID
+             , PAY_TYPE
+        FROM TB_COUPON_PAYTYPE
+        WHERE CPN_ID = #{cpnId}
+    </select>
+
+    <select id="getLimitedTimeCouponList" parameterType="int" resultType="CouponLimitedTime">
+        /* TscCoupon.getLimitedTimeCouponList */
+        SELECT	LIMIT_CPN_ID
+             ,LIMIT_CPN_NM
+             ,CPN_ID
+             ,DOWN_LIMIT_QTY
+             ,DOWN_STDT
+             ,DOWN_EDDT
+             ,DEL_YN
+             ,REG_NO
+             ,REG_DT
+             ,UPD_NO
+             ,UPD_DT
+        FROM	TB_LIMITED_TIME_COUPON
+        WHERE	1=1
+          AND  CPN_ID = #{cpnId}
+          AND  DEL_YN = 'N'
+    </select>
+
+    <update id="updateCouponMstInfo" parameterType="Coupon">
+        /* TscCoupon.updateCouponMstInfo */
+        UPDATE	TB_COUPON	SET
+        CPN_NM = #{cpnNm}
+        , SITE_CD = #{siteCd}
+        , AF_LINK_CD = #{afLinkCd}
+        , CPN_TYPE = #{cpnType}
+        , APPLY_SCOPE = #{applyScope}
+        , DC_WAY = #{dcWay}
+        , DC_PVAL = #{dcPval}
+        , DC_MVAL = #{dcMval}
+        , DC_AVAL = #{dcAval}
+        , MAX_DC_AMT = #{maxDcAmt}
+        , PD_GB = #{pdGb}
+        <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 = 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}
+        , CPN_STAT = #{cpnStat}
+        , END_ALIM_YN = #{endAlimYn}
+        , UPD_NO = #{updNo}
+        , UPD_DT = CURRENT_TIMESTAMP()
+        , FIRST_ORD_YN = #{firstOrdYn}
+        , DOWN_ABL_YN = #{downAblYn}
+        <choose>
+            <when test='newCustYn != null and newCustYn == "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='newCustYn != null and newCustYn == "N"'>
+                , CUST_JOIN_STDT = null
+                , CUST_JOIN_EDDT = null
+            </when>
+        </choose>
+        <choose>
+            <when test='firstOrdYn != null and firstOrdYn == "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='firstOrdYn != null and firstOrdYn == "N"'>
+                , BUY_STDT = null
+                , BUY_EDDT = null
+            </when>
+        </choose>
+        , NEW_CUST_YN = #{newCustYn}
+        WHERE CPN_ID = #{cpnId}
+    </update>
+
+    <delete id="deleteCouponCustGubun" parameterType="Coupon">
+        /* TscCoupon.deleteCouponCustGubun */
+        DELETE FROM	TB_COUPON_CUST_GBN
+        WHERE	CPN_ID = #{cpnId}
+    </delete>
+
+    <delete id="deleteCouponCustGrade" parameterType="Coupon">
+        /* TscCoupon.deleteCouponCustGrade */
+        DELETE FROM	TB_COUPON_CUST_GRADE
+        WHERE	CPN_ID = #{cpnId}
+    </delete>
+
+    <delete id="deleteCouponPayType" parameterType="Coupon">
+        /* TscCoupon.deleteCouponPayType */
+        DELETE FROM	TB_COUPON_PAYTYPE
+        WHERE	CPN_ID = #{cpnId}
+    </delete>
+
+    <update id="deleteCouponRefVal" parameterType="Coupon">
+        /* TscCoupon.deleteCouponRefVal */
+        UPDATE TB_COUPON_REFVAL SET
+            DEL_YN = 'Y'
+                                  , UPD_NO = #{updNo}
+                                  , UPD_DT = CURRENT_TIMESTAMP
+        WHERE CPN_ID = #{cpnId}
+          AND DEL_YN = 'N'
+    </update>
+
+    <update id="deleteCouponBurden" parameterType="Coupon">
+        /* TscCoupon.deleteCouponBurden */
+        UPDATE TB_COUPON_BURDEN SET
+            DEL_YN = 'Y'
+                                  , UPD_NO = #{updNo}
+                                  , UPD_DT = CURRENT_TIMESTAMP
+        WHERE CPN_ID = #{cpnId}
+          AND DEL_YN = 'N'
+    </update>
+
+    <update id="deleteLimitedTimeCoupon" parameterType="Coupon">
+        /* TscCoupon.deleteLimitedTimeCoupon */
+        UPDATE TB_LIMITED_TIME_COUPON SET
+            DEL_YN = 'Y'
+                                        , UPD_NO = #{updNo}
+                                        , UPD_DT = CURRENT_TIMESTAMP
+        WHERE CPN_ID = #{cpnId}
+          AND DEL_YN = 'N'
+    </update>
+
+    <!-- 쿠폰 등록 -->
+    <insert id="couponInsert" parameterType="Coupon" keyProperty="cpnId">
+        /* TscCoupon.couponInsert*/
+        INSERT INTO TB_COUPON (
+        CPN_ID
+        , CPN_NM
+        , SITE_CD
+        , AF_LINK_CD
+        , CPN_TYPE
+        , APPLY_SCOPE
+        , DC_WAY
+        , DC_PVAL
+        , DC_MVAL
+        , DC_AVAL
+        , MAX_DC_AMT
+        , PD_GB
+        , AVAIL_STDT
+        , AVAIL_EDDT
+        , AVAIL_DAYS
+        , CUST_PUB_LIMIT_QTY
+        , TOT_PUB_LIMIT_QTY
+        , ONE_PUB_QTY
+        , DN_GB
+        , DC_CD_GB
+        , DOWN_STDT
+        , DOWN_EDDT
+        , BUY_LIMIT_AMT
+        , PLAN_SQ
+        , REISSUANCE
+        , CPN_STAT
+        , END_ALIM_YN
+        , REG_NO
+        , REG_DT
+        , UPD_NO
+        , UPD_DT
+        , FIRST_ORD_YN
+        , DOWN_ABL_YN
+        , CUST_JOIN_STDT
+        , CUST_JOIN_EDDT
+        , BUY_STDT
+        , BUY_EDDT
+        , NEW_CUST_YN
+        ) VALUES (
+        #{cpnId}
+        , #{cpnNm}
+        , #{siteCd}
+        , #{afLinkCd}
+        , #{cpnType}
+        , #{applyScope}
+        , #{dcWay}
+        , #{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>
+        , #{custPubLimitQty}
+        , #{totPubLimitQty}
+        , #{onePubQty}
+        , #{dnGb}
+        , #{dcCdGb}
+        , DATE_FORMAT(#{downStdt} , '%Y-%m-%d %H:%i:%s')
+        , DATE_FORMAT(#{downEddt} , '%Y-%m-%d %H:%i:%s')
+        , #{buyLimitAmt}
+        , #{planSq}
+        , #{reissuance}
+        , #{cpnStat}
+        , #{endAlimYn}
+        , #{regNo}
+        , CURRENT_TIMESTAMP()
+        , #{updNo}
+        , CURRENT_TIMESTAMP()
+        , #{firstOrdYn}
+        , #{downAblYn}
+        <choose>
+            <when test='newCustYn != null and newCustYn == "Y"'>
+                , DATE_FORMAT(#{custJoinStdt} , '%Y-%m-%d %H:%i:%s')
+                , DATE_FORMAT(#{custJoinEddt} , '%Y-%m-%d %H:%i:%s')
+            </when>
+            <when test='newCustYn != null and newCustYn == "N"'>
+                , null
+                , null
+            </when>
+        </choose>
+        <choose>
+            <when test='firstOrdYn != null and firstOrdYn == "Y"'>
+                , DATE_FORMAT(#{buyStdt} , '%Y-%m-%d %H:%i:%s')
+                , DATE_FORMAT(#{buyEddt} , '%Y-%m-%d %H:%i:%s')
+            </when>
+            <when test='firstOrdYn != null and firstOrdYn == "N"'>
+                , DATE_FORMAT(#{buyStdt} , '%Y-%m-%d %H:%i:%s')
+                , DATE_FORMAT(#{buyEddt} , '%Y-%m-%d %H:%i:%s')
+            </when>
+        </choose>
+        , #{newCustYn}
+        ) ON DUPLICATE KEY UPDATE
+        CPN_NM = #{cpnNm}
+        , SITE_CD = #{siteCd}
+        , AF_LINK_CD = #{afLinkCd}
+        , CPN_TYPE = #{cpnType}
+        , APPLY_SCOPE = #{applyScope}
+        , DC_WAY = #{dcWay}
+        , DC_PVAL = #{dcPval}
+        , DC_MVAL = #{dcMval}
+        , DC_AVAL = #{dcAval}
+        , MAX_DC_AMT = #{maxDcAmt}
+        , PD_GB = #{pdGb}
+        <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 = 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}
+        , CPN_STAT = #{cpnStat}
+        , END_ALIM_YN = #{endAlimYn}
+        , UPD_NO = #{updNo}
+        , UPD_DT = now()
+        , FIRST_ORD_YN = #{firstOrdYn}
+        , DOWN_ABL_YN = #{downAblYn}
+        <choose>
+            <when test='newCustYn != null and newCustYn == "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='newCustYn != null and newCustYn == "N"'>
+                , CUST_JOIN_STDT = null
+                , CUST_JOIN_EDDT = null
+            </when>
+        </choose>
+        <choose>
+            <when test='firstOrdYn != null and firstOrdYn == "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='firstOrdYn != null and firstOrdYn == "N"'>
+                , BUY_STDT = null
+                , BUY_EDDT = null
+            </when>
+        </choose>
+        , NEW_CUST_YN = #{newCustYn}
+    </insert>
+
+    <insert id="createCouponCustGubun" parameterType="Coupon">
+        /* TscCoupon.createCouponCustGubun */
+        INSERT INTO TB_COUPON_CUST_GBN (
+                                         CPN_ID
+                                       , USABLE_CUST_GB
+                                       , REG_NO
+                                       , REG_DT
+        ) VALUES (
+                     #{cpnId}
+                 , #{usableCustGb}
+                 , #{regNo}
+                 , CURRENT_TIMESTAMP()
+                 )
+    </insert>
+
+    <insert id="createCouponCustGrade" parameterType="Coupon">
+        /* TscCoupon.createCouponCustGrade */
+        INSERT INTO TB_COUPON_CUST_GRADE (
+                                           CPN_ID
+                                         , USABLE_CUST_GRADE
+                                         , REG_NO
+                                         , REG_DT
+        ) VALUES (
+                     #{cpnId}
+                 , #{usableCustGrade}
+                 , #{regNo}
+                 , CURRENT_TIMESTAMP()
+                 )
+    </insert>
+
+    <insert id="createCouponPayType" parameterType="Coupon">
+        /* TscCoupon.createCouponPayType */
+        INSERT INTO TB_COUPON_PAYTYPE (
+                                        CPN_ID
+                                      , PAY_TYPE
+                                      , REG_NO
+                                      , REG_DT
+        ) VALUES (
+                     #{cpnId}
+                 , #{payType}
+                 , #{regNo}
+                 , CURRENT_TIMESTAMP()
+                 )
+    </insert>
+
+    <!-- 쿠폰 적용대상 등록 -->
+    <insert id="saveCouponRefVal" parameterType="CouponRefval" keyProperty="cpnRefvalSq">
+        /* TscCoupon.saveCouponRefVal */
+        INSERT INTO TB_COUPON_REFVAL (
+        CPN_ID
+        , CPN_REFVAL_SQ
+        , CPN_TYPE
+        , CPN_TARGET
+        , REF_VAL
+        <if test='refFormalGb != null and refFormalGb != ""'>
+            , REF_FORMAL_GB
+        </if>
+        <if test='refBrandCd != null and refBrandCd != ""'>
+            , REF_BRAND_CD
+        </if>
+        , REG_NO
+        , REG_DT
+        , UPD_NO
+        , UPD_DT
+        ) VALUES (
+        #{cpnId}
+        , #{cpnRefvalSq}
+        , #{cpnType}
+        , #{cpnTarget}
+        , #{refVal}
+        <if test='refFormalGb != null and refFormalGb != ""'>
+            , #{refFormalGb}
+        </if>
+        <if test='refBrandCd != null and refBrandCd != ""'>
+            , #{refBrandCd}
+        </if>
+        , #{regNo}
+        , CURRENT_TIMESTAMP()
+        , #{updNo}
+        , CURRENT_TIMESTAMP()
+        ) ON DUPLICATE KEY UPDATE
+        REF_VAL = #{refVal}
+        , CPN_TYPE = #{cpnType}
+        , CPN_TARGET = #{cpnTarget}
+        , REF_FORMAL_GB = #{refFormalGb}
+        , REF_BRAND_CD = #{refBrandCd}
+        , DEL_YN = #{delYn}
+        , UPD_NO = #{updNo}
+        , UPD_DT = now()
+    </insert>
+
+    <!-- 쿠폰 입점업체 분담율 등록 -->
+    <insert id="saveCouponBurden" parameterType="CouponBurden">
+        /* TscCoupon.saveCouponBurden */
+        INSERT INTO TB_COUPON_BURDEN( CPN_ID
+                                    , SUPPLY_COMP_CD
+                                    , BURDEN_RATE
+                                    , REG_NO
+                                    , REG_DT
+                                    , UPD_NO
+                                    , UPD_DT)
+        VALUES ( #{cpnId}
+               , #{supplyCompCd}
+               , #{burdenRate}
+               , #{regNo}
+               , CURRENT_TIMESTAMP()
+               , #{updNo}
+               , CURRENT_TIMESTAMP()
+               ) ON DUPLICATE KEY UPDATE
+            BURDEN_RATE = #{burdenRate}
+            , UPD_NO = #{updNo}
+            , UPD_DT = now()
+    </insert>
+
+    <insert id="createLimitedTimeCoupon" parameterType="CouponLimitedTime" keyProperty="limitCpnId">
+        /* TscCoupon.createLimitedTimeCoupon */
+        INSERT INTO TB_LIMITED_TIME_COUPON (
+                                             LIMIT_CPN_ID
+                                           , LIMIT_CPN_NM
+                                           , CPN_ID
+                                           , DOWN_LIMIT_QTY
+                                           , DOWN_STDT
+                                           , DOWN_EDDT
+                                           , DEL_YN
+                                           , REG_NO
+                                           , REG_DT
+                                           , UPD_NO
+                                           , UPD_DT
+        ) VALUES (
+                     #{limitCpnId}
+                 ,#{limitCpnNm}
+                 ,#{cpnId}
+                 ,#{downLimitQty}
+                 ,DATE_FORMAT(#{downStdt},'%Y-%m-%d %H:%i:%s')
+                 ,DATE_FORMAT(#{downEddt},'%Y-%m-%d %H:%i:%s')
+                 ,'N'
+                 ,#{regNo}
+                 ,CURRENT_TIMESTAMP()
+                 ,#{updNo}
+                 ,CURRENT_TIMESTAMP()
+                 ) ON DUPLICATE KEY UPDATE
+            LIMIT_CPN_NM = #{limitCpnNm}
+            , DOWN_LIMIT_QTY = #{downLimitQty}
+            , DOWN_STDT = DATE_FORMAT(#{downStdt},'%Y-%m-%d %H:%i:%s')
+            , DOWN_EDDT = DATE_FORMAT(#{downEddt},'%Y-%m-%d %H:%i:%s')
+            , DEL_YN = 'N'
+            , UPD_NO = #{updNo}
+            , UPD_DT = CURRENT_TIMESTAMP()
+    </insert>
+
+    <!-- 특정 쿠폰 발급받은 회원 조회-->
+    <select id="getCouponIssueCustList" parameterType="CustCoupon" resultType="CustCoupon">
+        /* TscCoupon.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">
+        /* TscCoupon.updateCustCouponAvailEddt */
+        UPDATE TB_CUST_COUPON
+        SET AVAIL_EDDT = DATE_FORMAT(#{availEddt} , '%Y-%m-%d')
+          , UPD_NO = #{updNo}
+          , UPD_DT = CURRENT_TIMESTAMP()
+        WHERE CPN_ID = #{cpnId}
+          AND USED_DT IS NOT NULL
+          AND CUST_NO = #{custNo}
+          AND CUST_CPN_SQ = #{custCpnSq}
+    </update>
+
+    <!-- 특정 쿠폰 발급받은 회원 조회-->
+    <select id="getSerialOverlapCheck" parameterType="Coupon" resultType="int">
+        /* TscCoupon.getSerialOverlapCheck : 기간 내 중복 시리얼넘버 체크 */
+        WITH CHECK_DATA AS (
+        SELECT C.CPN_ID
+        , C.DOWN_STDT
+        , C.DOWN_EDDT
+        , C.AVAIL_STDT
+        , C.AVAIL_EDDT
+        , C.AVAIL_DAYS
+        FROM TB_COUPON C
+        INNER JOIN (SELECT CPN_ID
+        , RD_CPN_NM
+        FROM TB_RANDOM_COUPON
+        WHERE RD_CPN_NM = #{rdCpnNm}
+        GROUP BY CPN_ID, RD_CPN_NM ) RC
+        ON C.CPN_ID = RC.CPN_ID
+        )
+        SELECT SUM(A.CNT) AS CNT
+        FROM ( SELECT COUNT(1) AS CNT		<!-- 다운 시작일이 겹치는 쿠폰번호 찾기 -->
+        FROM CHECK_DATA C
+        WHERE 1=1
+        AND C.DOWN_STDT >= STR_TO_DATE(#{downStdt}, '%Y-%m-%d %H:%i:%s')
+        AND C.DOWN_STDT <![CDATA[ <= ]]> STR_TO_DATE(#{downEddt}, '%Y-%m-%d %H:%i:%s')
+        UNION
+        SELECT COUNT(1) AS CNT		<!-- 다운 종료일이 겹치는 쿠폰번호 찾기 -->
+        FROM CHECK_DATA C
+        WHERE 1=1
+        AND C.DOWN_EDDT >= STR_TO_DATE(#{downStdt}, '%Y-%m-%d %H:%i:%s')
+        AND C.DOWN_EDDT <![CDATA[ <= ]]> STR_TO_DATE(#{downEddt}, '%Y-%m-%d %H:%i:%s')
+        ) A
+    </select>
+
+    <!-- 고객 쿠폰 발행 -->
+    <insert id="createRandomCouponInfo" parameterType="Coupon">
+        /* TscCoupon.createRandomCouponInfo */
+        INSERT INTO TB_RANDOM_COUPON (
+                                       RD_CPN_NM
+                                     , CPN_ID
+                                     , REG_NO
+                                     , REG_DT
+                                     , UPD_NO
+                                     , UPD_DT
+        ) VALUES (
+                     #{rdCpnNm}
+                 , #{cpnId}
+                 , #{regNo}
+                 , CURRENT_TIMESTAMP()
+                 , #{updNo}
+                 , CURRENT_TIMESTAMP()
+                 )
+    </insert>
+
+    <!-- 특정 쿠폰 발급받은 회원 조회-->
+    <select id="getRandomCouponNmCnt" parameterType="String" resultType="int">
+        /* TscCoupon.getRandomCouponNmCnt : 중복 시리얼넘버 체크 */
+        SELECT COUNT(1) AS CNT
+        FROM TB_RANDOM_COUPON
+        WHERE RD_CPN_NM = #{value}
+    </select>
+
+    <!-- 쿠폰 적용대상 수정-->
+    <update id="updateCouponRefval" parameterType="CouponRefval" >
+        /* TscCoupon.updateCouponRefval */
+        UPDATE TB_COUPON_REFVAL
+        SET DEL_YN = 'Y'
+        , UPD_NO = #{updNo}
+        , UPD_DT = CURRENT_TIMESTAMP()
+        WHERE CPN_ID = #{cpnId}
+        AND CPN_REFVAL_SQ IN
+        <foreach collection="cpnRefvalSqArr" item="item" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </update>
+
+    <!-- 고객 쿠폰 발행 -->
+    <insert id="saveCouponCustPub" parameterType="CustCoupon">
+        /* TscCoupon.saveCouponCustPub */
+        INSERT INTO TB_CUST_COUPON (
+                                     CUST_NO
+                                   , CPN_ID
+                                   , AVAIL_STDT
+                                   , AVAIL_EDDT
+                                   , PUB_REASON
+                                   , PUB_REASON_DTL
+                                   , END_ALIM_SEND_YN
+                                   , REG_NO
+                                   , REG_DT
+                                   , UPD_NO
+                                   , UPD_DT
+        ) VALUES (
+                     #{custNo}
+                 , #{cpnId}
+                 , DATE_FORMAT(#{availStdt} , '%Y%m%d%H%i%S')
+                 , DATE_FORMAT(#{availEddt} , '%Y%m%d%H%i%S')
+                 , #{pubReason}
+                 , #{pubReasonDtl}
+                 , #{endAlimSendYn}
+                 , #{regNo}
+                 , CURRENT_TIMESTAMP()
+                 , #{updNo}
+                 , CURRENT_TIMESTAMP()
+                 )
+    </insert>
+
+    <!-- 쿠폰발급받은회원 조회-->
+    <select id="getCpnPubCustList" parameterType="int" resultType="Coupon">
+        /* TscCoupon.getCpnPubCustList */
+        SELECT	A.CUST_NO
+             ,B.CUST_NM
+             ,B.CUST_GB
+             ,FN_GET_CODE_NM('G100',B.CUST_GB) AS CUST_GB_NM
+             ,B.CUST_GRADE
+             ,FN_GET_CODE_NM('G110',B.CUST_GRADE) AS CUST_GRADE_NM
+             ,A.AVAIL_STDT
+             ,A.AVAIL_EDDT
+             ,CASE WHEN A.USED_DT IS NOT NULL THEN 'Y'
+                   ELSE 'N' END USE_YN
+             ,A.USED_DT
+             ,A.PUB_REASON
+             ,FN_GET_CODE_NM('G068',A.PUB_REASON) AS PUB_REASON_NM
+             ,A.PUB_REASON_DTL
+             ,A.REG_NO
+             ,A.REG_DT
+        FROM 	TB_CUST_COUPON A
+                    LEFT OUTER JOIN TB_CUSTOMER B
+                                    ON		A.CUST_NO = B.CUST_NO
+        WHERE 1=1
+          AND A.CPN_ID = #{cpnId}
+    </select>
+
+    <!-- 선착순쿠폰 삭제 -->
+    <update id="updateLimitedTimeCouponList" parameterType="CouponLimitedTime" >
+        /* TscCoupon.updateLimitedTimeCouponList */
+        UPDATE TB_LIMITED_TIME_COUPON
+        SET DEL_YN = 'Y'
+        , UPD_NO = #{updNo}
+        , UPD_DT = CURRENT_TIMESTAMP()
+        WHERE CPN_ID = #{cpnId}
+        AND LIMIT_CPN_ID IN
+        <foreach collection="arrLimitCpnId" item="item" index="index"  open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </update>
+
+    <update id="updateCouponStat" parameterType="Coupon">
+        /* TscCoupon.updateCouponStat */
+        UPDATE TB_COUPON SET
+        CPN_STAT = #{cpnStat}
+        <if test="cpnStat == 'G232_14'">
+            , DEL_YN = 'Y'
+        </if>
+        , UPD_NO = #{updNo}
+        , UPD_DT = CURRENT_TIMESTAMP()
+        WHERE CPN_ID = #{cpnId}
+    </update>
+
+    <!-- 쿠폰조회 목록 -->
+    <select id="getCouponRetrieveList" parameterType="Coupon" resultType="Coupon">
+        /* TscCoupon.getCouponRetrieveList */
+        SELECT A.CPN_ID                                               /*쿠폰ID*/
+        , A.CPN_NM                                               /*쿠폰명*/
+        , A.SITE_CD                                              /*사이트코드(공통코드G000)*/
+        , A.CPN_TYPE                                             /*쿠폰유형(공통코드G230)*/
+        , A.DC_WAY                                               /*할인방식(공통코드G240)*/
+        , A.DC_PVAL                                              /*할인값(PC). 할인방식이 금액이면 할인금액, 율이면 할인율*/
+        , A.DC_MVAL                                              /*할인값(모바일). 할인방식이 금액이면 할인금액, 율이면 할인율*/
+        , A.MAX_DC_AMT                                           /*최고할인값. 할인방식이 금액이면 최고할인금액, 율이면 최고할인율*/
+        , A.PD_GB                                                /*기간/일수구분(P 기간, D 일수)*/
+        , DATE_FORMAT(A.AVAIL_STDT,'%Y%m%d%H%i%S') AS AVAIL_STDT /*유효시작일시(기간/일수구분 "P 기간"일 때 사용됨)*/
+        , DATE_FORMAT(A.AVAIL_EDDT,'%Y%m%d%H%i%S') AS AVAIL_EDDT /*유효종료일시(기간/일수구분 "P 기간"일 때 사용됨)*/
+        , A.AVAIL_DAYS                                           /*유효일수(기간/일수구분 "D 일수"일 때 사용됨)*/
+        , A.CUST_PUB_LIMIT_QTY                                   /*고객당발행제한수량(0은 무제한)*/
+        , A.TOT_PUB_LIMIT_QTY                                    /*총발행제한수량(0은 무제한)*/
+        , A.ONE_PUB_QTY                                          /*1회발행수량*/
+        , A.DN_GB                                                /*다운로드구분(A:자동다운로드, D:직접다운로드). 다운로드가능여부가 "Y 다운로드가능"일 때만 사용됨*/
+        , A.BUY_LIMIT_AMT                                        /*구매제한금액(0은 제한없음)*/
+        FROM   TB_COUPON A
+        WHERE  A.SITE_CD = #{siteCd}
+        <if test="cpnId !=null and cpnId !=''">
+            AND	   A.CPN_ID = #{cpnId}
+        </if>
+        <if test="cpnNm !=null and cpnNm !=''">
+            AND	   A.CPN_NM LIKE CONCAT('%',#{cpnNm},'%')
+        </if>
+        <if test="cpnType !=null and cpnType !=''">
+            AND	   A.CPN_TYPE = #{cpnType}
+        </if>
+    </select>
+
+</mapper>