Commit 4143422a by pye52

现在扫码相同离线订单时不作处理并播放提示音

parent bf766952
...@@ -222,7 +222,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -222,7 +222,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
qrCodeText.setText(msg); qrCodeText.setText(msg);
break; break;
case QRCodeState.FAILED: case QRCodeState.FAILED:
String failedText = event.getMessage();
if (TextUtils.isEmpty(failedText)) {
TTSHelper.speak("无效二维码"); TTSHelper.speak("无效二维码");
} else {
TTSHelper.speak(failedText);
}
qrCodeViewModel.scan(); qrCodeViewModel.scan();
break; break;
case QRCodeState.ILLEGAL: case QRCodeState.ILLEGAL:
......
...@@ -52,6 +52,14 @@ public class PayData { ...@@ -52,6 +52,14 @@ public class PayData {
return payState == PAY_SUCCESS; return payState == PAY_SUCCESS;
} }
public boolean failed() {
return payState == PAY_FAILED;
}
public boolean offline() {
return payState == PAY_OFFLINE;
}
public void paySuccess() { public void paySuccess() {
payState = PAY_SUCCESS; payState = PAY_SUCCESS;
} }
......
...@@ -119,6 +119,13 @@ public class QRCodeViewModel extends ViewModel { ...@@ -119,6 +119,13 @@ public class QRCodeViewModel extends ViewModel {
} }
PayData newPay = new PayData(deviceSN, scanData, terminalType); PayData newPay = new PayData(deviceSN, scanData, terminalType);
// 扫描到的二维码,先检查是否已存在该订单(若标记“支付失败”,则认为该订单不存在)
PayData existsPay = payDataRepository.queryPayDataByPayCode(scanData);
if (existsPay != null && !existsPay.failed()) {
// 存在相同订单时不作处理
qrCodeState.postValue(new QRCodeState(QRCodeState.FAILED, "请不要重复扫码"));
return;
}
// 扫描到的二维码保存到数据库 // 扫描到的二维码保存到数据库
long lastInsertId = payDataRepository.insertPayData(newPay); long lastInsertId = payDataRepository.insertPayData(newPay);
if (lastInsertId == -1) { if (lastInsertId == -1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment