记得上下班打卡 | git大法好,push需谨慎

Commit d2daec1f authored by 胡佳晨's avatar 胡佳晨

Merge remote-tracking branch 'origin/dev' into dev

parents b9375d4c f5ef77ca
......@@ -75,7 +75,7 @@ public class PerformancesExpressController extends BaseController {
@RequiresPermissions("kylin:performancesExpress:placeOrder")
@PostMapping("/placeOrder")
@ResponseBody
public AjaxResult placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) throws Exception {
public AjaxResult placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) {
ResponseDto res = performancesExpressServiceImpl.placeOrder(performanceExpressSearchAdminParam);
try {
if (res.isSuccess()) {
......
......@@ -202,6 +202,13 @@ public class KylinRefundsStatusServiceImpl {
mongoTemplate.insert(kylinOrderRefundEntitiesVo, KylinOrderRefundEntitiesVo.class.getSimpleName());
}
List<String> orderRefundIds = new ArrayList<>();
orderRefundIds.add(orderRefundsId);
List<String> orderIds = new ArrayList<>();
orderIds.add(orderTicketsId);
dataUtils.delOrderRefundVo(orderRefundIds);
dataUtils.delOrderRefundVoByOrderId(orderIds);
return true;
}
......
......@@ -121,7 +121,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
return voList;
}
public ResponseDto placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) throws Exception {
public ResponseDto placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) {
List<String> ids = performanceExpressSearchAdminParam.getIds();
for (String orderTicketsId : ids) {
// 已经存在未取消的下单数据过滤掉
......@@ -179,7 +179,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
hBody.put("dAddress", orderInfo.getExpressAddress());
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequestTest(hBody, "/public/order/v1/placeOrder");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/placeOrder");
System.out.println(result);
HashMap hashMap = new HashMap();
try {
......@@ -283,11 +283,11 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
.notIn("express_status", expressStatus)
);
if (null != orderExpressInfo) {
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("orderId", orderExpressInfo.getOrderExpressCode());
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/cancelOrder");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/cancelOrder");
HashMap hashMap = JsonUtils.fromJson(result, HashMap.class);
System.out.println(result);
if (hashMap.get("succ").equals("fail")) {
......@@ -329,12 +329,12 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
.notIn("express_status", expressStatus)
);
if (null != orderExpressInfo) {
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("orderId", orderExpressInfo.getOrderExpressCode());
hBody.put("searchType", 1); //查询类型:1,正向单查询,传入的orderid为正向定单号,2,退货单查询,传入的orderid为退货原始订单号
hBody.put("searchType", "1"); //查询类型:1,正向单查询,传入的orderid为正向定单号,2,退货单查询,传入的orderid为退货原始订单号
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/getResult");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/getResult");
HashMap hashMap = JsonUtils.fromJson(result, HashMap.class);
System.out.println(result);
if (hashMap.get("succ").equals("fail")) {
......@@ -375,7 +375,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
);
if (null != orderExpressInfo) {
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("jProvince", jProvince);
hBody.put("jCity", jCity);
hBody.put("jAddress", jAddress);
......@@ -383,12 +383,12 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
hBody.put("dProvince", orderInfo.getProvince());
hBody.put("dCity", orderInfo.getCity());
hBody.put("dAddress", orderInfo.getExpressAddress());
hBody.put("expressType", expressType);
hBody.put("expressType", expressType.toString());
// hBody.put("parcelWeighs", 2.00);
// hBody.put("volume", "10,10,20");
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/getFreight");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/getFreight");
HashMap hashMap = JsonUtils.fromJson(result, HashMap.class);
System.out.println(result);
if (hashMap.get("succ").equals("fail")) {
......@@ -420,11 +420,11 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
.notIn("express_status", expressStatus)
);
if (null != orderExpressInfo) {
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("orderId", orderExpressInfo.getOrderExpressCode());
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/getListFreight");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/getListFreight");
HashMap hashMap = JsonUtils.fromJson(result, HashMap.class);
System.out.println(result);
if (hashMap.get("succ").equals("fail")) {
......@@ -462,11 +462,11 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
.notIn("express_status", expressStatus)
);
if (null != orderExpressInfo) {
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("orderId", orderExpressInfo.getOrderExpressCode());
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/listOrderRoute");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/listOrderRoute");
HashMap hashMap = JsonUtils.fromJson(result, HashMap.class);
System.out.println(result);
if (hashMap.get("succ").equals("fail")) {
......@@ -499,7 +499,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
}
// @Async
public void batchPlaceOrder(String performanceId) throws Exception {
public void batchPlaceOrder(String performanceId) {
int count;
int limitNum = 10;
int mid = 0;
......
package com.liquidnet.client.admin.zhengzai.kylin.utils;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.UserPathDto;
import com.liquidnet.service.kylin.entity.KylinOrderExpress;
import com.liquidnet.service.kylin.mapper.KylinOrderExpressMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
......@@ -57,15 +55,12 @@ public class ShunfengSignUtils {
*/
private final static Long CHECK_TIME = 600000L;
@Autowired
private KylinOrderExpressMapper kylinOrderExpressMapper;
/**
* 生成签名并请求
* @param hbody 请求body
* @return
*/
public String generateSignatureAndRequestTest(Map<String, String> hbody, String url) throws Exception {
public String generateSignatureAndRequestNew(Map<String, String> hbody, String url) {
long currentTimeMillis = System.currentTimeMillis(); // 时间戳
String timestamp = currentTimeMillis + "";
hbody.put("companyId", APP_ID);
......@@ -79,21 +74,25 @@ public class ShunfengSignUtils {
headers.put("sign", sign);
headers.put("Content-Type", "application/json;charset=utf-8");
headers.put("Accept", "application/json");
// CloseableHttpClient client = HttpClients.createDefault();
Map<String, String> querys = new HashMap<>();
HttpResponse httpResponse = HttpClientUtils.doPost(URL, url, "", headers, querys, hbody);
System.out.println(httpResponse);
try {
HttpResponse httpResponse = HttpClientUtils.doPost(URL, url, "", headers, querys, body);
if (httpResponse.getStatusLine().getStatusCode() == 200) {
System.out.println("发送请求成功");
HttpEntity entity = httpResponse.getEntity();
// 发送响应且编码UTF8!!!
return EntityUtils.toString(entity, "utf-8");
}
return "error";
} catch (Exception e) {
System.out.println("发送请求失败");
e.printStackTrace();
return e.getMessage();
}
return null;
}
/**
* 生成签名并请求
* 生成签名并请求 线上Received fatal alert:handshake_failure 废弃
* @param hbody 请求body
* @return
*/
......@@ -173,47 +172,4 @@ public class ShunfengSignUtils {
return Base64.encodeBase64URLSafeString(bytes);
}
/**
* 接收请求且验签(可在控制层调用此方法)
* @param params 接收请求参数
* @param request 接收请求
* @return
*/
public boolean receiveRequestAndCheckSign(String params, HttpServletRequest request) {
// 请求方APPID
String sendAppId = request.getHeader("sendAppId");
// 请求方时间戳
String timestamp = request.getHeader("timestamp");
// 请求方签名
String sign = request.getHeader("sign");
if (StringUtils.isBlank(sendAppId)) {
System.out.println("参数sendAppId不能为空");
return false;
}
if (StringUtils.isBlank(timestamp)) {
System.out.println("参数timestamp不能为空");
return false;
}
if (StringUtils.isBlank(sign)) {
System.out.println("参数sign不能为空");
return false;
}
// 校验签名是否过期
long requestTime = Long.parseLong(timestamp);
long now = System.currentTimeMillis();
if (Math.abs(now - requestTime) > CHECK_TIME) {
System.out.println("签名过期!");
return false;
}
// 请求方参数+请求方时间戳+SK 生成签名
String thisSign = genSign(timestamp, params);
// 获取的签名和请求方签名比较是否一致
if (!thisSign.equals(sign)) {
System.out.println("签名错误");
return false;
}
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment