Przeglądaj źródła

재입고알림톡 배치

eskim 4 lat temu
rodzic
commit
0e7218bb0b

+ 17 - 0
src/main/java/com/style24/batch/biz/dao/TsbGoodsDao.java

@@ -14,6 +14,7 @@ import com.style24.persistence.domain.IfBrand;
 import com.style24.persistence.domain.IfProduct;
 import com.style24.persistence.domain.IfProvider;
 import com.style24.persistence.domain.Option;
+import com.style24.persistence.domain.ReinboundInform;
 import com.style24.persistence.domain.WmsStock;
 
 import com.gagaframework.web.parameter.GagaMap;
@@ -678,5 +679,21 @@ public interface TsbGoodsDao {
 	 * @since 2021. 4. 7
 	 */
 	int createGoodsBenefit();
+	
+	/**
+	 * 재입고알림 목록
+	 *
+	 * @author eskim
+	 * @since 2021. 07. 01
+	 */
+	Collection<ReinboundInform> getReinboundInformList();
+	
+	/**
+	 * 재입고 알림톡 발송처리
+	 * 
+	 * @author eskim
+	 * @since 2021. 7. 1
+	 */
+	int updateReinboundInform(ReinboundInform reinboundInform);
 
 }

+ 84 - 0
src/main/java/com/style24/batch/biz/job/goods/TsbGoodsReinboundJob.java

@@ -0,0 +1,84 @@
+package com.style24.batch.biz.job.goods;
+
+import java.util.Collection;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.style24.batch.biz.job.TsbAbstractJob;
+import com.style24.batch.biz.service.TsbGoodsService;
+import com.style24.batch.support.env.TsbConstants;
+import com.style24.core.biz.service.TscKakaotalkService;
+import com.style24.persistence.domain.ReinboundInform;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.gagaframework.web.parameter.GagaMap;
+
+/**
+ * 재입고 알림
+ * 
+ * @author eskim
+ * @since 2021. 07. 01
+ */
+@Component
+@Slf4j
+public class TsbGoodsReinboundJob extends TsbAbstractJob<ReinboundInform, ReinboundInform, ReinboundInform> {
+
+	@Autowired
+	private TsbGoodsService goodsService;
+	
+	@Autowired
+	private TscKakaotalkService coreKakaotalkService;
+
+	private int succCnt = 0;
+	private int failCnt = 0;
+
+	@Override
+	public ReinboundInform read() throws Exception {
+
+		ReinboundInform reinboundInform = new ReinboundInform();
+		return reinboundInform;
+	}
+
+	@Override
+	public ReinboundInform process(ReinboundInform reinboundInform) throws Exception {
+		return reinboundInform;
+	}
+
+	@Override
+	public ReinboundInform write(ReinboundInform reinboundInform) throws Exception {
+
+		Collection<ReinboundInform> reinboundInformList = goodsService.getReinboundInformList();
+		if (reinboundInformList == null || reinboundInformList.isEmpty()) {
+			return reinboundInform;	
+		}
+		
+		for (ReinboundInform reinbound : reinboundInformList) {
+			// 재입고 알림톡 발송
+			
+			GagaMap goods = new GagaMap();
+			goods.set("custNo", reinbound.getCustNo());
+			goods.set("custNm", reinbound.getCustNm());
+			goods.set("goodsNm", reinbound.getGoodsNm());
+			goods.set("optCd1", reinbound.getOptCd1Nm());
+			goods.set("optCd2", reinbound.getOptCd2());
+			goods.set("cellPhnno", reinbound.getCellPhnno());
+			goods.set("goodsCd", reinbound.getGoodsCd());
+			goods.set("colorCd", reinbound.getOptCd1());
+			int result = coreKakaotalkService.goodsRestock(goods, TsbConstants.REG_NO);
+			if (result > 0) {
+				reinbound.setUpdNo(TsbConstants.REG_NO);
+				goodsService.updateReinboundInform(reinbound);	
+			}
+		}
+		
+		return reinboundInform;	
+	}
+
+	@Override
+	public void notify(ReinboundInform reinboundInform) throws Exception {
+		super.printResult(succCnt, failCnt);
+	}
+
+}

+ 22 - 0
src/main/java/com/style24/batch/biz/service/TsbGoodsService.java

@@ -23,6 +23,7 @@ import com.style24.persistence.domain.IfBrand;
 import com.style24.persistence.domain.IfProduct;
 import com.style24.persistence.domain.IfProvider;
 import com.style24.persistence.domain.Option;
+import com.style24.persistence.domain.ReinboundInform;
 import com.style24.persistence.domain.WmsStock;
 
 import io.netty.util.internal.StringUtil;
