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

Commit 87e5680e authored by jiangxiulong's avatar jiangxiulong

快递

parent c066a8d0
...@@ -9,7 +9,6 @@ import com.liquidnet.service.kylin.dao.PerformanceExpressPerformanceOrderListAdm ...@@ -9,7 +9,6 @@ import com.liquidnet.service.kylin.dao.PerformanceExpressPerformanceOrderListAdm
import com.liquidnet.service.kylin.dto.param.PerformanceExpressSearchAdminParam; import com.liquidnet.service.kylin.dto.param.PerformanceExpressSearchAdminParam;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -31,16 +30,18 @@ public class PerformancesExpressController extends BaseController { ...@@ -31,16 +30,18 @@ public class PerformancesExpressController extends BaseController {
private String prefix = "zhengzai/kylin/performancesExpress"; private String prefix = "zhengzai/kylin/performancesExpress";
@Value("${liquidnet.shunfeng.url}") /*@Value("${liquidnet.shunfeng.url}")
private String url; public String url;
@Value("${liquidnet.shunfeng.sk}") @Value("${liquidnet.shunfeng.sk}")
private String sk; private String sk;
@Value("${liquidnet.shunfeng.appid}") @Value("${liquidnet.shunfeng.appid}")
private String appid; private String appid;*/
@Autowired @Autowired
private PerformancesExpressServiceImpl performancesExpressServiceImpl; private PerformancesExpressServiceImpl performancesExpressServiceImpl;
private ShunfengSignUtils shunfengSignUtils;
/** /**
* 查询演出列表 * 查询演出列表
*/ */
...@@ -90,7 +91,7 @@ public class PerformancesExpressController extends BaseController { ...@@ -90,7 +91,7 @@ public class PerformancesExpressController extends BaseController {
System.out.println("时间戳:"+currentTimeMillis); System.out.println("时间戳:"+currentTimeMillis);
// 生成签名并请求 // 生成签名并请求
String result = ShunfengSignUtils.generateSignatureAndRequest(currentTimeMillis + "", body); String result = shunfengSignUtils.generateSignatureAndRequest(currentTimeMillis + "", body, "/order/v1/placeOrder");
System.out.println("响应:"+result); System.out.println("响应:"+result);
return true; return true;
} }
......
...@@ -28,12 +28,17 @@ public class ShunfengSignUtils { ...@@ -28,12 +28,17 @@ public class ShunfengSignUtils {
* appId * appId
*/ */
@Value("${liquidnet.shunfeng.appid}") @Value("${liquidnet.shunfeng.appid}")
private static String APP_ID = ""; private String APP_ID;
/** /**
* sk * sk
*/ */
@Value("${liquidnet.shunfeng.sk}") @Value("${liquidnet.shunfeng.sk}")
private static String SK = ""; private String SK;
/**
* url
*/
@Value("${liquidnet.shunfeng.url}")
private String URL;
/** /**
* 签名有效期(可根据实际业务设定)单位:毫秒 * 签名有效期(可根据实际业务设定)单位:毫秒
*/ */
...@@ -45,14 +50,15 @@ public class ShunfengSignUtils { ...@@ -45,14 +50,15 @@ public class ShunfengSignUtils {
* @param body 请求body * @param body 请求body
* @return * @return
*/ */
public static String generateSignatureAndRequest(String timestamp, String body) { public String generateSignatureAndRequest(String timestamp, String body, String url) {
// 生成签名 // 生成签名
String sign = genSign(timestamp,body); String sign = genSign(timestamp,body);
System.out.println("签名:"+sign); System.out.println("签名:"+sign);
CloseableHttpClient client = HttpClients.createDefault(); CloseableHttpClient client = HttpClients.createDefault();
// 请求下单地址 // 请求下单地址
HttpPost httpPost = new HttpPost("https://butler-dev-ms.sf-express.com/public/order/v1/placeOrder"); HttpPost httpPost = new HttpPost(URL + url);
System.out.println("请求的url:"+URL + url);
// sendAppId(sendAppId需赋值appId) // sendAppId(sendAppId需赋值appId)
httpPost.addHeader("sendAppId", APP_ID); httpPost.addHeader("sendAppId", APP_ID);
// 时间戳需和获取验签时一致!!! // 时间戳需和获取验签时一致!!!
...@@ -99,7 +105,7 @@ public class ShunfengSignUtils { ...@@ -99,7 +105,7 @@ public class ShunfengSignUtils {
* @param body 请求body * @param body 请求body
* @return * @return
*/ */
private static String genSign(String timestamp, String body) { private String genSign(String timestamp, String body) {
if (StringUtils.isEmpty(body)) { if (StringUtils.isEmpty(body)) {
body = ""; body = "";
} }
...@@ -121,7 +127,7 @@ public class ShunfengSignUtils { ...@@ -121,7 +127,7 @@ public class ShunfengSignUtils {
* @param request 接收请求 * @param request 接收请求
* @return * @return
*/ */
public static boolean receiveRequestAndCheckSign(String params, HttpServletRequest request) { public boolean receiveRequestAndCheckSign(String params, HttpServletRequest request) {
// 请求方APPID // 请求方APPID
String sendAppId = request.getHeader("sendAppId"); String sendAppId = request.getHeader("sendAppId");
// 请求方时间戳 // 请求方时间戳
...@@ -148,7 +154,7 @@ public class ShunfengSignUtils { ...@@ -148,7 +154,7 @@ public class ShunfengSignUtils {
return false; return false;
} }
// 请求方参数+请求方时间戳+SK 生成签名 // 请求方参数+请求方时间戳+SK 生成签名
String thisSign = ShunfengSignUtils.genSign(timestamp, params); String thisSign = genSign(timestamp, params);
// 获取的签名和请求方签名比较是否一致 // 获取的签名和请求方签名比较是否一致
if (!thisSign.equals(sign)) { if (!thisSign.equals(sign)) {
System.out.println("签名错误"); System.out.println("签名错误");
......
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