MTing 5 days ago
parent
commit
a1529d0b06
  1. 35
      app/src/main/java/com/ouxuan/oxface/network/api/PadApiService.java
  2. 35
      app/src/main/java/com/ouxuan/oxface/network/utils/NetworkUtils.java
  3. 43
      app/src/main/java/com/ouxuan/oxface/orderOX/OrderSelectionActivity.java

35
app/src/main/java/com/ouxuan/oxface/network/api/PadApiService.java

@ -1129,12 +1129,18 @@ public interface PadApiService {
@SerializedName("order_id") @SerializedName("order_id")
private String orderId; // 订单ID private String orderId; // 订单ID
@SerializedName("verify_code")
@SerializedName("v_code")
private String verifyCode; // 核销码 private String verifyCode; // 核销码
@SerializedName("type") @SerializedName("type")
private int type; // 验证类型 1验证码验证 2人脸验证 3扫码验证 4扫码器验证 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) { public VerifyOrderRequest(String token, String orderId, String verifyCode, int type) {
this.token = token; this.token = token;
this.orderId = orderId; this.orderId = orderId;
@ -1142,6 +1148,25 @@ public interface PadApiService {
this.type = type; 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 // Getters and Setters
public String getToken() { return token; } public String getToken() { return token; }
public void setToken(String token) { this.token = token; } public void setToken(String token) { this.token = token; }
@ -1154,6 +1179,14 @@ public interface PadApiService {
public int getType() { return type; } public int getType() { return type; }
public void setType(int type) { this.type = 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; }
} }
/** /**

35
app/src/main/java/com/ouxuan/oxface/network/utils/NetworkUtils.java

@ -718,16 +718,18 @@ public class NetworkUtils {
* @param orderId 订单ID * @param orderId 订单ID
* @param verifyCode 核销码 * @param verifyCode 核销码
* @param type 验证类型 1验证码验证 2人脸验证 3扫码验证 4扫码器验证 * @param type 验证类型 1验证码验证 2人脸验证 3扫码验证 4扫码器验证
* @param orderType 订单类型
* @param hardwareId 硬件ID
* @param callback 回调接口 * @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<PadApiService.VerifyOrderResponse> callback) { NetworkCallback<PadApiService.VerifyOrderResponse> callback) {
if (padApiService == null) { if (padApiService == null) {
callback.onError(-1, "NetworkUtils未初始化,请先调用init()方法"); callback.onError(-1, "NetworkUtils未初始化,请先调用init()方法");
return; 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(); callback.onStart();
padApiService.verifyOrder(request).enqueue(new Callback<ApiResponse<PadApiService.VerifyOrderResponse>>() { padApiService.verifyOrder(request).enqueue(new Callback<ApiResponse<PadApiService.VerifyOrderResponse>>() {
@ -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<PadApiService.VerifyOrderResponse> 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<PadApiService.VerifyOrderResponse> callback) {
// 调用新的重载方法orderType默认为0
verifyOrder(token, orderId, verifyCode, type, 0, callback);
}
/**
* 核销订单向后兼容版本默认type=1 * 核销订单向后兼容版本默认type=1
* @param token 访问令牌 * @param token 访问令牌
* @param orderId 订单ID * @param orderId 订单ID

43
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.orderOX.model.OrderVerificationData;
import com.ouxuan.oxface.utils.LogManager; import com.ouxuan.oxface.utils.LogManager;
import com.ouxuan.oxface.data.LoginDataManager; import com.ouxuan.oxface.data.LoginDataManager;
import com.ouxuan.oxface.data.DeviceSelectDataManager; // 添加设备数据管理器导入
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop; import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
@ -61,6 +62,8 @@ public class OrderSelectionActivity extends AppCompatActivity {
// 登录数据管理器 // 登录数据管理器
private LoginDataManager loginDataManager; private LoginDataManager loginDataManager;
// 设备数据管理器
private DeviceSelectDataManager deviceDataManager;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -81,6 +84,8 @@ public class OrderSelectionActivity extends AppCompatActivity {
// 初始化登录数据管理器必须在initViews之前 // 初始化登录数据管理器必须在initViews之前
loginDataManager = LoginDataManager.getInstance(this); loginDataManager = LoginDataManager.getInstance(this);
// 初始化设备数据管理器
deviceDataManager = DeviceSelectDataManager.getInstance(this);
initViews(); initViews();
initData(); initData();
@ -263,6 +268,14 @@ public class OrderSelectionActivity extends AppCompatActivity {
return; return;
} }
// 获取设备ID
int hardwareId = deviceDataManager.getSelectedHardwareId();
if (hardwareId <= 0) {
LogManager.logError(TAG, "获取设备ID失败");
showToast("获取设备ID失败,无法核销订单");
return;
}
// 获取订单ID和核销码 // 获取订单ID和核销码
String orderId = order.getOrder_no(); String orderId = order.getOrder_no();
// 将verifyCode声明为final避免lambda表达式中的问题 // 将verifyCode声明为final避免lambda表达式中的问题
@ -274,17 +287,23 @@ public class OrderSelectionActivity extends AppCompatActivity {
return; 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("正在核销订单,请稍候..."); showToast("正在核销订单,请稍候...");
// 调用NetworkUtils.verifyOrder接口进行实际核销传递verificationType参数
// 调用NetworkUtils.verifyOrder接口进行实际核销传递设备ID和订单类型
com.ouxuan.oxface.network.utils.NetworkUtils.verifyOrder( com.ouxuan.oxface.network.utils.NetworkUtils.verifyOrder(
token, token,
orderId, orderId,
verifyCode, verifyCode,
verificationType, // 传递验证类型参数
verificationType, // 使用verificationType作为type参数
orderType, // 添加orderType参数
hardwareId, // 添加hardwareId参数
new com.ouxuan.oxface.network.callback.NetworkCallback<com.ouxuan.oxface.network.api.PadApiService.VerifyOrderResponse>() { new com.ouxuan.oxface.network.callback.NetworkCallback<com.ouxuan.oxface.network.api.PadApiService.VerifyOrderResponse>() {
@Override @Override
@ -325,6 +344,9 @@ public class OrderSelectionActivity extends AppCompatActivity {
intent.putExtra("project", order.getProject()); intent.putExtra("project", order.getProject());
intent.putExtra("status", status); intent.putExtra("status", status);
intent.putExtra("message", message); intent.putExtra("message", message);
// 添加设备ID和订单类型参数
intent.putExtra("hardware_id", hardwareId);
intent.putExtra("order_type_param", orderType);
// 传递完整的订单数据和核销结果数据 // 传递完整的订单数据和核销结果数据
intent.putExtra("order_data", new Gson().toJson(order)); intent.putExtra("order_data", new Gson().toJson(order));
@ -345,6 +367,9 @@ public class OrderSelectionActivity extends AppCompatActivity {
resultIntent.putExtra("verification_type", verificationType); resultIntent.putExtra("verification_type", verificationType);
resultIntent.putExtra("verify_status", status); resultIntent.putExtra("verify_status", status);
resultIntent.putExtra("verify_message", message); resultIntent.putExtra("verify_message", message);
// 添加设备ID和订单类型参数
resultIntent.putExtra("hardware_id", hardwareId);
resultIntent.putExtra("order_type_param", orderType);
setResult(RESULT_OK, resultIntent); setResult(RESULT_OK, resultIntent);
finish(); finish();
@ -372,6 +397,9 @@ public class OrderSelectionActivity extends AppCompatActivity {
intent.putExtra("status", "核销失败"); intent.putExtra("status", "核销失败");
intent.putExtra("message", displayMessage); intent.putExtra("message", displayMessage);
intent.putExtra("order_data", new Gson().toJson(order)); intent.putExtra("order_data", new Gson().toJson(order));
// 添加设备ID和订单类型参数
intent.putExtra("hardware_id", hardwareId);
intent.putExtra("order_type_param", orderType);
startActivity(intent); startActivity(intent);
@ -383,6 +411,9 @@ public class OrderSelectionActivity extends AppCompatActivity {
resultIntent.putExtra("verification_type", verificationType); resultIntent.putExtra("verification_type", verificationType);
resultIntent.putExtra("verify_status", "核销失败"); resultIntent.putExtra("verify_status", "核销失败");
resultIntent.putExtra("verify_message", displayMessage); resultIntent.putExtra("verify_message", displayMessage);
// 添加设备ID和订单类型参数
resultIntent.putExtra("hardware_id", hardwareId);
resultIntent.putExtra("order_type_param", orderType);
setResult(RESULT_OK, resultIntent); setResult(RESULT_OK, resultIntent);
finish(); finish();
@ -408,6 +439,9 @@ public class OrderSelectionActivity extends AppCompatActivity {
intent.putExtra("status", "核销异常"); intent.putExtra("status", "核销异常");
intent.putExtra("message", displayMessage); intent.putExtra("message", displayMessage);
intent.putExtra("order_data", new Gson().toJson(order)); intent.putExtra("order_data", new Gson().toJson(order));
// 添加设备ID和订单类型参数
intent.putExtra("hardware_id", hardwareId);
intent.putExtra("order_type_param", orderType);
startActivity(intent); startActivity(intent);
@ -419,6 +453,9 @@ public class OrderSelectionActivity extends AppCompatActivity {
resultIntent.putExtra("verification_type", verificationType); resultIntent.putExtra("verification_type", verificationType);
resultIntent.putExtra("verify_status", "核销异常"); resultIntent.putExtra("verify_status", "核销异常");
resultIntent.putExtra("verify_message", displayMessage); resultIntent.putExtra("verify_message", displayMessage);
// 添加设备ID和订单类型参数
resultIntent.putExtra("hardware_id", hardwareId);
resultIntent.putExtra("order_type_param", orderType);
setResult(RESULT_OK, resultIntent); setResult(RESULT_OK, resultIntent);
finish(); finish();

Loading…
Cancel
Save