|
|
@@ -4,8 +4,10 @@ import java.io.BufferedReader;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStreamReader;
|
|
|
import java.io.OutputStreamWriter;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.io.Writer;
|
|
|
import java.net.URL;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
@@ -1493,11 +1495,14 @@ public class TsfOrderService {
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
// http://ldfront.style24.com/pg/create/npay/goodsxml?product%5B0%5D%5Bid%5D=A83F-DP568S&product%5B0%5D%5BoptionManageCodes%5D=14019445-2&supplementSearch=true&optionSearch=true
|
|
|
// product%5B0%5D%5Bid%5D=A83F-DP568S&product%5B0%5D%5BoptionManageCodes%5D=14019445-2&supplementSearch=true&optionSearch=true
|
|
|
+ // http://ldfront.style24.com/pg/create/npay/goodsxml?product%5B0%5D%5Bid%5D=STYS00000143&product%5B0%5D%5BoptionManageCodes%5D=14237291-10/14237321-4/14237322-6&supplementSearch=true&optionSearch=true
|
|
|
+ // product%5B0%5D%5Bid%5D=STYS00000143&product%5B0%5D%5BoptionManageCodes%5D=14237291-10/14237321-4/14237322-6&supplementSearch=true&optionSearch=true
|
|
|
// 이스케이프코드 : %5B = [ , %5D = ]
|
|
|
|
|
|
try {
|
|
|
String goodsCdStr = "";
|
|
|
String optionManageCodesStr = "";
|
|
|
+ String optionManageCodes = "";
|
|
|
String queryStr = request.getQueryString();
|
|
|
String[] arr1 = queryStr.split("product");
|
|
|
|
|
|
@@ -1521,8 +1526,10 @@ public class TsfOrderService {
|
|
|
} else if (arr3[0].contains("optionManageCodes")) {
|
|
|
if ("".equals(optionManageCodesStr)) {
|
|
|
optionManageCodesStr = optionManageCodesStr + arr3[1];
|
|
|
+ optionManageCodes = optionManageCodes + arr3[1];
|
|
|
} else {
|
|
|
optionManageCodesStr = optionManageCodesStr + "," + arr3[1];
|
|
|
+ optionManageCodes = optionManageCodes + "/" + arr3[1];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1742,30 +1749,40 @@ public class TsfOrderService {
|
|
|
if (stockQtySave5 < Integer.parseInt(goods5stockQty[g5])) stockQty = Integer.parseInt(goods5stockQty[g5]);
|
|
|
|
|
|
// 세트상품은 최대 5개이므로 마무리.
|
|
|
- sb.append(getCombinationXml(manageCode.toString(), addPrice, stockQty, compsInfoList.size()));
|
|
|
+ if (optionManageCodes.equals(manageCode.toString())) {
|
|
|
+ sb.append(getCombinationXml(manageCode.toString(), addPrice, stockQty, compsInfoList.size()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- sb.append(getCombinationXml(manageCode.toString(), addPrice, stockQty, compsInfoList.size()));
|
|
|
+ if (optionManageCodes.equals(manageCode.toString())) {
|
|
|
+ sb.append(getCombinationXml(manageCode.toString(), addPrice, stockQty, compsInfoList.size()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- sb.append(getCombinationXml(manageCode.toString(), addPrice, stockQty, compsInfoList.size()));
|
|
|
+ if (optionManageCodes.equals(manageCode.toString())) {
|
|
|
+ sb.append(getCombinationXml(manageCode.toString(), addPrice, stockQty, compsInfoList.size()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- sb.append(getCombinationXml(manageCode.toString(), addPrice, stockQty, compsInfoList.size()));
|
|
|
+ if (optionManageCodes.equals(manageCode.toString())) {
|
|
|
+ sb.append(getCombinationXml(manageCode.toString(), addPrice, stockQty, compsInfoList.size()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- sb.append(getCombinationXml(manageCode.toString(), addPrice, stockQty, compsInfoList.size()));
|
|
|
+ if (optionManageCodes.equals(manageCode.toString())) {
|
|
|
+ sb.append(getCombinationXml(manageCode.toString(), addPrice, stockQty, compsInfoList.size()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1915,25 +1932,27 @@ public class TsfOrderService {
|
|
|
|
|
|
// 옵션 옵션조합정보
|
|
|
for(GoodsStock optInfo : optList) {
|
|
|
- sb.append("\t\t\t<combination>\n");
|
|
|
- sb.append("\t\t\t\t<manageCode>").append(optInfo.getOptCd()).append("</manageCode>\n");
|
|
|
- sb.append("\t\t\t\t<price>").append(optInfo.getAddPrice()).append("</price>\n");
|
|
|
- sb.append("\t\t\t\t<stockQuantity>").append(optInfo.getStockQty()).append("</stockQuantity>\n");
|
|
|
- sb.append("\t\t\t\t<status>true</status>\n");
|
|
|
-
|
|
|
- // 옵션 옵션조합정보 색상
|
|
|
- sb.append("\t\t\t\t<options>\n");
|
|
|
- sb.append("\t\t\t\t\t<name>색상</name>\n");
|
|
|
- sb.append("\t\t\t\t\t<id>").append(optInfo.getOptCd1()).append("</id>\n");
|
|
|
- sb.append("\t\t\t\t</options>\n");
|
|
|
-
|
|
|
- // 옵션 옵션조합정보 사이즈
|
|
|
- sb.append("\t\t\t\t<options>\n");
|
|
|
- sb.append("\t\t\t\t\t<name>사이즈</name>\n");
|
|
|
- sb.append("\t\t\t\t\t<id>").append(optInfo.getOptCd2()).append("</id>\n");
|
|
|
- sb.append("\t\t\t\t</options>\n");
|
|
|
-
|
|
|
- sb.append("\t\t\t</combination>\n");
|
|
|
+ if (optionManageCode.equals(optInfo.getOptCd())) {
|
|
|
+ sb.append("\t\t\t<combination>\n");
|
|
|
+ sb.append("\t\t\t\t<manageCode>").append(optInfo.getOptCd()).append("</manageCode>\n");
|
|
|
+ sb.append("\t\t\t\t<price>").append(optInfo.getAddPrice()).append("</price>\n");
|
|
|
+ sb.append("\t\t\t\t<stockQuantity>").append(optInfo.getStockQty()).append("</stockQuantity>\n");
|
|
|
+ sb.append("\t\t\t\t<status>true</status>\n");
|
|
|
+
|
|
|
+ // 옵션 옵션조합정보 색상
|
|
|
+ sb.append("\t\t\t\t<options>\n");
|
|
|
+ sb.append("\t\t\t\t\t<name>색상</name>\n");
|
|
|
+ sb.append("\t\t\t\t\t<id>").append(optInfo.getOptCd1()).append("</id>\n");
|
|
|
+ sb.append("\t\t\t\t</options>\n");
|
|
|
+
|
|
|
+ // 옵션 옵션조합정보 사이즈
|
|
|
+ sb.append("\t\t\t\t<options>\n");
|
|
|
+ sb.append("\t\t\t\t\t<name>사이즈</name>\n");
|
|
|
+ sb.append("\t\t\t\t\t<id>").append(optInfo.getOptCd2()).append("</id>\n");
|
|
|
+ sb.append("\t\t\t\t</options>\n");
|
|
|
+
|
|
|
+ sb.append("\t\t\t</combination>\n");
|
|
|
+ }
|
|
|
}
|
|
|
} else {// 입점업체 상품 정보
|
|
|
// 옵션 아이템정보 색상
|
|
|
@@ -1950,16 +1969,18 @@ public class TsfOrderService {
|
|
|
|
|
|
// 옵션 옵션조합정보
|
|
|
for(GoodsStock optInfo : optList) {
|
|
|
- sb.append("\t\t\t<combination>\n");
|
|
|
- sb.append("\t\t\t\t<manageCode>").append(optInfo.getOptCd()).append("</manageCode>\n");
|
|
|
- sb.append("\t\t\t\t<price>").append(optInfo.getAddPrice()).append("</price>\n");
|
|
|
- sb.append("\t\t\t\t<stockQuantity>").append(optInfo.getStockQty()).append("</stockQuantity>\n");
|
|
|
- sb.append("\t\t\t\t<status>true</status>\n");
|
|
|
- sb.append("\t\t\t\t<options>\n");
|
|
|
- sb.append("\t\t\t\t\t<name>옵션</name>\n");
|
|
|
- sb.append("\t\t\t\t\t<id>").append(optInfo.getOptCd()).append("</id>\n");
|
|
|
- sb.append("\t\t\t\t</options>\n");
|
|
|
- sb.append("\t\t\t</combination>\n");
|
|
|
+ if (optionManageCode.equals(optInfo.getOptCd())) {
|
|
|
+ sb.append("\t\t\t<combination>\n");
|
|
|
+ sb.append("\t\t\t\t<manageCode>").append(optInfo.getOptCd()).append("</manageCode>\n");
|
|
|
+ sb.append("\t\t\t\t<price>").append(optInfo.getAddPrice()).append("</price>\n");
|
|
|
+ sb.append("\t\t\t\t<stockQuantity>").append(optInfo.getStockQty()).append("</stockQuantity>\n");
|
|
|
+ sb.append("\t\t\t\t<status>true</status>\n");
|
|
|
+ sb.append("\t\t\t\t<options>\n");
|
|
|
+ sb.append("\t\t\t\t\t<name>옵션</name>\n");
|
|
|
+ sb.append("\t\t\t\t\t<id>").append(optInfo.getOptCd()).append("</id>\n");
|
|
|
+ sb.append("\t\t\t\t</options>\n");
|
|
|
+ sb.append("\t\t\t</combination>\n");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2197,4 +2218,110 @@ public class TsfOrderService {
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 네이버페이 찜하기 정보 전송
|
|
|
+ * @param
|
|
|
+ * @return GagaMap
|
|
|
+ * @author card007
|
|
|
+ * @since 2021. 08. 17
|
|
|
+ */
|
|
|
+ public GagaMap sendZzimToNC(Goods goods, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
+ GagaMap result = new GagaMap();
|
|
|
+ // 1.0, 2.0 일때 구분값 처리
|
|
|
+ URL _url = new URL(env.getProperty("naverPay.zzim.api.url"));
|
|
|
+ String ENCODING = "UTF-8";
|
|
|
+
|
|
|
+ HttpsURLConnection conn = (HttpsURLConnection)_url.openConnection();
|
|
|
+
|
|
|
+ conn.setDoInput(true);
|
|
|
+ conn.setDoOutput(true);
|
|
|
+ conn.setUseCaches(false);
|
|
|
+ conn.setRequestMethod("POST");
|
|
|
+ conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
|
+
|
|
|
+ // 네이버페이 기본정보
|
|
|
+ String shopId = env.getProperty("naverPay.shop.id"); // shopId
|
|
|
+ String certificationKey = env.getProperty("naverPay.certification.key"); // 네이버페이 인증키
|
|
|
+ String goodsUrl = env.getProperty("domain.front"); // 상품 경로
|
|
|
+ goodsUrl += "/goods/detail/form?goodsCd=" + goods.getGoodsCd();
|
|
|
+ if ("Y".equals(goods.getSelfGoodsYn())) {
|
|
|
+ goodsUrl += "&colorCd=" + goods.getColorCd();
|
|
|
+ } else {
|
|
|
+ goodsUrl += "&colorCd=XX";
|
|
|
+ }
|
|
|
+ String goodsImgUrl = env.getProperty("upload.goods.view") + "/" + goods.getSysImgNm(); // 상품 이미지 경로
|
|
|
+
|
|
|
+ // 상품정보 설정
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ _urlEncode(sb, "SHOP_ID", shopId);
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "CERTI_KEY", certificationKey);
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "ITEM_ID", goods.getGoodsCd());
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "ITEM_NAME", goods.getGoodsNm());
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "ITEM_UPRICE", String.valueOf(goods.getCurrPrice()));
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "ITEM_IMAGE", goodsImgUrl);
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "ITEM_URL", goodsUrl);
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "RESERVE1", "");
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "RESERVE2", "");
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "RESERVE3", "");
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "RESERVE4", "");
|
|
|
+ sb.append('&');
|
|
|
+ _urlEncode(sb, "RESERVE5", "");
|
|
|
+
|
|
|
+ // 주문 등록 API 호출
|
|
|
+ Writer writer = new OutputStreamWriter(conn.getOutputStream(), ENCODING);
|
|
|
+ writer.write(sb.toString());
|
|
|
+
|
|
|
+ writer.flush();
|
|
|
+ writer.close();
|
|
|
+
|
|
|
+ int respCode = conn.getResponseCode();
|
|
|
+ log.info("CHECK RESP CODE ::::: {}", respCode);
|
|
|
+
|
|
|
+ if (respCode != 200) {
|
|
|
+ throw new RuntimeException(String.format("NC Response fail : %d %s", respCode, conn.getResponseMessage()));
|
|
|
+ }
|
|
|
+
|
|
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
|
|
+
|
|
|
+ String itemId = reader.readLine();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(itemId)) {
|
|
|
+ String popupUrl = env.getProperty("naverPay.zzim.popup.url");
|
|
|
+ log.info("popupUrl >>> {}", popupUrl);
|
|
|
+ result.put("state", "success");
|
|
|
+ result.put("action", popupUrl);
|
|
|
+ result.put("shopId", shopId);
|
|
|
+ result.put("itemId", itemId);
|
|
|
+ } else {
|
|
|
+ throw new IllegalStateException(String.format("NC Response fail : %d %s", reader.readLine().toString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ conn.disconnect();
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void _urlEncode(StringBuilder sb, String key, String value) {
|
|
|
+ String ENCODING = "UTF-8";
|
|
|
+ try {
|
|
|
+ sb.append(URLEncoder.encode(key, ENCODING));
|
|
|
+ sb.append('=');
|
|
|
+ sb.append(URLEncoder.encode(value, ENCODING));
|
|
|
+ }
|
|
|
+ catch(UnsupportedEncodingException e) {
|
|
|
+ //일어나지 않음
|
|
|
+ throw new Error(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|