瀏覽代碼

생일쿠폰 안내 배치 추가

jsshin 5 年之前
父節點
當前提交
7af97fff53

+ 10 - 0
src/main/java/com/style24/batch/biz/dao/TsbCustomerDao.java

@@ -173,4 +173,14 @@ public interface TsbCustomerDao {
 	 * @since  2021. 05. 07
 	 */
 	int updateCustomerGrade(CustGrade custGrade);
+
+	/**
+	 * 생일자대상 목록
+	 *
+	 * @param  customerSearch - 사이트 코드
+	 * @return Collection<Customer> - 목록
+	 * @author jsshin
+	 * @since  2021. 05. 10
+	 */
+	Collection<Customer> getBirthDayTargetList(CustomerSearch customerSearch);
 }

+ 65 - 0
src/main/java/com/style24/batch/biz/job/marketing/TsbBirthdayCouponNoticeJob.java

@@ -0,0 +1,65 @@
+package com.style24.batch.biz.job.marketing;
+
+import com.gagaframework.web.parameter.GagaMap;
+import com.style24.batch.biz.job.TsbAbstractJob;
+import com.style24.batch.biz.service.TsbCustomerService;
+import com.style24.batch.support.env.TsbConstants;
+import com.style24.core.support.env.TscConstants;
+import com.style24.persistence.domain.Customer;
+import com.style24.persistence.domain.CustomerSearch;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Collection;
+
+/**
+ * 생일자 쿠폰 안내
+ *
+ * @author jsshin
+ * @since 2021.05.10
+ */
+@Component
+@Slf4j
+public class TsbBirthdayCouponNoticeJob extends TsbAbstractJob<Collection<Customer>, GagaMap, GagaMap> {
+
+	@Autowired
+	TsbCustomerService customerService;
+
+	private int succCnt = 0;
+	private int failCnt = 0;
+
+	@Override
+	public Collection<Customer> read() throws Exception {
+		CustomerSearch customerSearch = new CustomerSearch();
+		customerSearch.setSiteCd(TscConstants.Site.STYLE24.value());
+		return customerService.getBirthDayTargetList(customerSearch);
+	}
+
+	@Override
+	public GagaMap process(Collection<Customer> readItem) throws Exception {
+
+		for (Customer customer: readItem) {
+			try {
+				customer.setRegNo(TsbConstants.REG_NO);
+				customer.setUpdNo(TsbConstants.REG_NO);
+				customerService.sendBirthDayCouponNotice(customer);
+				succCnt++;
+			} catch (Exception e) {
+				failCnt++;
+			}
+
+		}
+		return null;
+	}
+
+	@Override
+	public GagaMap write(GagaMap convertedItem) throws Exception {
+		return null;
+	}
+
+	@Override
+	public void notify(GagaMap resultItem) throws Exception {
+		super.printResult(succCnt, failCnt);
+	}
+}

+ 37 - 0
src/main/java/com/style24/batch/biz/service/TsbCustomerService.java

@@ -321,4 +321,41 @@ public class TsbCustomerService {
 	}
 
 
+	/**
+	 * 생일쿠폰안내대상 목록
+	 *
+	 * @param customerSearch - 사이트 코드
+	 * @return Collection<Customer> - 목록
+	 * @author jsshin
+	 * @since  2021. 05. 10
+	 */
+	public Collection<Customer> getBirthDayTargetList(CustomerSearch customerSearch) {
+		return customerDao.getBirthDayTargetList(customerSearch);
+	}
+
+
+	/**
+	 * 생일쿠폰 안내
+	 *
+	 * @param customer - 사이트 코드
+	 * @author jsshin
+	 * @since  2021. 05. 10
+	 */
+	@Transactional("shopTxnManager")
+	public void sendBirthDayCouponNotice(Customer customer) {
+		// TODO: 이메일 발송 모듈 붙어야 함 2021.05.10 jsshin
+		// 이메일 발송
+		if (StringUtils.isNotBlank(customer.getEmail())) {
+
+		}
+		CustContactHst custContactHst = new CustContactHst();
+		custContactHst.setContactType(TscConstants.ContactType.BIRTH_COUPON_NOTICE.value());
+		custContactHst.setContactMethod(TscConstants.ContactMethod.EMAIL.value());
+		custContactHst.setContactContents("생일쿠폰 다운로드 안내");
+		custContactHst.setSenderNo(TsbConstants.REG_NO);
+		custContactHst.setReceiverNo(customer.getCustNo());
+		custContactHst.setRegNo(TsbConstants.REG_NO);
+		//접촉 이력 저장
+		coreCustomerService.createCustomerContactHistory(custContactHst);
+	}
 }

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

