Browse Source

注销 - step 3 - 调整支付二维码逻辑(只用显示不用查询支付状态)、对接ETC设备连接功能

GZBranch
wufasong 5 days ago
parent
commit
f7ef549c1e

+ 6
- 28
app/src/main/java/com/huntersun/vkyes/etcopencard/project/ui/activity/after/LogoutEtcPayActivity.java View File

@@ -114,33 +114,12 @@ public class LogoutEtcPayActivity extends AppActivity {
}

/**
* 支付状态检查
* 确认支付完成(业务员手动确认)
*/
private void pay() {
binding.paid.setEnabled(false);
// 使用原有的储值卡充值-查询支付结果接口
FatherBean<SendTheVerificationCodeBean> fatherBean = new FatherBean<>();
fatherBean.bizContent = new SendTheVerificationCodeBean();
fatherBean.bizContent.setOrderNum(orderNo); // 使用订单号
fatherBean.bizContent.setCardId(""); // 储值卡编号(设备注销可能不需要)
fatherBean.bizContent.setPayConfigId(Constants.PAY_CONFIG_ID); // 支付配置编号
// 储值卡充值-查询支付结果
MyRetrofit.newInstanceGZ(this, IFCode.IFCODE812, fatherBean.bizContent, new MyRetrofit.ReturnResult() {
@Override
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) {
hideDialog();
binding.paid.setEnabled(true);
handlePaymentStatus(bizContent.getTradeState());
}

@Override
public void onError(Response<Result> resp) {
MyRetrofit.ReturnResult.super.onError(resp);
binding.paid.setEnabled(true);
}
});
// 业务员确认支付完成,直接返回成功
setResult(RESULT_OK);
finish();
}
/**
@@ -151,9 +130,8 @@ public class LogoutEtcPayActivity extends AppActivity {
switch (tradeState) {
case "SUCCESS": //支付成功
toast("支付成功!");
Bundle bundle = new Bundle();
bundle.putString("from", "1");
jumpToPage(CommonDealSuccessActivity.class, bundle);
// 支付成功后,通知Step3连接设备执行注销
setResult(RESULT_OK);
finish();
break;
case "PAYING": //支付中

+ 6
- 0
app/src/main/java/com/huntersun/vkyes/etcopencard/project/ui/activity/after/LogoutEtcStep2Activity.java View File

@@ -273,6 +273,9 @@ public class LogoutEtcStep2Activity extends AppActivity {
// 传递违约金信息
intent.putExtra("cancelAmount", getIntent().getLongExtra("cancelAmount", 0));
intent.putExtra("needPayment", getIntent().getBooleanExtra("needPayment", false));
// 传递是否有设备信息
intent.putExtra("hasDevice", hasOBU == 1);

LogUtils.i(this.getClass().getSimpleName(), "传递参数: " + JSONObject.toJSONString(intent.getExtras()));
@@ -310,6 +313,9 @@ public class LogoutEtcStep2Activity extends AppActivity {
// 传递违约金信息
intent.putExtra("cancelAmount", getIntent().getLongExtra("cancelAmount", 0));
intent.putExtra("needPayment", getIntent().getBooleanExtra("needPayment", false));
// 传递是否有设备信息
intent.putExtra("hasDevice", hasOBU == 1);

LogUtils.i(this.getClass().getSimpleName(), "传递参数: " + JSONObject.toJSONString(intent.getExtras()));

+ 128
- 23
app/src/main/java/com/huntersun/vkyes/etcopencard/project/ui/activity/after/LogoutEtcStep3Activity.java View File

@@ -26,6 +26,8 @@ import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean;
import com.huntersun.vkyes.etcopencard.project.api.bean.SendTheVerificationCodeBean;
import com.huntersun.vkyes.etcopencard.project.api.bean.DeviceCancelQrCodeResponse;
import com.huntersun.vkyes.etcopencard.project.bluetooth.BluetoothWriteCardWriteTab;
import com.huntersun.vkyes.etcopencard.project.bluetooth.MethodManager;
import com.huntersun.vkyes.etcopencard.project.bluetooth.ServiceStatus;
import com.huntersun.vkyes.etcopencard.project.dialog.ConfirmDialog;
import com.huntersun.vkyes.etcopencard.project.tool.MyShared;
import com.huntersun.vkyes.etcopencard.project.utils.Constants;
@@ -93,6 +95,9 @@ public class LogoutEtcStep3Activity extends AppActivity {
private long cancelAmount = 0; // 违约金金额(分)
private String orderNo = ""; // 订单号
private boolean needPayment = false; // 是否需要支付违约金
// 设备相关
private boolean hasDevice = false; // 是否有设备需要注销

@Override
protected View getLayoutView() {
@@ -135,6 +140,9 @@ public class LogoutEtcStep3Activity extends AppActivity {
cancelAmount = getIntent().getLongExtra("cancelAmount", 0);
needPayment = getIntent().getBooleanExtra("needPayment", false);
// 接收设备信息
hasDevice = getIntent().getBooleanExtra("hasDevice", false);
curBizContent = JSONObject.parseObject(getIntent().getStringExtra("content"), ResultBean.BizContent.class);
} catch (JsonParseException e) {
// toast("json数据加载错误");
@@ -392,27 +400,73 @@ public class LogoutEtcStep3Activity extends AppActivity {
}

/**
* 写卡->确认注销
* 连接ETC设备并执行注销指令
*/
// private void toWriteCommand(ResultBean.BizContent bizContent) {
// BluetoothWriteCardWriteTab.writeCommandToCardWithCode51(
// this, true, bizContent.getCommand(), curBizContent.getCardId(),
// 9, bizContent.getCosRecordId(), new BluetoothWriteCardWriteTab.Callback() {
// public void success(int Plk) {
// confirmLogoutEtc(20);
// }

