瀏覽代碼

연관상품 (쇼핑백 > 추천상품 (담은 상품이 있는 경우) 메소드 분리 및 브랜드 연관상품 목록 로직 수정

gagamel 4 年之前
父節點
當前提交
277a1f0f49
共有 1 個文件被更改,包括 35 次插入2 次删除
  1. 35 2
      src/main/java/com/style24/front/biz/thirdparty/EigeneaiApi.java

+ 35 - 2
src/main/java/com/style24/front/biz/thirdparty/EigeneaiApi.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 
 import com.google.gson.Gson;
+import com.style24.persistence.domain.Cart;
 import com.style24.persistence.domain.eigene.Eigeneai;
 import com.style24.persistence.domain.eigene.Eigeneai.Item;
 import com.style24.persistence.domain.eigene.Eigeneai.Result;
@@ -335,7 +336,6 @@ public class EigeneaiApi {
 	/**
 	 * 연관상품 목록
 	 * 사용되는 화면 영역)
-	 * 		쇼핑백 > 추천상품 (담은 상품이 있는 경우)
 	 * 		상품상세 > 함께 본 상품
 	 * @param goodsCd - 상품코드
 	 * @param size - 결과에 포함할 상품수
@@ -354,6 +354,39 @@ public class EigeneaiApi {
 		return new ArrayList<Result>();
 	}
 
+	/**
+	 * 연관상품 목록
+	 * 사용되는 화면 영역)
+	 * 		쇼핑백 > 추천상품 (담은 상품이 있는 경우)
+	 * @param cartList - 장바구니목록
+	 * @param size - 결과에 포함할 상품수
+	 * @return
+	 * @author gagamel
+	 * @since 2021. 5. 14
+	 */
+	public Collection<Result> getRelatedGoodsList(Collection<Cart> cartList, int size) {
+		if (cartList != null && !cartList.isEmpty()) {
+			StringBuilder sb = new StringBuilder();
+			int idx = 0;
+
+			for (Cart cart : cartList) {
+				if (idx++ > 0) {
+					sb.append(",");
+				}
+				sb.append(cart.getGoodsCd());
+			}
+
+			String requestUrl = apiUrl + "/a037?cuid=" + cuid + "&size=" + size + "&iids=" + sb.toString() + "&cps=true&cpt=m001";
+
+			Eigeneai eigeneai = this.getEigeneaiInfo(requestUrl);
+			if (eigeneai.getResults() != null && !eigeneai.getResults().isEmpty()) {
+				return eigeneai.getResults();
+			}
+		}
+
+		return new ArrayList<Result>();
+	}
+
 	/**
 	 * 브랜드 연관상품 목록
 	 * 사용되는 화면 영역)
@@ -366,7 +399,7 @@ public class EigeneaiApi {
 	 * @since 2021. 5. 14
 	 */
 	public Collection<Result> getBrandRelatedGoodsList(int size, String goodsCd, Integer brandGroupNo) {
-		String requestUrl = apiUrl + "/a038?cuid=" + cuid + "&size=" + size + "&iids=" + goodsCd + "&cps=true&cpt=c001&cpcids=" + brandGroupNo;
+		String requestUrl = apiUrl + "/a038?cuid=" + cuid + "&size=" + size + "&iids=" + goodsCd + "&cps=true&cpt=b004&bids=" + brandGroupNo;
 
 		Eigeneai eigeneai = this.getEigeneaiInfo(requestUrl);
 		if (eigeneai.getResults() != null && !eigeneai.getResults().isEmpty()) {