Procházet zdrojové kódy

쿠폰 소멸예정 알림톡

sowon4187 před 5 roky
rodič
revize
757fa55643

+ 14 - 0
src/main/java/com/style24/batch/biz/dao/TsbCouponDao.java

@@ -1,7 +1,11 @@
 package com.style24.batch.biz.dao;
 
 import com.style24.core.support.annotation.ShopDs;
+import com.style24.persistence.domain.Coupon;
 import com.style24.persistence.domain.CustCoupon;
+
+import java.util.Collection;
+
 import org.springframework.stereotype.Repository;
 
 /**
@@ -15,4 +19,14 @@ import org.springframework.stereotype.Repository;
 public interface TsbCouponDao {
 
 	CustCoupon getCouponBenefitInfo(CustCoupon custCoupon);
+	
+	/**
+	 * 쿠폰 기간만료 알림톡(7일) 리스트
+	 *
+	 * @param coupon
+	 * @return Collection<coupon>
+	 * @author sowon
+	 * @since  2021. 05. 31
+	 */
+	Collection<Coupon> getSendCouponExpectList(Coupon coupon);
 }

+ 59 - 0
src/main/java/com/style24/batch/biz/job/marketing/TsbExpectCouponJob.java

@@ -0,0 +1,59 @@
+package com.style24.batch.biz.job.marketing;
+
+import java.util.Collection;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.gagaframework.web.parameter.GagaMap;
+import com.style24.batch.biz.job.TsbAbstractJob;
+import com.style24.batch.biz.service.TsbCouponService;
+import com.style24.batch.biz.service.TsbGiftcardService;
+import com.style24.batch.support.env.TsbConstants;
+import com.style24.core.biz.service.TscKakaotalkService;
+import com.style24.persistence.domain.Coupon;
+import com.style24.persistence.domain.GiftCard;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Component
+@Slf4j
+public class TsbExpectCouponJob  extends TsbAbstractJob<Collection<Coupon>, GagaMap, GagaMap>{
+	
+	@Autowired
+	TsbCouponService couponService;
+	
+	@Autowired
+	TscKakaotalkService kakaoService;
+	
+	private int succCnt = 0;
+	private int failCnt = 0;
+	@Override
+	public Collection<Coupon> read() throws Exception {
+		Coupon coupon = new Coupon();
+		return couponService.getSendCouponExpectList(coupon);
+	}
+	@Override
+	public GagaMap process(Collection<Coupon> readItem) throws Exception {
+		for (Coupon coupon : readItem) {
+			try {
+				kakaoService.sendCouponExpectNotify(coupon, coupon.getCustNo());
+				succCnt++;
+			} catch (Exception e) {
+				failCnt++;
+				log.error(e.getMessage());
+			}
+		}
+		return null;
+	}
+	@Override
+	public GagaMap write(GagaMap convertedItem) throws Exception {
+		return null;
+	}
+	@Override
+	public void notify(GagaMap resultItem) throws Exception {
+		super.printResult(succCnt, failCnt);
+	}
+
+	
+}

+ 16 - 0
src/main/java/com/style24/batch/biz/service/TsbCouponService.java

@@ -7,10 +7,13 @@ import com.style24.core.biz.service.TscCouponService;
 import com.style24.core.biz.service.TscEnvsetService;
 import com.style24.core.biz.service.TscKakaotalkService;
 import com.style24.core.support.env.TscConstants;
+import com.style24.persistence.domain.Coupon;
 import com.style24.persistence.domain.CustCoupon;
 import com.style24.persistence.domain.Customer;
 import com.style24.persistence.domain.CustomerSearch;
 import com.style24.persistence.domain.Envset;
+import com.style24.persistence.domain.Point;
+
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -89,5 +92,18 @@ public class TsbCouponService {
 		custCoupon.setCpnId(cpnId);
 		return couponDao.getCouponBenefitInfo(custCoupon);
 	}
+	
+	/**
+	 * 쿠폰 기간만료 알림톡(7일) 리스트
+	 *
+	 * @param coupon
+	 * @return Collection<Coupon>
+	 * @author sowon
+	 * @since  2021. 05. 31
+	 */
+	@Transactional("shopTxnManager")
+	public Collection<Coupon> getSendCouponExpectList(Coupon coupon){
+		return couponDao.getSendCouponExpectList(coupon);
+	}
 
 }

