Commit 9a9fee77 by pye52

修复部分细节问题

1、离线支付增加延时(留出播报beep的声音)
2、现在同一订单号不允许重复生成了
parent 3ee8dacf
......@@ -37,7 +37,9 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
* "标记成功"状态: 在WebSocket未链接时,"在线支付"订单直接标记为"离线支付",并更新到数据库成功的状态
*/
public class PayOfflineViewModel extends ViewModel {
private static final long TIMEOUT = 5;
private static final long TIMEOUT = 5 * 1000;
// 在线支付延迟150ms执行,留出时间给扫码反馈
private static final long REQUEST_DELAY = 150;
private static final long DEFAULT_DELAY = 3 * 1000;
private Gson gson;
private String deviceSN;
......@@ -69,7 +71,7 @@ public class PayOfflineViewModel extends ViewModel {
public void exec(PayData payData) {
MarkRunnable runnable = new MarkRunnable(payData);
SCTaskExecutor.getInstance().executeOnDiskIO(runnable);
SCTaskExecutor.getInstance().schedule(runnable, REQUEST_DELAY, TimeUnit.MILLISECONDS);
}
private void cancelTimeout() {
......@@ -87,7 +89,7 @@ public class PayOfflineViewModel extends ViewModel {
// 只要Socket链接成功,则搜索数据库需要离线支付的订单,并发送给后台
cancelTimeout();
TimeoutRunnable timeoutRunnable = new TimeoutRunnable();
timeoutFuture = SCTaskExecutor.getInstance().schedule(timeoutRunnable, TIMEOUT, TimeUnit.SECONDS);
timeoutFuture = SCTaskExecutor.getInstance().schedule(timeoutRunnable, TIMEOUT, TimeUnit.MILLISECONDS);
RequestRunnable runnable = new RequestRunnable();
SCTaskExecutor.getInstance().executeOnDiskIO(runnable);
}
......
......@@ -38,8 +38,8 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
*/
public class PayOnlineViewModel extends ViewModel {
private static final long TIMEOUT = 5 * 1000;
// 在线支付延迟100ms执行,留出时间给扫码反馈
private static final long REQUEST_DELAY = 100;
// 在线支付延迟150ms执行,留出时间给扫码反馈
private static final long REQUEST_DELAY = 150;
private static final long DEFAULT_DELAY = 3 * 1000;
private Gson gson;
private String deviceSN;
......
......@@ -119,10 +119,9 @@ public class QRCodeViewModel extends ViewModel {
}
PayData newPay = new PayData(deviceSN, scanData, terminalType);
// 扫描到的二维码,先检查是否已存在该订单(若标记“支付失败”,则认为该订单不存在)
// 扫描到的二维码,先检查该订单是否已存在
PayData existsPay = payDataRepository.queryPayDataByPayCode(scanData);
if (existsPay != null && !existsPay.failed()) {
// 存在相同订单时不作处理
if (existsPay != null) {
qrCodeState.postValue(new QRCodeState(QRCodeState.FAILED, "请不要重复扫码"));
return;
}
......
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