|
|
@@ -3,9 +3,7 @@ package com.style24.front.biz.service;
|
|
|
import java.io.*;
|
|
|
import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import javax.net.ssl.HttpsURLConnection;
|
|
|
import javax.servlet.http.Cookie;
|
|
|
@@ -1148,7 +1146,7 @@ public class TsfOrderService {
|
|
|
// 3.주문정보 저장
|
|
|
coreOrderDao.updateNaverPayOrderNo(param);
|
|
|
result.put("npayOrderUrl", env.getProperty("naverPay.order.url"));
|
|
|
- result.put("orderkey", result.get("orderKey").toString());
|
|
|
+ result.put("orderkey", param.getNpayOrdNo());
|
|
|
result.put("resultNo", result.get("resultNo").toString());
|
|
|
|
|
|
result.put("state", "sucess");
|
|
|
@@ -1245,10 +1243,11 @@ public class TsfOrderService {
|
|
|
* @author xodud1202
|
|
|
* @since 2021. 05. 12
|
|
|
*/
|
|
|
- public void createNpayGoodsXml50(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ public void createNpayGoodsXml50(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
- // http://locd.michaa2.sisun.com/order/createNpayGoodsXml.do?product[0][id]=G2019070300016&product[0][optionManageCodes]=010_5|55|&supplementSearch=true&optionSearch=true
|
|
|
- // product[0][id]=G2019070300016&product[0][optionManageCodes]=010_5|55|&supplementSearch=true&optionSearch=true
|
|
|
+ // 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
|
|
|
+ // 이스케이프코드 : %5B = [ , %5D = ]
|
|
|
|
|
|
try {
|
|
|
String goodsCdStr = "";
|
|
|
@@ -1294,22 +1293,17 @@ public class TsfOrderService {
|
|
|
String goodsImgUrl = env.getProperty("upload.goods.view"); // 상품 이미지 경로
|
|
|
int totPrice = 0; // 전체 주문 금액
|
|
|
|
|
|
- sb.append("<?xml version='1.0' encoding='utf-8'?>");
|
|
|
- sb.append("<products>");
|
|
|
+ sb.append("<?xml version='1.0' encoding='utf-8'?>\n");
|
|
|
+ sb.append("<products>\n");
|
|
|
|
|
|
for (int i=0; i<goodsCdArr.length; i++) {
|
|
|
Order item = new Order();
|
|
|
|
|
|
item.setGoodsCd(goodsCdArr[i]);
|
|
|
- //shopInfo.setLang(CommonCodeConstant.SHIP_CONTR_KOREA); //KOR
|
|
|
- //shopInfo.setDevice(CommonCodeConstant.DEIVCE_WEB); //WEB
|
|
|
|
|
|
// 9.상품 옵션
|
|
|
- String optionManageCodesArrStr = coreOrderService.simpleDecode(optionManageCodesArr[i]);
|
|
|
- String [] arr = optionManageCodesArrStr.split(",");
|
|
|
- item.setOptCd(arr[0]);
|
|
|
-
|
|
|
- arr[1] = coreOrderService.simpleDecode(arr[1]);
|
|
|
+ String optionManageCode = coreOrderService.simpleDecode(optionManageCodesArr[i]);
|
|
|
+ item.setOptCd(optionManageCode);
|
|
|
|
|
|
// 주문 상품 옵션 정보 조회
|
|
|
GoodsStock opt = new GoodsStock();
|
|
|
@@ -1340,130 +1334,174 @@ public class TsfOrderService {
|
|
|
// 반송지 정보
|
|
|
Delivery rtnInfo = goodsDao.getGoodsDeliveryInfo(goods.getGoodsCd());
|
|
|
|
|
|
- sb.append("<product>");
|
|
|
- sb.append("<id>").append(goodsCdArr[i]).append("</id>");
|
|
|
- sb.append("<merchantProductId>").append(goodsCdArr[i]).append("</merchantProductId>");
|
|
|
- sb.append("<ecMallProductId>").append(goodsCdArr[i]).append("</ecMallProductId>");
|
|
|
- sb.append("<name>").append(goods.getGoodsNm()).append("</name>");
|
|
|
- sb.append("<status>").append(goodsStat).append("</status>");
|
|
|
- sb.append("<basePrice>").append(goods.getCurrPrice() + opt.getAddPrice()).append("</basePrice>");
|
|
|
+ sb.append("\t<product>\n");
|
|
|
+ sb.append("\t\t<id>").append(goodsCdArr[i]).append("</id>\n");
|
|
|
+ sb.append("\t\t<merchantProductId>").append(goodsCdArr[i]).append("</merchantProductId>\n");
|
|
|
+ sb.append("\t\t<ecMallProductId>").append(goodsCdArr[i]).append("</ecMallProductId>\n");
|
|
|
+ sb.append("\t\t<name>").append(goods.getGoodsNm()).append("</name>\n");
|
|
|
+ sb.append("\t\t<status>").append(goodsStat).append("</status>\n");
|
|
|
+ sb.append("\t\t<basePrice>").append(goods.getCurrPrice() + opt.getAddPrice()).append("</basePrice>\n");
|
|
|
// TODO http: 부분 운영 프로토콜 확인 후 수정 필요(운영 상품상세가 HTTPS일 경우 분기처리 필요(개발서버, 운영 구분))
|
|
|
- sb.append("<infoUrl>").append("http:" + domain + goods.getGoodsCd()).append("</infoUrl>");
|
|
|
- sb.append("<imageUrl>").append("http:" + goodsImgUrl + "/" + goods.getSysImgNm()).append("</imageUrl>");
|
|
|
+ sb.append("\t\t<infoUrl>").append("http:" + domain + "/goods/detail/form?goodsCd=" + goods.getGoodsCd()).append("</infoUrl>\n");
|
|
|
+ sb.append("\t\t<imageUrl>").append("http:" + goodsImgUrl + "/" + goods.getSysImgNm()).append("</imageUrl>\n");
|
|
|
|
|
|
// 12.반품주소
|
|
|
- if (rtnInfo != null) {
|
|
|
- if (rtnInfo.getRtnLocZipcode() != null && !"".equals(rtnInfo.getRtnLocZipcode())) {
|
|
|
- // 2.1 반품정보
|
|
|
- sb.append("<returnInfo>");
|
|
|
- sb.append("<zipcode>").append(rtnInfo.getRtnLocZipcode()).append("</zipcode>");
|
|
|
- sb.append("<address1>").append(rtnInfo.getRtnLocBaseAddr()).append("</address1>");
|
|
|
- sb.append("<address2>").append(rtnInfo.getRtnLocDtlAddr()).append("</address2>");
|
|
|
- sb.append("<sellername>").append(rtnInfo.getRtnLocNm()).append("</sellername>");
|
|
|
- sb.append("<contact1>").append(rtnInfo.getRtnLocTelno()).append("</contact1>");
|
|
|
- sb.append("</returnInfo>");
|
|
|
-
|
|
|
- // 반품배송비, 교환배송비
|
|
|
- sb.append("<returnShippingFee>").append(goods.getRtnDelvFee()).append("</returnShippingFee>");
|
|
|
- sb.append("<exchangeShippingFee>").append(goods.getDelvFee() + goods.getRtnDelvFee()).append("</exchangeShippingFee>");
|
|
|
- }
|
|
|
+ if (rtnInfo != null && rtnInfo.getRtnLocZipcode() != null && !"".equals(rtnInfo.getRtnLocZipcode())) {
|
|
|
+ // 2.1 반품정보
|
|
|
+ sb.append("\t\t<returnInfo>\n");
|
|
|
+ sb.append("\t\t\t<zipcode>").append(rtnInfo.getRtnLocZipcode()).append("</zipcode>\n");
|
|
|
+ sb.append("\t\t\t<address1>").append(rtnInfo.getRtnLocBaseAddr()).append("</address1>\n");
|
|
|
+ sb.append("\t\t\t<address2>").append(rtnInfo.getRtnLocDtlAddr()).append("</address2>\n");
|
|
|
+ sb.append("\t\t\t<sellername>").append(rtnInfo.getRtnLocNm()).append("</sellername>\n");
|
|
|
+ sb.append("\t\t\t<contact1>").append(rtnInfo.getRtnLocTelno()).append("</contact1>\n");
|
|
|
+ sb.append("\t\t</returnInfo>\n");
|
|
|
+
|
|
|
+ // 반품배송비, 교환배송비
|
|
|
+ sb.append("\t\t<returnShippingFee>").append(goods.getRtnDelvFee()).append("</returnShippingFee>\n");
|
|
|
+ sb.append("\t\t<exchangeShippingFee>").append(goods.getDelvFee() + goods.getRtnDelvFee()).append("</exchangeShippingFee>\n");
|
|
|
}
|
|
|
|
|
|
// 옵션정보 지원여부 true
|
|
|
- sb.append("<optionSupport>true</optionSupport>");
|
|
|
+ sb.append("\t\t<optionSupport>true</optionSupport>\n");
|
|
|
|
|
|
// 상품 옵션 전체 정보 조회
|
|
|
Collection<GoodsStock> optList = goodsDao.getGoodsOptionInfoList(opt);
|
|
|
|
|
|
- String[] colorList = new String[optList.size()];
|
|
|
String[] colorNmList = new String[optList.size()];
|
|
|
+ String[] colorList = new String[optList.size()];
|
|
|
String[] sizeList = new String[optList.size()];
|
|
|
int count = 0;
|
|
|
for(GoodsStock optInfo : optList) {
|
|
|
colorNmList[count] = optInfo.getColorNm();
|
|
|
colorList[count] = optInfo.getOptCd1();
|
|
|
sizeList[count] = optInfo.getOptCd2();
|
|
|
+ count++;
|
|
|
}
|
|
|
|
|
|
+ colorNmList = new HashSet<String>(Arrays.asList(colorNmList)).toArray(new String[0]);
|
|
|
+ colorList = new HashSet<String>(Arrays.asList(colorList)).toArray(new String[0]);
|
|
|
+ sizeList = new HashSet<String>(Arrays.asList(sizeList)).toArray(new String[0]);
|
|
|
+
|
|
|
// 옵션 정보
|
|
|
- sb.append("<option>");
|
|
|
+ sb.append("\t\t<option>\n");
|
|
|
|
|
|
// 9.1 옵션 아이템정보 색상
|
|
|
- /*sb.append("<optionItem>");
|
|
|
- sb.append("<type>SELECT</type>");
|
|
|
- sb.append("<name>칼라</name>");
|
|
|
- sb.append("<value>");
|
|
|
- sb.append("<id>").append("<![CDATA[" + arr[0] + "]]>").append("</id>");
|
|
|
- sb.append("<text>").append("<![CDATA[" + shopInfo.getGoods_color_nm() + "]]>").append("</text>");
|
|
|
- sb.append("</value>");
|
|
|
- sb.append("</optionItem>");
|
|
|
-
|
|
|
- String goodsSizeStr = coreOrderService.decodeStr(arr[1]);
|
|
|
+ sb.append("\t\t\t<optionItem>\n");
|
|
|
+ sb.append("\t\t\t\t<type>SELECT</type>\n");
|
|
|
+ sb.append("\t\t\t\t<name>색상</name>\n");
|
|
|
+ for(int j = 0 ; j < colorList.length ; j++) {
|
|
|
+ sb.append("\t\t\t\t<value>\n");
|
|
|
+ sb.append("\t\t\t\t\t<id>").append(colorList[j]).append("</id>\n");
|
|
|
+ sb.append("\t\t\t\t\t<text>").append(colorNmList[j]).append("</text>\n");
|
|
|
+ sb.append("\t\t\t\t</value>\n");
|
|
|
+ }
|
|
|
+ sb.append("\t\t\t</optionItem>\n");
|
|
|
|
|
|
// 9.1 옵션 아이템정보 사이즈
|
|
|
- sb.append("<optionItem>");
|
|
|
- sb.append("<type>SELECT</type>");
|
|
|
- sb.append("<name>사이즈</name>");
|
|
|
- sb.append("<value>");
|
|
|
- sb.append("<id>").append("<![CDATA[" + arr[1] + "]]>").append("</id>");
|
|
|
- sb.append("<text>").append("<![CDATA[" + goodsSizeStr + "]]>").append("</text>");
|
|
|
- sb.append("</value>");
|
|
|
- sb.append("</optionItem>");
|
|
|
+ sb.append("\t\t\t<optionItem>\n");
|
|
|
+ sb.append("\t\t\t\t<type>SELECT</type>\n");
|
|
|
+ sb.append("\t\t\t\t<name>사이즈</name>\n");
|
|
|
+ for(int j = 0 ; j < sizeList.length ; j++) {
|
|
|
+ sb.append("\t\t\t\t<value>\n");
|
|
|
+ sb.append("\t\t\t\t\t<id>").append(sizeList[j]).append("</id>\n");
|
|
|
+ sb.append("\t\t\t\t\t<text>").append(sizeList[j]).append("</text>\n");
|
|
|
+ sb.append("\t\t\t\t</value>\n");
|
|
|
+ }
|
|
|
+ sb.append("\t\t\t</optionItem>\n");
|
|
|
|
|
|
// 9.3 옵션 옵션조합정보
|
|
|
- sb.append("<combination>");
|
|
|
- sb.append("<price>").append(0).append("</price>");
|
|
|
- sb.append("<manageCode>").append("<![CDATA[" + optionManageCodesArrStr + "]]>").append("</manageCode>");
|
|
|
- //sb.append("<stockQuantity>").append(5).append("</stockQuantity>");
|
|
|
- sb.append("<status>true</status>");
|
|
|
-
|
|
|
- // 9.3.1 옵션 옵션조합정보 색상
|
|
|
- sb.append("<options>");
|
|
|
- sb.append("<name>칼라</name>");
|
|
|
- sb.append("<id>").append("<![CDATA[" + arr[0] + "]]>").append("</id>");
|
|
|
- sb.append("</options>");
|
|
|
-
|
|
|
- // 9.3.2 옵션 옵션조합정보 사이즈
|
|
|
- sb.append("<options>");
|
|
|
- sb.append("<name>사이즈</name>");
|
|
|
- sb.append("<id>").append("<![CDATA[" + arr[1] + "]]>").append("</id>");
|
|
|
- sb.append("</options>");
|
|
|
-
|
|
|
- sb.append("</combination>");
|
|
|
- sb.append("</option>");
|
|
|
+ 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");
|
|
|
+
|
|
|
+ // 9.3.1 옵션 옵션조합정보 색상
|
|
|
+ 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");
|
|
|
+
|
|
|
+ // 9.3.2 옵션 옵션조합정보 사이즈
|
|
|
+ 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");
|
|
|
+ }
|
|
|
+ sb.append("\t\t</option>\n");
|
|
|
|
|
|
// 10. 배송정보조회
|
|
|
- // 5.2.1 업체별 기본배송비, 무료배송비 조회
|
|
|
- Ship ship = new Ship();
|
|
|
- ship.setCompany_mng_idx(shopInfo.getCompany_mng_idx());
|
|
|
- ship = shipService.localShipInfo(ship);
|
|
|
-
|
|
|
- sb.append("<shippingPolicy>");
|
|
|
- sb.append("<groupId>").append(shopInfo.getCompany_mng_idx()).append("</groupId>");
|
|
|
- sb.append("<method>").append("DELIVERY").append("</method>");
|
|
|
- sb.append("<feeType>").append("CONDITIONAL_FREE").append("</feeType>");
|
|
|
- sb.append("<feePayType>").append("PREPAYED").append("</feePayType>");
|
|
|
- sb.append("<feePrice>").append(ship.getShip_amt()).append("</feePrice>");
|
|
|
-
|
|
|
- sb.append("<conditionalFree>");
|
|
|
- sb.append("<basePrice>").append(ship.getFree_ship_amt()).append("</basePrice>");
|
|
|
- sb.append("</conditionalFree>");
|
|
|
+ // 5.2.1 업체별 기본배송비, 무료배송비
|
|
|
+ String delvFeeCd = "";
|
|
|
+ if("Y".equals(goods.getSelfGoodsYn())) {
|
|
|
+ delvFeeCd = "WMS";
|
|
|
+ } else {
|
|
|
+ delvFeeCd = goods.getDelvFeeCd();
|
|
|
+ }
|
|
|
+ String delvFeeCrite = "CHARGE";
|
|
|
+ int delvFee = goods.getDelvFee();
|
|
|
+ String feePayType = "PREPAYED";
|
|
|
+ // 배송비 조건
|
|
|
+ if(TscConstants.DelvFeeCrite.NORMAL.value().equals(goods.getDelvFeeCrite())) {
|
|
|
+ delvFeeCrite = "CONDITIONAL_FREE"; // 조건부 무료(배송비 조건이 무료이거나 배송 방법이 착불일때만 배송비는 0원으로 변경)
|
|
|
+ } else if(TscConstants.DelvFeeCrite.FREE.value().equals(goods.getDelvFeeCrite())) {
|
|
|
+ delvFeeCrite = "FREE";
|
|
|
+ feePayType = "FREE";
|
|
|
+ delvFee = 0;
|
|
|
+ }
|
|
|
|
|
|
- sb.append("<surchargeByArea>");
|
|
|
- sb.append("<apiSupport>").append("true").append("</apiSupport>");
|
|
|
- sb.append("</surchargeByArea>");
|
|
|
+ sb.append("\t\t<shippingPolicy>\n");
|
|
|
+ sb.append("\t\t\t<groupId>").append(delvFeeCd).append("</groupId>\n");
|
|
|
+ sb.append("\t\t\t<method>").append("DELIVERY").append("</method>\n");
|
|
|
+ sb.append("\t\t\t<feeType>").append(delvFeeCrite).append("</feeType>\n");
|
|
|
+ sb.append("\t\t\t<feePayType>").append(feePayType).append("</feePayType>\n");
|
|
|
+ sb.append("\t\t\t<feePrice>").append(delvFee).append("</feePrice>\n");
|
|
|
+ if(!"FREE".equals(delvFeeCrite)) {
|
|
|
+ sb.append("\t\t\t<conditionalFree>\n");
|
|
|
+ sb.append("\t\t\t\t<basePrice>").append(goods.getMinOrdAmt()).append("</basePrice>\n");
|
|
|
+ sb.append("\t\t\t</conditionalFree>\n");
|
|
|
+ }
|
|
|
|
|
|
- sb.append("</shippingPolicy>");
|
|
|
+ sb.append("\t\t</shippingPolicy>\n");
|
|
|
|
|
|
- sb.append("</product>");*/
|
|
|
+ sb.append("\t</product>\n");
|
|
|
}
|
|
|
- sb.append("</products>");
|
|
|
+ sb.append("</products>\n");
|
|
|
//for end
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
- //write(response, sb.toString());
|
|
|
+ log.info("CHECK CREATE NAVERPAY GOODS XML ::::: \n{}", sb.toString());
|
|
|
+ write(response, sb.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Write XML Data and flush
|
|
|
+ * @param response - HttpServletResponse
|
|
|
+ * @param result - 결과
|
|
|
+ * @author xodud1202
|
|
|
+ * @since 2021. 05. 13
|
|
|
+ */
|
|
|
+ public void write(HttpServletResponse response, String result) throws Exception {
|
|
|
+ Writer writer = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ response.setContentType("text/xml; charset=utf-8");
|
|
|
+ response.setHeader("Cache-Control", "no-cache");
|
|
|
+
|
|
|
+ writer = response.getWriter();
|
|
|
+ writer.write(result);
|
|
|
+ writer.flush();
|
|
|
+ } catch(Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new IllegalStateException("상품 정보 등록 실패");
|
|
|
+ } finally {
|
|
|
+ if (writer != null) writer.close();
|
|
|
}
|
|
|
}
|
|
|
|