diff --git a/app/src/main/java/com/ouxuan/oxface/network/api/PadApiService.java b/app/src/main/java/com/ouxuan/oxface/network/api/PadApiService.java index 9985e42..d692948 100644 --- a/app/src/main/java/com/ouxuan/oxface/network/api/PadApiService.java +++ b/app/src/main/java/com/ouxuan/oxface/network/api/PadApiService.java @@ -1126,7 +1126,7 @@ public interface PadApiService { @SerializedName("token") private String token; // 访问令牌 - @SerializedName("order_id") + @SerializedName("order_no") private String orderId; // 订单ID @SerializedName("v_code") @@ -1141,6 +1141,15 @@ public interface PadApiService { @SerializedName("hardware_id") private int hardwareId; // 硬件ID + @SerializedName("card_no") + private String cardNo; // 卡号 + + @SerializedName("user_face_id") + private String userFaceId; // 用户人脸ID + + @SerializedName("dont_open_door") + private String dontOpenDoor; // 是否不开启门禁 + public VerifyOrderRequest(String token, String orderId, String verifyCode, int type) { this.token = token; this.orderId = orderId; @@ -1167,6 +1176,19 @@ public interface PadApiService { this.hardwareId = hardwareId; } + // 新增构造函数,包含所有参数 + public VerifyOrderRequest(String token, String orderId, String verifyCode, int type, int orderType, int hardwareId, String cardNo, String userFaceId, String dontOpenDoor) { + this.token = token; + this.orderId = orderId; + this.verifyCode = verifyCode; + this.type = type; + this.orderType = orderType; + this.hardwareId = hardwareId; + this.cardNo = cardNo; + this.userFaceId = userFaceId; + this.dontOpenDoor = dontOpenDoor; + } + // Getters and Setters public String getToken() { return token; } public void setToken(String token) { this.token = token; } @@ -1187,6 +1209,18 @@ public interface PadApiService { // 新增hardwareId的getter和setter public int getHardwareId() { return hardwareId; } public void setHardwareId(int hardwareId) { this.hardwareId = hardwareId; } + + // 新增cardNo的getter和setter + public String getCardNo() { return cardNo; } + public void setCardNo(String cardNo) { this.cardNo = cardNo; } + + // 新增userFaceId的getter和setter + public String getUserFaceId() { return userFaceId; } + public void setUserFaceId(String userFaceId) { this.userFaceId = userFaceId; } + + // 新增dontOpenDoor的getter和setter + public String getDontOpenDoor() { return dontOpenDoor; } + public void setDontOpenDoor(String dontOpenDoor) { this.dontOpenDoor = dontOpenDoor; } } /** @@ -1194,7 +1228,7 @@ public interface PadApiService { */ public static class VerifyOrderResponse { @SerializedName("result") - private boolean result; // 核销结果 + private VerifyOrderResult result; // 核销结果 @SerializedName("message") private String message; // 响应消息 @@ -1202,15 +1236,141 @@ public interface PadApiService { @SerializedName("order_info") private OrderInfo orderInfo; // 订单信息 + @SerializedName("avatar_url") + private String avatarUrl; // 用户头像URL + + @SerializedName("nickname") + private String nickname; // 用户昵称 + // Getters and Setters - public boolean isResult() { return result; } - public void setResult(boolean result) { this.result = result; } + public VerifyOrderResult getResult() { return result; } + public void setResult(VerifyOrderResult result) { this.result = result; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public OrderInfo getOrderInfo() { return orderInfo; } public void setOrderInfo(OrderInfo orderInfo) { this.orderInfo = orderInfo; } + + public String getAvatarUrl() { return avatarUrl; } + public void setAvatarUrl(String avatarUrl) { this.avatarUrl = avatarUrl; } + + public String getNickname() { return nickname; } + public void setNickname(String nickname) { this.nickname = nickname; } + } + + /** + * 核销订单结果模型 + */ + public static class VerifyOrderResult { + @SerializedName("order_no") + private String orderNo; // 订单号 + + @SerializedName("start_time") + private String startTime; // 开始时间 + + @SerializedName("end_time") + private String endTime; // 结束时间 + + @SerializedName("order_type") + private int orderType; // 订单类型 + + @SerializedName("project") + private String project; // 项目名称 + + @SerializedName("number") + private int number; // 数量 + + @SerializedName("v_code") + private java.util.List vCode; // 验证码列表 + + @SerializedName("info") + private VerifyOrderInfo info; // 订单信息 + + @SerializedName("success") + private int success; // 成功状态 + + @SerializedName("pv_usage_duration") + private int pvUsageDuration; // 使用时长 + + @SerializedName("many_enter") + private boolean manyEnter; // 是否多次进入 + + // Getters and Setters + public String getOrderNo() { return orderNo; } + public void setOrderNo(String orderNo) { this.orderNo = orderNo; } + + public String getStartTime() { return startTime; } + public void setStartTime(String startTime) { this.startTime = startTime; } + + public String getEndTime() { return endTime; } + public void setEndTime(String endTime) { this.endTime = endTime; } + + public int getOrderType() { return orderType; } + public void setOrderType(int orderType) { this.orderType = orderType; } + + public String getProject() { return project; } + public void setProject(String project) { this.project = project; } + + public int getNumber() { return number; } + public void setNumber(int number) { this.number = number; } + + public java.util.List getVCode() { return vCode; } + public void setVCode(java.util.List vCode) { this.vCode = vCode; } + + public VerifyOrderInfo getInfo() { return info; } + public void setInfo(VerifyOrderInfo info) { this.info = info; } + + public int getSuccess() { return success; } + public void setSuccess(int success) { this.success = success; } + + public int getPvUsageDuration() { return pvUsageDuration; } + public void setPvUsageDuration(int pvUsageDuration) { this.pvUsageDuration = pvUsageDuration; } + + public boolean isManyEnter() { return manyEnter; } + public void setManyEnter(boolean manyEnter) { this.manyEnter = manyEnter; } + } + + /** + * 核销订单信息模型 + */ + public static class VerifyOrderInfo { + @SerializedName("card_no") + private String cardNo; // 卡号 + + @SerializedName("rest_number") + private int restNumber; // 剩余次数 + + @SerializedName("status") + private int status; // 状态 + + @SerializedName("verify_desc") + private String verifyDesc; // 验证描述 + + @SerializedName("verify_time") + private String verifyTime; // 验证时间 + + @SerializedName("verify_type") + private int verifyType; // 验证类型 + + // Getters and Setters + public String getCardNo() { return cardNo; } + public void setCardNo(String cardNo) { this.cardNo = cardNo; } + + public int getRestNumber() { return restNumber; } + public void setRestNumber(int restNumber) { this.restNumber = restNumber; } + + public int getStatus() { return status; } + public void setStatus(int status) { this.status = status; } + + public String getVerifyDesc() { return verifyDesc; } + public void setVerifyDesc(String verifyDesc) { this.verifyDesc = verifyDesc; } + + public String getVerifyTime() { return verifyTime; } + public void setVerifyTime(String verifyTime) { this.verifyTime = verifyTime; } + + public int getVerifyType() { return verifyType; } + public void setVerifyType(int verifyType) { this.verifyType = verifyType; } } /** diff --git a/app/src/main/java/com/ouxuan/oxface/network/utils/NetworkUtils.java b/app/src/main/java/com/ouxuan/oxface/network/utils/NetworkUtils.java index 9d73484..7fa967c 100644 --- a/app/src/main/java/com/ouxuan/oxface/network/utils/NetworkUtils.java +++ b/app/src/main/java/com/ouxuan/oxface/network/utils/NetworkUtils.java @@ -720,16 +720,19 @@ public class NetworkUtils { * @param type 验证类型 1验证码验证 2人脸验证 3扫码验证 4扫码器验证 * @param orderType 订单类型 * @param hardwareId 硬件ID + * @param cardNo 卡号 + * @param userFaceId 用户人脸ID + * @param dontOpenDoor 是否不开启门禁 * @param callback 回调接口 */ - public static void verifyOrder(String token, String orderId, String verifyCode, int type, int orderType, int hardwareId, + public static void verifyOrder(String token, String orderId, String verifyCode, int type, int orderType, int hardwareId, String cardNo, String userFaceId, String dontOpenDoor, NetworkCallback callback) { if (padApiService == null) { callback.onError(-1, "NetworkUtils未初始化,请先调用init()方法"); return; } - PadApiService.VerifyOrderRequest request = new PadApiService.VerifyOrderRequest(token, orderId, verifyCode, type, orderType, hardwareId); + PadApiService.VerifyOrderRequest request = new PadApiService.VerifyOrderRequest(token, orderId, verifyCode, type, orderType, hardwareId, cardNo, userFaceId, dontOpenDoor); callback.onStart(); padApiService.verifyOrder(request).enqueue(new Callback>() { @@ -772,6 +775,22 @@ public class NetworkUtils { * @param verifyCode 核销码 * @param type 验证类型 1验证码验证 2人脸验证 3扫码验证 4扫码器验证 * @param orderType 订单类型 + * @param hardwareId 硬件ID + * @param callback 回调接口 + */ + public static void verifyOrder(String token, String orderId, String verifyCode, int type, int orderType, int hardwareId, + NetworkCallback callback) { + // 调用新的重载方法,其他参数使用默认值 + verifyOrder(token, orderId, verifyCode, type, orderType, hardwareId, "", "", "on", callback); + } + + /** + * 核销订单 + * @param token 访问令牌 + * @param orderId 订单ID + * @param verifyCode 核销码 + * @param type 验证类型 1验证码验证 2人脸验证 3扫码验证 4扫码器验证 + * @param orderType 订单类型 * @param callback 回调接口 */ public static void verifyOrder(String token, String orderId, String verifyCode, int type, int orderType, diff --git a/app/src/main/java/com/ouxuan/oxface/orderOX/OrderSelectionActivity.java b/app/src/main/java/com/ouxuan/oxface/orderOX/OrderSelectionActivity.java index 7da9605..99fc2a6 100644 --- a/app/src/main/java/com/ouxuan/oxface/orderOX/OrderSelectionActivity.java +++ b/app/src/main/java/com/ouxuan/oxface/orderOX/OrderSelectionActivity.java @@ -290,13 +290,20 @@ public class OrderSelectionActivity extends AppCompatActivity { // 获取订单类型 int orderType = order.getOrder_type(); + // 获取卡号 + String cardNo = order.getInfo() != null ? order.getInfo().getCard_no() : ""; + + // 获取用户人脸ID + String userFaceId = order.getInfo() != null ? order.getInfo().getUser_face_id() : ""; + LogManager.logInfo(TAG, "调用核销接口: orderId=" + orderId + ", verifyCode=" + verifyCode + - ", hardwareId=" + hardwareId + ", orderType=" + orderType); + ", hardwareId=" + hardwareId + ", orderType=" + orderType + ", cardNo=" + cardNo + + ", userFaceId=" + userFaceId); // 显示加载状态 showToast("正在核销订单,请稍候..."); - // 调用NetworkUtils.verifyOrder接口进行实际核销,传递设备ID和订单类型 + // 调用NetworkUtils.verifyOrder接口进行实际核销,传递所有必要参数 com.ouxuan.oxface.network.utils.NetworkUtils.verifyOrder( token, orderId, @@ -304,6 +311,9 @@ public class OrderSelectionActivity extends AppCompatActivity { verificationType, // 使用verificationType作为type参数 orderType, // 添加orderType参数 hardwareId, // 添加hardwareId参数 + cardNo, // 添加cardNo参数 + userFaceId, // 添加userFaceId参数 + "on", // 添加dontOpenDoor参数,默认为"on" new com.ouxuan.oxface.network.callback.NetworkCallback() { @Override @@ -321,7 +331,8 @@ public class OrderSelectionActivity extends AppCompatActivity { String message = "订单核销成功"; if (data != null) { - if (data.isResult()) { + // 检查核销结果是否成功 + if (data.getResult() != null && data.getResult().getSuccess() == 3) { status = "核销成功"; message = data.getMessage() != null && !data.getMessage().isEmpty() ? data.getMessage() : "订单核销成功";