Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MiYaFastCashier
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangjiantao
MiYaFastCashier
Commits
a5a2e488
Commit
a5a2e488
authored
Jun 23, 2022
by
赵鹏翔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fastjson去除,改用gson
parent
7b072ec1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
39 deletions
+49
-39
build.gradle
app/build.gradle
+0
-1
proguard-rules.pro
app/proguard-rules.pro
+0
-3
AliPayCodeActivity.kt
...c/main/java/com/miya/fastcashier/ui/AliPayCodeActivity.kt
+2
-2
PayCodeActivity.kt
app/src/main/java/com/miya/fastcashier/ui/PayCodeActivity.kt
+23
-12
WxPayCodeActivity.kt
...rc/main/java/com/miya/fastcashier/ui/WxPayCodeActivity.kt
+14
-11
PayViewModel.kt
.../main/java/com/miya/fastcashier/viewmodel/PayViewModel.kt
+10
-10
No files found.
app/build.gradle
View file @
a5a2e488
...
...
@@ -77,7 +77,6 @@ dependencies {
testImplementation
'junit:junit:4.+'
implementation
'com.alibaba:fastjson:1.2.8'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
implementation
'com.github.ybq:Android-SpinKit:1.4.0'
...
...
app/proguard-rules.pro
View file @
a5a2e488
...
...
@@ -124,9 +124,6 @@
-
dontwarn
java
.
nio
.
file
.
*
-
dontwarn
org
.
codehaus
.
mojo
.
animal_sniffer
.
IgnoreJRERequirement
-
dontwarn
okio
.
**
# fastjson
-
dontwarn
com
.
alibaba
.
fastjson
.
**
-
keep
class
com
.
alibaba
.
fastjson
.
**
{
*
;
}
#Gson
-
keep
class
com
.
google
.
gson
.
**
{
*
;}
-
keep
class
com
.
google
.
**
{
*
;}
...
...
app/src/main/java/com/miya/fastcashier/ui/AliPayCodeActivity.kt
View file @
a5a2e488
...
...
@@ -4,7 +4,7 @@ import android.content.Intent
import
android.os.Bundle
import
android.widget.Toast
import
androidx.lifecycle.ViewModelProvider
import
com.
alibaba.fastjson.JSON
import
com.
blankj.utilcode.util.GsonUtils
import
com.blankj.utilcode.util.LogUtils
import
com.fastcashier.lib_common.base.BaseActivity
import
com.fastcashier.lib_common.config.IntentExtra
...
...
@@ -53,7 +53,7 @@ class AliPayCodeActivity : BaseActivity() {
val
extra
=
intent
.
getSerializableExtra
(
IntentExtra
.
KEY_EXTRA_PAYSERVICERESPONSE
)
extra
?.
let
{
val
payServiceResponse
=
it
as
PayServiceResponse
LogUtils
.
e
(
JSON
.
toJSONString
(
payServiceResponse
))
LogUtils
.
e
(
GsonUtils
.
toJson
(
payServiceResponse
))
tvPrice
.
text
=
"¥"
.
plus
(
StringPriceFormatUtils
.
transStringPriceToDecimalString
(
payServiceResponse
.
tradPrice
))
runBlocking
(
Dispatchers
.
IO
)
{
val
qrcode
=
BitmapUtils
.
createBarcodeBitmap
(
payServiceResponse
.
payQrCode
,
9
,
453
,
453
)
...
...
app/src/main/java/com/miya/fastcashier/ui/PayCodeActivity.kt
View file @
a5a2e488
...
...
@@ -2,10 +2,9 @@ package com.miya.fastcashier.ui
import
android.os.Bundle
import
android.widget.Toast
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.content.res.AppCompatResources
import
androidx.lifecycle.ViewModelProvider
import
com.
alibaba.fastjson.JSON
import
com.
blankj.utilcode.util.GsonUtils
import
com.blankj.utilcode.util.LogUtils
import
com.fastcashier.lib_common.base.BaseActivity
import
com.fastcashier.lib_common.config.IntentExtra
...
...
@@ -47,24 +46,36 @@ class PayCodeActivity : BaseActivity() {
val
extra
=
intent
.
getSerializableExtra
(
IntentExtra
.
KEY_EXTRA_PAYSERVICERESPONSE
)
extra
?.
let
{
val
payServiceResponse
=
it
as
PayServiceResponse
LogUtils
.
e
(
JSON
.
toJSONString
(
payServiceResponse
))
tvPrice
.
text
=
"¥"
.
plus
(
StringPriceFormatUtils
.
transStringPriceToDecimalString
(
payServiceResponse
.
tradPrice
))
if
(
payServiceResponse
.
chanelTag
==
"1"
){
LogUtils
.
e
(
GsonUtils
.
toJson
(
payServiceResponse
))
tvPrice
.
text
=
"¥"
.
plus
(
StringPriceFormatUtils
.
transStringPriceToDecimalString
(
payServiceResponse
.
tradPrice
))
if
(
payServiceResponse
.
chanelTag
==
"1"
)
{
//初始化微信皮肤
setTheme
(
R
.
style
.
Theme_MiYaFastCashier_Green
)
tvPayGuide
.
text
=
"微信扫描二维码 向我付款"
;
tvPayGuide
.
setCompoundDrawables
(
AppCompatResources
.
getDrawable
(
this
,
ic_wxpay
)
,
null
,
null
,
null
);
tvPayGuide
.
setCompoundDrawables
(
AppCompatResources
.
getDrawable
(
this
,
ic_wxpay
),
null
,
null
,
null
);
cPayCodeBg
.
setBackgroundResource
(
R
.
color
.
green
)
}
else
{
}
else
{
//初始化支付宝皮肤
setTheme
(
R
.
style
.
Theme_MiYaFastCashier_Blue
)
tvPayGuide
.
setCompoundDrawables
(
AppCompatResources
.
getDrawable
(
this
,
ic_alipay
)
,
null
,
null
,
null
);
tvPayGuide
.
setCompoundDrawables
(
AppCompatResources
.
getDrawable
(
this
,
ic_alipay
),
null
,
null
,
null
);
tvPayGuide
.
text
=
"支付宝扫描二维码 向我付款"
;
cPayCodeBg
.
setBackgroundResource
(
R
.
color
.
blue
)
}
runBlocking
(
Dispatchers
.
IO
)
{
val
qrcode
=
BitmapUtils
.
createBarcodeBitmap
(
payServiceResponse
.
payQrCode
,
9
,
403
,
403
)
val
qrcode
=
BitmapUtils
.
createBarcodeBitmap
(
payServiceResponse
.
payQrCode
,
9
,
403
,
403
)
runOnUiThread
{
ivPayCode
.
setImageBitmap
(
qrcode
)
//支付结果查询
...
...
@@ -73,15 +84,15 @@ class PayCodeActivity : BaseActivity() {
}
}
viewModel
.
payResultLiveData
.
observe
(
this
,{
result
->
viewModel
.
payResultLiveData
.
observe
(
this
,
{
result
->
result
.
getOrElse
{
it
.
message
?.
let
{
it1
->
CenterToasty
.
error
(
this
,
it1
,
Toast
.
LENGTH_LONG
).
show
()
}
it
.
message
?.
let
{
it1
->
CenterToasty
.
error
(
this
,
it1
,
Toast
.
LENGTH_LONG
).
show
()
}
return
@observe
}
result
.
getOrNull
().
also
{
it
?.
let
{
it1
->
PayResultActivity
.
start
(
this
@PayCodeActivity
,
it1
)
PayResultActivity
.
start
(
this
@PayCodeActivity
,
it1
)
}
}
})
...
...
app/src/main/java/com/miya/fastcashier/ui/WxPayCodeActivity.kt
View file @
a5a2e488
...
...
@@ -3,9 +3,8 @@ package com.miya.fastcashier.ui
import
android.content.Intent
import
android.os.Bundle
import
android.widget.Toast
import
androidx.appcompat.app.AppCompatActivity
import
androidx.lifecycle.ViewModelProvider
import
com.
alibaba.fastjson.JSON
import
com.
blankj.utilcode.util.GsonUtils
import
com.blankj.utilcode.util.LogUtils
import
com.fastcashier.lib_common.base.BaseActivity
import
com.fastcashier.lib_common.config.IntentExtra
...
...
@@ -53,10 +52,12 @@ class WxPayCodeActivity : BaseActivity() {
val
extra
=
intent
.
getSerializableExtra
(
IntentExtra
.
KEY_EXTRA_PAYSERVICERESPONSE
)
extra
?.
let
{
val
payServiceResponse
=
it
as
PayServiceResponse
LogUtils
.
e
(
JSON
.
toJSONString
(
payServiceResponse
))
tvPrice
.
text
=
"¥"
.
plus
(
StringPriceFormatUtils
.
transStringPriceToDecimalString
(
payServiceResponse
.
tradPrice
))
LogUtils
.
e
(
GsonUtils
.
toJson
(
payServiceResponse
))
tvPrice
.
text
=
"¥"
.
plus
(
StringPriceFormatUtils
.
transStringPriceToDecimalString
(
payServiceResponse
.
tradPrice
))
runBlocking
(
Dispatchers
.
IO
)
{
val
qrcode
=
BitmapUtils
.
createBarcodeBitmap
(
payServiceResponse
.
payQrCode
,
9
,
453
,
453
)
val
qrcode
=
BitmapUtils
.
createBarcodeBitmap
(
payServiceResponse
.
payQrCode
,
9
,
453
,
453
)
runOnUiThread
{
ivPayCode
.
setImageBitmap
(
qrcode
)
//支付结果查询
...
...
@@ -65,20 +66,22 @@ class WxPayCodeActivity : BaseActivity() {
}
}
viewModel
.
payResultLiveData
.
observe
(
this
,{
result
->
viewModel
.
payResultLiveData
.
observe
(
this
,
{
result
->
result
.
getOrElse
{
it
.
message
?.
let
{
it1
->
{
if
(!
it1
.
contains
(
"未付款"
)){
CenterToasty
.
error
(
this
,
it1
,
Toast
.
LENGTH_LONG
).
show
()
it
.
message
?.
let
{
it1
->
{
if
(!
it1
.
contains
(
"未付款"
))
{
CenterToasty
.
error
(
this
,
it1
,
Toast
.
LENGTH_LONG
).
show
()
}
}
}
}
}
return
@observe
}
result
.
getOrNull
().
also
{
it
?.
let
{
it1
->
OrderRecordManageKit
.
setSerialNumber
()
PayResultActivity
.
start
(
this
@WxPayCodeActivity
,
it1
)
PayResultActivity
.
start
(
this
@WxPayCodeActivity
,
it1
)
}
}
})
...
...
app/src/main/java/com/miya/fastcashier/viewmodel/PayViewModel.kt
View file @
a5a2e488
...
...
@@ -4,7 +4,7 @@ import android.text.TextUtils
import
androidx.lifecycle.MutableLiveData
import
androidx.lifecycle.ViewModel
import
androidx.lifecycle.viewModelScope
import
com.
alibaba.fastjson.JSON
import
com.
blankj.utilcode.util.GsonUtils
import
com.elvishew.xlog.XLog
import
com.fastcashier.lib_common.function.account.AccountService
import
com.fastcashier.lib_common.function.pay.PayRepository
...
...
@@ -29,7 +29,7 @@ class PayViewModel : ViewModel() {
* 退款全额
*/
fun
refund
(
payServiceResponse
:
PayServiceResponse
)
{
XLog
.
d
(
"开始退款:${
JSON.toJSONString
(payServiceResponse)}"
)
XLog
.
d
(
"开始退款:${
GsonUtils.toJson
(payServiceResponse)}"
)
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
//退款
var
refundPayServiceResponse
:
PayServiceResponse
?
=
null
...
...
@@ -41,7 +41,7 @@ class PayViewModel : ViewModel() {
refundParams
[
"refundOrderNo"
]
=
refundOrderNo
refundParams
[
"refundPrice"
]
=
payServiceResponse
.
tradPrice
refundPayServiceResponse
=
PayRepository
.
refundByOrderNo
(
refundParams
)
XLog
.
d
(
"退款成功:${
JSON.toJSONString
(refundPayServiceResponse)}"
)
XLog
.
d
(
"退款成功:${
GsonUtils.toJson
(refundPayServiceResponse)}"
)
//保存到数据库
ViewPayOrderData
.
insert
(
refundPayServiceResponse
)
refundLiveData
.
postValue
(
Result
.
success
(
refundPayServiceResponse
))
...
...
@@ -77,7 +77,7 @@ class PayViewModel : ViewModel() {
* 退款固定数额
*/
fun
refund
(
payServiceResponse
:
PayServiceResponse
,
refundPrice
:
String
)
{
XLog
.
d
(
"开始退款:${
JSON.toJSONString
(payServiceResponse)}"
)
XLog
.
d
(
"开始退款:${
GsonUtils.toJson
(payServiceResponse)}"
)
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
//退款
var
refundPayServiceResponse
:
PayServiceResponse
?
=
null
...
...
@@ -89,7 +89,7 @@ class PayViewModel : ViewModel() {
refundParams
[
"refundOrderNo"
]
=
refundOrderNo
refundParams
[
"refundPrice"
]
=
refundPrice
refundPayServiceResponse
=
PayRepository
.
refundByOrderNo
(
refundParams
)
XLog
.
d
(
"退款成功:${
JSON.toJSONString
(refundPayServiceResponse)}"
)
XLog
.
d
(
"退款成功:${
GsonUtils.toJson
(refundPayServiceResponse)}"
)
//保存到数据库
ViewPayOrderData
.
insert
(
refundPayServiceResponse
)
refundLiveData
.
postValue
(
Result
.
success
(
refundPayServiceResponse
))
...
...
@@ -152,7 +152,7 @@ class PayViewModel : ViewModel() {
try
{
val
payServiceResponse
=
PayRepository
.
generatePayCode
(
orderNo
,
priceFen
,
payType
)
payServiceResponseLiveData
.
postValue
(
Result
.
success
(
payServiceResponse
))
XLog
.
d
(
"生成付款码成功${
JSON.toJSONString
(payServiceResponse)}"
)
XLog
.
d
(
"生成付款码成功${
GsonUtils.toJson
(payServiceResponse)}"
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
XLog
.
d
(
"生成付款码异常${e.message}"
)
...
...
@@ -172,7 +172,7 @@ class PayViewModel : ViewModel() {
XLog
.
d
(
"支付查询订单号:${payServiceResponse.shopTradeNo}"
)
val
payServiceResponseResult
=
PayRepository
.
payResultQuery
(
payServiceResponse
.
shopTradeNo
)
XLog
.
d
(
"支付查询结果:${
JSON.toJSONString
(payServiceResponseResult)}"
)
XLog
.
d
(
"支付查询结果:${
GsonUtils.toJson
(payServiceResponseResult)}"
)
//加入数据库
ViewPayOrderData
.
insert
(
payServiceResponseResult
)
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponseResult
))
...
...
@@ -196,7 +196,7 @@ class PayViewModel : ViewModel() {
try
{
XLog
.
d
(
"开始退款支付查询:${orderNo}"
)
val
payServiceResponseResult
=
PayRepository
.
payResultQuery
(
orderNo
)
XLog
.
d
(
"退款支付查询成功:${
JSON.toJSONString
(payServiceResponseResult)}"
)
XLog
.
d
(
"退款支付查询成功:${
GsonUtils.toJson
(payServiceResponseResult)}"
)
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponseResult
))
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
...
...
@@ -242,11 +242,11 @@ class PayViewModel : ViewModel() {
//保存到数据库
ViewPayOrderData
.
insert
(
payServiceResponse
)
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponse
))
XLog
.
d
(
"被扫支付成功${
JSON.toJSONString
(payServiceResponse)}"
)
XLog
.
d
(
"被扫支付成功${
GsonUtils.toJson
(payServiceResponse)}"
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
payResultLiveData
.
postValue
(
Result
.
failure
(
e
))
XLog
.
d
(
"被扫支付异常${
JSON.toJSONString
(e.message)}"
)
XLog
.
d
(
"被扫支付异常${
GsonUtils.toJson
(e.message)}"
)
}
}
...
...
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