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
df5f03e0
Commit
df5f03e0
authored
Feb 08, 2022
by
jiangjiantao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一期开发完成
parent
569947bb
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
420 additions
and
77 deletions
+420
-77
build.gradle
app/build.gradle
+18
-2
Pay-Platform.jar
app/libs/Pay-Platform.jar
+0
-0
mobile-pay-1.72.jar
app/libs/mobile-pay-1.72.jar
+0
-0
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+3
-0
BaseApplication.kt
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
+75
-8
PayRepository.kt
...ain/java/com/miya/fastcashier/repository/PayRepository.kt
+34
-37
AliPayCodeActivity.kt
...c/main/java/com/miya/fastcashier/ui/AliPayCodeActivity.kt
+1
-2
LoginActivity.kt
app/src/main/java/com/miya/fastcashier/ui/LoginActivity.kt
+1
-1
PayActivity.kt
app/src/main/java/com/miya/fastcashier/ui/PayActivity.kt
+76
-0
PriceInputActivity.kt
...c/main/java/com/miya/fastcashier/ui/PriceInputActivity.kt
+19
-11
NumberManualDialog.kt
...java/com/miya/fastcashier/ui/dialog/NumberManualDialog.kt
+1
-1
PayViewModel.kt
.../main/java/com/miya/fastcashier/viewmodel/PayViewModel.kt
+59
-8
activity_ali_pay_code.xml
app/src/main/res/layout/activity_ali_pay_code.xml
+2
-1
activity_pay.xml
app/src/main/res/layout/activity_pay.xml
+112
-0
activity_price_input.xml
app/src/main/res/layout/activity_price_input.xml
+3
-3
activity_wx_pay_code.xml
app/src/main/res/layout/activity_wx_pay_code.xml
+2
-1
dialog_number_input.xml
app/src/main/res/layout/dialog_number_input.xml
+14
-2
fastcashier.jks
fastcashier.jks
+0
-0
No files found.
app/build.gradle
View file @
df5f03e0
...
...
@@ -7,18 +7,32 @@ android {
compileSdkVersion
31
buildToolsVersion
"30.0.3"
signingConfigs
{
myConfig
{
keyAlias
'fastcashier'
keyPassword
'123456'
storeFile
file
(
'../fastcashier.jks'
)
storePassword
'123456'
}
}
defaultConfig
{
applicationId
"com.miya.fastcashier"
minSdkVersion
16
targetSdkVersion
31
versionCode
1
versionName
"
1
.0"
versionCode
2
versionName
"
2
.0"
multiDexEnabled
true
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
}
buildTypes
{
debug
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
release
{
signingConfig
signingConfigs
.
myConfig
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
...
...
@@ -50,6 +64,7 @@ dependencies {
implementation
'com.rengwuxian.materialedittext:library:2.1.4'
implementation
'com.github.GrenderG:Toasty:1.5.2'
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation
files
(
'libs/Pay-Platform.jar'
)
testImplementation
'junit:junit:4.+'
implementation
'com.squareup.retrofit2:converter-gson:2.9.0'
implementation
(
'com.squareup.retrofit2:converter-simplexml:2.9.0'
)
{
...
...
@@ -65,4 +80,5 @@ dependencies {
implementation
'com.tencent:mmkv:1.2.12'
implementation
'com.github.ybq:Android-SpinKit:1.4.0'
implementation
'com.github.d-max:spots-dialog:1.1@aar'
implementation
'com.elvishew:xlog:1.10.1'
}
\ No newline at end of file
app/libs/Pay-Platform.jar
0 → 100644
View file @
df5f03e0
File added
app/libs/mobile-pay-1.72.jar
deleted
100644 → 0
View file @
569947bb
File deleted
app/src/main/AndroidManifest.xml
View file @
df5f03e0
...
...
@@ -46,6 +46,9 @@
<activity
android:name=
".ui.RefundActivity"
android:theme=
"@style/Theme.MiYaFastCashier.Dark"
/>
<activity
android:name=
".ui.PayActivity"
android:theme=
"@style/Theme.MiYaFastCashier.Dark"
/>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
View file @
df5f03e0
...
...
@@ -4,10 +4,23 @@ import android.app.Activity
import
android.app.Application
import
android.content.Context
import
android.os.Bundle
import
android.util.Log
import
androidx.multidex.MultiDexApplication
import
com.elvishew.xlog.LogConfiguration
import
com.elvishew.xlog.LogLevel
import
com.elvishew.xlog.XLog
import
com.elvishew.xlog.printer.AndroidPrinter
import
com.elvishew.xlog.printer.ConsolePrinter
import
com.elvishew.xlog.printer.Printer
import
com.elvishew.xlog.printer.file.FilePrinter
import
com.elvishew.xlog.printer.file.backup.NeverBackupStrategy
import
com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
import
com.miya.fastcashier.utils.DateUtils
import
com.miya.print.PrinterManager
import
com.sdy.miya.moblie.component.pay.core.utils.PayLogFileUtils
import
com.tencent.mmkv.MMKV
import
java.io.File
import
java.util.*
class
BaseApplication
:
MultiDexApplication
()
{
override
fun
onCreate
()
{
...
...
@@ -16,20 +29,74 @@ class BaseApplication : MultiDexApplication() {
PrinterManager
.
getInstance
().
init
(
this
)
//屏幕适配
screenAdapt
()
MMKV
.
initialize
(
this
);
MMKV
.
initialize
(
this
)
//日志
logConfig
()
}
private
fun
logConfig
(){
XLog
.
init
(
LogLevel
.
ALL
);
val
config
=
LogConfiguration
.
Builder
()
.
logLevel
(
if
(
BuildConfig
.
DEBUG
)
LogLevel
.
ALL
// 指定日志级别,低于该级别的日志将不会被打印,默认为 LogLevel.ALL
else
LogLevel
.
NONE
)
.
enableThreadInfo
()
// 允许打印线程信息,默认禁止
.
build
()
val
androidPrinter
:
Printer
=
AndroidPrinter
(
true
)
// 通过 android.util.Log 打印日志的打印器
val
consolePrinter
:
Printer
=
ConsolePrinter
()
// 通过 System.out 打印日志到控制台的打印器
val
filePrinter
:
Printer
=
FilePrinter
.
Builder
(
applicationContext
.
getExternalFilesDir
(
null
)
!!
.
absolutePath
+
File
.
separator
+
"log"
)
// 指定保存日志文件的路径
.
fileNameGenerator
(
DateFileNameGenerator
())
// 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
.
backupStrategy
(
NeverBackupStrategy
())
// 指定日志文件备份策略,默认为 FileSizeBackupStrategy(1024 * 1024)
.
build
()
XLog
.
init
(
// 初始化 XLog
config
,
// 指定日志配置,如果不指定,会默认使用 new LogConfiguration.Builder().build()
androidPrinter
,
// 添加任意多的打印器。如果没有添加任何打印器,会默认使用 AndroidPrinter(Android)/ConsolePrinter(java)
consolePrinter
,
filePrinter
)
//支付日志文件夹
PayLogFileUtils
.
initLogPath
(
applicationContext
.
getExternalFilesDir
(
null
)
!!
.
absolutePath
+
File
.
separator
+
"payLog"
)
}
private
fun
screenAdapt
()
{
registerActivityLifecycleCallbacks
(
object
:
ActivityLifecycleCallbacks
{
override
fun
onActivityCreated
(
activity
:
Activity
,
savedInstanceState
:
Bundle
?)
{
setDensity
(
activity
,
this
@BaseApplication
)
XLog
.
d
(
DateUtils
.
format18
(
Date
())+
" onActivityCreated"
)
}
override
fun
onActivityStarted
(
activity
:
Activity
)
{
XLog
.
d
(
DateUtils
.
format18
(
Date
())+
" onActivityStarted"
)
}
override
fun
onActivityResumed
(
activity
:
Activity
)
{
XLog
.
d
(
DateUtils
.
format18
(
Date
())+
" onActivityResumed"
)
}
override
fun
onActivityPaused
(
activity
:
Activity
)
{
XLog
.
d
(
DateUtils
.
format18
(
Date
())+
" onActivityPaused"
)
}
override
fun
onActivityStopped
(
activity
:
Activity
)
{
XLog
.
d
(
DateUtils
.
format18
(
Date
())+
" onActivityStopped"
)
}
override
fun
onActivitySaveInstanceState
(
activity
:
Activity
,
outState
:
Bundle
)
{
XLog
.
d
(
DateUtils
.
format18
(
Date
())+
" onActivitySaveInstanceState"
)
}
override
fun
onActivityDestroyed
(
activity
:
Activity
)
{
XLog
.
d
(
DateUtils
.
format18
(
Date
())+
" onActivityDestroyed"
)
}
override
fun
onActivityStarted
(
activity
:
Activity
)
{}
override
fun
onActivityResumed
(
activity
:
Activity
)
{}
override
fun
onActivityPaused
(
activity
:
Activity
)
{}
override
fun
onActivityStopped
(
activity
:
Activity
)
{}
override
fun
onActivitySaveInstanceState
(
activity
:
Activity
,
outState
:
Bundle
)
{}
override
fun
onActivityDestroyed
(
activity
:
Activity
)
{}
})
}
...
...
app/src/main/java/com/miya/fastcashier/repository/PayRepository.kt
View file @
df5f03e0
...
...
@@ -2,14 +2,17 @@ package com.miya.fastcashier.repository
import
android.text.TextUtils
import
androidx.annotation.WorkerThread
import
com.blankj.utilcode.util.LogUtils
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.utils.DateUtils
import
com.sdy.miya.moblie.component.pay.core.constance.AppTagConstance
import
com.sdy.miya.moblie.component.pay.core.result.MiYaMobilePayResult
import
com.sdy.miya.moblie.component.pay.core.result.ResultBuilder
import
com.sdy.miya.moblie.component.pay.platform.MiYaPlatformPayService
import
com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import
java.lang.Exception
import
java.util.HashMap
import
java.text.SimpleDateFormat
import
java.util.*
/**
* 提供支付、退款的功能
...
...
@@ -20,39 +23,28 @@ object PayRepository {
* 支付功能
*/
@WorkerThread
fun
pay
(
params
:
Map
<
String
,
String
>):
PayServiceResponse
{
if
(
params
==
null
)
{
throw
RuntimeException
(
"MiyaPayServiceComponent startPay params is null"
)
}
val
baseUrl
=
params
[
"baseUrl"
]
val
payPrice
=
params
[
"payPrice"
]
val
payType
=
params
[
"payType"
]
val
token
=
params
[
"token"
]
val
goodsDetail
=
params
[
"goodsDetail"
]
val
signKey
=
params
[
"signKey"
]
val
saasid
=
params
[
"saasid"
]
val
marketid
=
params
[
"marketid"
]
val
posId
=
params
[
"posId"
]
val
cashierCode
=
params
[
"cashierCode"
]
val
version
=
params
[
"version"
]
val
orderNo
=
params
[
"orderNo"
]
val
memberPhone
=
params
[
"memberPhone"
]
var
terminalParams
=
params
[
"terminalParams"
]
val
paymentInfoShowMessage
=
params
[
"paymentInfoShowMessage"
]
checkNotNull
(
baseUrl
)
{
"MiyaPayServiceComponent startPay baseUrl is null"
}
checkNotNull
(
payPrice
)
{
"MiyaPayServiceComponent startPay payPrice is null"
}
checkNotNull
(
payType
)
{
"MiyaPayServiceComponent startPay payType is null"
}
checkNotNull
(
goodsDetail
)
{
"MiyaPayServiceComponent startPay goodsDetail is null"
}
checkNotNull
(
signKey
)
{
"MiyaPayServiceComponent startPay signKey is null"
}
checkNotNull
(
saasid
)
{
"MiyaPayServiceComponent startPay saasid is null"
}
checkNotNull
(
marketid
)
{
"MiyaPayServiceComponent startPay marketid is null"
}
checkNotNull
(
posId
)
{
"MiyaPayServiceComponent startPay posId is null"
}
checkNotNull
(
cashierCode
)
{
"MiyaPayServiceComponent startPay cashierCode is null"
}
checkNotNull
(
version
)
{
"MiyaPayServiceComponent startPay version is null"
}
checkNotNull
(
orderNo
)
{
"MiyaPayServiceComponent startPay oderNo is null"
}
fun
pay
(
orderNo
:
String
,
payPrice
:
String
,
token
:
String
,
payType
:
String
):
PayServiceResponse
{
val
shopInfo
=
AccountService
.
getAccountInfo
()
?.
shopInfo
val
baseUrl
=
shopInfo
?.
miyaPayPlatformUrl
;
val
signKey
=
shopInfo
?.
miyaPayPlatformSignKey
val
saasid
=
shopInfo
?.
saasid
val
marketid
=
shopInfo
?.
storeId
val
posId
=
shopInfo
?.
posId
val
cashierCode
=
shopInfo
?.
operatorId
val
version
=
"1.5"
checkNotNull
(
baseUrl
)
{
"startPay baseUrl is null"
}
checkNotNull
(
payPrice
)
{
"startPay payPrice is null"
}
checkNotNull
(
payType
)
{
"startPay payType is null"
}
checkNotNull
(
signKey
)
{
"startPay signKey is null"
}
checkNotNull
(
saasid
)
{
"startPay saasid is null"
}
checkNotNull
(
marketid
)
{
" startPay marketid is null"
}
checkNotNull
(
posId
)
{
" startPay posId is null"
}
checkNotNull
(
cashierCode
)
{
" startPay cashierCode is null"
}
checkNotNull
(
version
)
{
" startPay version is null"
}
checkNotNull
(
orderNo
)
{
" startPay oderNo is null"
}
val
paramsMap
:
MutableMap
<
String
,
Any
?>
=
HashMap
(
14
,
1.0f
)
paramsMap
[
"baseUrl"
]
=
baseUrl
...
...
@@ -63,7 +55,6 @@ object PayRepository {
paramsMap
[
"cashierCode"
]
=
cashierCode
paramsMap
[
"version"
]
=
version
paramsMap
[
"token"
]
=
token
paramsMap
[
"goodsDetail"
]
=
goodsDetail
paramsMap
[
"payPrice"
]
=
payPrice
paramsMap
[
"payType"
]
=
payType
paramsMap
[
"orderNo"
]
=
orderNo
...
...
@@ -165,8 +156,6 @@ object PayRepository {
checkNotNull
(
signKey
)
{
"signKey is null"
}
checkNotNull
(
saasid
)
{
"saasid is null"
}
checkNotNull
(
marketid
)
{
"marketid is null"
}
// checkNotNull(posId) { "posId is null" }
// checkNotNull(cashierCode) { "cashierCode is null" }
checkNotNull
(
orderNo
)
{
"orderNo is null"
}
val
paramsMap
:
MutableMap
<
String
,
Any
?>
=
HashMap
(
14
,
1.0f
)
...
...
@@ -180,6 +169,14 @@ object PayRepository {
paramsMap
[
"payPrice"
]
=
payPrice
paramsMap
[
"payType"
]
=
payType
paramsMap
[
"orderNo"
]
=
orderNo
paramsMap
[
"startTime"
]
=
DateUtils
.
format18
(
Date
())
var
date
=
Date
()
val
calendar
=
Calendar
.
getInstance
()
calendar
.
time
=
date
;
//过期时间设置为超过2个小时即为过期
calendar
.
add
(
Calendar
.
HOUR_OF_DAY
,
2
);
date
=
calendar
.
time
;
paramsMap
[
"expireTime"
]
=
DateUtils
.
format18
(
date
)
try
{
val
miYaMobilePayResult
=
...
...
app/src/main/java/com/miya/fastcashier/ui/AliPayCodeActivity.kt
View file @
df5f03e0
...
...
@@ -32,12 +32,12 @@ import com.tencent.mmkv.MMKV
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.runBlocking
import
java.util.*
import
kotlin.concurrent.timerTask
/***
* 支付宝付款码
*/
class
AliPayCodeActivity
:
AppCompatActivity
()
{
private
lateinit
var
viewModel
:
PayViewModel
private
lateinit
var
binding
:
ActivityAliPayCodeBinding
...
...
@@ -98,7 +98,6 @@ class AliPayCodeActivity : AppCompatActivity() {
}
}
})
}
override
fun
onStop
()
{
...
...
app/src/main/java/com/miya/fastcashier/ui/LoginActivity.kt
View file @
df5f03e0
...
...
@@ -78,7 +78,7 @@ class LoginActivity : AppCompatActivity() {
if
(
loginState
.
usernameError
!=
null
)
{
username
.
error
=
getString
(
loginState
.
usernameError
)
}
if
(
loginState
.
passwordError
!=
null
)
{
if
(
loginState
.
passwordError
!=
null
&&
!
TextUtils
.
isEmpty
(
password
.
text
)
)
{
password
.
error
=
getString
(
loginState
.
passwordError
)
}
})
...
...
app/src/main/java/com/miya/fastcashier/ui/PayActivity.kt
0 → 100644
View file @
df5f03e0
package
com.miya.fastcashier.ui
import
android.content.Intent
import
android.os.Bundle
import
android.view.KeyEvent
import
android.widget.Toast
import
androidx.lifecycle.ViewModelProvider
import
com.miya.fastcashier.databinding.ActivityPayBinding
import
com.miya.fastcashier.databinding.ActivityRefundBinding
import
com.miya.fastcashier.ui.dialog.MessageDialog
import
com.miya.fastcashier.ui.dialog.NumberManualDialog
import
com.miya.fastcashier.ui.dialog.NumberManualDialog.NumberInputListener
import
com.miya.fastcashier.ui.dialog.RefundInfoDialog
import
com.miya.fastcashier.utils.CenterToasty
import
com.miya.fastcashier.utils.DateUtils
import
com.miya.fastcashier.utils.ScanGunKeyEventHelper
import
com.miya.fastcashier.utils.clickWithTrigger
import
com.miya.fastcashier.viewmodel.PayViewModel
import
com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import
com.tencent.mmkv.MMKV
import
java.util.*
class
PayActivity
:
BaseActivity
()
{
private
lateinit
var
viewModel
:
PayViewModel
private
lateinit
var
binding
:
ActivityPayBinding
private
var
scanGunKeyEventHelper
:
ScanGunKeyEventHelper
=
ScanGunKeyEventHelper
()
private
lateinit
var
price
:
String
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
val
kv
=
MMKV
.
defaultMMKV
()
binding
=
ActivityPayBinding
.
inflate
(
layoutInflater
)
setContentView
(
binding
.
root
)
viewModel
=
ViewModelProvider
(
this
).
get
(
PayViewModel
::
class
.
java
)
price
=
intent
.
getStringExtra
(
"price"
).
toString
()
val
tvPayPrice
=
binding
.
tvPayPrice
tvPayPrice
.
text
=
"¥${price.toDouble()}"
viewModel
.
payResultLiveData
.
observe
(
this
,
{
payResult
->
dismissProgressDialog
()
payResult
.
onFailure
{
it
.
message
?.
let
{
it1
->
CenterToasty
.
error
(
this
,
it1
,
Toast
.
LENGTH_LONG
).
show
()
}
}
payResult
.
onSuccess
{
//自增流水
val
today
=
DateUtils
.
format8
(
Date
())
var
no
=
kv
.
getInt
(
today
,
0
);
kv
.
putInt
(
DateUtils
.
format8
(
Date
()),++
no
)
val
intent
=
Intent
()
intent
.
setClass
(
this
@PayActivity
,
PayResultActivity
::
class
.
java
)
intent
.
putExtra
(
"payServiceResponse"
,
it
)
startActivity
(
intent
)
}
})
val
tvBack
=
binding
.
tvBack
val
ivBack
=
binding
.
ivBack
tvBack
.
clickWithTrigger
{
finish
()
}
ivBack
.
clickWithTrigger
{
finish
()
}
scanGunKeyEventHelper
.
setOnBarCodeCatchListener
{
showProgressDialog
(
"正在支付.."
)
viewModel
.
pay
(
price
,
it
)
}
}
override
fun
dispatchKeyEvent
(
event
:
KeyEvent
?):
Boolean
{
scanGunKeyEventHelper
.
analysisKeyEvent
(
event
)
return
super
.
dispatchKeyEvent
(
event
)
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/ui/PriceInputActivity.kt
View file @
df5f03e0
...
...
@@ -35,11 +35,21 @@ class PriceInputActivity : BaseActivity() {
val
tvBack
=
binding
.
tvBack
val
ivBack
=
binding
.
ivBack
val
etPrice
=
binding
.
etPrice
// val loading = binding.loading
val
numKeyboard
=
binding
.
numKeyboard
tvScanPayCode
.
clickWithTrigger
{
CenterToasty
.
normal
(
this
,
"暂时不支持此功能"
,
Toast
.
LENGTH_SHORT
).
show
();
val
price
=
etPrice
.
text
if
(
TextUtils
.
isEmpty
(
price
)){
CenterToasty
.
error
(
this
,
"请输入金额!"
,
Toast
.
LENGTH_LONG
).
show
()
return
@clickWithTrigger
}
val
intent
=
Intent
()
intent
.
setClass
(
this
@PriceInputActivity
,
PayActivity
::
class
.
java
)
intent
.
putExtra
(
"price"
,
price
)
startActivity
(
intent
)
}
tvGeneratePayCode
.
clickWithTrigger
{
...
...
@@ -49,7 +59,6 @@ class PriceInputActivity : BaseActivity() {
GeneratePayCodeClickListener
{
override
fun
choose
(
payType
:
String
)
{
showProgressDialog
(
"生成付款码"
)
// loading.visibility = View.VISIBLE
viewModel
.
generatePayCode
(
etPrice
.
text
.
toString
(),
payType
)
}
})
...
...
@@ -80,7 +89,7 @@ class PriceInputActivity : BaseActivity() {
currentCode
+=
"."
etPrice
.
setText
(
currentCode
)
}
else
{
CenterToasty
.
error
(
this
,
"金额格式有误!"
,
Toast
.
LENGTH_
LONG
).
show
()
CenterToasty
.
error
(
this
,
"金额格式有误!"
,
Toast
.
LENGTH_
SHORT
).
show
()
}
}
else
->
{
...
...
@@ -90,23 +99,23 @@ class PriceInputActivity : BaseActivity() {
currentCode
.
substring
(
currentCode
.
indexOf
(
"."
),
currentCode
.
length
-
1
)
if
(
tmp
.
length
<
2
)
{
if
(
BigDecimal
(
currentCode
+
it
).
compareTo
(
BigDecimal
.
ZERO
)
==
0
&&
tmp
.
length
==
1
)
{
CenterToasty
.
error
(
this
,
"金额不能为0!"
,
Toast
.
LENGTH_
LONG
).
show
()
CenterToasty
.
error
(
this
,
"金额不能为0!"
,
Toast
.
LENGTH_
SHORT
).
show
()
}
else
{
currentCode
+=
it
etPrice
.
setText
(
currentCode
)
etPrice
.
text
=
currentCode
}
}
else
{
CenterToasty
.
error
(
this
,
"金额最多设置2位小数!"
,
Toast
.
LENGTH_
LONG
).
show
()
CenterToasty
.
error
(
this
,
"金额最多设置2位小数!"
,
Toast
.
LENGTH_
SHORT
).
show
()
}
}
else
{
if
(
currentCode
.
startsWith
(
"0"
)
&&
currentCode
.
length
==
1
&&
it
==
0
)
{
CenterToasty
.
error
(
this
,
"第二位不能输入0!"
,
Toast
.
LENGTH_
LONG
).
show
()
CenterToasty
.
error
(
this
,
"第二位不能输入0!"
,
Toast
.
LENGTH_
SHORT
).
show
()
}
else
{
if
(
BigDecimal
(
currentCode
+
it
).
compareTo
(
BigDecimal
(
"99999"
))
==
1
)
{
CenterToasty
.
error
(
this
,
"金额不能超过99999!"
,
Toast
.
LENGTH_
LONG
).
show
()
CenterToasty
.
error
(
this
,
"金额不能超过99999!"
,
Toast
.
LENGTH_
SHORT
).
show
()
}
else
{
currentCode
+=
it
etPrice
.
setText
(
currentCode
)
etPrice
.
text
=
currentCode
}
}
}
...
...
@@ -116,7 +125,6 @@ class PriceInputActivity : BaseActivity() {
viewModel
.
payServiceResponseLiveData
.
observe
(
this
,
{
result
->
dismissProgressDialog
()
// loading.visibility = View.GONE
result
.
getOrElse
{
it
.
message
?.
let
{
it1
->
CenterToasty
.
error
(
this
,
it1
,
Toast
.
LENGTH_LONG
).
show
()
}
...
...
app/src/main/java/com/miya/fastcashier/ui/dialog/NumberManualDialog.kt
View file @
df5f03e0
...
...
@@ -25,7 +25,7 @@ import java.math.BigDecimal
class
NumberManualDialog
(
context
:
Context
,
)
:
Dialog
(
context
)
{
private
lateinit
var
ivClose
:
ImageView
private
lateinit
var
etNumber
:
MaterialEditText
private
lateinit
var
etNumber
:
TextView
private
lateinit
var
tvErrInfo
:
TextView
private
lateinit
var
numKeyboard
:
NumKeyboard
private
lateinit
var
numInputFinish
:
Button
...
...
app/src/main/java/com/miya/fastcashier/viewmodel/PayViewModel.kt
View file @
df5f03e0
...
...
@@ -7,12 +7,14 @@ import androidx.lifecycle.viewModelScope
import
com.alibaba.fastjson.JSON
import
com.blankj.utilcode.util.LogUtils
import
com.blankj.utilcode.util.NumberUtils
import
com.elvishew.xlog.XLog
import
com.miya.fastcashier.beans.LoginRequest
import
com.miya.fastcashier.beans.SelfCashierAccountInfo
import
com.miya.fastcashier.repository.PayRepository
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.service.LoginService
import
com.miya.fastcashier.service.PrintService
import
com.miya.fastcashier.utils.DateUtils
import
com.sdy.miya.moblie.component.pay.core.error.ParamInvalidException
import
com.sdy.miya.moblie.component.pay.platform.bean.MiyaOrderRefundResponse
import
com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
...
...
@@ -29,9 +31,8 @@ class PayViewModel : ViewModel() {
val
payServiceResponseLiveData
:
MutableLiveData
<
Result
<
PayServiceResponse
>>
=
MutableLiveData
()
val
payResultLiveData
:
MutableLiveData
<
Result
<
PayServiceResponse
>>
=
MutableLiveData
()
fun
refund
(
payServiceResponse
:
PayServiceResponse
)
{
XLog
.
d
(
"开始退款:${JSON.toJSONString(payServiceResponse)}"
)
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
//退款
var
refundPayServiceResponse
:
PayServiceResponse
?
=
null
...
...
@@ -43,12 +44,15 @@ class PayViewModel : ViewModel() {
refundParams
[
"refundPrice"
]
=
payServiceResponse
.
tradPrice
;
refundPayServiceResponse
=
PayRepository
.
refundByOrderNo
(
refundParams
)
refundLiveData
.
postValue
(
Result
.
success
(
refundPayServiceResponse
))
XLog
.
d
(
"退款成功:${JSON.toJSONString(refundPayServiceResponse)}"
)
}
catch
(
e
:
Exception
)
{
XLog
.
d
(
"退款异常:${e.message}"
)
refundLiveData
.
postValue
(
Result
.
failure
(
e
))
}
//退款打印
try
{
XLog
.
d
(
"开始退款打印"
)
AccountService
.
getAccountInfo
()
?.
let
{
refundPayServiceResponse
?.
let
{
it1
->
PrintService
.
refundPrint
(
it
,
...
...
@@ -56,6 +60,7 @@ class PayViewModel : ViewModel() {
)
}
}
}
catch
(
e
:
Exception
){
XLog
.
d
(
"退款打印异常${e.message}"
)
refundLiveData
.
postValue
(
Result
.
failure
(
e
))
}
...
...
@@ -69,6 +74,7 @@ class PayViewModel : ViewModel() {
* price 传进来要是分,整数
*/
fun
generatePayCode
(
price
:
String
,
payType
:
String
)
{
XLog
.
d
(
"开始生成主扫码"
)
if
(
TextUtils
.
isEmpty
(
price
))
{
payServiceResponseLiveData
.
value
=
Result
.
failure
(
ParamInvalidException
(
"请输入金额!"
))
return
...
...
@@ -83,15 +89,16 @@ class PayViewModel : ViewModel() {
}
val
sassid
=
AccountService
.
getAccountInfo
()
?.
shopInfo
?.
saasid
// val storeId = AccountService.getAccountInfo()?.shopInfo?.storeId
val
orderNo
=
sassid
+
System
.
currentTimeMillis
()
XLog
.
d
(
"主扫码订单号${orderNo}"
)
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
try
{
val
payServiceResponse
=
PayRepository
.
generatePayCode
(
orderNo
,
priceFen
,
payType
)
LogUtils
.
e
(
"生成付款码:${JSON.toJSONString(payServiceResponse)}"
)
payServiceResponseLiveData
.
postValue
(
Result
.
success
(
payServiceResponse
))
XLog
.
d
(
"生成付款码成功${JSON.toJSONString(payServiceResponse)}"
)
}
catch
(
e
:
Exception
)
{
XLog
.
d
(
"生成付款码异常${e.message}"
)
payServiceResponseLiveData
.
postValue
(
Result
.
failure
(
e
))
}
}
...
...
@@ -105,12 +112,13 @@ class PayViewModel : ViewModel() {
payResultJob
=
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
while
(
isActive
)
{
try
{
LogUtils
.
e
(
"支付查询订单号:${payServiceResponse.shopTradeNo}"
)
XLog
.
d
(
"支付查询订单号:${payServiceResponse.shopTradeNo}"
)
val
payServiceResponseResult
=
PayRepository
.
payResultQuery
(
payServiceResponse
.
shopTradeNo
)
LogUtils
.
e
(
"支付查询结果:${JSON.toJSONString(payServiceResponseResult)}"
)
XLog
.
d
(
"支付查询结果:${JSON.toJSONString(payServiceResponseResult)}"
)
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponseResult
))
break
}
catch
(
e
:
Exception
)
{
XLog
.
d
(
"支付查询异常:${e.message}"
)
e
.
printStackTrace
()
payResultLiveData
.
postValue
(
Result
.
failure
(
e
))
Thread
.
sleep
(
5000
)
...
...
@@ -126,14 +134,57 @@ class PayViewModel : ViewModel() {
fun
payResultQuery
(
orderNo
:
String
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
){
try
{
LogUtils
.
e
(
"退款支付查询订单号
:${orderNo}"
)
XLog
.
d
(
"开始退款支付查询
:${orderNo}"
)
val
payServiceResponseResult
=
PayRepository
.
payResultQuery
(
orderNo
)
LogUtils
.
e
(
"退款支付查询结果
:${JSON.toJSONString(payServiceResponseResult)}"
)
XLog
.
d
(
"退款支付查询成功
:${JSON.toJSONString(payServiceResponseResult)}"
)
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponseResult
))
}
catch
(
e
:
Exception
)
{
XLog
.
d
(
"退款支付查询异常:${e.message}"
)
payResultLiveData
.
postValue
(
Result
.
failure
(
e
))
}
}
}
/**
* 金额是元,首先要转成分
*/
fun
pay
(
price
:
String
,
payCode
:
String
){
XLog
.
d
(
"被扫开始"
)
if
(
TextUtils
.
isEmpty
(
price
))
{
payResultLiveData
.
value
=
Result
.
failure
(
ParamInvalidException
(
"请输入金额!"
))
return
}
if
(
TextUtils
.
isEmpty
(
payCode
))
{
payResultLiveData
.
value
=
Result
.
failure
(
ParamInvalidException
(
"付款码为空!"
))
return
}
val
priceFen
:
String
try
{
priceFen
=
price
.
toDouble
().
times
(
100
).
toInt
().
toString
()
}
catch
(
e
:
java
.
lang
.
Exception
)
{
payResultLiveData
.
value
=
Result
.
failure
(
ParamInvalidException
(
"金额有误!"
))
return
}
val
sassid
=
AccountService
.
getAccountInfo
()
?.
shopInfo
?.
saasid
val
orderNo
=
sassid
+
System
.
currentTimeMillis
()
XLog
.
d
(
"被扫参数 orderNo = ${orderNo} price = ${priceFen} payCode = ${payCode}"
)
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
try
{
//0代表不分类别付款
val
payServiceResponse
=
PayRepository
.
pay
(
orderNo
,
priceFen
,
payCode
,
"0"
)
payResultLiveData
.
postValue
(
Result
.
success
(
payServiceResponse
))
XLog
.
d
(
"被扫支付成功${JSON.toJSONString(payServiceResponse)}"
)
}
catch
(
e
:
Exception
)
{
payResultLiveData
.
postValue
(
Result
.
failure
(
e
))
XLog
.
d
(
"被扫支付异常${JSON.toJSONString(e.message)}"
)
}
}
}
}
\ No newline at end of file
app/src/main/res/layout/activity_ali_pay_code.xml
View file @
df5f03e0
...
...
@@ -8,6 +8,7 @@
android:background=
"@color/blue"
android:focusable=
"true"
android:focusableInTouchMode=
"true"
android:keepScreenOn=
"true"
tools:context=
".ui.PriceInputActivity"
>
<TextView
...
...
@@ -92,7 +93,7 @@
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"44dp"
android:textColor=
"#878E9D"
android:text=
"请在
1分钟
内扫描二维码付款"
android:text=
"请在
2个小时
内扫描二维码付款"
android:textSize=
"24sp"
/>
<ImageView
...
...
app/src/main/res/layout/activity_pay.xml
0 → 100644
View file @
df5f03e0
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/colorPrimary"
android:focusable=
"true"
android:focusableInTouchMode=
"true"
tools:context=
".ui.PriceInputActivity"
>
<TextView
android:id=
"@+id/tvBack"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"60dp"
android:layout_marginLeft=
"60dp"
android:layout_marginTop=
"32dp"
android:text=
"@string/back"
android:textColor=
"@color/white"
android:textSize=
"24sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<ImageView
android:id=
"@+id/ivBack"
android:layout_width=
"24dp"
android:layout_height=
"48dp"
android:contentDescription=
"@string/back"
android:padding=
"6dp"
android:src=
"@mipmap/ic_left_arrow"
app:layout_constraintBottom_toBottomOf=
"@+id/tvBack"
app:layout_constraintEnd_toStartOf=
"@+id/tvBack"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/tvBack"
/>
<ImageView
android:layout_width=
"195dp"
android:layout_height=
"20dp"
android:layout_marginEnd=
"32dp"
android:layout_marginRight=
"32dp"
android:src=
"@mipmap/ic_logo_white"
app:layout_constraintBottom_toBottomOf=
"@+id/tvBack"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/tvBack"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_marginTop=
"87dp"
android:background=
"@color/white"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
android:id=
"@+id/tvScanGuide"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"148dp"
android:text=
"请长按唤起红外扫描订单条码"
android:textColor=
"#141C30"
android:textSize=
"36sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/tvPayPriceHint"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"281dp"
android:text=
"收款金额"
android:textColor=
"#141C30"
android:layout_marginEnd=
"5dp"
android:textSize=
"32sp"
app:layout_constraintEnd_toStartOf=
"@+id/guideline"
app:layout_constraintTop_toTopOf=
"parent"
android:layout_marginRight=
"5dp"
/>
<TextView
android:id=
"@+id/tvPayPrice"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"273dp"
android:text=
"¥98.5"
android:textColor=
"#141C30"
android:layout_marginStart=
"5dp"
android:textSize=
"48sp"
android:textStyle=
"bold"
app:layout_constraintStart_toEndOf=
"@id/guideline"
app:layout_constraintTop_toTopOf=
"parent"
android:layout_marginLeft=
"5dp"
/>
<ImageView
android:layout_width=
"541dp"
android:layout_height=
"386dp"
android:layout_marginTop=
"46dp"
android:src=
"@mipmap/app_refund_code_scan_guide"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/tvPayPrice"
/>
<androidx.constraintlayout.widget.Guideline
android:id=
"@+id/guideline"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
app:layout_constraintGuide_begin=
"360dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_price_input.xml
View file @
df5f03e0
...
...
@@ -81,13 +81,13 @@
android:background=
"#89889A"
android:layout_marginLeft=
"32dp"
/>
<
com.rengwuxian.materialedittext.MaterialEditText
<
TextView
android:id=
"@+id/etPrice"
android:layout_width=
"591dp"
android:layout_height=
"wrap_content"
android:hint=
"输入收款金额"
a
pp:met_textColorHint=
"#89889A
"
a
pp:met_textColor=
"@color/white
"
a
ndroid:textColor=
"@color/white
"
a
ndroid:textColorHint=
"#89889A
"
android:textAlignment=
"textEnd"
android:textSize=
"47sp"
android:paddingTop=
"5dp"
...
...
app/src/main/res/layout/activity_wx_pay_code.xml
View file @
df5f03e0
...
...
@@ -7,6 +7,7 @@
android:id=
"@+id/cPayCodeBg"
android:background=
"@color/green"
android:focusable=
"true"
android:keepScreenOn=
"true"
android:focusableInTouchMode=
"true"
tools:context=
".ui.PriceInputActivity"
>
...
...
@@ -92,7 +93,7 @@
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"44dp"
android:textColor=
"#878E9D"
android:text=
"请在
1分钟
内扫描二维码付款"
android:text=
"请在
2个小时
内扫描二维码付款"
android:textSize=
"24sp"
/>
<ImageView
...
...
app/src/main/res/layout/dialog_number_input.xml
View file @
df5f03e0
...
...
@@ -32,7 +32,7 @@
android:layout_marginRight=
"38dp"
/>
<
com.rengwuxian.materialedittext.MaterialEditText
<
TextView
android:id=
"@+id/etNumber"
android:layout_width=
"510dp"
android:layout_height=
"wrap_content"
...
...
@@ -40,14 +40,26 @@
android:layout_marginStart=
"46dp"
android:layout_marginEnd=
"46dp"
android:hint=
"请输入"
android:textColorHint=
"#C8C7CC"
android:gravity=
"center_horizontal"
android:textSize=
"36sp"
android:
inputType=
"textEmailAddress
"
android:
textColor=
"#141C30
"
android:selectAllOnFocus=
"true"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
app:layout_constraintStart_toStartOf=
"@+id/numKeyboard"
app:layout_constraintEnd_toEndOf=
"@+id/numKeyboard"
android:layout_marginTop=
"12dp"
android:layout_marginLeft=
"105dp"
android:layout_marginRight=
"105dp"
android:background=
"#E6E9EF"
app:layout_constraintTop_toBottomOf=
"@+id/etNumber"
/>
<TextView
android:id=
"@+id/tvErrInfo"
android:layout_width=
"wrap_content"
...
...
fastcashier.jks
0 → 100644
View file @
df5f03e0
File added
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