@@ -836,4 +837,25 @@ public class TsbGoodsService {
 		return goodsDao.createGoodsBenefit();
 	}
 
+	/**
+	 * 재입고알림 목록
+	 *
+	 * @return
+	 * @author eskim
+	 * @since 2021. 07. 01
+	 */
+	public Collection<ReinboundInform> getReinboundInformList() {
+		return goodsDao.getReinboundInformList();
+	}
+
+	/** 재입고 알림톡 발송처리
+	 * 
+	 * @author eskim
+	 * @since 2021. 7. 01
+	 */
+	@Transactional("shopTxnManager")
+	public int updateReinboundInform(ReinboundInform reinboundInform) {
+		return goodsDao.updateReinboundInform(reinboundInform);
+	}
+	
 }

+ 16 - 3
src/main/java/com/style24/batch/biz/task/TsbGoodsTask.java

@@ -9,13 +9,11 @@ import com.style24.batch.biz.job.delivery.TsbShopGoodsStockJob;
 import com.style24.batch.biz.job.goods.TsbDaumAllEp;
 import com.style24.batch.biz.job.goods.TsbDaumReviewEp;
 import com.style24.batch.biz.job.goods.TsbDaumSummaryEp;
-import com.style24.batch.biz.job.goods.TsbDaumAllEp;
-import com.style24.batch.biz.job.goods.TsbDaumReviewEp;
-import com.style24.batch.biz.job.goods.TsbDaumSummaryEp;
 import com.style24.batch.biz.job.goods.TsbGoodsBenefitJob;
 import com.style24.batch.biz.job.goods.TsbGoodsBenefitPriceJob;
 import com.style24.batch.biz.job.goods.TsbGoodsInfantsSafeNoJob;
 import com.style24.batch.biz.job.goods.TsbGoodsPriceJob;
+import com.style24.batch.biz.job.goods.TsbGoodsReinboundJob;
 import com.style24.batch.biz.job.goods.TsbGoodsRelateScoreJob;
 import com.style24.batch.biz.job.goods.TsbGoodsSearchAllJob;
 import com.style24.batch.biz.job.goods.TsbGoodsSearchSectionJob;
@@ -111,6 +109,9 @@ public class TsbGoodsTask {
 
 	@Autowired
 	private TsbGoodsSearchSectionJob goodsSearcSectionJob;
+	
+	@Autowired
+	private TsbGoodsReinboundJob goodsReinboundJob;
 
 	/**
 	 * 초 분 시 일 월 주(년)
@@ -383,4 +384,16 @@ public class TsbGoodsTask {
 		goodsSearcSectionJob.runById("cron.goods.search.section.create");
 	}
 
+	
+	/**
+	 * 재입고 알림
+	 *
+	 * @throws Exception
+	 */
+	@Scheduled(cron = "${cron.goods.reinbound.notify}")
+	@Async
+	public void reinboundJob() throws Exception {
+		goodsReinboundJob.runById("cron.goods.reinbound.notify");
+	}
+
 }

+ 16 - 0
src/main/java/com/style24/batch/biz/web/TsbGoodsController.java

@@ -14,6 +14,7 @@ import com.style24.batch.biz.job.goods.TsbDaumSummaryEp;
 import com.style24.batch.biz.job.goods.TsbGoodsBenefitJob;
 import com.style24.batch.biz.job.goods.TsbGoodsBenefitPriceJob;
 import com.style24.batch.biz.job.goods.TsbGoodsPriceJob;
+import com.style24.batch.biz.job.goods.TsbGoodsReinboundJob;
 import com.style24.batch.biz.job.goods.TsbGoodsRelateScoreJob;
 import com.style24.batch.biz.job.goods.TsbGoodsSearchAllJob;
 import com.style24.batch.biz.job.goods.TsbGoodsSearchSectionJob;
@@ -110,6 +111,9 @@ public class TsbGoodsController extends TscBaseController {
 
 	@Autowired
 	private TsbSocialGoodsJob socialGoodsJob;
+	
+	@Autowired
+	private TsbGoodsReinboundJob goodsReinboundJob;
 
 	/**
 	 * 상품 타이틀예약 적용 주기 : 시간배치 - 매시 1분 (소셜과 시간 중복)
@@ -369,5 +373,17 @@ public class TsbGoodsController extends TscBaseController {
 		goodsSearchSectionJob.runById("cron.goods.search.section.create");
 		return "OK";
 	}
+	
+	/**
+	 * 재입고 알림톡  : 시간배치
+	 *
+	 * @throws Exception
+	 */
+	@GetMapping("/reinbound/notify")
+	@ResponseBody
+	public String notifyGoodsReinbound() throws Exception {
+		goodsReinboundJob.runById("cron.goods.reinbound.notify");
+		return "OK";
+	}
 
 }