// @Override
// public void fail(String str) {
// new ConfirmDialog.Builder(LogoutEtcStep3Activity.this).setMsg(str, "", "确定", "", R.mipmap.icon_lotgout_etc_hint, 0, true)
// .onClick(new ConfirmDialog.Result() {
// @Override
// public void confirm() {
// }
// }).show();
// }
// });
// }
private void connectDeviceAndLogout() {
// 连接蓝牙设备
bluetoothLink(new Currency() {
@Override
public void success() {
// 蓝牙连接成功,执行注销指令
executeLogoutCommand();
}

@Override
public void success9901(int isPlk) {
// 9901设备连接成功,执行注销指令
executeLogoutCommand();
}

@Override
public void close() {
// 连接失败
ToastUtils.show("设备连接失败,请重试");
}
});
}

/**
* 执行注销指令
*/
private void executeLogoutCommand() {
// 这里需要调用注销指令接口获取指令
// 暂时使用模拟数据
if (AppConfig.isMockDataEnabled()) {
// 模拟执行成功
confirmLogoutEtc(20);
} else {
// 实际应该调用注销指令接口
// 获取指令后执行写卡操作
String command = ""; // 从接口获取
String result = writeCard(command);
// 回传指令结果
// cancelBack(cardId, command, cosRecordId, result);
}
}

/**
* 写卡操作
*/
private String writeCard(String commands) {
String[] commands_arry = commands.split(",");
String[] results = new String[commands_arry.length];
for (int i = 0; i < commands_arry.length; i++) {
// 透传写卡指令
ServiceStatus resp_string = MethodManager.sendApduICC(commands_arry[i]);
results[i] = resp_string.getServiceInfo();
}
// 返回执行结果
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < results.length; i++) {
buffer.append(results[i]);
if (i != results.length - 1) {
buffer.append(",");
}
}
return buffer.toString();
}

@Override
protected void initData() {
@@ -430,8 +484,8 @@ public class LogoutEtcStep3Activity extends AppActivity {
// 需要支付违约金,获取支付二维码
getPaymentQrCode();
} else {
// 不需要支付违约金,直接完成注销
confirmLogoutEtc(0);
// 不需要支付违约金,检查是否需要连接设备
checkDeviceConnection();
}
}
@@ -512,7 +566,7 @@ public class LogoutEtcStep3Activity extends AppActivity {
intent.putExtra("amount", amount);
intent.putExtra("qrBase64", qrBase64);
intent.putExtra("orderNo", orderNo);
startActivity(intent);
startActivityForResult(intent, 1001);
Log.i(this.getClass().getSimpleName(), "跳转到支付界面,金额: " + amountText);
@@ -523,6 +577,57 @@ public class LogoutEtcStep3Activity extends AppActivity {
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1001) {
if (resultCode == RESULT_OK) {
// 支付成功,检查是否需要连接设备
checkDeviceConnection();
} else {
// 支付失败或取消
ToastUtils.show("支付失败或已取消");
}
}
}
/**
* 检查是否需要连接设备
*/
private void checkDeviceConnection() {
if (hasDevice) {
// 有设备需要注销,弹窗确认是否连接设备
showDeviceConnectionConfirmDialog();
} else {
// 没有设备需要注销,直接完成注销
confirmLogoutEtc(0);
}
}
/**
* 显示设备连接确认弹窗
*/
private void showDeviceConnectionConfirmDialog() {
new ConfirmDialog.Builder(this)
.setMsg("检测到您选择了有设备注销,是否开始连接ETC设备进行注销操作?",
"设备连接确认", "开始连接", "取消注销", 0, 0, false)
.onClick(new ConfirmDialog.Result() {
@Override
public void confirm() {
// 用户确认连接设备
connectDeviceAndLogout();
}
@Override
public void cancel() {
// 用户取消注销
ToastUtils.show("注销流程已取消");
finish();
}
})
.show();
}

@Override
protected void onDestroy() {
super.onDestroy();

+ 1
- 1
app/src/main/res/layout-v2/activity_logout_etc_pay.xml View File

@@ -85,7 +85,7 @@
android:layout_marginTop="@dimen/dp_65"
android:layout_marginBottom="@dimen/dp_30"
android:background="@drawable/button_circle_selector3"
android:text="确认支付"
android:text="确认支付完成"
android:textColor="#FFFFFF" />
</LinearLayout>
</FrameLayout>

Loading…
Cancel
Save