|
@ -250,37 +250,192 @@ public class OrderSelectionActivity extends AppCompatActivity { |
|
|
* 执行订单核销 |
|
|
* 执行订单核销 |
|
|
*/ |
|
|
*/ |
|
|
private void performOrderVerification(OrderVerificationData.OrderItem order) { |
|
|
private void performOrderVerification(OrderVerificationData.OrderItem order) { |
|
|
LogManager.logInfo(TAG, "执行订单核销: " + order.getOrder_no()); |
|
|
|
|
|
|
|
|
LogManager.logInfo(TAG, "开始执行订单核销: " + order.getOrder_no()); |
|
|
|
|
|
|
|
|
// 停止倒计时 |
|
|
// 停止倒计时 |
|
|
stopCountdown(); |
|
|
stopCountdown(); |
|
|
|
|
|
|
|
|
// 准备结果数据 |
|
|
|
|
|
|
|
|
// 获取认证token |
|
|
|
|
|
String token = loginDataManager.getAuthToken(); |
|
|
|
|
|
if (token == null || token.isEmpty()) { |
|
|
|
|
|
LogManager.logError(TAG, "获取认证token失败"); |
|
|
|
|
|
showToast("获取认证token失败,无法核销订单"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取订单ID和核销码 |
|
|
|
|
|
String orderId = order.getOrder_no(); |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (verifyCode == null || verifyCode.isEmpty()) { |
|
|
|
|
|
LogManager.logError(TAG, "未找到有效的核销码"); |
|
|
|
|
|
showToast("未找到有效的核销码,无法核销订单"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LogManager.logInfo(TAG, "调用核销接口: orderId=" + orderId + ", verifyCode=" + verifyCode); |
|
|
|
|
|
|
|
|
|
|
|
// 显示加载状态 |
|
|
|
|
|
showToast("正在核销订单,请稍候..."); |
|
|
|
|
|
|
|
|
|
|
|
// 调用NetworkUtils.verifyOrder接口进行实际核销 |
|
|
|
|
|
com.ouxuan.oxface.network.utils.NetworkUtils.verifyOrder( |
|
|
|
|
|
token, |
|
|
|
|
|
orderId, |
|
|
|
|
|
verifyCode, |
|
|
|
|
|
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")); |
|
|
|
|
|
|
|
|
|
|
|
runOnUiThread(() -> { |
|
|
|
|
|
// 核销成功,跳转到结果页面并传递完整的核销结果数据 |
|
|
|
|
|
String status = "核销成功"; |
|
|
|
|
|
String message = "订单核销成功"; |
|
|
|
|
|
|
|
|
|
|
|
if (data != null) { |
|
|
|
|
|
if (data.isResult()) { |
|
|
|
|
|
status = "核销成功"; |
|
|
|
|
|
message = data.getMessage() != null && !data.getMessage().isEmpty() |
|
|
|
|
|
? data.getMessage() : "订单核销成功"; |
|
|
|
|
|
} else { |
|
|
|
|
|
status = "核销失败"; |
|
|
|
|
|
message = data.getMessage() != null && !data.getMessage().isEmpty() |
|
|
|
|
|
? data.getMessage() : "订单核销失败"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
showToast(message); |
|
|
|
|
|
|
|
|
|
|
|
// 跳转到核销结果页面,传递完整的订单和核销结果数据 |
|
|
|
|
|
Intent intent = new Intent(OrderSelectionActivity.this, OrderVerificationResultActivity.class); |
|
|
|
|
|
intent.putExtra("verification_type", verificationType); |
|
|
|
|
|
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.getInfo().getCard_no() : ""); |
|
|
|
|
|
intent.putExtra("project", order.getProject()); |
|
|
|
|
|
intent.putExtra("status", status); |
|
|
|
|
|
intent.putExtra("message", message); |
|
|
|
|
|
|
|
|
|
|
|
// 传递完整的订单数据和核销结果数据 |
|
|
|
|
|
intent.putExtra("order_data", new Gson().toJson(order)); |
|
|
|
|
|
if (data != null) { |
|
|
|
|
|
intent.putExtra("verify_result", new Gson().toJson(data)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
startActivity(intent); |
|
|
|
|
|
|
|
|
|
|
|
// 准备返回结果给调用Activity |
|
|
Intent resultIntent = new Intent(); |
|
|
Intent resultIntent = new Intent(); |
|
|
resultIntent.putExtra("selected_order", new Gson().toJson(order)); |
|
|
resultIntent.putExtra("selected_order", new Gson().toJson(order)); |
|
|
resultIntent.putExtra("order_no", order.getOrder_no()); |
|
|
resultIntent.putExtra("order_no", order.getOrder_no()); |
|
|
resultIntent.putExtra("verification_code", order.getVerificationCode()); |
|
|
|
|
|
|
|
|
resultIntent.putExtra("verification_code", verifyCode); |
|
|
resultIntent.putExtra("order_type", order.getOrder_type()); |
|
|
resultIntent.putExtra("order_type", order.getOrder_type()); |
|
|
resultIntent.putExtra("card_no", order.getInfo() != null ? order.getInfo().getCard_no() : ""); |
|
|
resultIntent.putExtra("card_no", order.getInfo() != null ? order.getInfo().getCard_no() : ""); |
|
|
resultIntent.putExtra("project", order.getProject()); |
|
|
resultIntent.putExtra("project", order.getProject()); |
|
|
resultIntent.putExtra("verification_type", verificationType); |
|
|
resultIntent.putExtra("verification_type", verificationType); |
|
|
|
|
|
resultIntent.putExtra("verify_status", status); |
|
|
|
|
|
resultIntent.putExtra("verify_message", message); |
|
|
|
|
|
|
|
|
|
|
|
setResult(RESULT_OK, resultIntent); |
|
|
|
|
|
finish(); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onError(int errorCode, String errorMessage) { |
|
|
|
|
|
LogManager.logError(TAG, "核销请求失败: errorCode=" + errorCode + ", errorMessage=" + errorMessage); |
|
|
|
|
|
|
|
|
|
|
|
runOnUiThread(() -> { |
|
|
|
|
|
String displayMessage = errorMessage != null && !errorMessage.isEmpty() |
|
|
|
|
|
? errorMessage : "订单核销失败,错误码: " + errorCode; |
|
|
|
|
|
|
|
|
|
|
|
showToast(displayMessage); |
|
|
|
|
|
|
|
|
|
|
|
// 核销失败也跳转到结果页面显示失败信息 |
|
|
|
|
|
Intent intent = new Intent(OrderSelectionActivity.this, OrderVerificationResultActivity.class); |
|
|
|
|
|
intent.putExtra("verification_type", verificationType); |
|
|
|
|
|
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.getInfo().getCard_no() : ""); |
|
|
|
|
|
intent.putExtra("project", order.getProject()); |
|
|
|
|
|
intent.putExtra("status", "核销失败"); |
|
|
|
|
|
intent.putExtra("message", displayMessage); |
|
|
|
|
|
intent.putExtra("order_data", new Gson().toJson(order)); |
|
|
|
|
|
|
|
|
|
|
|
startActivity(intent); |
|
|
|
|
|
|
|
|
|
|
|
// 设置失败结果 |
|
|
|
|
|
Intent resultIntent = new Intent(); |
|
|
|
|
|
resultIntent.putExtra("selected_order", new Gson().toJson(order)); |
|
|
|
|
|
resultIntent.putExtra("order_no", order.getOrder_no()); |
|
|
|
|
|
resultIntent.putExtra("verification_code", verifyCode); |
|
|
|
|
|
resultIntent.putExtra("verification_type", verificationType); |
|
|
|
|
|
resultIntent.putExtra("verify_status", "核销失败"); |
|
|
|
|
|
resultIntent.putExtra("verify_message", displayMessage); |
|
|
|
|
|
|
|
|
setResult(RESULT_OK, resultIntent); |
|
|
setResult(RESULT_OK, resultIntent); |
|
|
|
|
|
finish(); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 显示成功提示并跳转到结果页面 |
|
|
|
|
|
showToast("订单核销成功"); |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onException(Throwable throwable) { |
|
|
|
|
|
LogManager.logError(TAG, "核销请求异常", throwable); |
|
|
|
|
|
|
|
|
// 跳转到核销结果页面 |
|
|
|
|
|
Intent intent = new Intent(this, OrderVerificationResultActivity.class); |
|
|
|
|
|
|
|
|
runOnUiThread(() -> { |
|
|
|
|
|
String displayMessage = "网络请求异常: " + throwable.getMessage(); |
|
|
|
|
|
showToast(displayMessage); |
|
|
|
|
|
|
|
|
|
|
|
// 异常情况也跳转到结果页面显示异常信息 |
|
|
|
|
|
Intent intent = new Intent(OrderSelectionActivity.this, OrderVerificationResultActivity.class); |
|
|
intent.putExtra("verification_type", verificationType); |
|
|
intent.putExtra("verification_type", verificationType); |
|
|
intent.putExtra("order_no", order.getOrder_no()); |
|
|
intent.putExtra("order_no", order.getOrder_no()); |
|
|
intent.putExtra("verification_code", order.getVerificationCode()); |
|
|
|
|
|
|
|
|
intent.putExtra("verification_code", verifyCode); |
|
|
intent.putExtra("order_type", order.getOrder_type()); |
|
|
intent.putExtra("order_type", order.getOrder_type()); |
|
|
intent.putExtra("card_no", order.getInfo() != null ? order.getInfo().getCard_no() : ""); |
|
|
intent.putExtra("card_no", order.getInfo() != null ? order.getInfo().getCard_no() : ""); |
|
|
intent.putExtra("status", "核销成功"); |
|
|
|
|
|
|
|
|
intent.putExtra("project", order.getProject()); |
|
|
|
|
|
intent.putExtra("status", "核销异常"); |
|
|
|
|
|
intent.putExtra("message", displayMessage); |
|
|
|
|
|
intent.putExtra("order_data", new Gson().toJson(order)); |
|
|
|
|
|
|
|
|
startActivity(intent); |
|
|
startActivity(intent); |
|
|
|
|
|
|
|
|
|
|
|
// 设置异常结果 |
|
|
|
|
|
Intent resultIntent = new Intent(); |
|
|
|
|
|
resultIntent.putExtra("selected_order", new Gson().toJson(order)); |
|
|
|
|
|
resultIntent.putExtra("order_no", order.getOrder_no()); |
|
|
|
|
|
resultIntent.putExtra("verification_code", verifyCode); |
|
|
|
|
|
resultIntent.putExtra("verification_type", verificationType); |
|
|
|
|
|
resultIntent.putExtra("verify_status", "核销异常"); |
|
|
|
|
|
resultIntent.putExtra("verify_message", displayMessage); |
|
|
|
|
|
|
|
|
|
|
|
setResult(RESULT_OK, resultIntent); |
|
|
finish(); |
|
|
finish(); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onComplete() { |
|
|
|
|
|
LogManager.logInfo(TAG, "核销请求完成"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|