Commit a5a2e488 authored by 赵鹏翔's avatar 赵鹏翔

fastjson去除,改用gson

parent 7b072ec1
......@@ -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'
......
......@@ -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.**{*;}
......
......@@ -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)
......
......@@ -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)
}
}
})
......
......@@ -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)
}
}
})
......
......@@ -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)}")
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment