|
|
@@ -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(); |