|
@@ -3,6 +3,7 @@ package com.iamberry.rst.service.order;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.iamberry.rst.core.order.EfastOrder;
|
|
import com.iamberry.rst.core.order.EfastOrder;
|
|
|
|
+import com.iamberry.rst.core.order.EfastOrderItem;
|
|
import com.iamberry.rst.core.order.Order;
|
|
import com.iamberry.rst.core.order.Order;
|
|
import com.iamberry.rst.core.order.OrderItem;
|
|
import com.iamberry.rst.core.order.OrderItem;
|
|
import com.iamberry.rst.faces.order.EfastOrderService;
|
|
import com.iamberry.rst.faces.order.EfastOrderService;
|
|
@@ -455,4 +456,82 @@ public class EfastOrderServiceImpl implements EfastOrderService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public JSONObject returnOrderFormEfast(EfastOrder efastOrder) throws Exception {
|
|
|
|
+ StringBuilder returnDetail = new StringBuilder();
|
|
|
|
+ if (efastOrder == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ if (efastOrder.getItemList() == null || efastOrder.getItemList().size() == 0) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ List<EfastOrderItem> itemList = efastOrder.getItemList();
|
|
|
|
+ for (int i = 0;i < itemList.size();i++) {
|
|
|
|
+ EfastOrderItem item = itemList.get(i);
|
|
|
|
+ returnDetail.append(item.getItemColorBar());
|
|
|
|
+ returnDetail.append("@");
|
|
|
|
+ returnDetail.append(item.getItemNum());
|
|
|
|
+ returnDetail.append("@");
|
|
|
|
+ returnDetail.append(item.getItemDiscount());
|
|
|
|
+ returnDetail.append("@");
|
|
|
|
+ returnDetail.append(efastOrder.getOrderDealCode());
|
|
|
|
+ if (i < itemList.size() - 1) {
|
|
|
|
+ returnDetail.append(",");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 组装数据
|
|
|
|
+ Map<String, String> requestData = new HashMap<String, String>();
|
|
|
|
+ requestData.put("return_shipping_name", efastOrder.getOrderPostFirm()); // 退单物流代码
|
|
|
|
+ requestData.put("kehu_return_invoice_no", efastOrder.getOrderPostNum()); // 退单物流单号
|
|
|
|
+ requestData.put("return_type", "2");
|
|
|
|
+ requestData.put("app_nick", NameUtils.getConfig("app_nick"));
|
|
|
|
+ requestData.put("app_key", NameUtils.getConfig("app_key"));
|
|
|
|
+ requestData.put("app_secret", NameUtils.getConfig("app_secret"));
|
|
|
|
+ requestData.put("timestamp",DateTimeUtil.format(new Date(),"yyyyMMddHHmmss"));
|
|
|
|
+ requestData.put("app_act", "efast.trade.return");
|
|
|
|
+ requestData.put("order_sn", efastOrder.getOrderId());
|
|
|
|
+ requestData.put("return_shipping", "");
|
|
|
|
+ requestData.put("return_pfje_fee", "");
|
|
|
|
+ requestData.put("return_other_discount", "");
|
|
|
|
+ requestData.put("return_pay", "2");
|
|
|
|
+ requestData.put("return_reason", "");
|
|
|
|
+ requestData.put("return_desc", "");
|
|
|
|
+ requestData.put("return_ck", "");
|
|
|
|
+ requestData.put("return_detail", returnDetail.toString());
|
|
|
|
+ try {
|
|
|
|
+ String resultJson = HttpClient431Util.doPost(requestData, NameUtils.getConfig("efast_base_url"));
|
|
|
|
+ resultJson = StringEscapeUtils.unescapeJava(resultJson);
|
|
|
|
+ logger.info("return-订单号为:" + efastOrder.getOrderDealCode() + "的订单,百胜返回信息:" + resultJson);
|
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(resultJson);
|
|
|
|
+ JSONObject respData = JSONObject.fromObject(jsonObject.get("resp_data"));
|
|
|
|
+ return respData;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ logger.error("return-订单号为:" + efastOrder.getOrderDealCode() + "的订单,发生错误:" + e.getMessage());
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public JSONObject receiveOrderFormEfast(EfastOrder efastOrder) throws Exception {
|
|
|
|
+ // 组装数据
|
|
|
|
+ Map<String, String> requestData = new HashMap<String, String>();
|
|
|
|
+ requestData.put("app_nick", NameUtils.getConfig("app_nick"));
|
|
|
|
+ requestData.put("app_key", NameUtils.getConfig("app_key"));
|
|
|
|
+ requestData.put("app_secret", NameUtils.getConfig("app_secret"));
|
|
|
|
+ requestData.put("app_act", "efast.return_receive");
|
|
|
|
+ requestData.put("return_sn", efastOrder.getOrderId());
|
|
|
|
+ requestData.put("timestamp",DateTimeUtil.format(new Date(),"yyyyMMddHHmmss"));
|
|
|
|
+ try {
|
|
|
|
+ String resultJson = HttpClient431Util.doPost(requestData, NameUtils.getConfig("efast_base_url"));
|
|
|
|
+ resultJson = StringEscapeUtils.unescapeJava(resultJson);
|
|
|
|
+ logger.info("receive-订单号为:" + efastOrder.getOrderDealCode() + "的订单,百胜返回信息:" + resultJson);
|
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(resultJson);
|
|
|
|
+ JSONObject respData = JSONObject.fromObject(jsonObject.get("resp_data"));
|
|
|
|
+ return respData;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ logger.error("return-订单号为:" + efastOrder.getOrderDealCode() + "的订单,发生错误:" + e.getMessage());
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|