|
@ -6,6 +6,9 @@ import com.ouxuan.oxface.network.api.PadApiService; |
|
|
import com.ouxuan.oxface.orderOX.OrderVerificationResultActivity; |
|
|
import com.ouxuan.oxface.orderOX.OrderVerificationResultActivity; |
|
|
import com.ouxuan.oxface.orderOX.OrderSelectionActivity; |
|
|
import com.ouxuan.oxface.orderOX.OrderSelectionActivity; |
|
|
import com.ouxuan.oxface.utils.LogManager; |
|
|
import com.ouxuan.oxface.utils.LogManager; |
|
|
|
|
|
import com.ouxuan.oxface.orderOX.model.OrderVerificationData; |
|
|
|
|
|
import com.ouxuan.oxface.data.LoginDataManager; |
|
|
|
|
|
import com.ouxuan.oxface.data.DeviceSelectDataManager; |
|
|
import com.google.gson.JsonObject; |
|
|
import com.google.gson.JsonObject; |
|
|
import com.google.gson.Gson; |
|
|
import com.google.gson.Gson; |
|
|
|
|
|
|
|
@ -251,6 +254,31 @@ public class OrderVerificationResultHandler { |
|
|
* 处理人脸验证结果 |
|
|
* 处理人脸验证结果 |
|
|
*/ |
|
|
*/ |
|
|
private void handleFaceVerificationResult(PadApiService.CheckOrderResult data) { |
|
|
private void handleFaceVerificationResult(PadApiService.CheckOrderResult data) { |
|
|
|
|
|
// 检查订单数量,如果只有一条订单则直接核销,否则跳转到订单选择页面 |
|
|
|
|
|
if (data != null && data.getResult() != null && data.getResult().size() == 1) { |
|
|
|
|
|
// 只有一条订单,直接执行核销 |
|
|
|
|
|
LogManager.logInfo(TAG, "检测到只有一条订单,直接执行核销操作"); |
|
|
|
|
|
|
|
|
|
|
|
// 获取订单信息 |
|
|
|
|
|
PadApiService.CheckOrderItem order = data.getResult().get(0); |
|
|
|
|
|
|
|
|
|
|
|
// 构造OrderVerificationData.OrderItem对象用于核销 |
|
|
|
|
|
OrderVerificationData.OrderItem orderItem = new OrderVerificationData.OrderItem(); |
|
|
|
|
|
orderItem.setOrder_no(order.getOrderNo()); |
|
|
|
|
|
orderItem.setStart_time(order.getStartTime()); |
|
|
|
|
|
orderItem.setEnd_time(order.getEndTime()); |
|
|
|
|
|
orderItem.setOrder_type(Integer.parseInt(order.getOrderType())); |
|
|
|
|
|
orderItem.setProject(order.getProject()); |
|
|
|
|
|
orderItem.setNumber(order.getNumber()); |
|
|
|
|
|
orderItem.setV_code(order.getVCode()); |
|
|
|
|
|
orderItem.setInfo(order.getInfo()); |
|
|
|
|
|
orderItem.setSuccess(order.getSuccess()); |
|
|
|
|
|
orderItem.setPv_usage_duration(order.getPvUsageDuration()); |
|
|
|
|
|
orderItem.setMany_enter(order.isManyEnter()); |
|
|
|
|
|
|
|
|
|
|
|
// 直接执行核销操作 |
|
|
|
|
|
performDirectOrderVerification(orderItem); |
|
|
|
|
|
} else { |
|
|
// 重新构造完整的响应数据结构,包含所有必要字段 |
|
|
// 重新构造完整的响应数据结构,包含所有必要字段 |
|
|
Gson gson = new Gson(); |
|
|
Gson gson = new Gson(); |
|
|
|
|
|
|
|
@ -274,6 +302,234 @@ public class OrderVerificationResultHandler { |
|
|
listener.navigateToOrderSelectionPage(orderDataJson, OrderVerificationManager.TYPE_FACE_VERIFICATION, null); |
|
|
listener.navigateToOrderSelectionPage(orderDataJson, OrderVerificationManager.TYPE_FACE_VERIFICATION, null); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 直接执行订单核销操作 |
|
|
|
|
|
* @param order 订单项 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void performDirectOrderVerification(OrderVerificationData.OrderItem order) { |
|
|
|
|
|
LogManager.logInfo(TAG, "直接执行订单核销: " + order.getOrder_no()); |
|
|
|
|
|
|
|
|
|
|
|
// 获取认证信息 |
|
|
|
|
|
LoginDataManager loginDataManager = LoginDataManager.getInstance(context); |
|
|
|
|
|
DeviceSelectDataManager deviceDataManager = DeviceSelectDataManager.getInstance(context); |
|
|
|
|
|
|
|
|
|
|
|
String token = loginDataManager.getAuthToken(); |
|
|
|
|
|
int hardwareId = deviceDataManager.getSelectedHardwareId(); |
|
|
|
|
|
int orderType = order.getOrder_type(); |
|
|
|
|
|
|
|
|
|
|
|
if (token == null || token.isEmpty()) { |
|
|
|
|
|
LogManager.logError(TAG, "获取认证token失败"); |
|
|
|
|
|
if (listener != null) { |
|
|
|
|
|
listener.showToast("获取认证token失败,无法核销订单"); |
|
|
|
|
|
} |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (hardwareId <= 0) { |
|
|
|
|
|
LogManager.logError(TAG, "获取设备ID失败"); |
|
|
|
|
|
if (listener != null) { |
|
|
|
|
|
listener.showToast("获取设备ID失败,无法核销订单"); |
|
|
|
|
|
} |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取核销码 - 根据订单类型决定是否需要核销码 |
|
|
|
|
|
final String verifyCode; |
|
|
|
|
|
if (orderType != 3) { |
|
|
|
|
|
// 非年月卡订单需要核销码 |
|
|
|
|
|
String tempVerifyCode = getVerificationCode(order); |
|
|
|
|
|
if (tempVerifyCode == null || tempVerifyCode.isEmpty()) { |
|
|
|
|
|
LogManager.logError(TAG, "未找到有效的核销码"); |
|
|
|
|
|
if (listener != null) { |
|
|
|
|
|
listener.showToast("未找到有效的核销码,无法核销订单"); |
|
|
|
|
|
} |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
verifyCode = tempVerifyCode; |
|
|
|
|
|
} else { |
|
|
|
|
|
// 年月卡订单(orderType == 3)不需要核销码,保持verifyCode为空字符串 |
|
|
|
|
|
verifyCode = ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取卡号 - 根据订单类型处理info字段 |
|
|
|
|
|
String cardNo = ""; |
|
|
|
|
|
if (order.getOrder_type() == 3) { |
|
|
|
|
|
// 年月卡 - 从info对象中提取card_no |
|
|
|
|
|
cardNo = order.getInfo() != null ? order.getCardNoFromInfo() : ""; |
|
|
|
|
|
} else if (order.getOrder_type() == 1) { |
|
|
|
|
|
// 人次票 - info字段本身就是预订信息,但卡号可能在其他地方 |
|
|
|
|
|
// 这里保持空字符串,因为人次票可能没有卡号概念 |
|
|
|
|
|
cardNo = ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取用户人脸ID |
|
|
|
|
|
String userFaceId = order.getInfo() != null ? order.getUserFaceIdFromInfo() : ""; |
|
|
|
|
|
|
|
|
|
|
|
LogManager.logInfo(TAG, "调用核销接口: orderId=" + order.getOrder_no() + ", verifyCode=" + verifyCode + |
|
|
|
|
|
", hardwareId=" + hardwareId + ", orderType=" + orderType + ", cardNo=" + cardNo + |
|
|
|
|
|
", userFaceId=" + userFaceId); |
|
|
|
|
|
|
|
|
|
|
|
if (listener != null) { |
|
|
|
|
|
listener.showToast("正在核销订单,请稍候..."); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 调用NetworkUtils.verifyOrder接口进行实际核销,传递所有必要参数 |
|
|
|
|
|
com.ouxuan.oxface.network.utils.NetworkUtils.verifyOrder( |
|
|
|
|
|
token, |
|
|
|
|
|
order.getOrder_no(), |
|
|
|
|
|
verifyCode, // 根据订单类型决定是否传递核销码 |
|
|
|
|
|
OrderVerificationManager.TYPE_FACE_VERIFICATION, // 使用人脸验证类型作为type参数 |
|
|
|
|
|
orderType, // 添加orderType参数 |
|
|
|
|
|
hardwareId, // 添加hardwareId参数 |
|
|
|
|
|
cardNo, // 添加cardNo参数 |
|
|
|
|
|
userFaceId, // 添加userFaceId参数 |
|
|
|
|
|
"on", // 添加dontOpenDoor参数,默认为"on" |
|
|
|
|
|
new com.ouxuan.oxface.network.callback.NetworkCallback<com.ouxuan.oxface.network.api.PadApiService.VerifyOrderResponse>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onStart() { |
|
|
|
|
|
LogManager.logInfo(TAG, "核销请求开始"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onSuccess(com.ouxuan.oxface.network.api.PadApiService.VerifyOrderResponse data) { |
|
|
|
|
|
LogManager.logInfo(TAG, "核销请求成功: " + (data != null ? data.toString() : "null")); |
|
|
|
|
|
|
|
|
|
|
|
// 核销成功,跳转到结果页面并传递完整的核销结果数据 |
|
|
|
|
|
String status = "核销成功"; |
|
|
|
|
|
String message = "订单核销成功"; |
|
|
|
|
|
|
|
|
|
|
|
if (data != null) { |
|
|
|
|
|
// 检查核销结果是否成功 (根据接口返回的code是否为0来判断) |
|
|
|
|
|
if (data.getResult() != null) { |
|
|
|
|
|
status = "核销成功"; |
|
|
|
|
|
message = data.getMessage() != null && !data.getMessage().isEmpty() |
|
|
|
|
|
? data.getMessage() : "订单核销成功"; |
|
|
|
|
|
} else { |
|
|
|
|
|
status = "核销失败"; |
|
|
|
|
|
message = data.getMessage() != null && !data.getMessage().isEmpty() |
|
|
|
|
|
? data.getMessage() : "订单核销失败"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (listener != null) { |
|
|
|
|
|
listener.showToast(message); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 创建跳转到OrderVerificationResultActivity的Intent |
|
|
|
|
|
android.content.Intent intent = new android.content.Intent(context, OrderVerificationResultActivity.class); |
|
|
|
|
|
intent.putExtra("verification_type", OrderVerificationManager.TYPE_FACE_VERIFICATION); |
|
|
|
|
|
intent.putExtra("order_no", order.getOrder_no()); |
|
|
|
|
|
intent.putExtra("verification_code", verifyCode); |
|
|
|
|
|
intent.putExtra("order_type", order.getOrder_type()); |
|
|
|
|
|
intent.putExtra("card_no", order.getInfo() != null ? order.getCardNoFromInfo() : ""); |
|
|
|
|
|
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)); |
|
|
|
|
|
if (data != null) { |
|
|
|
|
|
intent.putExtra("verify_result", new Gson().toJson(data)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LogManager.logInfo(TAG, "准备跳转到验证结果页面,订单号: " + order.getOrder_no()); |
|
|
|
|
|
|
|
|
|
|
|
if (listener != null) { |
|
|
|
|
|
listener.navigateToResultPage(intent); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onError(int errorCode, String errorMessage) { |
|
|
|
|
|
LogManager.logError(TAG, "核销请求失败: errorCode=" + errorCode + ", errorMessage=" + errorMessage); |
|
|
|
|
|
|
|
|
|
|
|
String displayMessage = errorMessage != null && !errorMessage.isEmpty() |
|
|
|
|
|
? errorMessage : "订单核销失败,错误码: " + errorCode; |
|
|
|
|
|
|
|
|
|
|
|
if (listener != null) { |
|
|
|
|
|
listener.showToast(displayMessage); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 核销失败也跳转到结果页面显示失败信息 |
|
|
|
|
|
android.content.Intent intent = new android.content.Intent(context, OrderVerificationResultActivity.class); |
|
|
|
|
|
intent.putExtra("verification_type", OrderVerificationManager.TYPE_FACE_VERIFICATION); |
|
|
|
|
|
intent.putExtra("order_no", order.getOrder_no()); |
|
|
|
|
|
intent.putExtra("verification_code", verifyCode); |
|
|
|
|
|
intent.putExtra("order_type", order.getOrder_type()); |
|
|
|
|
|
intent.putExtra("card_no", order.getInfo() != null ? order.getCardNoFromInfo() : ""); |
|
|
|
|
|
intent.putExtra("project", order.getProject()); |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
if (listener != null) { |
|
|
|
|
|
listener.navigateToResultPage(intent); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onException(Throwable throwable) { |
|
|
|
|
|
LogManager.logError(TAG, "核销请求异常", throwable); |
|
|
|
|
|
|
|
|
|
|
|
String displayMessage = "网络请求异常: " + throwable.getMessage(); |
|
|
|
|
|
if (listener != null) { |
|
|
|
|
|
listener.showToast(displayMessage); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 异常情况也跳转到结果页面显示异常信息 |
|
|
|
|
|
android.content.Intent intent = new android.content.Intent(context, OrderVerificationResultActivity.class); |
|
|
|
|
|
intent.putExtra("verification_type", OrderVerificationManager.TYPE_FACE_VERIFICATION); |
|
|
|
|
|
intent.putExtra("order_no", order.getOrder_no()); |
|
|
|
|
|
intent.putExtra("verification_code", verifyCode); |
|
|
|
|
|
intent.putExtra("order_type", order.getOrder_type()); |
|
|
|
|
|
intent.putExtra("card_no", order.getInfo() != null ? order.getCardNoFromInfo() : ""); |
|
|
|
|
|
intent.putExtra("project", order.getProject()); |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
if (listener != null) { |
|
|
|
|
|
listener.navigateToResultPage(intent); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onComplete() { |
|
|
|
|
|
LogManager.logInfo(TAG, "核销请求完成"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取订单的核销码 |
|
|
|
|
|
* @param order 订单项 |
|
|
|
|
|
* @return 核销码字符串 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String getVerificationCode(OrderVerificationData.OrderItem order) { |
|
|
|
|
|
String verifyCode = order.getVerificationCode(); |
|
|
|
|
|
|
|
|
|
|
|
if (verifyCode == null || verifyCode.isEmpty()) { |
|
|
|
|
|
// 如果没有直接的验证码,尝试从v_code字段获取 |
|
|
|
|
|
if (order.getV_code() != null && !order.getV_code().isEmpty()) { |
|
|
|
|
|
verifyCode = order.getV_code().get(0); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return verifyCode; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 处理扫码验证结果 |
|
|
* 处理扫码验证结果 |
|
|