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
0e901650
authored
Mar 07, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化状态切换流程:
1、现在在线、离线支付失败(离线支付则为订单标记失败)后都会走同一个流程,进而最终换重置到扫码状态 2、收到在线支付结果时,若当前处理订单为空,则重置扫码状态
parent
bbd70a5f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
32 deletions
+42
-32
app/src/main/java/com/bgycc/smartcanteen/MainActivity.java
+41
-32
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOnlineViewModel.java
+1
-0
No files found.
app/src/main/java/com/bgycc/smartcanteen/MainActivity.java
View file @
0e901650
...
...
@@ -160,40 +160,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
sendText
.
setText
(
log
);
break
;
case
PayOnlineState
.
SUCCESS
:
message
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
pay_success
));
String
successText
=
event
.
getMessage
();
if
(
TextUtils
.
isEmpty
(
successText
))
{
message
.
setText
(
R
.
string
.
pay_success
);
TTSHelper
.
speak
(
getString
(
R
.
string
.
pay_success
));
}
else
{
message
.
setText
(
successText
);
TTSHelper
.
speak
(
successText
);
}
qrCodeViewModel
.
scan
();
String
successTime
=
payDateFormat
.
format
(
new
Date
());
String
successLog
=
"支付成功: "
+
successTime
+
" - "
+
event
.
getMessage
();
LogUtils
.
file
(
TAG
,
successLog
);
if
(
debugVs
!=
null
)
return
;
recText
.
setText
(
successLog
);
paidSuccess
(
event
.
getMessage
());
break
;
case
PayOnlineState
.
FAILED
:
message
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
pay_failed
));
String
failedText
=
event
.
getMessage
();
if
(
TextUtils
.
isEmpty
(
failedText
))
{
message
.
setText
(
R
.
string
.
pay_failed
);
TTSHelper
.
speak
(
getString
(
R
.
string
.
pay_failed
));
}
else
{
message
.
setText
(
failedText
);
TTSHelper
.
speak
(
failedText
);
}
qrCodeViewModel
.
scan
();
String
failedTime
=
payDateFormat
.
format
(
new
Date
());
String
failedLog
=
"支付失败: "
+
failedTime
+
" - "
+
event
.
getMessage
();
LogUtils
.
file
(
TAG
,
failedLog
);
if
(
debugVs
!=
null
)
return
;
recText
.
setText
(
failedLog
);
paidFailed
(
event
.
getMessage
());
break
;
}
});
...
...
@@ -212,6 +182,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
qrCodeViewModel
.
scan
();
break
;
case
PayOfflineState
.
MARK_FAILED
:
paidFailed
(
event
.
getMessage
());
break
;
}
});
...
...
@@ -286,6 +259,42 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
SCWebSocketClient
.
getInstance
().
tryConnect
();
}
private
void
paidSuccess
(
String
successMessage
)
{
message
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
pay_success
));
if
(
TextUtils
.
isEmpty
(
successMessage
))
{
message
.
setText
(
R
.
string
.
pay_success
);
TTSHelper
.
speak
(
getString
(
R
.
string
.
pay_success
));
}
else
{
message
.
setText
(
successMessage
);
TTSHelper
.
speak
(
successMessage
);
}
qrCodeViewModel
.
scan
();
String
successTime
=
payDateFormat
.
format
(
new
Date
());
String
successLog
=
"支付成功: "
+
successTime
+
" - "
+
successMessage
;
LogUtils
.
file
(
TAG
,
successLog
);
if
(
debugVs
!=
null
)
return
;
recText
.
setText
(
successLog
);
}
private
void
paidFailed
(
String
failedMessage
)
{
message
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
pay_failed
));
if
(
TextUtils
.
isEmpty
(
failedMessage
))
{
message
.
setText
(
R
.
string
.
pay_failed
);
TTSHelper
.
speak
(
getString
(
R
.
string
.
pay_failed
));
}
else
{
message
.
setText
(
failedMessage
);
TTSHelper
.
speak
(
failedMessage
);
}
qrCodeViewModel
.
scan
();
String
failedTime
=
payDateFormat
.
format
(
new
Date
());
String
failedLog
=
"支付失败: "
+
failedTime
+
" - "
+
failedMessage
;
LogUtils
.
file
(
TAG
,
failedLog
);
if
(
debugVs
!=
null
)
return
;
recText
.
setText
(
failedLog
);
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
...
...
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOnlineViewModel.java
View file @
0e901650
...
...
@@ -103,6 +103,7 @@ public class PayOnlineViewModel extends ViewModel {
// 1、action为"PAY_RESULT"
if
(
payRequest
==
null
||
payRequest
.
getData
().
isEmpty
())
{
LogUtils
.
w
(
TAG
,
"后台返回在线支付结果,但没有待处理任务"
);
payOnlineState
.
postValue
(
new
PayOnlineState
(
PayOnlineState
.
IDLE
));
return
;
}
LogUtils
.
d
(
TAG
,
"在线支付结果响应: "
+
original
);
...
...
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