From a1529d0b06fdda3fa3423dba5cbca0186f516ae8 Mon Sep 17 00:00:00 2001 From: MTing Date: Wed, 10 Sep 2025 10:20:53 +0800 Subject: [PATCH] fix 4 --- .../ouxuan/oxface/network/api/PadApiService.java | 35 +++++++++++++++++- .../ouxuan/oxface/network/utils/NetworkUtils.java | 35 +++++++++++++++++- .../oxface/orderOX/OrderSelectionActivity.java | 43 ++++++++++++++++++++-- 3 files changed, 107 insertions(+), 6 deletions(-) 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 1ff1d05..9985e42 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 @@ -1129,12 +1129,18 @@ public interface PadApiService { @SerializedName("order_id") private String orderId; // 订单ID - @SerializedName("verify_code") + @SerializedName("v_code") private String verifyCode; // 核销码 @SerializedName("type") private int type; // 验证类型 1验证码验证 2人脸验证 3扫码验证 4扫码器验证 + @SerializedName("order_type") + private int orderType; // 订单类型 + + @SerializedName("hardware_id") + private int hardwareId; // 硬件ID + public VerifyOrderRequest(String token, String orderId, String verifyCode, int type) { this.token = token; this.orderId = orderId; @@ -1142,6 +1148,25 @@ public interface PadApiService { this.type = type; } + // 新增构造函数,包含orderType参数 + public VerifyOrderRequest(String token, String orderId, String verifyCode, int type, int orderType) { + this.token = token; + this.orderId = orderId; + this.verifyCode = verifyCode; + this.type = type; + this.orderType = orderType; + } + + // 新增构造函数,包含orderType和hardwareId参数 + public VerifyOrderRequest(String token, String orderId, String verifyCode, int type, int orderType, int hardwareId) { + this.token = token; + this.orderId = orderId; + this.verifyCode = verifyCode; + this.type = type; + this.orderType = orderType; + this.hardwareId = hardwareId; + } + // Getters and Setters public String getToken() { return token; } public void setToken(String token) { this.token = token; } @@ -1154,6 +1179,14 @@ public interface PadApiService { public int getType() { return type; } public void setType(int type) { this.type = type; } + + // 新增orderType的getter和setter + public int getOrderType() { return orderType; } + public void setOrderType(int orderType) { this.orderType = orderType; } + + // 新增hardwareId的getter和setter + public int getHardwareId() { return hardwareId; } + public void setHardwareId(int hardwareId) { this.hardwareId = hardwareId; } } /** 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 a0bbd88..9d73484 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 @@ -718,16 +718,18 @@ public class NetworkUtils { * @param orderId 订单ID * @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, + public static void verifyOrder(String token, String orderId, String verifyCode, int type, int orderType, int hardwareId, NetworkCallback callback) { if (padApiService == null) { callback.onError(-1, "NetworkUtils未初始化,请先调用init()方法"); return; } - PadApiService.VerifyOrderRequest request = new PadApiService.VerifyOrderRequest(token, orderId, verifyCode, type); + PadApiService.VerifyOrderRequest request = new PadApiService.VerifyOrderRequest(token, orderId, verifyCode, type, orderType, hardwareId); callback.onStart(); padApiService.verifyOrder(request).enqueue(new Callback>() { @@ -764,6 +766,35 @@ public class NetworkUtils { } /** + * 核销订单 + * @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, + NetworkCallback callback) { + // 调用新的重载方法,hardwareId默认为0 + verifyOrder(token, orderId, verifyCode, type, orderType, 0, callback); + } + + /** + * 核销订单 + * @param token 访问令牌 + * @param orderId 订单ID + * @param verifyCode 核销码 + * @param type 验证类型 1验证码验证 2人脸验证 3扫码验证 4扫码器验证 + * @param callback 回调接口 + */ + public static void verifyOrder(String token, String orderId, String verifyCode, int type, + NetworkCallback callback) { + // 调用新的重载方法,orderType默认为0 + verifyOrder(token, orderId, verifyCode, type, 0, callback); + } + + /** * 核销订单(向后兼容版本,默认type=1) * @param token 访问令牌 * @param orderId 订单ID 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 5d8a98b..7da9605 100644 --- a/app/src/main/java/com/ouxuan/oxface/orderOX/OrderSelectionActivity.java +++ b/app/src/main/java/com/ouxuan/oxface/orderOX/OrderSelectionActivity.java @@ -24,6 +24,7 @@ import com.ouxuan.oxface.orderOX.adapter.OrderSelectionAdapter; import com.ouxuan.oxface.orderOX.model.OrderVerificationData; import com.ouxuan.oxface.utils.LogManager; import com.ouxuan.oxface.data.LoginDataManager; +import com.ouxuan.oxface.data.DeviceSelectDataManager; // 添加设备数据管理器导入 import com.bumptech.glide.Glide; import com.bumptech.glide.load.resource.bitmap.CircleCrop; import com.bumptech.glide.request.RequestOptions; @@ -61,6 +62,8 @@ public class OrderSelectionActivity extends AppCompatActivity { // 登录数据管理器 private LoginDataManager loginDataManager; + // 设备数据管理器 + private DeviceSelectDataManager deviceDataManager; @Override protected void onCreate(Bundle savedInstanceState) { @@ -81,6 +84,8 @@ public class OrderSelectionActivity extends AppCompatActivity { // 初始化登录数据管理器(必须在initViews之前) loginDataManager = LoginDataManager.getInstance(this); + // 初始化设备数据管理器 + deviceDataManager = DeviceSelectDataManager.getInstance(this); initViews(); initData(); @@ -263,6 +268,14 @@ public class OrderSelectionActivity extends AppCompatActivity { return; } + // 获取设备ID + int hardwareId = deviceDataManager.getSelectedHardwareId(); + if (hardwareId <= 0) { + LogManager.logError(TAG, "获取设备ID失败"); + showToast("获取设备ID失败,无法核销订单"); + return; + } + // 获取订单ID和核销码 String orderId = order.getOrder_no(); // 将verifyCode声明为final,避免lambda表达式中的问题 @@ -274,17 +287,23 @@ public class OrderSelectionActivity extends AppCompatActivity { return; } - LogManager.logInfo(TAG, "调用核销接口: orderId=" + orderId + ", verifyCode=" + verifyCode + ", type=" + verificationType); + // 获取订单类型 + int orderType = order.getOrder_type(); + + LogManager.logInfo(TAG, "调用核销接口: orderId=" + orderId + ", verifyCode=" + verifyCode + + ", hardwareId=" + hardwareId + ", orderType=" + orderType); // 显示加载状态 showToast("正在核销订单,请稍候..."); - // 调用NetworkUtils.verifyOrder接口进行实际核销,传递verificationType参数 + // 调用NetworkUtils.verifyOrder接口进行实际核销,传递设备ID和订单类型 com.ouxuan.oxface.network.utils.NetworkUtils.verifyOrder( token, orderId, verifyCode, - verificationType, // 传递验证类型参数 + verificationType, // 使用verificationType作为type参数 + orderType, // 添加orderType参数 + hardwareId, // 添加hardwareId参数 new com.ouxuan.oxface.network.callback.NetworkCallback() { @Override @@ -325,6 +344,9 @@ public class OrderSelectionActivity extends AppCompatActivity { intent.putExtra("project", order.getProject()); intent.putExtra("status", status); intent.putExtra("message", message); + // 添加设备ID和订单类型参数 + intent.putExtra("hardware_id", hardwareId); + intent.putExtra("order_type_param", orderType); // 传递完整的订单数据和核销结果数据 intent.putExtra("order_data", new Gson().toJson(order)); @@ -345,6 +367,9 @@ public class OrderSelectionActivity extends AppCompatActivity { resultIntent.putExtra("verification_type", verificationType); resultIntent.putExtra("verify_status", status); resultIntent.putExtra("verify_message", message); + // 添加设备ID和订单类型参数 + resultIntent.putExtra("hardware_id", hardwareId); + resultIntent.putExtra("order_type_param", orderType); setResult(RESULT_OK, resultIntent); finish(); @@ -372,6 +397,9 @@ public class OrderSelectionActivity extends AppCompatActivity { intent.putExtra("status", "核销失败"); intent.putExtra("message", displayMessage); intent.putExtra("order_data", new Gson().toJson(order)); + // 添加设备ID和订单类型参数 + intent.putExtra("hardware_id", hardwareId); + intent.putExtra("order_type_param", orderType); startActivity(intent); @@ -383,6 +411,9 @@ public class OrderSelectionActivity extends AppCompatActivity { resultIntent.putExtra("verification_type", verificationType); resultIntent.putExtra("verify_status", "核销失败"); resultIntent.putExtra("verify_message", displayMessage); + // 添加设备ID和订单类型参数 + resultIntent.putExtra("hardware_id", hardwareId); + resultIntent.putExtra("order_type_param", orderType); setResult(RESULT_OK, resultIntent); finish(); @@ -408,6 +439,9 @@ public class OrderSelectionActivity extends AppCompatActivity { intent.putExtra("status", "核销异常"); intent.putExtra("message", displayMessage); intent.putExtra("order_data", new Gson().toJson(order)); + // 添加设备ID和订单类型参数 + intent.putExtra("hardware_id", hardwareId); + intent.putExtra("order_type_param", orderType); startActivity(intent); @@ -419,6 +453,9 @@ public class OrderSelectionActivity extends AppCompatActivity { resultIntent.putExtra("verification_type", verificationType); resultIntent.putExtra("verify_status", "核销异常"); resultIntent.putExtra("verify_message", displayMessage); + // 添加设备ID和订单类型参数 + resultIntent.putExtra("hardware_id", hardwareId); + resultIntent.putExtra("order_type_param", orderType); setResult(RESULT_OK, resultIntent); finish();