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

Commit 54533841 authored by jiangxiulong's avatar jiangxiulong

test

parent ece5d399
......@@ -75,7 +75,7 @@ public class PerformancesExpressController extends BaseController {
@RequiresPermissions("kylin:performancesExpress:placeOrder")
@PostMapping("/placeOrder")
@ResponseBody
public AjaxResult placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) {
public AjaxResult placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) throws Exception {
ResponseDto res = performancesExpressServiceImpl.placeOrder(performanceExpressSearchAdminParam);
try {
if (res.isSuccess()) {
......
......@@ -121,7 +121,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
return voList;
}
public ResponseDto placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) {
public ResponseDto placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) throws Exception {
List<String> ids = performanceExpressSearchAdminParam.getIds();
for (String orderTicketsId : ids) {
// 已经存在未取消的下单数据过滤掉
......@@ -155,7 +155,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
kylinOrderExpressMapper.insert(kylinOrderExpressPre);
// 请求下单数据
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("custid", custid);
hBody.put("jCompany", jCompany);
hBody.put("jContact", jContact);
......@@ -165,21 +165,21 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
hBody.put("jAddress", jAddress);
// TODO: 2021/6/30 前端选择
hBody.put("payMethod", 2);// 运费付款方式:0-寄付月结;1-寄付现结;2-收方付;3-第三方付;
hBody.put("expressType", expressType);// 顺丰特快
hBody.put("payMethod", "2");// 运费付款方式:0-寄付月结;1-寄付现结;2-收方付;3-第三方付;
hBody.put("expressType", expressType.toString());// 顺丰特快
hBody.put("depositumInfo", depositumInfo);
hBody.put("orderId", OrderExpressCode);
hBody.put("depositumNo", orderInfo.getNumber());
hBody.put("depositumNo", orderInfo.getNumber().toString());
hBody.put("dContact", orderInfo.getExpressContacts());
hBody.put("dMobile", orderInfo.getExpressPhone());
hBody.put("dAddress", orderInfo.getExpressAddress());
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/placeOrder");
String result = shunfengSignUtils.generateSignatureAndRequestTest(hBody, "/public/order/v1/placeOrder");
System.out.println(result);
HashMap hashMap = new HashMap();
try {
......@@ -499,7 +499,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
}
// @Async
public void batchPlaceOrder(String performanceId) {
public void batchPlaceOrder(String performanceId) throws Exception {
int count;
int limitNum = 10;
int mid = 0;
......
......@@ -10,6 +10,7 @@ import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
......@@ -23,6 +24,7 @@ import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* <p>
......@@ -58,6 +60,38 @@ public class ShunfengSignUtils {
@Autowired
private KylinOrderExpressMapper kylinOrderExpressMapper;
/**
* 生成签名并请求
* @param hbody 请求body
* @return
*/
public String generateSignatureAndRequestTest(Map<String, String> hbody, String url) throws Exception {
long currentTimeMillis = System.currentTimeMillis(); // 时间戳
String timestamp = currentTimeMillis + "";
hbody.put("companyId", APP_ID);
String body = JsonUtils.toJson(hbody);
// 生成签名
String sign = genSign(timestamp,body);
Map<String, String> headers = new HashMap<>();
headers.put("sendAppId", APP_ID);
headers.put("timestamp", timestamp);
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);
if (httpResponse.getStatusLine().getStatusCode() == 200) {
System.out.println("发送请求成功");
HttpEntity entity = httpResponse.getEntity();
// 发送响应且编码UTF8!!!
return EntityUtils.toString(entity, "utf-8");
}
return "error";
}
/**
* 生成签名并请求
* @param hbody 请求body
......
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