+ 66 - 0
src/main/java/com/style24/persistence/domain/ReinboundInform.java

@@ -0,0 +1,66 @@
+package com.style24.persistence.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.style24.core.support.session.TscSession;
+import com.style24.core.support.util.CryptoUtils;
+import com.style24.core.support.util.MaskingUtils;
+import com.style24.persistence.TscBaseDomain;
+
+import lombok.Data;
+
+/**
+ * 재입고 알림 Domain
+ *
+ * @author eskim
+ * @since 2020. 12. 16
+ */
+@SuppressWarnings("serial")
+@Data
+public class ReinboundInform extends TscBaseDomain {
+
+	private Integer rinbdInfoSq;
+	private int custNo;
+	private String goodsCd;
+	private String optCd;
+	private String optCd1;
+	private String optCd2;
+	private String reqDt;
+	private String informDt;
+	private int pastDays;
+
+	private String custId;
+	private String brandEnm;
+	private String GoodsNm;
+	private String custNm;
+	private String cellPhnno;
+	private String goodsStat;
+	private String optCd1Nm;
+	private String sysImgNm;
+	private int currStockQty;
+	private String soldoutYn;
+
+	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+	private String[] arrRinbdInfoSq;
+
+	// 암호화 대상 복호화 처리
+	public String getCustNm() {
+		this.custNm = CryptoUtils.decryptAES(this.custNm);
+		return this.custNm;
+	}
+	
+	public String getCellPhnno() {
+		this.cellPhnno = CryptoUtils.decryptAES(this.cellPhnno);
+		return this.cellPhnno;
+	}
+
+	// Masking
+	public String getMaskingCustId() {
+		return TscSession.getAttribute("maskingYn").equals("Y") ? MaskingUtils.id(this.custId) : this.custId;
+	}
+
+	public String getMaskingCustNm() {
+		return TscSession.getAttribute("maskingYn").equals("Y") ? MaskingUtils.name(getCustNm()) : getCustNm();
+
+	}
+	
+}

+ 39 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsbGoods.xml

@@ -3217,4 +3217,43 @@
 		FROM TB_SHOP_STOCK
 	</insert>
 	
+	<!-- 재입고알림 목록 -->
+	<select id="getReinboundInformList"  resultType="ReinboundInform">
+		/* TsbGoods.getReinboundInformList */
+		SELECT IA.RINBD_INFO_SQ
+		       , IA.GOODS_CD
+		       , IA.OPT_CD
+		       , IA.OPT_CD1
+		       , IA.OPT_CD2
+		       , IA.REQ_DT
+		       , IA.CUST_NO
+		       , C.CUST_ID
+		       , C.CUST_NM
+		       , C.CELL_PHNNO
+		       , G.GOODS_NM
+		       , CO.COLOR_KNM AS OPT_CD1_NM
+		       , VS.CURR_STOCK_QTY
+		  FROM TB_REINBOUND_INFORM IA
+		  INNER JOIN TB_GOODS G ON IA.GOODS_CD = G.GOODS_CD
+		                        AND G.GOODS_STAT = 'G008_90'
+		  INNER JOIN VW_STOCK VS ON IA.GOODS_CD = VS.GOODS_CD
+		                         AND IA.OPT_CD = VS.OPT_CD
+		                         AND VS.SOLDOUT_YN = 'N'
+		                         AND VS.CURR_STOCK_QTY > 0
+		  INNER JOIN TB_CUSTOMER C ON IA.CUST_NO = C.CUST_NO
+		  INNER JOIN TB_COLOR CO ON IA.OPT_CD1 = CO.COLOR_CD
+		  WHERE IA.INFORM_DT IS NULL  -- 미발송건
+		  AND DATEDIFF(CURRENT_DATE(),IA.REQ_DT) <![CDATA[<=]]> 15 /*경과일수*/
+	</select>
+	
+	<!-- 재입고 알림톡 발송처리 -->
+	<update id="updateReinboundInform" parameterType="ReinboundInform">
+		/* TsbGoods.updateReinboundInform */
+		UPDATE TB_REINBOUND_INFORM
+		SET INFORM_DT = NOW()
+		  , UPD_NO = #{updNo}
+		  , UPD_DT = NOW()
+		WHERE RINBD_INFO_SQ = #{rinbdInfoSq}
+	</update>
+	
 </mapper>

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

@@ -46,6 +46,7 @@ cron:
         search:
             all.create: 2 22 2 29 2 ?            #검색전체색인 생성
             section.create: 2 22 2 29 2 ?        #검색부분색인 생성
+        reinbound.notify:  2 22 2 29 2 ?           #재입고알림톡 발송
 
     # 회원(고객)
     customer: