|
@@ -9,31 +9,41 @@ import com.tuigai.tuigai_tongcheng_api.enums.OrderSourceEnum;
|
|
|
import com.tuigai.tuigai_tongcheng_api.model.RefoundPasenger;
|
|
|
import com.tuigai.tuigai_tongcheng_api.model.RefoundSegment;
|
|
|
import com.tuigai.tuigai_tongcheng_api.model.RefoundTrainOrder;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+@Slf4j
|
|
|
public class RefundOrderUtils {
|
|
|
|
|
|
- public static String url = "https://console-docs.apipost.cn/preview/6b1028452d54a34a/5a0d52a660d075c6";
|
|
|
+ public static String url = "http://8.218.227.156:8010/post/refund/id";
|
|
|
|
|
|
public static RefoundTrainOrder generateRefundOrder(JSONObject jsonObject) throws IOException {
|
|
|
JSONObject refundPassengerJson = jsonObject.getJSONObject("refundPassenger");
|
|
|
- JSONObject refundOrderJson = jsonObject.getJSONObject("refundOrderJson");
|
|
|
- JSONObject refundSegmentJson = jsonObject.getJSONObject("refundSegmentJson");
|
|
|
+ JSONObject refundOrderJson = jsonObject.getJSONObject("refundOrder");
|
|
|
+ JSONObject refundSegmentJson = jsonObject.getJSONObject("refundSegment");
|
|
|
String orderId = refundOrderJson.getString("orderSerialNo");
|
|
|
Float ticketPrice = refundOrderJson.getFloat("ticketPrice");
|
|
|
String ticketNo = refundOrderJson.getString("electronicTicketNo");
|
|
|
String outId = refundOrderJson.getString("refundSerialNo");
|
|
|
//请求身份证
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
- param.put("refundserialNo", outId);
|
|
|
- param.put("partitionKey", orderId);
|
|
|
+ param.put("refundSerialNo", outId);
|
|
|
+ param.put("partitionKey", refundOrderJson.getString("partitionKey"));
|
|
|
param.put("ticketPrice", ticketPrice);
|
|
|
String result = OkHttpUtil.doPostRequest(url, JSONObject.toJSONString(param));
|
|
|
- JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ log.info("result", result);
|
|
|
+ JSONObject resultJson = null;
|
|
|
+ try {
|
|
|
+ resultJson = Utils.isEmpty(result) || "null".equals(result) ? new JSONObject() : JSONObject.parseObject(result);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单id:{}", orderId, e);
|
|
|
+ resultJson = new JSONObject();
|
|
|
+ }
|
|
|
String creditNo = resultJson.getString("creditNo");
|
|
|
|
|
|
//乘客信息
|
|
@@ -67,8 +77,8 @@ public class RefundOrderUtils {
|
|
|
RefoundSegment refoundSegment = new RefoundSegment();
|
|
|
refoundSegment.outId = outId;
|
|
|
refoundSegment.orderId = orderId;
|
|
|
- refoundSegment.from_station = resultJson.getString("departureStation");
|
|
|
- refoundSegment.to_station = resultJson.getString("arrivalStation");
|
|
|
+ refoundSegment.from_station = UnicodeUtil.toString(refundSegmentJson.getString("departureStation"));
|
|
|
+ refoundSegment.to_station = UnicodeUtil.toString(refundSegmentJson.getString("arrivalStation"));
|
|
|
refoundSegment.from_time = DateUtil.formatDateTime(new Date(refundSegmentJson.getLong("gmtDeparture")));
|
|
|
refoundSegment.to_time = DateUtil.formatDateTime(new Date(refundSegmentJson.getLong("gmtArrive")));
|
|
|
refoundSegment.trainCode = refundSegmentJson.getString("trainCode");
|