Commit 329c641e by 吕明尚

修改对接实现类

parent dfbf9c83
......@@ -103,4 +103,14 @@ public class VendingMachineController {
public String sendOrder(SendOrder sendOrder) {
return vendingMachineSrevice.sendOrder(sendOrder);
}
@PostMapping("/pickupCodeCheck")
public void pickupCodeCheck(String pickupCode, String machineId) {
vendingMachineSrevice.pickupCodeCheck(pickupCode, machineId);
}
@GetMapping("/queryPayInfo")
public void queryPayInfo(String machineId, String orderSn) {
vendingMachineSrevice.queryPayInfo(machineId, orderSn);
}
}
......@@ -39,4 +39,8 @@ public interface VendingMachineSrevice {
String orderList(QueryOrder queryOrder);
String sendOrder(SendOrder sendOrder);
void pickupCodeCheck(String pickupCode, String machineId);
void queryPayInfo(String machineId, String orderSn);
}
......@@ -477,6 +477,55 @@ public class VendingMachineSreviceImpl implements VendingMachineSrevice {
return "";
}
@Override
public void pickupCodeCheck(String pickupCode, String machineId) {
Map<String, Object> map = new HashMap<>();
map.put("version", "1.0");
map.put("pickup_code", pickupCode);
map.put("machine_id", machineId);
map.put("sign_type", "MD5");
map.put("nonce_str", UUID.randomUUID().toString().replace("-", ""));
String sign = formatBizQueryParaMap(map, true, false);
try {
map.put("sign", MD5Util.MD5Encode(sign, "UTF-8").toLowerCase());
} catch (Exception e) {
throw new RuntimeException(e);
}
JSONObject jsonObject = new JSONObject(map);
String url = VendingMachineConstants.DOMAIN + VendingMachineConstants.PICKUP_CODE_CHECK;
String result = HttpRequest.post(url)
.contentType("multipart/form-data")
.body(jsonObject.toString()).execute().body();
JSONObject entries = new JSONObject(result);
if (entries.containsKey("code") && entries.getStr("code").equals("0")) {
JSONArray content = entries.getJSONArray("content");
content.forEach(item -> {
});
}
}
@Override
public void queryPayInfo(String machineId, String orderSn) {
String accessToken = obtain();
String url = VendingMachineConstants.DOMAIN + VendingMachineConstants.QUERY_PAY_INFO;
String result = HttpRequest.get(url)
.contentType("application/json")
.form("api_token", accessToken)
.form("version", "1.0")
.form("machine_id", machineId)
.form("order_sn", orderSn)
.execute().body();
JSONObject entries = new JSONObject(result);
if (entries.containsKey("code") && entries.getStr("code").equals("0")) {
JSONArray content = entries.getJSONArray("content");
content.forEach(item -> {
});
}
}
public String obtain() {
String o;
......
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