+ 1 - 1
src/main/java/com/style24/batch/biz/service/TsbPointService.java

@@ -76,7 +76,7 @@ public class TsbPointService {
 	}
 	
 	/**
-	 * 상품권 기간만료 알림톡(30일) 리스트
+	 * 포인트 기간만료 알림톡(30일) 리스트
 	 *
 	 * @param point
 	 * @return Collection<Point>

+ 19 - 0
src/main/java/com/style24/batch/biz/task/TsbCustomerTask.java

@@ -1,6 +1,8 @@
 package com.style24.batch.biz.task;
 
 import com.style24.batch.biz.job.marketing.TsbCombackCouponNoticeJob;
+import com.style24.batch.biz.job.marketing.TsbExpectCouponJob;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -73,6 +75,9 @@ public class TsbCustomerTask {
 	
 	@Autowired
 	private TsbExpectGiftcardJob expectGiftcardJob;
+	
+	@Autowired
+	private TsbExpectCouponJob expectCouponJob;
 
 	@Autowired
 	private TsbReviewGuideJob reviewGuideJob;
@@ -257,6 +262,20 @@ public class TsbCustomerTask {
 	public void giftcardExpectJob() throws Exception {
 		expectGiftcardJob.runById("cron.customer.giftcard.expect.notify");
 	}
+	
+	/**
+	 * 쿠폰 기간만료 알림톡(7일)
+	 *
+	 * @throws Exception - 예외처리
+	 * @author sowon
+	 * @since 2021. 05. 31
+	 */
+	@Scheduled(cron = "${cron.customer.coupon.expect.notify}")
+	@Async
+	public void couponExpectJob() throws Exception {
+		expectCouponJob.runById("cron.customer.coupon.expect.notify");
+	}
+
 
 	/**
 	 * 상품평등록안내발송 처리

+ 24 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsbCoupon.xml

@@ -74,6 +74,30 @@
 		AND   CP.SITE_CD = #{siteCd}
 		AND   CP.CPN_STAT = 'G232_11'
 	</select>
+	
+	<select id="getSendCouponExpectList" parameterType="Coupon" resultType="Coupon">
+		/*TsbCoupon.getSendCouponExpectList*/
+		SELECT  C.CUST_NO 
+		      , C.CUST_NM 
+		      , C.CELL_PHNNO
+		      , CC.CPN_ID 
+		      , TC.CPN_NM 
+		      , TC.DC_AVAL
+		      , TC.PD_GB 
+		      , TC.DC_MVAL                                                                     AS DC_VAL
+		      , CASE WHEN TC.DC_WAY = 'G240_10' THEN '원'
+		            ELSE '%'
+		       END                                                                             AS DC_WAY
+		      , DATE_FORMAT(CC.AVAIL_EDDT , '%Y.%m.%d') AS AVAIL_EDDT
+		FROM TB_CUST_COUPON CC INNER JOIN TB_CUSTOMER C 
+		                  ON CC.CUST_NO = C.CUST_NO
+		                       INNER JOIN TB_COUPON TC
+		                  ON CC.CPN_ID = TC.CPN_ID 
+		WHERE CC.USED_DT IS NULL
+		AND CC.AVAIL_EDDT BETWEEN CONCAT(DATE_FORMAT(DATE_ADD(NOW(), INTERVAL 7 DAY),'%Y-%m-%d'), ' 00:00:00') AND CONCAT(DATE_FORMAT(DATE_ADD(NOW(), INTERVAL 7 DAY),'%Y-%m-%d'), ' 23:59:59')
+		AND C.CUST_STAT = 'G104_10' /*활동회원 만 */
+		AND TC.CPN_STAT = 'G232_11'
+	</select>
 
 
 </mapper>

+ 1 - 1
src/main/resources/config/application.yml

@@ -54,7 +54,7 @@ cron:
         review.register.notify: 2 22 2 29 2 ?  #상품평등록안내 발송(일배치)
         giftcard.expect.notify : 2 22 2 29 2 ? #상품권 소멸예정 알림톡
         point.expect.notify : 2 22 2 29 2 ?    #포인트 소멸예정 알림톡
-        coupon.expect.notify : 2 22 2 29 2 ?    #쿠폰 소멸예정 알림톡
+        coupon.expect.notify : 2 22 2 29 2 ?   #쿠폰 소멸예정 알림톡
         
 
     # 전시