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
4e7d35ad
Commit
4e7d35ad
authored
Mar 13, 2022
by
gaodapeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改,优化,开发,自测
parent
023bc895
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
291 additions
and
50 deletions
+291
-50
build.gradle
app/build.gradle
+2
-1
BaseApplication.kt
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
+2
-0
ViewPayOrderData.kt
.../main/java/com/miya/fastcashier/beans/ViewPayOrderData.kt
+72
-0
PayDataDao.kt
app/src/main/java/com/miya/fastcashier/dao/PayDataDao.kt
+33
-0
PayDatabase.kt
app/src/main/java/com/miya/fastcashier/dao/PayDatabase.kt
+27
-0
PayRepository.kt
...ain/java/com/miya/fastcashier/repository/PayRepository.kt
+0
-1
PayActivity.kt
app/src/main/java/com/miya/fastcashier/ui/PayActivity.kt
+11
-10
SearchOrderActivity.kt
.../main/java/com/miya/fastcashier/ui/SearchOrderActivity.kt
+24
-14
ContextUtils.java
...rc/main/java/com/miya/fastcashier/utils/ContextUtils.java
+34
-0
PayViewModel.kt
.../main/java/com/miya/fastcashier/viewmodel/PayViewModel.kt
+36
-18
SearchOrderViewModel.kt
...va/com/miya/fastcashier/viewmodel/SearchOrderViewModel.kt
+14
-0
app_search_indicator.xml
app/src/main/res/drawable/app_search_indicator.xml
+10
-0
activity_pay.xml
app/src/main/res/layout/activity_pay.xml
+3
-1
activity_search_order.xml
app/src/main/res/layout/activity_search_order.xml
+10
-2
title.xml
app/src/main/res/layout/title.xml
+5
-3
styles.xml
app/src/main/res/values/styles.xml
+8
-0
No files found.
app/build.gradle
View file @
4e7d35ad
plugins
{
plugins
{
id
'com.android.application'
id
'com.android.application'
id
'kotlin-android'
id
'kotlin-android'
id
'kotlin-kapt'
}
}
android
{
android
{
...
@@ -63,7 +64,7 @@ dependencies {
...
@@ -63,7 +64,7 @@ dependencies {
implementation
'androidx.annotation:annotation:1.1.0'
implementation
'androidx.annotation:annotation:1.1.0'
implementation
'com.rengwuxian.materialedittext:library:2.1.4'
implementation
'com.rengwuxian.materialedittext:library:2.1.4'
implementation
'com.github.GrenderG:Toasty:1.5.2'
implementation
'com.github.GrenderG:Toasty:1.5.2'
annotationProcessor
'androidx.room:room-compiler:2.4.0'
kapt
'androidx.room:room-compiler:2.4.0'
implementation
'androidx.room:room-runtime:2.4.0'
implementation
'androidx.room:room-runtime:2.4.0'
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation
files
(
'libs/Pay-Platform.jar'
)
implementation
files
(
'libs/Pay-Platform.jar'
)
...
...
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
View file @
4e7d35ad
...
@@ -15,6 +15,7 @@ import com.elvishew.xlog.printer.Printer
...
@@ -15,6 +15,7 @@ import com.elvishew.xlog.printer.Printer
import
com.elvishew.xlog.printer.file.FilePrinter
import
com.elvishew.xlog.printer.file.FilePrinter
import
com.elvishew.xlog.printer.file.backup.NeverBackupStrategy
import
com.elvishew.xlog.printer.file.backup.NeverBackupStrategy
import
com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
import
com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
import
com.miya.fastcashier.utils.ContextUtils
import
com.miya.fastcashier.utils.DateUtils
import
com.miya.fastcashier.utils.DateUtils
import
com.miya.fastcashier.utils.DensityUtils
import
com.miya.fastcashier.utils.DensityUtils
import
com.miya.print.PrinterManager
import
com.miya.print.PrinterManager
...
@@ -27,6 +28,7 @@ import java.util.*
...
@@ -27,6 +28,7 @@ import java.util.*
class
BaseApplication
:
MultiDexApplication
()
{
class
BaseApplication
:
MultiDexApplication
()
{
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
super
.
onCreate
()
ContextUtils
.
init
(
this
)
//打印机初始化
//打印机初始化
PrinterManager
.
getInstance
().
init
(
this
)
PrinterManager
.
getInstance
().
init
(
this
)
//屏幕适配
//屏幕适配
...
...
app/src/main/java/com/miya/fastcashier/beans/ViewPayOrderData.kt
0 → 100644
View file @
4e7d35ad
package
com.miya.fastcashier.beans
import
android.text.TextUtils
import
androidx.room.Entity
import
androidx.room.PrimaryKey
import
com.miya.fastcashier.dao.DatabaseKeeper
import
com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
/**
* 封装层的
*/
@Entity
(
tableName
=
"pay_data"
)
data class
ViewPayOrderData
(
@PrimaryKey
//以订单号为主键
val
orderNo
:
String
,
//订单号
val
tradStatus
:
String
?
=
null
,
val
tradeNo
:
String
?
=
null
,
//交易流水号
val
tradPrice
:
String
?
=
null
,
//总价格
val
chanelTag
:
String
?
=
null
,
//支付方式
val
buyerId
:
String
?
=
null
,
//支付者id
val
couponMessage
:
String
?
=
null
,
val
chanelOrderTradeTime
:
String
?
=
null
,
//支付时间
val
miyaResponseTime
:
String
?
=
null
,
//返回支付时间
val
miyaOrderDesc
:
String
?
=
null
,
val
vipShopTag
:
String
?
=
null
,
val
buyerAccount
:
String
?
=
null
,
//支付者账户
val
memberCardNumber
:
String
?
=
null
,
//会员卡
val
platformName
:
String
?
=
null
,
val
refundOrderNo
:
String
?
=
null
,
//退款订单号
val
oriOrderPrice
:
String
?
=
null
,
//订单原价
val
refundPrice
:
String
?
=
null
,
//退款价格
val
payQrCode
:
String
?
=
null
,
//支付条码
)
{
companion
object
{
fun
create
(
payServiceResponse
:
PayServiceResponse
):
ViewPayOrderData
{
return
ViewPayOrderData
(
orderNo
=
payServiceResponse
.
shopTradeNo
,
tradStatus
=
payServiceResponse
.
tradStatus
,
tradeNo
=
payServiceResponse
.
chanelSerialNumber
,
tradPrice
=
payServiceResponse
.
tradPrice
,
chanelTag
=
payServiceResponse
.
chanelTag
,
buyerId
=
payServiceResponse
.
buyerId
,
couponMessage
=
payServiceResponse
.
couponMessage
,
chanelOrderTradeTime
=
payServiceResponse
.
chanelOrderTradeTime
,
miyaResponseTime
=
payServiceResponse
.
miyaResponseTime
,
miyaOrderDesc
=
payServiceResponse
.
miyaOrderDesc
,
vipShopTag
=
payServiceResponse
.
vipShopTag
,
buyerAccount
=
payServiceResponse
.
buyerAccount
,
memberCardNumber
=
payServiceResponse
.
memberCardNumber
,
platformName
=
payServiceResponse
.
platformName
,
refundOrderNo
=
payServiceResponse
.
refundOrderNo
,
oriOrderPrice
=
payServiceResponse
.
oriOrderPrice
,
refundPrice
=
payServiceResponse
.
refundPrice
,
payQrCode
=
payServiceResponse
.
payQrCode
)
}
fun
insert
(
payServiceResponse
:
PayServiceResponse
)
{
if
(
TextUtils
.
isEmpty
(
payServiceResponse
.
shopTradeNo
))
{
return
}
DatabaseKeeper
.
payDatabase
.
payDataDao
()
.
insertOne
(
create
(
payServiceResponse
))
}
fun
update
()
{
//TODO
}
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/dao/PayDataDao.kt
0 → 100644
View file @
4e7d35ad
package
com.miya.fastcashier.dao
import
androidx.room.*
import
com.miya.fastcashier.beans.ViewPayOrderData
@Dao
interface
PayDataDao
{
@Query
(
"SELECT COUNT(*) FROM pay_data"
)
fun
getSize
():
Int
@Query
(
"SELECT * FROM pay_data"
)
fun
getAll
():
MutableList
<
ViewPayOrderData
>
@Query
(
"SELECT * FROM pay_data LIMIT 20"
)
fun
getOnePage
():
MutableList
<
ViewPayOrderData
>
@Query
(
"SELECT ceil(COUNT(*))/10"
)
fun
getPageNum
():
Int
@Insert
fun
insertAll
(
list
:
MutableList
<
ViewPayOrderData
>)
@Insert
fun
insertOne
(
data
:
ViewPayOrderData
)
@Update
fun
updateOne
(
data
:
ViewPayOrderData
)
@Delete
fun
delete
(
user
:
ViewPayOrderData
)
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/dao/PayDatabase.kt
0 → 100644
View file @
4e7d35ad
package
com.miya.fastcashier.dao
import
androidx.room.Database
import
androidx.room.RoomDatabase
import
com.miya.fastcashier.beans.ViewPayOrderData
import
androidx.room.Room
import
com.miya.fastcashier.utils.ContextUtils
@Database
(
entities
=
[
ViewPayOrderData
::
class
],
exportSchema
=
false
,
version
=
1
)
abstract
class
PayDatabase
:
RoomDatabase
()
{
abstract
fun
payDataDao
():
PayDataDao
}
class
DatabaseKeeper
{
companion
object
{
val
payDatabase
:
PayDatabase
by
lazy
(
mode
=
LazyThreadSafetyMode
.
SYNCHRONIZED
)
{
Room
.
databaseBuilder
(
ContextUtils
.
getContext
(),
PayDatabase
::
class
.
java
,
"pay_data"
).
build
()
}
}
}
app/src/main/java/com/miya/fastcashier/repository/PayRepository.kt
View file @
4e7d35ad
...
@@ -98,7 +98,6 @@ object PayRepository {
...
@@ -98,7 +98,6 @@ object PayRepository {
checkNotNull
(
signKey
)
{
"refundByOrderNo signKey is null"
}
checkNotNull
(
signKey
)
{
"refundByOrderNo signKey is null"
}
checkNotNull
(
saasid
)
{
"refundByOrderNo saasid is null"
}
checkNotNull
(
saasid
)
{
"refundByOrderNo saasid is null"
}
checkNotNull
(
marketid
)
{
"refundByOrderNo marketid is null"
}
checkNotNull
(
marketid
)
{
"refundByOrderNo marketid is null"
}
checkNotNull
(
version
)
{
"refundByOrderNo version is null"
}
checkNotNull
(
oriOrderNo
)
{
"refundByOrderNo oriOrderNo is null"
}
checkNotNull
(
oriOrderNo
)
{
"refundByOrderNo oriOrderNo is null"
}
checkNotNull
(
refundOrderNo
)
{
"refundByOrderNo refundOrderNo is null"
}
checkNotNull
(
refundOrderNo
)
{
"refundByOrderNo refundOrderNo is null"
}
checkNotNull
(
refundPrice
)
{
"refundByOrderNo refundPrice is null"
}
checkNotNull
(
refundPrice
)
{
"refundByOrderNo refundPrice is null"
}
...
...
app/src/main/java/com/miya/fastcashier/ui/PayActivity.kt
View file @
4e7d35ad
...
@@ -26,7 +26,7 @@ class PayActivity : BaseActivity() {
...
@@ -26,7 +26,7 @@ class PayActivity : BaseActivity() {
private
lateinit
var
binding
:
ActivityPayBinding
private
lateinit
var
binding
:
ActivityPayBinding
private
var
scanGunKeyEventHelper
:
ScanGunKeyEventHelper
=
ScanGunKeyEventHelper
()
private
var
scanGunKeyEventHelper
:
ScanGunKeyEventHelper
=
ScanGunKeyEventHelper
()
private
lateinit
var
price
:
String
private
lateinit
var
price
:
String
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
...
@@ -39,32 +39,33 @@ class PayActivity : BaseActivity() {
...
@@ -39,32 +39,33 @@ class PayActivity : BaseActivity() {
val
tvPayPrice
=
binding
.
tvPayPrice
val
tvPayPrice
=
binding
.
tvPayPrice
tvPayPrice
.
text
=
"¥${price.toDouble()}"
tvPayPrice
.
text
=
"¥${price.toDouble()}"
viewModel
.
payResultLiveData
.
observe
(
this
,
{
payResult
->
viewModel
.
payResultLiveData
.
observe
(
this
,
{
payResult
->
dismissProgressDialog
()
dismissProgressDialog
()
payResult
.
onFailure
{
payResult
.
onFailure
{
it
.
message
?.
let
{
it1
->
CenterToasty
.
error
(
this
,
it1
,
Toast
.
LENGTH_LONG
).
show
()
}
it
.
message
?.
let
{
it1
->
CenterToasty
.
error
(
this
,
it1
,
Toast
.
LENGTH_LONG
).
show
()
}
}
}
payResult
.
onSuccess
{
payResult
.
onSuccess
{
//自增流水
//自增流水
val
today
=
DateUtils
.
format8
(
Date
())
val
today
=
DateUtils
.
format8
(
Date
())
var
no
=
kv
.
getInt
(
today
,
0
);
var
no
=
kv
.
getInt
(
today
,
0
);
kv
.
putInt
(
DateUtils
.
format8
(
Date
()),++
no
)
kv
.
putInt
(
DateUtils
.
format8
(
Date
()),
++
no
)
val
intent
=
Intent
()
val
intent
=
Intent
()
intent
.
setClass
(
this
@PayActivity
,
PayResultActivity
::
class
.
java
)
intent
.
setClass
(
this
@PayActivity
,
PayResultActivity
::
class
.
java
)
intent
.
putExtra
(
"payServiceResponse"
,
it
)
intent
.
putExtra
(
"payServiceResponse"
,
it
)
startActivity
(
intent
)
startActivity
(
intent
)
}
}
})
})
val
tvBack
=
binding
.
tvBack
val
tvBack
=
binding
.
clTitle
.
tvBack
val
ivBack
=
binding
.
ivBack
val
ivBack
=
binding
.
clTitle
.
ivBack
tvBack
.
clickWithTrigger
{
finish
()
}
tvBack
.
clickWithTrigger
{
finish
()
}
ivBack
.
clickWithTrigger
{
finish
()
}
ivBack
.
clickWithTrigger
{
finish
()
}
scanGunKeyEventHelper
.
setOnBarCodeCatchListener
{
scanGunKeyEventHelper
.
setOnBarCodeCatchListener
{
showProgressDialog
(
"正在支付.."
)
showProgressDialog
(
"正在支付.."
)
viewModel
.
pay
(
price
,
it
)
viewModel
.
pay
(
price
,
it
)
}
}
}
}
...
...
app/src/main/java/com/miya/fastcashier/ui/SearchOrderActivity.kt
View file @
4e7d35ad
...
@@ -11,11 +11,12 @@ import androidx.recyclerview.widget.RecyclerView
...
@@ -11,11 +11,12 @@ import androidx.recyclerview.widget.RecyclerView
import
androidx.viewpager2.adapter.FragmentStateAdapter
import
androidx.viewpager2.adapter.FragmentStateAdapter
import
com.google.android.material.tabs.TabLayoutMediator
import
com.google.android.material.tabs.TabLayoutMediator
import
com.miya.fastcashier.R
import
com.miya.fastcashier.R
import
com.miya.fastcashier.beans.ViewPayOrderData
import
com.miya.fastcashier.databinding.ActivitySearchOrderBinding
import
com.miya.fastcashier.databinding.ActivitySearchOrderBinding
import
com.miya.fastcashier.databinding.FragmentSearchOrderBinding
import
com.miya.fastcashier.databinding.FragmentSearchOrderBinding
import
com.miya.fastcashier.databinding.ItemSearchOrderListBinding
import
com.miya.fastcashier.databinding.ItemSearchOrderListBinding
import
com.miya.fastcashier.utils.MiYaPayPlantformPayWayEnum
import
com.miya.fastcashier.utils.MiYaPayPlantformPayWayEnum
import
com.
sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import
com.
miya.fastcashier.utils.clickWithTrigger
/**
/**
* 查单列表
* 查单列表
...
@@ -27,17 +28,8 @@ class SearchOrderActivity : BaseActivity() {
...
@@ -27,17 +28,8 @@ class SearchOrderActivity : BaseActivity() {
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
binding
=
ActivitySearchOrderBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
binding
=
ActivitySearchOrderBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
setContentView
(
binding
.
root
)
setContentView
(
binding
.
root
)
binding
.
title
.
tvBack
.
clickWithTrigger
{
finish
()
}
TabLayoutMediator
(
binding
.
title
.
ivBack
.
clickWithTrigger
{
finish
()
}
binding
.
tlIndicator
,
binding
.
vpPage
)
{
tab
,
position
->
when
(
position
)
{
0
->
tab
.
text
=
"微信"
1
->
tab
.
text
=
"支付宝"
else
->
tab
.
text
=
""
}
}.
attach
()
binding
.
vpPage
.
adapter
=
object
:
FragmentStateAdapter
(
this
)
{
binding
.
vpPage
.
adapter
=
object
:
FragmentStateAdapter
(
this
)
{
override
fun
getItemCount
():
Int
{
override
fun
getItemCount
():
Int
{
...
@@ -51,7 +43,22 @@ class SearchOrderActivity : BaseActivity() {
...
@@ -51,7 +43,22 @@ class SearchOrderActivity : BaseActivity() {
}
}
}
}
}
}
TabLayoutMediator
(
binding
.
tlIndicator
,
binding
.
vpPage
)
{
tab
,
position
->
when
(
position
)
{
0
->
tab
.
text
=
"微信"
1
->
tab
.
text
=
"支付宝"
else
->
tab
.
text
=
""
}
}.
attach
()
}
}
}
}
...
@@ -96,7 +103,10 @@ class SearchOrderFragment(payType: MiYaPayPlantformPayWayEnum.MiyaPayType) : Fra
...
@@ -96,7 +103,10 @@ class SearchOrderFragment(payType: MiYaPayPlantformPayWayEnum.MiyaPayType) : Fra
}
}
}
}
class
SearchOrderListAdapter
(
val
context
:
Context
,
private
val
list
:
MutableList
<
PayServiceResponse
>)
:
class
SearchOrderListAdapter
(
val
context
:
Context
,
private
val
list
:
MutableList
<
ViewPayOrderData
>
)
:
RecyclerView
.
Adapter
<
SearchOrderViewHolder
>()
{
RecyclerView
.
Adapter
<
SearchOrderViewHolder
>()
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
SearchOrderViewHolder
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
SearchOrderViewHolder
{
return
SearchOrderViewHolder
(
return
SearchOrderViewHolder
(
...
@@ -118,7 +128,7 @@ class SearchOrderListAdapter(val context: Context, private val list: MutableList
...
@@ -118,7 +128,7 @@ class SearchOrderListAdapter(val context: Context, private val list: MutableList
class
SearchOrderViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
class
SearchOrderViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
private
val
binding
:
ItemSearchOrderListBinding
=
ItemSearchOrderListBinding
.
bind
(
itemView
)
private
val
binding
:
ItemSearchOrderListBinding
=
ItemSearchOrderListBinding
.
bind
(
itemView
)
fun
setData
(
data
:
PayServiceResponse
)
{
fun
setData
(
data
:
ViewPayOrderData
)
{
binding
.
tvDate
.
text
=
data
.
chanelOrderTradeTime
binding
.
tvDate
.
text
=
data
.
chanelOrderTradeTime
}
}
...
...
app/src/main/java/com/miya/fastcashier/utils/ContextUtils.java
0 → 100644
View file @
4e7d35ad
package
com
.
miya
.
fastcashier
.
utils
;
import
android.content.Context
;
/**
* 描述: 上下文相关工具类
*/
public
class
ContextUtils
{
private
static
Context
context
;
private
ContextUtils
()
{
throw
new
UnsupportedOperationException
(
"u can't instantiate me..."
);
}
/**
* 初始化工具类
*
* @param context 上下文
*/
public
static
void
init
(
Context
context
)
{
ContextUtils
.
context
=
context
.
getApplicationContext
();
}
/**
* 获取ApplicationContext
*
* @return ApplicationContext
*/
public
static
Context
getContext
()
{
if
(
context
!=
null
)
return
context
;
throw
new
NullPointerException
(
"u should init first"
);
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/viewmodel/PayViewModel.kt
View file @
4e7d35ad
...
@@ -10,6 +10,8 @@ import com.blankj.utilcode.util.NumberUtils
...
@@ -10,6 +10,8 @@ import com.blankj.utilcode.util.NumberUtils
import
com.elvishew.xlog.XLog
import
com.elvishew.xlog.XLog
import
com.miya.fastcashier.beans.LoginRequest
import
com.miya.fastcashier.beans.LoginRequest
import
com.miya.fastcashier.beans.SelfCashierAccountInfo
import
com.miya.fastcashier.beans.SelfCashierAccountInfo
import
com.miya.fastcashier.beans.ViewPayOrderData
import
com.miya.fastcashier.dao.DatabaseKeeper
import
com.miya.fastcashier.repository.PayRepository
import
com.miya.fastcashier.repository.PayRepository
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.service.LoginService
import
com.miya.fastcashier.service.LoginService
...
@@ -34,18 +36,22 @@ class PayViewModel : ViewModel() {
...
@@ -34,18 +36,22 @@ class PayViewModel : ViewModel() {
fun
refund
(
payServiceResponse
:
PayServiceResponse
)
{
fun
refund
(
payServiceResponse
:
PayServiceResponse
)
{
XLog
.
d
(
"开始退款:${JSON.toJSONString(payServiceResponse)}"
)
XLog
.
d
(
"开始退款:${JSON.toJSONString(payServiceResponse)}"
)
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
//保存到数据库
ViewPayOrderData
.
insert
(
payServiceResponse
)
//退款
//退款
var
refundPayServiceResponse
:
PayServiceResponse
?
=
null
var
refundPayServiceResponse
:
PayServiceResponse
?
=
null
try
{
try
{
val
refundParams
=
HashMap
<
String
,
String
>()
val
refundParams
=
HashMap
<
String
,
String
>()
refundParams
[
"oriOrderNo"
]
=
payServiceResponse
.
shopTradeNo
;
refundParams
[
"oriOrderNo"
]
=
payServiceResponse
.
shopTradeNo
;
val
refundOrderNo
=
AccountService
.
getAccountInfo
()
?.
shopInfo
?.
saasid
+
System
.
currentTimeMillis
()
val
refundOrderNo
=
refundParams
[
"refundOrderNo"
]
=
refundOrderNo
;
AccountService
.
getAccountInfo
()
?.
shopInfo
?.
saasid
+
System
.
currentTimeMillis
()
refundParams
[
"refundPrice"
]
=
payServiceResponse
.
tradPrice
;
refundParams
[
"refundOrderNo"
]
=
refundOrderNo
refundParams
[
"refundPrice"
]
=
payServiceResponse
.
tradPrice
refundPayServiceResponse
=
PayRepository
.
refundByOrderNo
(
refundParams
)
refundPayServiceResponse
=
PayRepository
.
refundByOrderNo
(
refundParams
)
refundLiveData
.
postValue
(
Result
.
success
(
refundPayServiceResponse
))
refundLiveData
.
postValue
(
Result
.
success
(
refundPayServiceResponse
))
XLog
.
d
(
"退款成功:${JSON.toJSONString(refundPayServiceResponse)}"
)
XLog
.
d
(
"退款成功:${JSON.toJSONString(refundPayServiceResponse)}"
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
XLog
.
d
(
"退款异常:${e.message}"
)
XLog
.
d
(
"退款异常:${e.message}"
)
refundLiveData
.
postValue
(
Result
.
failure
(
e
))
refundLiveData
.
postValue
(
Result
.
failure
(
e
))
}
}
...
@@ -54,12 +60,16 @@ class PayViewModel : ViewModel() {
...
@@ -54,12 +60,16 @@ class PayViewModel : ViewModel() {
try
{
try
{
XLog
.
d
(
"开始退款打印"
)
XLog
.
d
(
"开始退款打印"
)
AccountService
.
getAccountInfo
()
AccountService
.
getAccountInfo
()
?.
let
{
refundPayServiceResponse
?.
let
{
it1
->
?.
let
{
PrintService
.
refundPrint
(
it
,
refundPayServiceResponse
?.
let
{
it1
->
it1
PrintService
.
refundPrint
(
)
it
,
}
}
it1
}
catch
(
e
:
Exception
){
)
}
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
XLog
.
d
(
"退款打印异常${e.message}"
)
XLog
.
d
(
"退款打印异常${e.message}"
)
refundLiveData
.
postValue
(
Result
.
failure
(
e
))
refundLiveData
.
postValue
(
Result
.
failure
(
e
))
}
}
...
@@ -84,12 +94,13 @@ class PayViewModel : ViewModel() {
...
@@ -84,12 +94,13 @@ class PayViewModel : ViewModel() {
try
{
try
{
priceFen
=
price
.
toDouble
().
times
(
100
).
toInt
().
toString
()
priceFen
=
price
.
toDouble
().
times
(
100
).
toInt
().
toString
()
}
catch
(
e
:
java
.
lang
.
Exception
)
{
}
catch
(
e
:
java
.
lang
.
Exception
)
{
e
.
printStackTrace
()
payServiceResponseLiveData
.
value
=
Result
.
failure
(
ParamInvalidException
(
"金额有误!"
))
payServiceResponseLiveData
.
value
=
Result
.
failure
(
ParamInvalidException
(
"金额有误!"
))
return
return
}
}
val
sassid
=
AccountService
.
getAccountInfo
()
?.
shopInfo
?.
saasid
val
sassid
=
AccountService
.
getAccountInfo
()
?.
shopInfo
?.
saasid
val
orderNo
=
sassid
+
System
.
currentTimeMillis
()
val
orderNo
=
sassid
+
System
.
currentTimeMillis
()
XLog
.
d
(
"主扫码订单号${orderNo}"
)
XLog
.
d
(
"主扫码订单号${orderNo}"
)
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
...
@@ -98,6 +109,7 @@ class PayViewModel : ViewModel() {
...
@@ -98,6 +109,7 @@ class PayViewModel : ViewModel() {
payServiceResponseLiveData
.
postValue
(
Result
.
success
(
payServiceResponse
))
payServiceResponseLiveData
.
postValue
(
Result
.
success
(
payServiceResponse
))
XLog
.
d
(
"生成付款码成功${JSON.toJSONString(payServiceResponse)}"
)
XLog
.
d
(
"生成付款码成功${JSON.toJSONString(payServiceResponse)}"
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
XLog
.
d
(
"生成付款码异常${e.message}"
)
XLog
.
d
(
"生成付款码异常${e.message}"
)
payServiceResponseLiveData
.
postValue
(
Result
.
failure
(
e
))
payServiceResponseLiveData
.
postValue
(
Result
.
failure
(
e
))
}
}
...
@@ -113,7 +125,8 @@ class PayViewModel : ViewModel() {
...
@@ -113,7 +125,8 @@ class PayViewModel : ViewModel() {
while
(
isActive
)
{
while
(
isActive
)
{
try
{
try
{
XLog
.
d
(
"支付查询订单号:${payServiceResponse.shopTradeNo}"
)
XLog
.
d
(
"支付查询订单号:${payServiceResponse.shopTradeNo}"
)
val
payServiceResponseResult
=
PayRepository
.
payResultQuery
(
payServiceResponse
.
shopTradeNo
)
val
payServiceResponseResult
=
PayRepository
.
payResultQuery
(
payServiceResponse
.
shopTradeNo
)
XLog
.
d
(
"支付查询结果:${JSON.toJSONString(payServiceResponseResult)}"
)
XLog
.
d
(
"支付查询结果:${JSON.toJSONString(payServiceResponseResult)}"
)
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponseResult
))
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponseResult
))
break
break
...
@@ -132,13 +145,14 @@ class PayViewModel : ViewModel() {
...
@@ -132,13 +145,14 @@ class PayViewModel : ViewModel() {
* 订单查询,退款查询
* 订单查询,退款查询
*/
*/
fun
payResultQuery
(
orderNo
:
String
)
{
fun
payResultQuery
(
orderNo
:
String
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
){
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
try
{
try
{
XLog
.
d
(
"开始退款支付查询:${orderNo}"
)
XLog
.
d
(
"开始退款支付查询:${orderNo}"
)
val
payServiceResponseResult
=
PayRepository
.
payResultQuery
(
orderNo
)
val
payServiceResponseResult
=
PayRepository
.
payResultQuery
(
orderNo
)
XLog
.
d
(
"退款支付查询成功:${JSON.toJSONString(payServiceResponseResult)}"
)
XLog
.
d
(
"退款支付查询成功:${JSON.toJSONString(payServiceResponseResult)}"
)
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponseResult
))
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponseResult
))
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
XLog
.
d
(
"退款支付查询异常:${e.message}"
)
XLog
.
d
(
"退款支付查询异常:${e.message}"
)
payResultLiveData
.
postValue
(
Result
.
failure
(
e
))
payResultLiveData
.
postValue
(
Result
.
failure
(
e
))
}
}
...
@@ -149,7 +163,7 @@ class PayViewModel : ViewModel() {
...
@@ -149,7 +163,7 @@ class PayViewModel : ViewModel() {
/**
/**
* 金额是元,首先要转成分
* 金额是元,首先要转成分
*/
*/
fun
pay
(
price
:
String
,
payCode
:
String
)
{
fun
pay
(
price
:
String
,
payCode
:
String
)
{
XLog
.
d
(
"被扫开始"
)
XLog
.
d
(
"被扫开始"
)
if
(
TextUtils
.
isEmpty
(
price
))
{
if
(
TextUtils
.
isEmpty
(
price
))
{
payResultLiveData
.
value
=
Result
.
failure
(
ParamInvalidException
(
"请输入金额!"
))
payResultLiveData
.
value
=
Result
.
failure
(
ParamInvalidException
(
"请输入金额!"
))
...
@@ -165,23 +179,27 @@ class PayViewModel : ViewModel() {
...
@@ -165,23 +179,27 @@ class PayViewModel : ViewModel() {
try
{
try
{
priceFen
=
price
.
toDouble
().
times
(
100
).
toInt
().
toString
()
priceFen
=
price
.
toDouble
().
times
(
100
).
toInt
().
toString
()
}
catch
(
e
:
java
.
lang
.
Exception
)
{
}
catch
(
e
:
java
.
lang
.
Exception
)
{
e
.
printStackTrace
()
payResultLiveData
.
value
=
Result
.
failure
(
ParamInvalidException
(
"金额有误!"
))
payResultLiveData
.
value
=
Result
.
failure
(
ParamInvalidException
(
"金额有误!"
))
return
return
}
}
val
sassid
=
AccountService
.
getAccountInfo
()
?.
shopInfo
?.
saasid
val
sassid
=
AccountService
.
getAccountInfo
()
?.
shopInfo
?.
saasid
val
orderNo
=
sassid
+
System
.
currentTimeMillis
()
val
orderNo
=
sassid
+
System
.
currentTimeMillis
()
XLog
.
d
(
"被扫参数 orderNo = $
{orderNo} price = ${priceFen} payCode = ${payCode}"
)
XLog
.
d
(
"被扫参数 orderNo = $
orderNo price = $priceFen payCode = $payCode"
)
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
try
{
try
{
//0代表不分类别付款
//0代表不分类别付款
val
payServiceResponse
=
PayRepository
.
pay
(
orderNo
,
priceFen
,
payCode
,
"0"
)
val
payServiceResponse
=
PayRepository
.
pay
(
orderNo
,
priceFen
,
payCode
,
"0"
)
//保存到数据库
ViewPayOrderData
.
insert
(
payServiceResponse
)
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponse
))
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponse
))
XLog
.
d
(
"被扫支付成功${JSON.toJSONString(payServiceResponse)}"
)
XLog
.
d
(
"被扫支付成功${JSON.toJSONString(payServiceResponse)}"
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
payResultLiveData
.
postValue
(
Result
.
failure
(
e
))
payResultLiveData
.
postValue
(
Result
.
failure
(
e
))
XLog
.
d
(
"被扫支付异常${JSON.toJSONString(e.message)}"
)
XLog
.
d
(
"被扫支付异常${JSON.toJSONString(e.message)}"
)
}
}
}
}
...
...
app/src/main/java/com/miya/fastcashier/viewmodel/SearchOrderViewModel.kt
0 → 100644
View file @
4e7d35ad
package
com.miya.fastcashier.viewmodel
import
androidx.lifecycle.MutableLiveData
import
com.miya.fastcashier.beans.ViewPayOrderData
import
com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
class
SearchOrderViewModel
{
val
payDataLiveData
:
MutableLiveData
<
Result
<
List
<
ViewPayOrderData
>>>
=
MutableLiveData
()
fun
getPayData
()
{
}
}
\ No newline at end of file
app/src/main/res/drawable/app_search_indicator.xml
0 → 100644
View file @
4e7d35ad
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<gradient
android:endColor=
"#D73672"
android:startColor=
"#FF4B8A"
/>
<corners
android:radius=
"40px"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/activity_pay.xml
View file @
4e7d35ad
...
@@ -8,7 +8,9 @@
...
@@ -8,7 +8,9 @@
android:focusableInTouchMode=
"true"
android:focusableInTouchMode=
"true"
tools:context=
".ui.PriceInputActivity"
>
tools:context=
".ui.PriceInputActivity"
>
<include
layout=
"@layout/title"
/>
<include
android:id=
"@+id/clTitle"
layout=
"@layout/title"
/>
<androidx.constraintlayout.widget.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_search_order.xml
View file @
4e7d35ad
...
@@ -4,19 +4,27 @@
...
@@ -4,19 +4,27 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
>
<include
layout=
"@layout/title"
/>
<include
android:id=
"@+id/title"
layout=
"@layout/title"
/>
<com.google.android.material.tabs.TabLayout
<com.google.android.material.tabs.TabLayout
android:id=
"@+id/tlIndicator"
android:id=
"@+id/tlIndicator"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"85dp"
android:layout_height=
"85dp"
android:layout_marginTop=
"87dp"
android:layout_marginTop=
"87dp"
app:layout_constraintTop_toTopOf=
"parent"
/>
android:background=
"@color/white"
app:layout_constraintTop_toTopOf=
"parent"
app:tabIndicator=
"@drawable/app_search_indicator"
app:tabIndicatorFullWidth=
"false"
app:tabIndicatorHeight=
"5dp"
app:tabTextAppearance=
"@style/tabText"
/>
<androidx.viewpager2.widget.ViewPager2
<androidx.viewpager2.widget.ViewPager2
android:id=
"@+id/vpPage"
android:id=
"@+id/vpPage"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_height=
"0dp"
android:background=
"@color/white"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/tlIndicator"
/>
app:layout_constraintTop_toBottomOf=
"@id/tlIndicator"
/>
...
...
app/src/main/res/layout/title.xml
View file @
4e7d35ad
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<merge
xmlns:android=
"http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<View
<View
android:id=
"@+id/vBg"
android:id=
"@+id/vBg"
...
@@ -42,4 +44,4 @@
...
@@ -42,4 +44,4 @@
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/tvBack"
/>
app:layout_constraintTop_toTopOf=
"@+id/tvBack"
/>
</merge>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
4e7d35ad
<resources>
<resources>
<style
name=
"BottomInAndOutStyle"
>
<style
name=
"BottomInAndOutStyle"
>
<item
name=
"android:windowEnterAnimation"
>
@anim/in_bottom
</item>
<item
name=
"android:windowEnterAnimation"
>
@anim/in_bottom
</item>
<item
name=
"android:windowExitAnimation"
>
@anim/out_bottom
</item>
<item
name=
"android:windowExitAnimation"
>
@anim/out_bottom
</item>
...
@@ -15,4 +16,11 @@
...
@@ -15,4 +16,11 @@
<item
name=
"DialogSpotColor"
>
@android:color/white
</item>
<item
name=
"DialogSpotColor"
>
@android:color/white
</item>
<item
name=
"DialogSpotCount"
>
4
</item>
<item
name=
"DialogSpotCount"
>
4
</item>
</style>
</style>
<style
name=
"tabText"
>
<item
name=
"android:textSize"
>
32sp
</item>
<item
name=
"android:textColor"
>
@color/color_333333
</item>
<item
name=
"android:lines"
>
1
</item>
<item
name=
"android:maxLines"
>
1
</item>
</style>
</resources>
</resources>
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