Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9a9fee77
authored
Mar 20, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复部分细节问题
1、离线支付增加延时(留出播报beep的声音) 2、现在同一订单号不允许重复生成了
parent
3ee8dacf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOfflineViewModel.java
+5
-3
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOnlineViewModel.java
+2
-2
app/src/main/java/com/bgycc/smartcanteen/viewModel/QRCodeViewModel.java
+2
-3
No files found.
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOfflineViewModel.java
View file @
9a9fee77
...
@@ -37,7 +37,9 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
...
@@ -37,7 +37,9 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
* "标记成功"状态: 在WebSocket未链接时,"在线支付"订单直接标记为"离线支付",并更新到数据库成功的状态
* "标记成功"状态: 在WebSocket未链接时,"在线支付"订单直接标记为"离线支付",并更新到数据库成功的状态
*/
*/
public
class
PayOfflineViewModel
extends
ViewModel
{
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
static
final
long
DEFAULT_DELAY
=
3
*
1000
;
private
Gson
gson
;
private
Gson
gson
;
private
String
deviceSN
;
private
String
deviceSN
;
...
@@ -69,7 +71,7 @@ public class PayOfflineViewModel extends ViewModel {
...
@@ -69,7 +71,7 @@ public class PayOfflineViewModel extends ViewModel {
public
void
exec
(
PayData
payData
)
{
public
void
exec
(
PayData
payData
)
{
MarkRunnable
runnable
=
new
MarkRunnable
(
payData
);
MarkRunnable
runnable
=
new
MarkRunnable
(
payData
);
SCTaskExecutor
.
getInstance
().
executeOnDiskIO
(
runnable
);
SCTaskExecutor
.
getInstance
().
schedule
(
runnable
,
REQUEST_DELAY
,
TimeUnit
.
MILLISECONDS
);
}
}
private
void
cancelTimeout
()
{
private
void
cancelTimeout
()
{
...
@@ -87,7 +89,7 @@ public class PayOfflineViewModel extends ViewModel {
...
@@ -87,7 +89,7 @@ public class PayOfflineViewModel extends ViewModel {
// 只要Socket链接成功,则搜索数据库需要离线支付的订单,并发送给后台
// 只要Socket链接成功,则搜索数据库需要离线支付的订单,并发送给后台
cancelTimeout
();
cancelTimeout
();
TimeoutRunnable
timeoutRunnable
=
new
TimeoutRunnable
();
TimeoutRunnable
timeoutRunnable
=
new
TimeoutRunnable
();
timeoutFuture
=
SCTaskExecutor
.
getInstance
().
schedule
(
timeoutRunnable
,
TIMEOUT
,
TimeUnit
.
SECONDS
);
timeoutFuture
=
SCTaskExecutor
.
getInstance
().
schedule
(
timeoutRunnable
,
TIMEOUT
,
TimeUnit
.
MILLI
SECONDS
);
RequestRunnable
runnable
=
new
RequestRunnable
();
RequestRunnable
runnable
=
new
RequestRunnable
();
SCTaskExecutor
.
getInstance
().
executeOnDiskIO
(
runnable
);
SCTaskExecutor
.
getInstance
().
executeOnDiskIO
(
runnable
);
}
}
...
...
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOnlineViewModel.java
View file @
9a9fee77
...
@@ -38,8 +38,8 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
...
@@ -38,8 +38,8 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
*/
*/
public
class
PayOnlineViewModel
extends
ViewModel
{
public
class
PayOnlineViewModel
extends
ViewModel
{
private
static
final
long
TIMEOUT
=
5
*
1000
;
private
static
final
long
TIMEOUT
=
5
*
1000
;
// 在线支付延迟1
0
0ms执行,留出时间给扫码反馈
// 在线支付延迟1
5
0ms执行,留出时间给扫码反馈
private
static
final
long
REQUEST_DELAY
=
1
0
0
;
private
static
final
long
REQUEST_DELAY
=
1
5
0
;
private
static
final
long
DEFAULT_DELAY
=
3
*
1000
;
private
static
final
long
DEFAULT_DELAY
=
3
*
1000
;
private
Gson
gson
;
private
Gson
gson
;
private
String
deviceSN
;
private
String
deviceSN
;
...
...
app/src/main/java/com/bgycc/smartcanteen/viewModel/QRCodeViewModel.java
View file @
9a9fee77
...
@@ -119,10 +119,9 @@ public class QRCodeViewModel extends ViewModel {
...
@@ -119,10 +119,9 @@ public class QRCodeViewModel extends ViewModel {
}
}
PayData
newPay
=
new
PayData
(
deviceSN
,
scanData
,
terminalType
);
PayData
newPay
=
new
PayData
(
deviceSN
,
scanData
,
terminalType
);
// 扫描到的二维码,先检查
是否已存在该订单(若标记“支付失败”,则认为该订单不存在)
// 扫描到的二维码,先检查
该订单是否已存在
PayData
existsPay
=
payDataRepository
.
queryPayDataByPayCode
(
scanData
);
PayData
existsPay
=
payDataRepository
.
queryPayDataByPayCode
(
scanData
);
if
(
existsPay
!=
null
&&
!
existsPay
.
failed
())
{
if
(
existsPay
!=
null
)
{
// 存在相同订单时不作处理
qrCodeState
.
postValue
(
new
QRCodeState
(
QRCodeState
.
FAILED
,
"请不要重复扫码"
));
qrCodeState
.
postValue
(
new
QRCodeState
(
QRCodeState
.
FAILED
,
"请不要重复扫码"
));
return
;
return
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment