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
4143422a
authored
Mar 20, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
现在扫码相同离线订单时不作处理并播放提示音
parent
bf766952
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletions
+21
-1
app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.java
+6
-1
app/src/main/java/com/bgycc/smartcanteen/entity/PayData.java
+8
-0
app/src/main/java/com/bgycc/smartcanteen/viewModel/QRCodeViewModel.java
+7
-0
No files found.
app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.java
View file @
4143422a
...
@@ -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
:
TTSHelper
.
speak
(
"无效二维码"
);
String
failedText
=
event
.
getMessage
();
if
(
TextUtils
.
isEmpty
(
failedText
))
{
TTSHelper
.
speak
(
"无效二维码"
);
}
else
{
TTSHelper
.
speak
(
failedText
);
}
qrCodeViewModel
.
scan
();
qrCodeViewModel
.
scan
();
break
;
break
;
case
QRCodeState
.
ILLEGAL
:
case
QRCodeState
.
ILLEGAL
:
...
...
app/src/main/java/com/bgycc/smartcanteen/entity/PayData.java
View file @
4143422a
...
@@ -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
;
}
}
...
...
app/src/main/java/com/bgycc/smartcanteen/viewModel/QRCodeViewModel.java
View file @
4143422a
...
@@ -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
)
{
...
...
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