|
|
@@ -2,10 +2,14 @@ package com.yc.ship.module.trade.service.orderjzdetail;
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.excel.util.DateUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.yc.ship.framework.common.pojo.PageResult;
|
|
|
@@ -14,23 +18,26 @@ import com.yc.ship.framework.security.core.LoginUser;
|
|
|
import com.yc.ship.framework.tenant.core.aop.TenantIgnore;
|
|
|
import com.yc.ship.module.trade.controller.admin.orderjzdetail.vo.OrderJzDetailPageReqVO;
|
|
|
import com.yc.ship.module.trade.controller.admin.orderjzdetail.vo.OrderJzDetailSaveReqVO;
|
|
|
+import com.yc.ship.module.trade.controller.app.ota.vo.OtaVoucherVO;
|
|
|
import com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO;
|
|
|
import com.yc.ship.module.trade.dal.dataobject.orderjz.OrderJzDO;
|
|
|
import com.yc.ship.module.trade.dal.dataobject.orderjzdetail.OrderJzDetailDO;
|
|
|
import com.yc.ship.module.trade.dal.mysql.order.TradeOrderMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.orderjz.OrderJzMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.orderjzdetail.OrderJzDetailMapper;
|
|
|
+import com.yc.ship.module.trade.framework.common.Base64Util;
|
|
|
+import com.yc.ship.module.trade.framework.common.ota.DesUtil;
|
|
|
+import com.yc.ship.module.trade.utils.MD5Utils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static com.yc.ship.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
|
|
@@ -98,7 +105,9 @@ public class OrderJzDetailServiceImpl implements OrderJzDetailService {
|
|
|
long count = 0;
|
|
|
String batchNo = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
// 先删除当前传入游客的历史接站数据
|
|
|
+ List<Long> visitorIds = new ArrayList<>();
|
|
|
for (OrderJzDetailSaveReqVO orderJzDetailSaveReqVO : createReqVOList) {
|
|
|
+ visitorIds.add(orderJzDetailSaveReqVO.getVisitorId());
|
|
|
orderJzDetailMapper.delete(new LambdaQueryWrapper<OrderJzDetailDO>().eq(OrderJzDetailDO::getVisitorId, orderJzDetailSaveReqVO.getVisitorId()));
|
|
|
}
|
|
|
//处理三方系统退票
|
|
|
@@ -109,22 +118,29 @@ public class OrderJzDetailServiceImpl implements OrderJzDetailService {
|
|
|
count++;
|
|
|
}
|
|
|
try {
|
|
|
+ cancelSupplierJz(visitorIds,orderJzDO.getId(),createReqVOList);
|
|
|
+
|
|
|
//处理三方系统出票 二期接站
|
|
|
- createSupplierJz(createReqVOList, orderDo);
|
|
|
+ String supplierOrderId = createSupplierJz(createReqVOList, orderDo);
|
|
|
+ paySupplierJz(supplierOrderId, orderJzDO.getId(),createReqVOList);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
- private void createSupplierJz(List<OrderJzDetailSaveReqVO> createReqVOList, TradeOrderDO tradeOrderDO) {
|
|
|
+ private String createSupplierJz(List<OrderJzDetailSaveReqVO> createReqVOList, TradeOrderDO tradeOrderDO) throws Exception {
|
|
|
Long id = null;
|
|
|
- String productId = "";
|
|
|
+ String productId = "2034192879786524673";
|
|
|
+ String method = "createOrder";
|
|
|
+ String createOrderUrl = "http://10.3.10.50/app-api/travelhub-ops-trade/trade/ota/212/" + method;
|
|
|
+ String userId = "67fd6a5e6a2a453a98f288b08d571234";
|
|
|
+ String userKey = "TFD9BEOK";
|
|
|
String bookname = "";
|
|
|
String mobile = "";
|
|
|
String idcard = "";
|
|
|
for (OrderJzDetailSaveReqVO orderJzDetailSaveReqVO : createReqVOList) {
|
|
|
- id = orderJzDetailSaveReqVO.getId();
|
|
|
+ id = orderJzDetailSaveReqVO.getJzId();
|
|
|
mobile = orderJzDetailSaveReqVO.getPhone();
|
|
|
idcard = orderJzDetailSaveReqVO.getIdCard();
|
|
|
}
|
|
|
@@ -133,7 +149,7 @@ public class OrderJzDetailServiceImpl implements OrderJzDetailService {
|
|
|
rep_body.put("travelDate", tradeOrderDO.getTravelDate());
|
|
|
rep_body.put("travelTime", "");
|
|
|
rep_body.put("quantity", createReqVOList.size());
|
|
|
- rep_body.put("productId", "productId");
|
|
|
+ rep_body.put("productId", productId);
|
|
|
rep_body.put("bookName", bookname);
|
|
|
rep_body.put("bookMobile", mobile);
|
|
|
rep_body.put("idCard", idcard);
|
|
|
@@ -148,48 +164,180 @@ public class OrderJzDetailServiceImpl implements OrderJzDetailService {
|
|
|
vistorList.add(vistor);
|
|
|
}
|
|
|
rep_body.put("visitPersons", vistorList);
|
|
|
-// String bodyStr = DesUtil.encrypt(rep_body.toString(),userKey);
|
|
|
-// String signStr = userId+method+timestamp+bodyStr+userKey;
|
|
|
-// log.info("jfg供应商预下单开始,signStr:{}",signStr);
|
|
|
-// String sign = MD5Utils.getMD5(signStr.getBytes("UTF-8"));
|
|
|
-//
|
|
|
-// JSONObject rep_head=new JSONObject();
|
|
|
-// rep_head.put("user_id", userId);
|
|
|
-// rep_head.put("method",method );
|
|
|
-// rep_head.put("timestamp", timestamp);
|
|
|
-// rep_head.put("sign", sign);
|
|
|
-//
|
|
|
-// JSONObject req=new JSONObject();
|
|
|
-// req.put("requestHead", rep_head);
|
|
|
-// req.put("requestBody", bodyStr);
|
|
|
-// Map<String, String> headMap = new HashMap<>();
|
|
|
-// headMap.put("Content-type", "application/x-www-form-urlencoded");
|
|
|
-// log.info("jfg供应商预下单开始,请求地址:{},请求参数:{}",createOrderUrl,req.toString());
|
|
|
-// String res = HttpUtil.createPost(createOrderUrl).contentType("application/json")
|
|
|
-// .body(Base64Util.encode(req.toString()))
|
|
|
-// .headerMap(headMap,false)
|
|
|
-// .timeout(100000)
|
|
|
-// .execute().body();
|
|
|
-// log.info("jfg供应商预下单完成,响应参数:{}",res);
|
|
|
-// // base64解密
|
|
|
-// String json = new String(Base64.decodeBase64(res.getBytes("UTF-8")));
|
|
|
-// log.info("jfg供应商预下单完成,响应response参数:{}",json);
|
|
|
-// JSONObject jsonObj = JSONUtil.parseObj(json);
|
|
|
-// JSONObject responseHead = jsonObj.getJSONObject("responseHead");
|
|
|
-// if(StringUtils.equals("1000",responseHead.getStr("res_code"))){
|
|
|
-// String response = jsonObj.getStr("responseBody");
|
|
|
-// String body = "";
|
|
|
-// try {
|
|
|
-// body = DesUtil.decrypt(response, userKey);
|
|
|
-// } catch (Exception e) {
|
|
|
-// log.info(e.toString());
|
|
|
-// }
|
|
|
-// log.info("jfg供应商预下单完成,响应body参数:{}",body);
|
|
|
-// JSONObject responseBody =JSONUtil.parseObj(body);
|
|
|
-// return CommonResult.success(new SupplierTradeOrderRespBO().setSupplierOrderNo(responseBody.getStr("partnerOrderId")));
|
|
|
-// }else{
|
|
|
-// return CommonResult.error(500,responseHead.getStr("res_msg"));
|
|
|
-// }
|
|
|
+ String bodyStr = DesUtil.encrypt(rep_body.toString(), userKey);
|
|
|
+ Long timestamp = System.currentTimeMillis() / 1000;
|
|
|
+ String signStr = userId + method + timestamp + bodyStr + userKey;
|
|
|
+ log.info("三峡二期系统预下单开始,signStr:{}", signStr);
|
|
|
+ String sign = MD5Utils.getMD5(signStr.getBytes("UTF-8"));
|
|
|
+
|
|
|
+ JSONObject rep_head = new JSONObject();
|
|
|
+ rep_head.put("user_id", userId);
|
|
|
+ rep_head.put("method", method);
|
|
|
+ rep_head.put("timestamp", timestamp);
|
|
|
+ rep_head.put("sign", sign);
|
|
|
+
|
|
|
+ JSONObject req = new JSONObject();
|
|
|
+ req.put("requestHead", rep_head);
|
|
|
+ req.put("requestBody", bodyStr);
|
|
|
+ Map<String, String> headMap = new HashMap<>();
|
|
|
+ headMap.put("Content-type", "application/x-www-form-urlencoded");
|
|
|
+ log.info("二期预下单开始,请求地址:{},请求参数:{}", createOrderUrl, req.toString());
|
|
|
+ String res = HttpUtil.createPost(createOrderUrl).contentType("application/json")
|
|
|
+ .body(Base64Util.encode(req.toString()))
|
|
|
+ .headerMap(headMap, false)
|
|
|
+ .timeout(100000)
|
|
|
+ .execute().body();
|
|
|
+ log.info("二期系统预下单完成,响应参数:{}", res);
|
|
|
+ // base64解密
|
|
|
+ log.info("二期系统预下单完成,响应response参数:{}", res);
|
|
|
+ JSONObject jsonObj = JSONUtil.parseObj(res);
|
|
|
+ JSONObject responseHead = jsonObj.getJSONObject("responseHead");
|
|
|
+ if (StringUtils.equals("1000", responseHead.getStr("res_code"))) {
|
|
|
+ String response = jsonObj.getStr("responseBody");
|
|
|
+ String body = "";
|
|
|
+ try {
|
|
|
+ body = DesUtil.decrypt(response, userKey);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info(e.toString());
|
|
|
+ }
|
|
|
+ log.error("二期下单完成,响应body参数:{}", body);
|
|
|
+ JSONObject responseBody =JSONUtil.parseObj(body);
|
|
|
+ return responseBody.getStr("orderId");
|
|
|
+ } else {
|
|
|
+ log.error("二期下单失败,响应response参数:{}", res);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void paySupplierJz(String supplierOrderId, Long jzId,List<OrderJzDetailSaveReqVO> createReqVOList) throws Exception {
|
|
|
+ String method = "payOrder";
|
|
|
+ String createOrderUrl = "http://10.3.10.50/app-api/travelhub-ops-trade/trade/ota/212/" + method;
|
|
|
+ String userId = "67fd6a5e6a2a453a98f288b08d571234";
|
|
|
+ String userKey = "TFD9BEOK";
|
|
|
+ JSONObject rep_body = new JSONObject();
|
|
|
+ rep_body.put("orderId", supplierOrderId);
|
|
|
+ rep_body.put("partnerOrderId", jzId);
|
|
|
+
|
|
|
+ String bodyStr = DesUtil.encrypt(rep_body.toString(), userKey);
|
|
|
+ Long timestamp = System.currentTimeMillis() / 1000;
|
|
|
+ String signStr = userId + method + timestamp + bodyStr + userKey;
|
|
|
+ log.info("二期订单支付开始,signStr:{}", signStr);
|
|
|
+ String sign = MD5Utils.getMD5(signStr.getBytes("UTF-8"));
|
|
|
+
|
|
|
+ JSONObject rep_head = new JSONObject();
|
|
|
+ rep_head.put("user_id", userId);
|
|
|
+ rep_head.put("method", method);
|
|
|
+ rep_head.put("timestamp", timestamp);
|
|
|
+ rep_head.put("sign", sign);
|
|
|
+
|
|
|
+ JSONObject req = new JSONObject();
|
|
|
+ req.put("requestHead", rep_head);
|
|
|
+ req.put("requestBody", bodyStr);
|
|
|
+ Map<String, String> headMap = new HashMap<>();
|
|
|
+ headMap.put("Content-type", "application/x-www-form-urlencoded");
|
|
|
+ log.info("二期预支付开始,请求地址:{},请求参数:{}", createOrderUrl, req.toString());
|
|
|
+ String res = HttpUtil.createPost(createOrderUrl).contentType("application/json")
|
|
|
+ .body(Base64Util.encode(req.toString()))
|
|
|
+ .headerMap(headMap, false)
|
|
|
+ .timeout(100000)
|
|
|
+ .execute().body();
|
|
|
+ log.info("二期系统支付完成,响应参数:{}", res);
|
|
|
+ // base64解密
|
|
|
+ String json = new String(org.apache.commons.codec.binary.Base64.decodeBase64(res.getBytes("UTF-8")));
|
|
|
+ log.info("二期系统支付完成,响应response参数:{}", json);
|
|
|
+ JSONObject jsonObj = JSONUtil.parseObj(json);
|
|
|
+ JSONObject responseHead = jsonObj.getJSONObject("responseHead");
|
|
|
+ if (StringUtils.equals("1000", responseHead.getStr("res_code"))) {
|
|
|
+ String response = jsonObj.getStr("responseBody");
|
|
|
+ String body = "";
|
|
|
+ try {
|
|
|
+ body = DesUtil.decrypt(response, userKey);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info(e.toString());
|
|
|
+ }
|
|
|
+ log.error("二期支付完成,响应body参数:{}", body);
|
|
|
+ JSONObject responseBody =JSONUtil.parseObj(body);
|
|
|
+ JSONArray vistors =responseBody.getJSONArray("visitPersons");
|
|
|
+ for (int i = 0; i < vistors.size(); i++) {
|
|
|
+ JSONObject vistor = vistors.getJSONObject(i);
|
|
|
+ String idCard = vistor.getStr("idCard");
|
|
|
+ String ticketId = vistor.getStr("ticketId");
|
|
|
+ orderJzDetailMapper.update(new UpdateWrapper<OrderJzDetailDO>().set("extend_order_no", supplierOrderId).set("extend_ticket_no", ticketId).eq("jz_id", jzId).eq("id_card", idCard));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("二期支付失败,响应response参数:{}", json);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void cancelSupplierJz(List<Long> visitorIds, Long jzId,List<OrderJzDetailSaveReqVO> createReqVOList) throws Exception {
|
|
|
+ String method = "cancelTicket";
|
|
|
+ String createOrderUrl = "http://10.3.10.50/app-api/travelhub-ops-trade/trade/ota/212/" + method;
|
|
|
+ String userId = "67fd6a5e6a2a453a98f288b08d571234";
|
|
|
+ String userKey = "TFD9BEOK";
|
|
|
+ List<OrderJzDetailDO> jzDetailList = orderJzDetailMapper.selectList(new QueryWrapper<OrderJzDetailDO>().in("visitor_id", visitorIds));
|
|
|
+ Map<String, List<OrderJzDetailDO>> groupList = jzDetailList.stream().filter(item -> StringUtils.isNotBlank(item.getExtendOrderNo())).collect(Collectors.groupingBy(OrderJzDetailDO::getExtendOrderNo));
|
|
|
+ if(groupList.isEmpty()){
|
|
|
+ log.error("无可退二期票信息"+jzId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ groupList.forEach((supplierOrderId, list) -> {
|
|
|
+ try {
|
|
|
+ JSONObject rep_body = new JSONObject();
|
|
|
+ rep_body.put("orderId", supplierOrderId);
|
|
|
+ rep_body.put("partnerOrderId", jzId);
|
|
|
+ List<String> ticketIds = new ArrayList<>();
|
|
|
+ for (OrderJzDetailDO item : list) {
|
|
|
+ ticketIds.add(item.getExtendTicketNo());
|
|
|
+ }
|
|
|
+ rep_body.set("refundDetailIds", ticketIds);
|
|
|
+ String bodyStr = DesUtil.encrypt(rep_body.toString(), userKey);
|
|
|
+ Long timestamp = System.currentTimeMillis() / 1000;
|
|
|
+ String signStr = userId + method + timestamp + bodyStr + userKey;
|
|
|
+ log.info("二期系统退票开始,signStr:{}", signStr);
|
|
|
+ String sign = MD5Utils.getMD5(signStr.getBytes("UTF-8"));
|
|
|
+
|
|
|
+ JSONObject rep_head = new JSONObject();
|
|
|
+ rep_head.put("user_id", userId);
|
|
|
+ rep_head.put("method", method);
|
|
|
+ rep_head.put("timestamp", timestamp);
|
|
|
+ rep_head.put("sign", sign);
|
|
|
+
|
|
|
+ JSONObject req = new JSONObject();
|
|
|
+ req.put("requestHead", rep_head);
|
|
|
+ req.put("requestBody", bodyStr);
|
|
|
+ Map<String, String> headMap = new HashMap<>();
|
|
|
+ headMap.put("Content-type", "application/x-www-form-urlencoded");
|
|
|
+ log.info("二期系统退票开始,请求地址:{},请求参数:{}", createOrderUrl, req.toString());
|
|
|
+ String res = HttpUtil.createPost(createOrderUrl).contentType("application/json")
|
|
|
+ .body(Base64Util.encode(req.toString()))
|
|
|
+ .headerMap(headMap, false)
|
|
|
+ .timeout(100000)
|
|
|
+ .execute().body();
|
|
|
+ log.info("二期系统退票完成,响应参数:{}", res);
|
|
|
+ // base64解密
|
|
|
+ String json = new String(org.apache.commons.codec.binary.Base64.decodeBase64(res.getBytes("UTF-8")));
|
|
|
+ log.info("二期系统退票完成,响应response参数:{}", json);
|
|
|
+ JSONObject jsonObj = JSONUtil.parseObj(json);
|
|
|
+ JSONObject responseHead = jsonObj.getJSONObject("responseHead");
|
|
|
+ if (StringUtils.equals("1000", responseHead.getStr("res_code"))) {
|
|
|
+ String response = jsonObj.getStr("responseBody");
|
|
|
+ String body = "";
|
|
|
+ try {
|
|
|
+ body = DesUtil.decrypt(response, userKey);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info(e.toString());
|
|
|
+ }
|
|
|
+ log.error("二期系统退票完成,响应body参数:{}", body);
|
|
|
+ } else {
|
|
|
+ log.error("二期系统退票失败,响应response参数:{}", json);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|