|
@@ -3,18 +3,27 @@ package com.zswl.cloud.springBtach.server.core.api.qiuxiang;
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
import com.zswl.cloud.springBatch.client.model.qiuxiang.OrderRequest;
|
|
import com.zswl.cloud.springBatch.client.model.qiuxiang.OrderRequest;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
+@Component
|
|
public class QiuXiangApi {
|
|
public class QiuXiangApi {
|
|
- private static final String BASE_URL = "http://your.api.url";
|
|
|
|
- private static final String APPID = "your_appid";
|
|
|
|
- private static final String SECRET = "your_secret";
|
|
|
|
|
|
+
|
|
|
|
+ @Value("${qxdj.url}")
|
|
|
|
+ private String BASE_URL;
|
|
|
|
+
|
|
|
|
+ @Value("${qxdj.appid}")
|
|
|
|
+ private String APPID;
|
|
|
|
+
|
|
|
|
+ @Value("${qxdj.secret}")
|
|
|
|
+ private String SECRET;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取接口调用凭证
|
|
* 获取接口调用凭证
|
|
*
|
|
*
|
|
* @return token
|
|
* @return token
|
|
*/
|
|
*/
|
|
- public static String getToken() {
|
|
|
|
|
|
+ public String getPlatformToken() {
|
|
String url = BASE_URL + "/token";
|
|
String url = BASE_URL + "/token";
|
|
String result = HttpRequest.get(url)
|
|
String result = HttpRequest.get(url)
|
|
.form("appid", APPID)
|
|
.form("appid", APPID)
|
|
@@ -31,7 +40,7 @@ public class QiuXiangApi {
|
|
* @param token 接口调用凭证
|
|
* @param token 接口调用凭证
|
|
* @return permissions
|
|
* @return permissions
|
|
*/
|
|
*/
|
|
- public static String getPermissions(String token) {
|
|
|
|
|
|
+ public String getPermissions(String token) {
|
|
String url = BASE_URL + "/permissions";
|
|
String url = BASE_URL + "/permissions";
|
|
String result = HttpRequest.get(url)
|
|
String result = HttpRequest.get(url)
|
|
.header("Authorization", "Bearer " + token)
|
|
.header("Authorization", "Bearer " + token)
|
|
@@ -47,7 +56,7 @@ public class QiuXiangApi {
|
|
* @param phone 用户手机号码
|
|
* @param phone 用户手机号码
|
|
* @return 登录信息,包含uid和新的token
|
|
* @return 登录信息,包含uid和新的token
|
|
*/
|
|
*/
|
|
- public static String loginUser(String token, String phone) {
|
|
|
|
|
|
+ public String loginUser(String token, String phone) {
|
|
String url = BASE_URL + "/user/login";
|
|
String url = BASE_URL + "/user/login";
|
|
String result = HttpRequest.get(url)
|
|
String result = HttpRequest.get(url)
|
|
.header("Token", token)
|
|
.header("Token", token)
|
|
@@ -65,7 +74,7 @@ public class QiuXiangApi {
|
|
* @param orderRequest 下单请求参数
|
|
* @param orderRequest 下单请求参数
|
|
* @return 订单信息,包含订单ID
|
|
* @return 订单信息,包含订单ID
|
|
*/
|
|
*/
|
|
- public static String placeOrder(String token, OrderRequest orderRequest) {
|
|
|
|
|
|
+ public String placeOrder(String token, OrderRequest orderRequest) {
|
|
String url = BASE_URL + "/user/order";
|
|
String url = BASE_URL + "/user/order";
|
|
|
|
|
|
JSONObject body = new JSONObject();
|
|
JSONObject body = new JSONObject();
|
|
@@ -93,12 +102,13 @@ public class QiuXiangApi {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 用户订单列表
|
|
* 用户订单列表
|
|
|
|
+ *
|
|
* @param userToken
|
|
* @param userToken
|
|
* @param lastOrderId
|
|
* @param lastOrderId
|
|
* @param count
|
|
* @param count
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static JSONObject orderList(String userToken, String lastOrderId, int count) {
|
|
|
|
|
|
+ public JSONObject orderList(String userToken, String lastOrderId, int count) {
|
|
String url = BASE_URL + "/user/order/list";
|
|
String url = BASE_URL + "/user/order/list";
|
|
JSONObject body = new JSONObject();
|
|
JSONObject body = new JSONObject();
|
|
body.put("lastOrderId", lastOrderId);
|
|
body.put("lastOrderId", lastOrderId);
|
|
@@ -116,15 +126,16 @@ public class QiuXiangApi {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 订单详情
|
|
* 订单详情
|
|
|
|
+ *
|
|
* @param userToken
|
|
* @param userToken
|
|
* @param orderId
|
|
* @param orderId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static JSONObject orderDelit(String userToken, String orderId) {
|
|
|
|
|
|
+ public JSONObject orderDelit(String userToken, String orderId) {
|
|
String url = BASE_URL + "/user/order";
|
|
String url = BASE_URL + "/user/order";
|
|
String result = HttpRequest.get(url)
|
|
String result = HttpRequest.get(url)
|
|
.header("Token", userToken)
|
|
.header("Token", userToken)
|
|
- .form("orderId",orderId)
|
|
|
|
|
|
+ .form("orderId", orderId)
|
|
.execute().body();
|
|
.execute().body();
|
|
|
|
|
|
JSONObject json = new JSONObject(result);
|
|
JSONObject json = new JSONObject(result);
|
|
@@ -134,12 +145,13 @@ public class QiuXiangApi {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 取消订单
|
|
* 取消订单
|
|
|
|
+ *
|
|
* @param token
|
|
* @param token
|
|
* @param orderId
|
|
* @param orderId
|
|
* @param reason
|
|
* @param reason
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static JSONObject cancelOrder(String token, String orderId, String reason) {
|
|
|
|
|
|
+ public JSONObject cancelOrder(String token, String orderId, String reason) {
|
|
String url = BASE_URL + "/user/order";
|
|
String url = BASE_URL + "/user/order";
|
|
JSONObject body = new JSONObject();
|
|
JSONObject body = new JSONObject();
|
|
body.put("orderId", orderId);
|
|
body.put("orderId", orderId);
|
|
@@ -156,11 +168,12 @@ public class QiuXiangApi {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取司机实时位置
|
|
* 获取司机实时位置
|
|
|
|
+ *
|
|
* @param token
|
|
* @param token
|
|
* @param orderId
|
|
* @param orderId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static JSONObject driverLocation(String token, String orderId) {
|
|
|
|
|
|
+ public JSONObject driverLocation(String token, String orderId) {
|
|
String url = BASE_URL + "/user/order/driver/location";
|
|
String url = BASE_URL + "/user/order/driver/location";
|
|
JSONObject body = new JSONObject();
|
|
JSONObject body = new JSONObject();
|
|
body.put("orderId", orderId);
|
|
body.put("orderId", orderId);
|
|
@@ -176,18 +189,19 @@ public class QiuXiangApi {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取司机行驶轨迹
|
|
* 获取司机行驶轨迹
|
|
|
|
+ *
|
|
* @param token
|
|
* @param token
|
|
* @param orderId
|
|
* @param orderId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static JSONObject driverLocationLog(String token, String orderId) {
|
|
|
|
|
|
+ public JSONObject driverLocationLog(String token, String orderId) {
|
|
String url = BASE_URL + "/user/order/driver/location/log";
|
|
String url = BASE_URL + "/user/order/driver/location/log";
|
|
JSONObject body = new JSONObject();
|
|
JSONObject body = new JSONObject();
|
|
body.put("orderId", orderId);
|
|
body.put("orderId", orderId);
|
|
|
|
|
|
String result = HttpRequest.get(url)
|
|
String result = HttpRequest.get(url)
|
|
.header("Token", token)
|
|
.header("Token", token)
|
|
- .form("orderId",orderId)
|
|
|
|
|
|
+ .form("orderId", orderId)
|
|
.execute().body();
|
|
.execute().body();
|
|
|
|
|
|
JSONObject json = new JSONObject(result);
|
|
JSONObject json = new JSONObject(result);
|