@@ -48,7 +48,7 @@ public class TsbCustomerTask {
 	 * @author jsshin
 	 * @since 2021. 03. 08
 	 */
-	//@Scheduled(cron = "${cron.customer.dormant.schedule}")
+	@Scheduled(cron = "${cron.customer.dormant.schedule}")
 //	@Scheduled(fixedDelay=360000)
 	@Async
 	public void dormantScheduleJob() throws Exception {
@@ -62,7 +62,7 @@ public class TsbCustomerTask {
 	 * @author jsshin
 	 * @since 2021. 03. 08
 	 */
-	//@Scheduled(cron = "${cron.customer.dormant.transform}")
+	@Scheduled(cron = "${cron.customer.dormant.transform}")
 //	@Scheduled(fixedDelay=360000)
 	@Async
 	public void dormantTransformJob() throws Exception {
@@ -76,7 +76,7 @@ public class TsbCustomerTask {
 	 * @author jsshin
 	 * @since 2021. 03. 08
 	 */
-	//@Scheduled(cron = "${cron.customer.secede.process}")
+	@Scheduled(cron = "${cron.customer.secede.process}")
 //	@Scheduled(fixedDelay=360000)
 	@Async
 	public void secedeProcessJob() throws Exception {
@@ -90,7 +90,7 @@ public class TsbCustomerTask {
 	 * @author jsshin
 	 * @since 2021. 05. 06
 	 */
-	//@Scheduled(cron = "${cron.customer.privacy.policy.notice}")
+	@Scheduled(cron = "${cron.customer.privacy.policy.notice}")
 //	@Scheduled(fixedDelay=360000)
 	@Async
 	public void privacyPolicyNoticeJob() throws Exception {
@@ -104,7 +104,7 @@ public class TsbCustomerTask {
 	 * @author jsshin
 	 * @since 2021. 05. 06
 	 */
-	//@Scheduled(cron = "${cron.customer.marketing.agreement.notice}")
+	@Scheduled(cron = "${cron.customer.marketing.agreement.notice}")
 //	@Scheduled(fixedDelay=360000)
 	@Async
 	public void marketingAgreementNoticeJob() throws Exception {
@@ -118,7 +118,7 @@ public class TsbCustomerTask {
 	 * @author jsshin
 	 * @since 2021. 05. 06
 	 */
-	//@Scheduled(cron = "${cron.customer.grade.change}")
+	@Scheduled(cron = "${cron.customer.grade.change}")
 //	@Scheduled(fixedDelay=360000)
 	@Async
 	public void gradeChangeJob() throws Exception {

+ 24 - 1
src/main/java/com/style24/batch/biz/task/TsbMarketingTask.java

@@ -1,5 +1,6 @@
 package com.style24.batch.biz.task;
 
+import com.style24.batch.biz.job.marketing.TsbBirthdayCouponNoticeJob;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -29,6 +30,11 @@ public class TsbMarketingTask {
 	
 	@Autowired
 	private TsbExpirePointJob expirePointJob;
+
+	@Autowired
+	private TsbBirthdayCouponNoticeJob birthdayCouponNoticeJob;
+
+
 	/**
 	 * 자동구매확정 포인트 지급
 	 *
@@ -36,12 +42,27 @@ public class TsbMarketingTask {
 	 * @author jsshin
 	 * @since 2021. 04. 23
 	 */
-	//@Scheduled(cron = "${cron.marketing.auto.buy.confirm}")
+	@Scheduled(cron = "${cron.marketing.auto.buy.confirm}")
 	// @Scheduled(fixedDelay=360000)
 	@Async
 	public void autoBuyConfirmJob() throws Exception {
 		autoBuyConfirmJob.runById("cron.marketing.auto.buy.confirm");
 	}
+
+
+	/**
+	 * 생일쿠폰 다운로드 안내
+	 *
+	 * @throws Exception - 예외처리
+	 * @author jsshin
+	 * @since 2021. 05. 10
+	 */
+	@Scheduled(cron = "${cron.marketing.birthday.coupon.notice}")
+//	@Scheduled(fixedDelay=360000)
+	@Async
+	public void birthdayCouponNoticeJob() throws Exception {
+		birthdayCouponNoticeJob.runById("cron.marketing.birthday.coupon.notice");
+	}
 	
 	/**
 	 * 포인트 소멸처리
@@ -70,4 +91,6 @@ public class TsbMarketingTask {
 	public void expireCartExpirationJob() throws Exception {
 		cartExpirationJob.runById("cron.marketing.cart.expiration");
 	}
+
+
 }

+ 17 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsbCustomer.xml

@@ -487,4 +487,21 @@
 		WHERE  CGH.APPLY_YMD = DATE_FORMAT(NOW(), '%Y%m%d')
 	</update>
 
+	<!--생일쿠폰 다운로드 안내 대상자-->
+	<select id="getBirthDayTargetList" parameterType="CustomerSearch" resultType="Customer">
+		/*TsbCustomerDao.getBirthDayTargetList*/
+		SELECT C.CUST_NO
+		     , C.CUST_ID
+		     , C.EMAIL
+		     , BB.BIRTH_YMD
+		FROM   TB_CUSTOMER C
+		INNER JOIN
+		       TB_BATCH_BIRTH BB
+		ON     C.CUST_NO = BB.CUST_NO
+		WHERE  C.CUST_STAT = 'G104_10'
+		AND    C.SITE_CD = #{siteCd}
+		AND    SUBSTR(BB.BIRTH_YMD, 5,8) > DATE_FORMAT(DATE_ADD(LAST_DAY(NOW()), INTERVAL -1 MONTH ), '%m%d')
+		AND    SUBSTR(BB.BIRTH_YMD, 5,8) <![CDATA[<]]> DATE_FORMAT(DATE_ADD(LAST_DAY(NOW()), INTERVAL 1 DAY), '%m%d')
+	</select>
+
 </mapper>