Browse Source

샵링커재고전송-브랜드별 재고분할비율 설정

jmh 4 years ago
parent
commit
deab458768

+ 100 - 4
src/main/java/com/style24/batch/biz/job/shoplinker/TsbShoplinkerStockJob.java

@@ -92,9 +92,12 @@ public class TsbShoplinkerStockJob extends TsbAbstractJob<Collection<ShoplinkerG
 
 			try {
 				StringBuilder sbRequest;
-				int opCnt = 0;
+				int qty = 0;
 				for (ShoplinkerGoods map : stockList) {
-					opCnt ++;
+					
+					// 21.10.18 재고비율 추가 - 샵링커에 전송 및 전송이력에는 재고비율 수량으로 저장함
+					// 참고)재고 마스터 테이블에는 원 수량임(동기화 처리시에도 원 수량으로 됨)
+					qty = GetStockQtyForBrand(map, false);
 
 					// xml 데이터 세팅
 					sbRequest = new StringBuilder();
@@ -105,14 +108,14 @@ public class TsbShoplinkerStockJob extends TsbAbstractJob<Collection<ShoplinkerG
 					sbRequest.append("		<customer_id>").append(customerId).append("</customer_id>\n");
 					sbRequest.append("		<mall_update_yn>N</mall_update_yn>\n");
 					sbRequest.append("		<partner_product_id><![CDATA[").append(map.getOptCd()).append("]]></partner_product_id>\n");
-					sbRequest.append("		<quantity>").append(map.getQuantity()).append("</quantity>\n");
+					sbRequest.append("		<quantity>").append(qty).append("</quantity>\n");
 
 					sbRequest.append("	</product>\n");
 					sbRequest.append("</shoplinker>\n");
 
 					regMap.setGoodsCd(map.getGoodsCd());
 					regMap.setOptCd(map.getOptCd());
-					regMap.setQuantity(map.getQuantity());
+					regMap.setQuantity(qty);
 
 					// 3. api 호출 및 결과 history 저장
 					callGoodsRegApi(regMap , sbRequest, map.getOptCd());
@@ -200,4 +203,97 @@ public class TsbShoplinkerStockJob extends TsbAbstractJob<Collection<ShoplinkerG
 
 		return succCnt;
 	}
+	
+	/**
+	 * 샵링커 브랜드별 재고비율
+	 *
+	 * @return
+	 * @author jmh
+	 * @since  2021. 10. 18
+	 */
+	private int GetStockQtyForBrand(ShoplinkerGoods map, boolean isFirst)
+    {
+        int resultQty = 0;
+        String brandCd = map.getBrand();
+        int qty = map.getQuantity();
+
+        if (brandCd.equals("S0016") || brandCd.equals("S0018") || brandCd.equals("S0012"))
+        {
+            if (qty >= 0 && qty <= 5)
+            {
+                resultQty = isFirst ? 1 : 0;
+            }
+            else if (qty >= 6 && qty <= 29)
+            {
+                resultQty = (int)Math.floor(qty * 0.25);
+            }
+            else if (qty >= 30)
+            {
+                resultQty = (int)Math.floor(qty * 0.4);
+            }
+        }
+        else if (brandCd.equals("S0005"))
+        {
+            if (qty >= 0 && qty <= 3)
+            {
+                resultQty = isFirst ? 1 : 0;
+            }
+            else if (qty >= 4 && qty <= 29)
+            {
+                resultQty = (int)Math.floor(qty * 0.25);
+            }
+            else if (qty >= 30)
+            {
+                resultQty = (int)Math.floor(qty * 0.4);
+            }
+        }
+        else if (brandCd.equals("S0003") || brandCd.equals("S0004") || brandCd.equals("S0007") || brandCd.equals("S0001") || brandCd.equals("S0006"))
+        {
+            if (qty >= 0 && qty <= 3)
+            {
+                resultQty = isFirst ? 1 : 0;
+            }
+            else if (qty >= 4 && qty <= 29)
+            {
+                resultQty = (int)Math.ceil(qty * 0.25);
+            }
+            else if (qty >= 30)
+            {
+                resultQty = (int)Math.floor(qty * 0.4);
+            }
+        }
+        else if (brandCd.equals("S0013"))
+        {
+            if (qty >= 0 && qty <= 2)
+            {
+                resultQty = isFirst ? 1 : 0;
+            }
+            else if (qty >= 3 && qty <= 29)
+            {
+                resultQty = (int)Math.ceil(qty * 0.25);
+            }
+            else if (qty >= 30)
+            {
+                resultQty = (int)Math.floor(qty * 0.4);
+            }
+        }
+
+        else if (brandCd.equals("S0015"))
+        {
+            if (qty >= 0 && qty <= 2)
+            {
+                resultQty = isFirst ? 1 : 0;
+            }
+            else if (qty >= 3 && qty <= 29)
+            {
+                resultQty = (int)Math.ceil(qty * 0.25);
+            }
+            else if (qty >= 30)
+            {
+                resultQty = (int)Math.floor(qty * 0.4);
+            }
+        }
+
+        return resultQty;
+    }
 }

+ 1 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsbShoplinker.xml

@@ -43,6 +43,7 @@
 			, A.GOODS_CD
 			, A.OPT_CD
 			, A.STOCK_QTY AS QUANTITY
+			, TG.BRAND_CD
 		FROM   SHOPLINKER_STOCK A
 		 INNER JOIN TB_GOODS TG ON A.GOODS_CD = TG.GOODS_CD
 		WHERE  A.SEND_YN = 'N'