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
38d5b2be
authored
May 29, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、适配后台的离线订单响应(上传成功、写入成功)
2、修复一个离线订单支付超时后又收到后台响应时的显示问题(此前会一直显示支付成功) 3、更新第三方库版本
parent
e9f2136f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
18 deletions
+17
-18
app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.java
+4
-0
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOfflineViewModel.java
+12
-17
daemon/build.gradle
+1
-1
No files found.
app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.java
View file @
38d5b2be
...
...
@@ -161,6 +161,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
payOnlineViewModel
.
getPayOnlineStateEvent
().
observe
(
this
,
event
->
{
switch
(
event
.
getState
())
{
case
PayOnlineState
.
IDLE
:
message
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
qrcode_normal
));
message
.
setText
(
R
.
string
.
pay_idle
);
break
;
case
PayOnlineState
.
SEND
:
message
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
pay_idle
));
message
.
setText
(
R
.
string
.
pay_wait
);
...
...
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOfflineViewModel.java
View file @
38d5b2be
package
com
.
bgycc
.
smartcanteen
.
viewModel
;
import
android.text.TextUtils
;
import
androidx.lifecycle.LiveData
;
import
androidx.lifecycle.MutableLiveData
;
import
androidx.lifecycle.ViewModel
;
...
...
@@ -97,8 +95,7 @@ public class PayOfflineViewModel extends ViewModel {
}
private
SCWebSocketListener
listener
=
new
SCWebSocketListenerAdapter
()
{
private
static
final
String
RESPONSE_MESSAGE
=
"message"
;
private
static
final
String
RESPONSE_OFFLINE_RESULT
=
"操作完成"
;
private
static
final
String
RESPONSE_PAY_OFFLINE_UPLOAD
=
"PAY_OFFLINE_UPLOAD"
;
private
static
final
String
RESPONSE_PAY_OFFLINE_RESULT
=
"PAY_OFFLINE_RESULT"
;
private
static
final
String
RESPONSE_SUCCESS
=
"0"
;
// 每心跳多少次后进行一次离线订单检测
...
...
@@ -123,30 +120,28 @@ public class PayOfflineViewModel extends ViewModel {
@Override
public
void
onMessage
(
String
action
,
JsonObject
obj
,
String
original
)
{
if
(
action
.
equals
(
RESPONSE_PAY_OFFLINE_RESULT
))
{
String
code
=
null
;
// 这里为了兼容新的消息体需要单独对code作判断
if
(
obj
.
has
(
"code"
))
{
code
=
obj
.
get
(
"code"
).
getAsString
();
}
switch
(
action
)
{
case
RESPONSE_PAY_OFFLINE_UPLOAD:
if
(
code
!=
null
&&
code
.
equals
(
RESPONSE_SUCCESS
))
{
// 离线订单只上传到服务器,未写入到服务器数据库
// 此时只需要更改其uploadTime(保证一定时间内不会频繁发送到服务器)
UpdateUploadTimeRunnable
runnable
=
new
UpdateUploadTimeRunnable
();
SCTaskExecutor
.
getInstance
().
executeOnDiskIO
(
runnable
);
}
break
;
case
RESPONSE_PAY_OFFLINE_RESULT:
if
(
code
!=
null
&&
code
.
equals
(
RESPONSE_SUCCESS
))
{
// 离线订单已写入到服务器数据库,可以标记为支付成功
LogUtils
.
d
(
TAG
,
"离线支付结果响应: "
+
original
);
ResponseRunnable
runnable
=
new
ResponseRunnable
(
original
);
SCTaskExecutor
.
getInstance
().
executeOnDiskIO
(
runnable
);
}
return
;
}
String
message
=
""
;
if
(
obj
.
has
(
RESPONSE_MESSAGE
))
{
message
=
obj
.
get
(
RESPONSE_MESSAGE
).
getAsString
();
break
;
}
if
(!
TextUtils
.
isEmpty
(
action
)
||
!
message
.
equals
(
RESPONSE_OFFLINE_RESULT
))
return
;
// 离线订单只上传到服务器,未写入到服务器数据库
// 此时只需要更改其uploadTime(保证一定时间内不会频繁发送到服务器)
UpdateUploadTimeRunnable
runnable
=
new
UpdateUploadTimeRunnable
();
SCTaskExecutor
.
getInstance
().
executeOnDiskIO
(
runnable
);
}
};
...
...
daemon/build.gradle
View file @
38d5b2be
...
...
@@ -100,5 +100,5 @@ dependencies {
testImplementation
'junit:junit:4.13'
androidTestImplementation
'androidx.test.ext:junit:1.1.1'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
implementation
'com.blankj:utilcodex:1.2
8.4
'
implementation
'com.blankj:utilcodex:1.2
9.0
'
}
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