Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Y
YPPos
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
朱世闯
YPPos
Commits
197c8c9d
Commit
197c8c9d
authored
Nov 12, 2021
by
UIUANG\Zsc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加现金支付
parent
e9bb0e8b
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
947 additions
and
105 deletions
+947
-105
gradle.xml
.idea/gradle.xml
+1
-1
misc.xml
.idea/misc.xml
+16
-0
runConfigurations.xml
.idea/runConfigurations.xml
+0
-10
build.gradle
app/build.gradle
+2
-2
output-metadata.json
app/release/output-metadata.json
+3
-3
yppos_v100007-1.00.007-release-2021-11-11.apk
app/release/yppos_v100007-1.00.007-release-2021-11-11.apk
+0
-0
CashPaySuccess.kt
...main/java/com/ypsx/yppos/http/data/bean/CashPaySuccess.kt
+8
-0
OrderPayment.kt
...c/main/java/com/ypsx/yppos/http/data/bean/OrderPayment.kt
+7
-0
UploadOrderResponse.kt
...java/com/ypsx/yppos/http/data/bean/UploadOrderResponse.kt
+1
-0
PosPayMethod.kt
...main/java/com/ypsx/yppos/http/data/entity/PosPayMethod.kt
+1
-1
InsertOrderRequest.kt
...va/com/ypsx/yppos/http/data/request/InsertOrderRequest.kt
+6
-3
HttpRequestManger.kt
...m/ypsx/yppos/http/repository/request/HttpRequestManger.kt
+16
-7
LogService.kt
app/src/main/java/com/ypsx/yppos/jobs/LogService.kt
+2
-2
SyncProductService.kt
app/src/main/java/com/ypsx/yppos/jobs/SyncProductService.kt
+2
-1
MainActivity.kt
app/src/main/java/com/ypsx/yppos/ui/activity/MainActivity.kt
+87
-35
CashPayPopupWindow.kt
...c/main/java/com/ypsx/yppos/ui/popup/CashPayPopupWindow.kt
+131
-0
CashPaySuccessPopWindow.kt
...n/java/com/ypsx/yppos/ui/popup/CashPaySuccessPopWindow.kt
+84
-0
OrderPayAmountPopupWindow.kt
...java/com/ypsx/yppos/ui/popup/OrderPayAmountPopupWindow.kt
+22
-9
CashierInputFilter.java
...rc/main/java/com/ypsx/yppos/utils/CashierInputFilter.java
+88
-0
PrintUtils.kt
app/src/main/java/com/ypsx/yppos/utils/PrintUtils.kt
+35
-16
RequestMainViewModel.kt
.../com/ypsx/yppos/viewmodel/request/RequestMainViewModel.kt
+35
-13
CashPayViewModel.kt
...n/java/com/ypsx/yppos/viewmodel/state/CashPayViewModel.kt
+22
-0
OrderPayAmountViewModel.kt
...com/ypsx/yppos/viewmodel/state/OrderPayAmountViewModel.kt
+37
-2
PaySuccessViewModel.kt
...ava/com/ypsx/yppos/viewmodel/state/PaySuccessViewModel.kt
+2
-0
btn_confirm_bg.xml
app/src/main/res/drawable/btn_confirm_bg.xml
+5
-0
edit_bg.xml
app/src/main/res/drawable/edit_bg.xml
+5
-0
popup_cash_pay.xml
app/src/main/res/layout/popup_cash_pay.xml
+155
-0
popup_cash_pay_success.xml
app/src/main/res/layout/popup_cash_pay_success.xml
+156
-0
popup_order_pay_amount.xml
app/src/main/res/layout/popup_order_pay_amount.xml
+17
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
.idea/gradle.xml
View file @
197c8c9d
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<component
name=
"GradleSettings"
>
<component
name=
"GradleSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<GradleProjectSettings>
<GradleProjectSettings>
<option
name=
"testRunner"
value=
"
PLATFORM
"
/>
<option
name=
"testRunner"
value=
"
GRADLE
"
/>
<option
name=
"distributionType"
value=
"DEFAULT_WRAPPED"
/>
<option
name=
"distributionType"
value=
"DEFAULT_WRAPPED"
/>
<option
name=
"externalProjectPath"
value=
"$PROJECT_DIR$"
/>
<option
name=
"externalProjectPath"
value=
"$PROJECT_DIR$"
/>
<option
name=
"gradleHome"
value=
"$USER_HOME$/.gradle/wrapper/dists/gradle-6.1.1-all/cfmwm155h49vnt3hynmlrsdst/gradle-6.1.1"
/>
<option
name=
"gradleHome"
value=
"$USER_HOME$/.gradle/wrapper/dists/gradle-6.1.1-all/cfmwm155h49vnt3hynmlrsdst/gradle-6.1.1"
/>
...
...
.idea/misc.xml
View file @
197c8c9d
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"DesignSurface"
>
<option
name=
"filePathToZoomLevelMap"
>
<map>
<entry
key=
"..\:/AndroidProject/YPPos/app/src/main/res/drawable/bg_popup_offer_details.xml"
value=
"0.3508682328907048"
/>
<entry
key=
"..\:/AndroidProject/YPPos/app/src/main/res/drawable/btn_confirm_bg.xml"
value=
"0.3508682328907048"
/>
<entry
key=
"..\:/AndroidProject/YPPos/app/src/main/res/drawable/edit_bg.xml"
value=
"0.3508682328907048"
/>
<entry
key=
"..\:/AndroidProject/YPPos/app/src/main/res/layout/activity_login.xml"
value=
"0.16347124117053483"
/>
<entry
key=
"..\:/AndroidProject/YPPos/app/src/main/res/layout/activity_main.xml"
value=
"0.16347124117053483"
/>
<entry
key=
"..\:/AndroidProject/YPPos/app/src/main/res/layout/activity_register.xml"
value=
"0.16347124117053483"
/>
<entry
key=
"..\:/AndroidProject/YPPos/app/src/main/res/layout/popup_cash_pay.xml"
value=
"0.33"
/>
<entry
key=
"..\:/AndroidProject/YPPos/app/src/main/res/layout/popup_cash_pay_success.xml"
value=
"0.33"
/>
<entry
key=
"..\:/AndroidProject/YPPos/app/src/main/res/layout/popup_order_pay_amount.xml"
value=
"0.16347124117053483"
/>
<entry
key=
"..\:/AndroidProject/YPPos/app/src/main/res/layout/popup_pay_success.xml"
value=
"0.16347124117053483"
/>
</map>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_11"
default=
"true"
project-jdk-name=
"11"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_11"
default=
"true"
project-jdk-name=
"11"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
</component>
...
...
.idea/runConfigurations.xml
deleted
100644 → 0
View file @
e9bb0e8b
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"RunConfigurationProducerService"
>
<option
name=
"ignoredProducers"
>
<set>
<option
value=
"com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer"
/>
</set>
</option>
</component>
</project>
\ No newline at end of file
app/build.gradle
View file @
197c8c9d
...
@@ -15,8 +15,8 @@ android {
...
@@ -15,8 +15,8 @@ android {
applicationId
"com.ypsx.yppos"
applicationId
"com.ypsx.yppos"
minSdkVersion
21
minSdkVersion
21
targetSdkVersion
30
targetSdkVersion
30
versionCode
10000
6
versionCode
10000
7
versionName
"1.00.00
6
"
versionName
"1.00.00
7
"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
}
}
...
...
app/release/output-metadata.json
View file @
197c8c9d
...
@@ -10,9 +10,9 @@
...
@@ -10,9 +10,9 @@
{
{
"type"
:
"SINGLE"
,
"type"
:
"SINGLE"
,
"filters"
:
[],
"filters"
:
[],
"versionCode"
:
10000
6
,
"versionCode"
:
10000
7
,
"versionName"
:
"1.00.00
6
"
,
"versionName"
:
"1.00.00
7
"
,
"outputFile"
:
"yppos_v10000
6-1.00.006-release-2021-11-0
1.apk"
"outputFile"
:
"yppos_v10000
7-1.00.007-release-2021-11-1
1.apk"
}
}
]
]
}
}
\ No newline at end of file
app/release/yppos_v10000
6-1.00.006-release-2021-11-0
1.apk
→
app/release/yppos_v10000
7-1.00.007-release-2021-11-1
1.apk
View file @
197c8c9d
No preview for this file type
app/src/main/java/com/ypsx/yppos/http/data/bean/CashPaySuccess.kt
0 → 100644
View file @
197c8c9d
package
com.ypsx.yppos.http.data.bean
data class
CashPaySuccess
(
var
payAmount
:
Double
,
var
changeAmount
:
Double
,
var
roundPrice
:
Double
,
var
orderNo
:
String
)
app/src/main/java/com/ypsx/yppos/http/data/bean/OrderPayment.kt
0 → 100644
View file @
197c8c9d
package
com.ypsx.yppos.http.data.bean
data class
OrderPayment
(
var
payMethod
:
String
,
var
payTime
:
String
,
var
total
:
Double
=
0.00
,
)
app/src/main/java/com/ypsx/yppos/http/data/bean/UploadOrderResponse.kt
View file @
197c8c9d
...
@@ -15,5 +15,6 @@ data class UploadOrderResponse(
...
@@ -15,5 +15,6 @@ data class UploadOrderResponse(
var
total
:
Double
,
var
total
:
Double
,
var
authCode
:
String
,
var
authCode
:
String
,
var
payMethod
:
String
,
)
)
app/src/main/java/com/ypsx/yppos/http/data/entity/PosPayMethod.kt
View file @
197c8c9d
...
@@ -4,7 +4,7 @@ enum class PosPayMethod {
...
@@ -4,7 +4,7 @@ enum class PosPayMethod {
CARDPAY
,
CARDPAY
,
//扫码聚合支付
//扫码聚合支付
CCB_BAR_PAY
,
CCB_BAR_PAY
,
CASHPAY
,
CASHPAY
,
//现金结算
UNIONPAY_POS
,
UNIONPAY_POS
,
//扫码
//扫码
OFFLINE_QRCODE_PAY
,
OFFLINE_QRCODE_PAY
,
...
...
app/src/main/java/com/ypsx/yppos/http/data/request/InsertOrderRequest.kt
View file @
197c8c9d
...
@@ -2,6 +2,7 @@ package com.ypsx.yppos.http.data.request
...
@@ -2,6 +2,7 @@ package com.ypsx.yppos.http.data.request
import
com.ypsx.yppos.http.data.bean.InsertOrderProductDTO
import
com.ypsx.yppos.http.data.bean.InsertOrderProductDTO
import
com.ypsx.yppos.http.data.bean.OrderActivityResponse
import
com.ypsx.yppos.http.data.bean.OrderActivityResponse
import
com.ypsx.yppos.http.data.bean.OrderPayment
data class
InsertOrderRequest
(
data class
InsertOrderRequest
(
var
activitys
:
List
<
OrderActivityResponse
>?
=
null
,
var
activitys
:
List
<
OrderActivityResponse
>?
=
null
,
...
@@ -19,7 +20,7 @@ data class InsertOrderRequest(
...
@@ -19,7 +20,7 @@ data class InsertOrderRequest(
var
posId
:
String
,
var
posId
:
String
,
var
storeId
:
String
,
var
storeId
:
String
,
var
status
:
String
,
var
status
:
String
,
var
roundPrice
:
Double
=
0.0
,
var
roundPrice
:
Double
=
0.0
,
//舍分金额
var
remark
:
String
?
=
null
,
var
remark
:
String
?
=
null
,
var
products
:
List
<
InsertOrderProductDTO
>,
var
products
:
List
<
InsertOrderProductDTO
>,
...
@@ -33,7 +34,9 @@ data class InsertOrderRequest(
...
@@ -33,7 +34,9 @@ data class InsertOrderRequest(
// 订单实际支付的金额=totalAmount-discountTotal
// 订单实际支付的金额=totalAmount-discountTotal
var
payAmount
:
Double
,
var
payAmount
:
Double
,
//找零金额
//找零金额
var
changeAmount
:
Double
=
0.0
,
var
changeAmount
:
Double
=
0.0
,
//找零金额
var
payments
:
List
<
OrderPayment
>?
=
null
)
)
app/src/main/java/com/ypsx/yppos/http/repository/request/HttpRequestManger.kt
View file @
197c8c9d
...
@@ -31,12 +31,14 @@ class HttpRequestManger {
...
@@ -31,12 +31,14 @@ class HttpRequestManger {
* 申请注册
* 申请注册
*/
*/
suspend
fun
applyPos
(
applyPosMachineRequest
:
ApplyPosMachineRequest
):
ApiResponse
<
PosMachineResponse
>
{
suspend
fun
applyPos
(
applyPosMachineRequest
:
ApplyPosMachineRequest
):
ApiResponse
<
PosMachineResponse
>
{
//清除数据
CacheUtil
.
setUpdateTimeBigger
(
""
)
CacheUtil
.
setUpdateTimeBigger
(
""
)
CacheUtil
.
setLoginResponse
(
null
)
CacheUtil
.
setLoginResponse
(
null
)
PosDatabase
.
clearAllTables
()
PosDatabase
.
clearAllTables
()
val
applyPosData
=
apiService
.
applyPos
(
applyPosMachineRequest
)
val
applyPosData
=
apiService
.
applyPos
(
applyPosMachineRequest
)
if
(
applyPosData
.
isSuccess
())
{
if
(
applyPosData
.
isSuccess
())
{
val
id
=
applyPosData
.
data
val
id
=
applyPosData
.
data
//根据POS机Id查询POS机详情
return
apiService
.
getById
(
id
)
return
apiService
.
getById
(
id
)
}
else
{
}
else
{
//抛出错误异常
//抛出错误异常
...
@@ -53,6 +55,7 @@ class HttpRequestManger {
...
@@ -53,6 +55,7 @@ class HttpRequestManger {
return
if
(
registerData
.
isSuccess
())
{
return
if
(
registerData
.
isSuccess
())
{
val
posId
=
registerData
.
data
.
id
val
posId
=
registerData
.
data
.
id
val
status
=
registerData
.
data
.
status
val
status
=
registerData
.
data
.
status
//如果在申请中,延时2秒继续获取详情
if
(
status
==
PosStatus
.
APPLY
.
name
)
{
if
(
status
==
PosStatus
.
APPLY
.
name
)
{
delay
(
2000
)
delay
(
2000
)
getById
(
posId
)
getById
(
posId
)
...
@@ -63,9 +66,6 @@ class HttpRequestManger {
...
@@ -63,9 +66,6 @@ class HttpRequestManger {
}
else
{
}
else
{
throw
AppException
(
registerData
.
code
,
registerData
.
message
)
throw
AppException
(
registerData
.
code
,
registerData
.
message
)
}
}
//抛出错误异常
// throw AppException(registerData.code, registerData.message)
}
}
/**
/**
...
@@ -81,17 +81,20 @@ class HttpRequestManger {
...
@@ -81,17 +81,20 @@ class HttpRequestManger {
val
loginData
=
apiService
.
posLogin
(
loginRequest
)
val
loginData
=
apiService
.
posLogin
(
loginRequest
)
if
(
loginData
.
isSuccess
())
{
if
(
loginData
.
isSuccess
())
{
val
data
=
loginData
.
data
val
data
=
loginData
.
data
//保存登录信息
CacheUtil
.
setLoginResponse
(
data
)
CacheUtil
.
setLoginResponse
(
data
)
val
posConfigData
=
apiService
.
getByPosId
(
posId
)
val
posConfigData
=
apiService
.
getByPosId
(
posId
)
if
(
posConfigData
.
isSuccess
())
{
if
(
posConfigData
.
isSuccess
())
{
val
configData
=
posConfigData
.
data
val
configData
=
posConfigData
.
data
//保存到数据库
PosConfigRepository
.
getInstance
().
savePosConfig
(
posId
,
configData
)
PosConfigRepository
.
getInstance
().
savePosConfig
(
posId
,
configData
)
val
askTime
=
CacheUtil
.
getUpdateTimeBigger
()
val
askTime
=
CacheUtil
.
getUpdateTimeBigger
()
val
currentTime
=
DateUtil
.
getTodayDateTime
()
val
currentTime
=
DateUtil
.
getTodayDateTime
()
//增量获取商品信息
val
productList
=
apiService
.
getProductList
(
storeId
,
askTime
)
val
productList
=
apiService
.
getProductList
(
storeId
,
askTime
)
if
(
productList
.
isSuccess
())
{
if
(
productList
.
isSuccess
())
{
PosProductRepository
.
getInstance
().
insertAll
(
productList
.
data
)
PosProductRepository
.
getInstance
().
insertAll
(
productList
.
data
)
//更新时间
CacheUtil
.
setUpdateTimeBigger
(
currentTime
)
CacheUtil
.
setUpdateTimeBigger
(
currentTime
)
return
loginData
return
loginData
}
else
{
}
else
{
...
@@ -115,6 +118,7 @@ class HttpRequestManger {
...
@@ -115,6 +118,7 @@ class HttpRequestManger {
payMethod
:
PosPayMethod
payMethod
:
PosPayMethod
):
UploadOrderResponse
{
):
UploadOrderResponse
{
val
list
=
arrayListOf
(
insertOrderRequest
)
val
list
=
arrayListOf
(
insertOrderRequest
)
//上传订单
val
uploadOrderData
=
apiService
.
uploadOrder
(
list
)
val
uploadOrderData
=
apiService
.
uploadOrder
(
list
)
if
(
uploadOrderData
.
isSuccess
())
{
if
(
uploadOrderData
.
isSuccess
())
{
...
@@ -123,6 +127,10 @@ class HttpRequestManger {
...
@@ -123,6 +127,10 @@ class HttpRequestManger {
val
data
=
uploadData
[
0
]
val
data
=
uploadData
[
0
]
val
success
=
data
.
success
val
success
=
data
.
success
if
(
success
)
{
if
(
success
)
{
if
(
payMethod
==
PosPayMethod
.
CASHPAY
)
{
data
.
payMethod
=
payMethod
.
name
return
data
}
var
cardPayPassword
:
String
?
=
null
var
cardPayPassword
:
String
?
=
null
if
(
payMethod
==
PosPayMethod
.
CARDPAY
)
{
if
(
payMethod
==
PosPayMethod
.
CARDPAY
)
{
cardPayPassword
=
""
cardPayPassword
=
""
...
@@ -135,10 +143,12 @@ class HttpRequestManger {
...
@@ -135,10 +143,12 @@ class HttpRequestManger {
total
=
insertOrderRequest
.
payAmount
,
total
=
insertOrderRequest
.
payAmount
,
cardPayPassword
=
cardPayPassword
cardPayPassword
=
cardPayPassword
)
)
//获得对应的支付订单签名
val
cashPaySignData
=
apiService
.
getCashPaySign
(
unifiedCashPaySignRequest
)
val
cashPaySignData
=
apiService
.
getCashPaySign
(
unifiedCashPaySignRequest
)
if
(
cashPaySignData
.
isSuccess
())
{
if
(
cashPaySignData
.
isSuccess
())
{
data
.
total
=
insertOrderRequest
.
payAmount
data
.
total
=
insertOrderRequest
.
payAmount
data
.
authCode
=
authCode
data
.
authCode
=
authCode
data
.
payMethod
=
payMethod
.
name
return
data
return
data
}
else
{
}
else
{
throw
AppException
(
cashPaySignData
.
code
,
cashPaySignData
.
getResponseMsg
())
throw
AppException
(
cashPaySignData
.
code
,
cashPaySignData
.
getResponseMsg
())
...
@@ -195,6 +205,7 @@ class HttpRequestManger {
...
@@ -195,6 +205,7 @@ class HttpRequestManger {
replyCommand
(
commandResponse
.
id
)
replyCommand
(
commandResponse
.
id
)
val
startTime
=
System
.
currentTimeMillis
()
val
startTime
=
System
.
currentTimeMillis
()
when
(
commandResponse
.
type
)
{
when
(
commandResponse
.
type
)
{
//上传日志文件
PosCommandType
.
UPLOAD_LOG
.
name
->
{
PosCommandType
.
UPLOAD_LOG
.
name
->
{
//压缩文件
//压缩文件
var
todayDate
=
DateUtil
.
getTodayDate
()
var
todayDate
=
DateUtil
.
getTodayDate
()
...
@@ -213,13 +224,11 @@ class HttpRequestManger {
...
@@ -213,13 +224,11 @@ class HttpRequestManger {
var
millis
=
System
.
currentTimeMillis
()
-
currentTimeMillis
var
millis
=
System
.
currentTimeMillis
()
-
currentTimeMillis
LogUtils
.
debugInfo
(
"压缩使用${millis}s"
)
LogUtils
.
debugInfo
(
"压缩使用${millis}s"
)
// zipFile(upLoadUrl,zipUrl)
// zipUrl.dXLog()
saveCommand
(
zipUrl
,
startTime
,
commandResponse
)
saveCommand
(
zipUrl
,
startTime
,
commandResponse
)
// upload.toString().dXLog()
}
}
//上传数据库
PosCommandType
.
UPLOAD_DB
.
name
->
{
PosCommandType
.
UPLOAD_DB
.
name
->
{
val
databasePath
=
appContext
.
getDatabasePath
(
name
)
val
databasePath
=
appContext
.
getDatabasePath
(
name
)
val
currentTimeMillis
=
System
.
currentTimeMillis
()
val
currentTimeMillis
=
System
.
currentTimeMillis
()
...
...
app/src/main/java/com/ypsx/yppos/jobs/LogService.kt
View file @
197c8c9d
...
@@ -70,9 +70,9 @@ class LogService : Service() {
...
@@ -70,9 +70,9 @@ class LogService : Service() {
private
fun
createEmptyNotification
()
{
private
fun
createEmptyNotification
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
va
r
channel
=
NotificationChannel
(
va
l
channel
=
NotificationChannel
(
"CHANNEL_ID"
,
"CHANNEL_NAME"
,
"CHANNEL_ID"
,
"CHANNEL_NAME"
,
NotificationManager
.
IMPORTANCE_
HIGH
NotificationManager
.
IMPORTANCE_
MIN
)
)
val
manager
=
getSystemService
(
NOTIFICATION_SERVICE
)
as
NotificationManager
val
manager
=
getSystemService
(
NOTIFICATION_SERVICE
)
as
NotificationManager
manager
.
createNotificationChannel
(
channel
)
manager
.
createNotificationChannel
(
channel
)
...
...
app/src/main/java/com/ypsx/yppos/jobs/SyncProductService.kt
View file @
197c8c9d
...
@@ -71,7 +71,7 @@ class SyncProductService: Service() {
...
@@ -71,7 +71,7 @@ class SyncProductService: Service() {
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
var
channel
=
NotificationChannel
(
var
channel
=
NotificationChannel
(
"CHANNEL_ID"
,
"CHANNEL_NAME"
,
"CHANNEL_ID"
,
"CHANNEL_NAME"
,
NotificationManager
.
IMPORTANCE_
HIGH
NotificationManager
.
IMPORTANCE_
MIN
)
)
val
manager
=
getSystemService
(
NOTIFICATION_SERVICE
)
as
NotificationManager
val
manager
=
getSystemService
(
NOTIFICATION_SERVICE
)
as
NotificationManager
manager
.
createNotificationChannel
(
channel
)
manager
.
createNotificationChannel
(
channel
)
...
@@ -79,6 +79,7 @@ class SyncProductService: Service() {
...
@@ -79,6 +79,7 @@ class SyncProductService: Service() {
Notification
.
Builder
(
appContext
,
"CHANNEL_ID"
)
Notification
.
Builder
(
appContext
,
"CHANNEL_ID"
)
.
setContentTitle
(
"后台服务"
)
.
setContentTitle
(
"后台服务"
)
.
setSmallIcon
(
R
.
drawable
.
icon_yp_logo
)
.
setSmallIcon
(
R
.
drawable
.
icon_yp_logo
)
.
setOnlyAlertOnce
(
true
)
.
build
()
.
build
()
startForeground
(
1
,
notification
)
startForeground
(
1
,
notification
)
// startForeground(1, new Notification());
// startForeground(1, new Notification());
...
...
app/src/main/java/com/ypsx/yppos/ui/activity/MainActivity.kt
View file @
197c8c9d
...
@@ -33,6 +33,8 @@ import com.ypsx.yppos.viewmodel.request.RequestMainViewModel
...
@@ -33,6 +33,8 @@ import com.ypsx.yppos.viewmodel.request.RequestMainViewModel
import
com.ypsx.yppos.viewmodel.state.MainViewModel
import
com.ypsx.yppos.viewmodel.state.MainViewModel
import
kotlinx.android.synthetic.main.activity_main.*
import
kotlinx.android.synthetic.main.activity_main.*
import
razerdp.basepopup.BasePopupWindow.*
import
razerdp.basepopup.BasePopupWindow.*
import
java.math.BigDecimal
import
java.math.RoundingMode
import
java.util.*
import
java.util.*
import
kotlin.collections.ArrayList
import
kotlin.collections.ArrayList
import
kotlin.system.exitProcess
import
kotlin.system.exitProcess
...
@@ -352,30 +354,60 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
...
@@ -352,30 +354,60 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
orderPayAmountPopupWindow
.
setData
(
orderNo
,
payment
)
orderPayAmountPopupWindow
.
setData
(
orderNo
,
payment
)
orderPayAmountPopupWindow
.
setPayClick
{
it
->
orderPayAmountPopupWindow
.
setPayClick
{
it
->
orderPayAmountPopupWindow
.
dismiss
()
orderPayAmountPopupWindow
.
dismiss
()
payAmountPopupWindow
=
PayAmountPopupWindow
(
this
@MainActivity
)
if
(
it
==
PosPayMethod
.
CASHPAY
)
{
payAmountPopupWindow
?.
showPopupWindow
()
val
cashPayPopupWindow
=
CashPayPopupWindow
(
this
@MainActivity
)
payAmountPopupWindow
?.
setData
(
it
,
payment
)
cashPayPopupWindow
.
showPopupWindow
()
payAmountPopupWindow
?.
onDismissListener
=
object
:
cashPayPopupWindow
.
setData
(
it
,
payment
)
OnDismissListener
()
{
cashPayPopupWindow
.
setCashPayClick
{
payMethod
,
receivablesMoney
,
roundMoney
,
changeMoney
,
payMoney
->
override
fun
onDismiss
()
{
cashPayPopupWindow
.
dismiss
()
payAmountPopupWindow
=
null
var
orderNo
=
mViewModel
.
orderNo
.
get
()
var
totalAmount
=
mViewModel
.
payAmount
.
get
()
var
payAmount
=
mViewModel
.
payAmount
.
get
()
var
promotionOnSaleTotal
=
mViewModel
.
discountSpecial
.
get
()
var
discountTotal
=
mViewModel
.
discountMoney
.
get
()
var
data
=
orderProductAdapter
.
data
var
arrayList
=
ArrayList
<
InsertOrderProductDTO
>()
arrayList
.
addAll
(
data
)
arrayList
.
addAll
(
posBuyPartsDeleted
)
"$realName 付款方式:${payMethod.name} "
.
dXLog
()
requestMainViewModel
.
createOrder
(
orderNo
,
totalAmount
.
toDouble
(),
payAmount
.
toDouble
(),
promotionOnSaleTotal
.
toDouble
(),
discountTotal
.
toDouble
(),
arrayList
,
payMethod
,
""
,
roundMoney
,
changeMoney
)
}
}
}
payAmountPopupWindow
?.
setKeyEventListener
{
event
->
}
else
{
scanGunKeyEventHelper
?.
analysisKeyEvent
(
event
)
payAmountPopupWindow
=
PayAmountPopupWindow
(
this
@MainActivity
)
return
@setKeyEventListener
true
payAmountPopupWindow
?.
showPopupWindow
()
}
payAmountPopupWindow
?.
setData
(
it
,
payment
)
payAmountPopupWindow
?.
setFinishClick
{
payAmountPopupWindow
?.
onDismissListener
=
object
:
payAmountPopupWindow
?.
dismiss
()
OnDismissListener
()
{
"${realName}支付超时"
.
dXLog
()
override
fun
onDismiss
()
{
val
messageDialog
=
MessagePopupWindow
(
this
@MainActivity
)
payAmountPopupWindow
=
null
messageDialog
.
showPopupWindow
()
}
messageDialog
.
setData
(
"支付超时"
,
"请确认是否支付成功"
,
gone
=
false
)
}
messageDialog
.
setMessageClick
{
payAmountPopupWindow
?.
setKeyEventListener
{
event
->
messageDialog
.
dismiss
()
scanGunKeyEventHelper
?.
analysisKeyEvent
(
event
)
mViewModel
.
resetOrderNo
()
return
@setKeyEventListener
true
productPromotionRequest
.
orderNo
=
mViewModel
.
orderNo
.
get
()
}
"${realName}点击我知道了,并重置小票号:${productPromotionRequest.orderNo}"
.
dXLog
()
payAmountPopupWindow
?.
setFinishClick
{
payAmountPopupWindow
?.
dismiss
()
"${realName}支付超时"
.
dXLog
()
val
messageDialog
=
MessagePopupWindow
(
this
@MainActivity
)
messageDialog
.
showPopupWindow
()
messageDialog
.
setData
(
"支付超时"
,
"请确认是否支付成功"
,
gone
=
false
)
messageDialog
.
setMessageClick
{
messageDialog
.
dismiss
()
mViewModel
.
resetOrderNo
()
productPromotionRequest
.
orderNo
=
mViewModel
.
orderNo
.
get
()
"${realName}点击我知道了,并重置小票号:${productPromotionRequest.orderNo}"
.
dXLog
()
}
}
}
}
}
}
}
...
@@ -423,13 +455,10 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
...
@@ -423,13 +455,10 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
val
orderId
=
it
.
data
?.
orderId
val
orderId
=
it
.
data
?.
orderId
val
total
=
it
.
data
?.
total
val
total
=
it
.
data
?.
total
var
authCode
=
it
.
data
?.
authCode
var
authCode
=
it
.
data
?.
authCode
if
(
payAmountPopupWindow
!=
null
&&
payAmountPopupWindow
!!
.
isShowing
&&
payAmountPopupWindow
!!
.
timeIsStart
())
{
if
(
payAmountPopupWindow
!=
null
&&
payAmountPopupWindow
!!
.
isShowing
&&
payAmountPopupWindow
!!
.
timeIsStart
())
{
payAmountPopupWindow
?.
setShowTimer
()
payAmountPopupWindow
?.
setShowTimer
()
requestMainViewModel
.
getStateByOrderId
(
orderId
!!
,
total
!!
,
authCode
!!
)
requestMainViewModel
.
getStateByOrderId
(
orderId
!!
,
total
!!
,
authCode
!!
)
}
}
//支付成功后,
//支付成功后,
// 获取支付状态
// 获取支付状态
//获取订单详情 进行打印
//获取订单详情 进行打印
...
@@ -452,7 +481,10 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
...
@@ -452,7 +481,10 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
})
})
requestMainViewModel
.
paySuccessState
.
observe
(
this
,
{
requestMainViewModel
.
paySuccessState
.
observe
(
this
,
{
payAmountPopupWindow
!!
.
dismiss
()
if
(
payAmountPopupWindow
!=
null
)
{
payAmountPopupWindow
!!
.
dismiss
()
}
if
(
it
.
isSuccess
)
{
if
(
it
.
isSuccess
)
{
if
(
payFailedPopWindow
!=
null
)
{
if
(
payFailedPopWindow
!=
null
)
{
payFailedPopWindow
!!
.
dismiss
()
payFailedPopWindow
!!
.
dismiss
()
...
@@ -462,14 +494,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
...
@@ -462,14 +494,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
paySuccessPopWindow
!!
.
setData
(
it
.
data
!!
)
paySuccessPopWindow
!!
.
setData
(
it
.
data
!!
)
paySuccessPopWindow
!!
.
onDismissListener
=
object
:
OnDismissListener
()
{
paySuccessPopWindow
!!
.
onDismissListener
=
object
:
OnDismissListener
()
{
override
fun
onDismiss
()
{
override
fun
onDismiss
()
{
mViewModel
.
resetOrderNo
()
paySuccessView
()
mViewModel
.
resetAmount
()
productPromotionRequest
.
orderNo
=
mViewModel
.
orderNo
.
get
()
productPromotionRequest
.
products
.
clear
()
posBuyPartsDeleted
.
clear
()
mViewModel
.
recyclerShow
.
set
(
false
)
orderProductAdapter
.
data
.
clear
()
orderProductAdapter
.
notifyDataSetChanged
()
}
}
}
}
}
else
{
}
else
{
...
@@ -491,6 +516,33 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
...
@@ -491,6 +516,33 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
})
})
}
}
})
})
requestMainViewModel
.
paySuccessStateCash
.
observe
(
this
,
{
val
payAmount
=
BigDecimal
(
it
.
data
!!
.
payAmount
).
minus
(
BigDecimal
.
valueOf
(
it
.
data
!!
.
roundPrice
))
.
plus
(
BigDecimal
.
valueOf
(
it
.
data
!!
.
changeAmount
)
).
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toString
()
val
paySuccessPopWindow
=
CashPaySuccessPopWindow
(
this
)
paySuccessPopWindow
.
showPopupWindow
()
paySuccessPopWindow
.
setData
(
payAmount
,
it
.
data
!!
.
changeAmount
.
toString
())
paySuccessPopWindow
.
onDismissListener
=
object
:
OnDismissListener
()
{
override
fun
onDismiss
()
{
paySuccessView
()
}
}
})
}
private
fun
paySuccessView
()
{
mViewModel
.
resetOrderNo
()
mViewModel
.
resetAmount
()
productPromotionRequest
.
orderNo
=
mViewModel
.
orderNo
.
get
()
productPromotionRequest
.
products
.
clear
()
posBuyPartsDeleted
.
clear
()
mViewModel
.
recyclerShow
.
set
(
false
)
orderProductAdapter
.
data
.
clear
()
orderProductAdapter
.
notifyDataSetChanged
()
}
}
...
...
app/src/main/java/com/ypsx/yppos/ui/popup/CashPayPopupWindow.kt
0 → 100644
View file @
197c8c9d
package
com.ypsx.yppos.ui.popup
import
android.content.Context
import
android.view.Gravity
import
android.view.View
import
android.view.inputmethod.EditorInfo
import
com.ypsx.base.base.appContext
import
com.ypsx.base.ext.util.screenWidth
import
com.ypsx.base.ext.view.afterTextChange
import
com.ypsx.base.util.dXLog
import
com.ypsx.yppos.R
import
com.ypsx.yppos.databinding.PopupCashPayBinding
import
com.ypsx.yppos.http.data.entity.PosPayMethod
import
com.ypsx.yppos.utils.CashierInputFilter
import
com.ypsx.yppos.utils.toastFailed
import
com.ypsx.yppos.viewmodel.state.CashPayViewModel
import
razerdp.basepopup.BasePopupWindow
import
java.math.BigDecimal
import
java.math.RoundingMode
class
CashPayPopupWindow
(
context
:
Context
)
:
BasePopupWindow
(
context
)
{
lateinit
var
bind
:
PopupCashPayBinding
private
var
roundMoney
:
Double
=
0.0
lateinit
var
payMethod
:
PosPayMethod
var
payAction
:
(
item
:
PosPayMethod
,
receivablesMoney
:
Double
,
roundMoney
:
Double
,
changeMoney
:
Double
,
payMoney
:
Double
)
->
Unit
=
{
_
:
PosPayMethod
,
_
:
Double
,
_
:
Double
,
_
:
Double
,
_
:
Double
->
}
init
{
setContentView
(
R
.
layout
.
popup_cash_pay
)
width
=
appContext
.
screenWidth
/
4
*
3
popupGravity
=
Gravity
.
CENTER
isOutSideTouchable
=
false
setOutSideDismiss
(
false
)
}
override
fun
onViewCreated
(
contentView
:
View
)
{
// 透出应付金额,应付金额四舍五入到分位(记录舍分金额)
bind
=
PopupCashPayBinding
.
bind
(
contentView
)
bind
.
vm
=
CashPayViewModel
()
bind
.
click
=
ProxyClick
()
setAutoShowKeyboard
(
bind
.
textView20
,
true
)
setKeyboardAdaptive
(
true
)
setKeyboardAdaptionMode
(
bind
.
textView23
,
FLAG_KEYBOARD_ALIGN_TO_ROOT
or
FLAG_KEYBOARD_ANIMATE_ALIGN
)
bind
.
textView20
.
filters
=
arrayOf
(
CashierInputFilter
())
bind
.
textView20
.
afterTextChange
{
if
(
it
.
isEmpty
())
{
bind
.
vm
?.
changeMoney
?.
set
(
0.0
)
bind
.
vm
?.
change2
?.
set
(
"¥${bind.vm?.changeMoney?.get()}"
)
}
else
{
val
payMoney
:
Double
?
=
bind
.
vm
?.
receivables
?.
get
()
if
(
payMoney
!=
null
)
{
if
(
payMoney
<=
it
.
toDouble
())
{
val
scale
=
BigDecimal
(
it
).
minus
(
BigDecimal
.
valueOf
(
payMoney
)).
setScale
(
1
)
bind
.
vm
?.
changeMoney
?.
set
(
scale
.
toDouble
())
bind
.
vm
?.
change2
?.
set
(
"¥${bind.vm?.changeMoney?.get()}"
)
}
else
{
bind
.
vm
?.
changeMoney
?.
set
(
0.0
)
bind
.
vm
?.
change2
?.
set
(
"¥${bind.vm?.changeMoney?.get()}"
)
}
}
}
}
bind
.
textView20
.
setOnEditorActionListener
{
v
,
actionId
,
event
->
if
(
actionId
==
EditorInfo
.
IME_ACTION_DONE
)
{
ProxyClick
().
confirm
()
return
@setOnEditorActionListener
true
}
return
@setOnEditorActionListener
false
}
}
fun
setData
(
payMethod
:
PosPayMethod
,
amount
:
String
)
{
this
.
payMethod
=
payMethod
val
rawData
=
BigDecimal
(
amount
)
val
scale
=
rawData
.
setScale
(
1
,
RoundingMode
.
HALF_UP
)
roundMoney
=
(
rawData
-
scale
).
toDouble
()
bind
.
vm
?.
receivables
?.
set
(
scale
.
toDouble
())
bind
.
vm
?.
receivables2
?.
set
(
"¥$scale"
)
// bind.vm?.actuallyPaid?.set(scale.toString())
bind
.
vm
?.
changeMoney
?.
set
(
0.0
)
bind
.
vm
?.
change2
?.
set
(
"¥${bind.vm?.changeMoney?.get()}"
)
"舍分金额:$roundMoney"
.
dXLog
()
}
inner
class
ProxyClick
{
fun
close
()
{
dismiss
()
}
fun
confirm
()
{
val
payMoney
:
String
=
bind
.
textView20
.
text
.
toString
()
val
receivables
:
Double
?
=
bind
.
vm
?.
receivables
?.
get
()
val
changeMoney
:
Double
?
=
bind
.
vm
?.
changeMoney
?.
get
()
if
(
payMoney
.
isEmpty
())
{
"应付金额不允许为空!"
.
toastFailed
()
return
}
if
(
receivables
!=
null
&&
changeMoney
!=
null
)
{
if
(
receivables
>
payMoney
.
toDouble
())
{
"实付金额不允许小于应付金额"
.
toastFailed
()
return
}
"应付金额:$receivables 舍分金额:$roundMoney 找零金额$changeMoney 实付金额:$payMoney"
.
dXLog
()
payAction
.
invoke
(
payMethod
,
receivables
,
roundMoney
,
changeMoney
,
payMoney
.
toDouble
()
)
}
}
}
fun
setCashPayClick
(
payAction
:
(
item
:
PosPayMethod
,
receivablesMoney
:
Double
,
roundMoney
:
Double
,
changeMoney
:
Double
,
payMoney
:
Double
)
->
Unit
)
{
this
.
payAction
=
payAction
}
}
\ No newline at end of file
app/src/main/java/com/ypsx/yppos/ui/popup/CashPaySuccessPopWindow.kt
0 → 100644
View file @
197c8c9d
package
com.ypsx.yppos.ui.popup
import
android.app.Activity
import
android.content.Context
import
android.view.Gravity
import
android.view.View
import
com.ypsx.base.base.appContext
import
com.ypsx.base.ext.util.screenWidth
import
com.ypsx.yppos.R
import
com.ypsx.yppos.databinding.PopupCashPaySuccessBinding
import
com.ypsx.yppos.viewmodel.state.PaySuccessViewModel
import
razerdp.basepopup.BasePopupWindow
import
java.util.*
class
CashPaySuccessPopWindow
(
context
:
Context
)
:
BasePopupWindow
(
context
)
{
lateinit
var
bind
:
PopupCashPaySuccessBinding
var
timer
:
Timer
?
=
null
var
task
:
TimerTask
?
=
null
var
recLen
=
5
lateinit
var
activity
:
Activity
init
{
setContentView
(
R
.
layout
.
popup_cash_pay_success
)
width
=
appContext
.
screenWidth
/
4
*
3
popupGravity
=
Gravity
.
CENTER
isOutSideTouchable
=
false
setOutSideDismiss
(
false
)
}
private
fun
stopTimer
()
{
if
(
task
!=
null
&&
timer
!=
null
)
{
timer
?.
cancel
()
timer
?.
purge
()
timer
=
null
task
=
null
}
}
override
fun
onViewCreated
(
contentView
:
View
)
{
bind
=
PopupCashPaySuccessBinding
.
bind
(
contentView
)
bind
.
vm
=
PaySuccessViewModel
()
bind
.
click
=
ProxyClick
()
activity
=
context
timer
=
Timer
()
task
=
object
:
TimerTask
()
{
override
fun
run
()
{
recLen
--
if
(
recLen
<
0
)
{
if
(
isShowing
)
{
activity
.
runOnUiThread
{
dismiss
()
}
}
stopTimer
()
}
}
}
timer
?.
schedule
(
task
,
1000
,
1000
);
}
fun
setData
(
payAmount
:
String
,
changeAmount
:
String
)
{
bind
.
vm
?.
payAmount
?.
set
(
payAmount
)
bind
.
vm
?.
changeAmount
?.
set
(
changeAmount
)
}
override
fun
dismiss
()
{
super
.
dismiss
()
stopTimer
()
}
inner
class
ProxyClick
{
fun
close
()
{
dismiss
()
}
}
}
\ No newline at end of file
app/src/main/java/com/ypsx/yppos/ui/popup/OrderPayAmountPopupWindow.kt
View file @
197c8c9d
...
@@ -33,15 +33,27 @@ class OrderPayAmountPopupWindow(context: Context) : BasePopupWindow(context) {
...
@@ -33,15 +33,27 @@ class OrderPayAmountPopupWindow(context: Context) : BasePopupWindow(context) {
bind
?.
vm
=
OrderPayAmountViewModel
()
bind
?.
vm
=
OrderPayAmountViewModel
()
bind
?.
click
=
ProxyClick
()
bind
?.
click
=
ProxyClick
()
val
offline
:
Boolean
=
bind
?.
vm
?.
scanOffline
?.
get
()
==
false
// val offline: Boolean = bind?.vm?.scanOffline?.get() == false
val
cardPay
:
Boolean
=
bind
?.
vm
?.
scanCardPay
?.
get
()
==
false
// val cardPay: Boolean = bind?.vm?.scanCardPay?.get() == false
if
(
offline
&&
cardPay
)
{
// val cashPay: Boolean = bind?.vm?.scanCashPay?.get() == false
bind
?.
rbOffline
?.
isChecked
=
true
when
(
bind
?.
vm
?.
firstName
?.
get
())
{
bind
?.
rbCardPay
?.
isChecked
=
false
PosPayMethod
.
CCB_BAR_PAY
.
name
,
}
else
if
(
offline
&&
!
cardPay
)
{
PosPayMethod
.
LCSW_BAR_PAY
.
name
->
{
bind
?.
rbOffline
?.
isChecked
=
true
bind
?.
rbOffline
?.
isChecked
=
true
}
else
if
(!
offline
&&
cardPay
)
{
bind
?.
rbCardPay
?.
isChecked
=
false
bind
?.
rbCardPay
?.
isChecked
=
true
bind
?.
rbCash
?.
isChecked
=
false
}
PosPayMethod
.
CARDPAY
.
name
->
{
bind
?.
rbOffline
?.
isChecked
=
false
bind
?.
rbCardPay
?.
isChecked
=
true
bind
?.
rbCash
?.
isChecked
=
false
}
PosPayMethod
.
CASHPAY
.
name
->
{
bind
?.
rbOffline
?.
isChecked
=
false
bind
?.
rbCardPay
?.
isChecked
=
false
bind
?.
rbCash
?.
isChecked
=
true
}
}
}
}
}
...
@@ -94,6 +106,7 @@ class OrderPayAmountPopupWindow(context: Context) : BasePopupWindow(context) {
...
@@ -94,6 +106,7 @@ class OrderPayAmountPopupWindow(context: Context) : BasePopupWindow(context) {
}
}
}
}
R
.
id
.
rb_cash
->
PosPayMethod
.
CASHPAY
R
.
id
.
rbCardPay
->
PosPayMethod
.
CARDPAY
R
.
id
.
rbCardPay
->
PosPayMethod
.
CARDPAY
else
->
PosPayMethod
.
CCB_BAR_PAY
else
->
PosPayMethod
.
CCB_BAR_PAY
}
}
...
...
app/src/main/java/com/ypsx/yppos/utils/CashierInputFilter.java
0 → 100644
View file @
197c8c9d
package
com
.
ypsx
.
yppos
.
utils
;
import
android.text.InputFilter
;
import
android.text.Spanned
;
import
android.text.TextUtils
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
class
CashierInputFilter
implements
InputFilter
{
Pattern
mPattern
;
//输入的最大金额
private
static
final
double
MAX_VALUE
=
9999.9
;
//小数点后的位数
private
static
final
int
POINTER_LENGTH
=
1
;
private
static
final
String
POINTER
=
"."
;
private
static
final
String
ZERO
=
"0"
;
public
CashierInputFilter
()
{
mPattern
=
Pattern
.
compile
(
"([0-9]|\\.)*"
);
}
/**
* @param source 新输入的字符串
* @param start 新输入的字符串起始下标,一般为0
* @param end 新输入的字符串终点下标,一般为source长度-1
* @param dest 输入之前文本框内容
* @param dstart 原内容起始坐标,一般为0
* @param dend 原内容终点坐标,一般为dest长度-1
* @return 输入内容
*/
@Override
public
CharSequence
filter
(
CharSequence
source
,
int
start
,
int
end
,
Spanned
dest
,
int
dstart
,
int
dend
)
{
String
sourceText
=
source
.
toString
();
String
destText
=
dest
.
toString
();
//验证删除等按键
if
(
TextUtils
.
isEmpty
(
sourceText
))
{
return
""
;
}
Matcher
matcher
=
mPattern
.
matcher
(
source
);
//已经输入小数点的情况下,只能输入数字
if
(
destText
.
contains
(
POINTER
))
{
if
(!
matcher
.
matches
())
{
return
""
;
}
else
{
if
(
POINTER
.
equals
(
source
.
toString
()))
{
//只能输入一个小数点
return
""
;
}
}
//验证小数点精度,保证小数点后只能输入两位
int
index
=
destText
.
indexOf
(
POINTER
);
int
length
=
dend
-
index
;
if
(
length
>
POINTER_LENGTH
)
{
return
dest
.
subSequence
(
dstart
,
dend
);
}
}
else
{
/**
* 没有输入小数点的情况下,只能输入小数点和数字
* 1. 首位不能输入小数点
* 2. 如果首位输入0,则接下来只能输入小数点了
*/
if
(!
matcher
.
matches
())
{
return
""
;
}
else
{
if
((
POINTER
.
equals
(
source
.
toString
()))
&&
TextUtils
.
isEmpty
(
destText
))
{
//首位不能输入小数点
return
""
;
}
else
if
(!
POINTER
.
equals
(
source
.
toString
())
&&
ZERO
.
equals
(
destText
))
{
//如果首位输入0,接下来只能输入小数点
return
""
;
}
}
}
//验证输入金额的大小
double
sumText
=
Double
.
parseDouble
(
destText
+
sourceText
);
if
(
sumText
>
MAX_VALUE
)
{
return
dest
.
subSequence
(
dstart
,
dend
);
}
return
dest
.
subSequence
(
dstart
,
dend
)
+
sourceText
;
}
}
app/src/main/java/com/ypsx/yppos/utils/PrintUtils.kt
View file @
197c8c9d
...
@@ -17,6 +17,8 @@ import com.ypsx.yppos.room.entity.PosBuy
...
@@ -17,6 +17,8 @@ import com.ypsx.yppos.room.entity.PosBuy
import
com.ypsx.yppos.room.entity.PosBuyPart
import
com.ypsx.yppos.room.entity.PosBuyPart
import
com.ypsx.yppos.room.entity.PosBuyPayment
import
com.ypsx.yppos.room.entity.PosBuyPayment
import
com.ypsx.yppos.room.entity.PosConfig
import
com.ypsx.yppos.room.entity.PosConfig
import
java.math.BigDecimal
import
java.math.RoundingMode
private
const
val
PRNSTS_OK
=
0
//OK
private
const
val
PRNSTS_OK
=
0
//OK
...
@@ -239,7 +241,7 @@ object PrintUtils {
...
@@ -239,7 +241,7 @@ object PrintUtils {
height
+=
printerManager
.
drawTextEx
(
height
+=
printerManager
.
drawTextEx
(
getAmountCenterSpace
(
getAmountCenterSpace
(
"应付款:${orderResponse.
pay
Amount}"
,
"应付款:${orderResponse.
total
Amount}"
,
"数量:${orderResponse.buyNumber}"
"数量:${orderResponse.buyNumber}"
),
),
0
,
0
,
...
@@ -252,10 +254,14 @@ object PrintUtils {
...
@@ -252,10 +254,14 @@ object PrintUtils {
fontStyle
,
fontStyle
,
0
0
)
)
val
minus
=
BigDecimal
.
valueOf
(
orderResponse
.
totalAmount
)
.
minus
(
BigDecimal
.
valueOf
(
orderResponse
.
roundPrice
))
val
scale1
=
minus
.
plus
(
BigDecimal
.
valueOf
(
orderResponse
.
changeAmount
))
.
setScale
(
2
).
toDouble
()
height
+=
printerManager
.
drawTextEx
(
height
+=
printerManager
.
drawTextEx
(
getAmountCenterSpace
(
getAmountCenterSpace
(
"实付款:${
orderResponse.payAmount
}"
,
"实付款:${
scale1
}"
,
"找零金额:${orderResponse.changeAmount}"
"找零金额:${orderResponse.changeAmount}"
),
),
0
,
0
,
...
@@ -274,9 +280,9 @@ object PrintUtils {
...
@@ -274,9 +280,9 @@ object PrintUtils {
)
)
var
payments
=
orderResponse
.
payments
var
payments
=
orderResponse
.
payments
var
payMethod
=
""
var
payMethod
=
""
var
total
=
""
var
total
=
orderResponse
.
totalAmount
if
(
payments
.
isNotEmpty
())
{
if
(
payments
.
isNotEmpty
())
{
total
=
payments
[
0
].
total
.
toString
()
payMethod
=
when
(
payments
[
0
].
payMethod
)
{
payMethod
=
when
(
payments
[
0
].
payMethod
)
{
PosPayMethod
.
CCB_BAR_PAY
.
name
,
PosPayMethod
.
LCSW_BAR_PAY
.
name
->
{
PosPayMethod
.
CCB_BAR_PAY
.
name
,
PosPayMethod
.
LCSW_BAR_PAY
.
name
->
{
"扫码支付"
"扫码支付"
...
@@ -284,17 +290,22 @@ object PrintUtils {
...
@@ -284,17 +290,22 @@ object PrintUtils {
PosPayMethod
.
CARDPAY
.
name
->
{
PosPayMethod
.
CARDPAY
.
name
->
{
"会员余额支付"
"会员余额支付"
}
}
PosPayMethod
.
CASHPAY
.
name
->{
"现金支付"
}
else
->
{
else
->
{
""
""
}
}
}
}
}
else
{
payMethod
=
"现金支付"
}
}
height
+=
printerManager
.
drawTextEx
(
height
+=
printerManager
.
drawTextEx
(
"付款方式:$payMethod $total"
,
0
,
height
,
384
,
-
1
,
fontName
,
fontSize
,
0
,
fontStyle
,
0
"付款方式:$payMethod $total"
,
0
,
height
,
384
,
-
1
,
fontName
,
fontSize
,
0
,
fontStyle
,
0
)
)
val
scale
=
minus
.
setScale
(
2
).
toDouble
()
height
+=
printerManager
.
drawTextEx
(
height
+=
printerManager
.
drawTextEx
(
" 实际扣款:${
total
}"
,
0
,
height
,
384
,
-
1
,
fontName
,
fontSize
,
0
,
fontStyle
,
0
" 实际扣款:${
scale
}"
,
0
,
height
,
384
,
-
1
,
fontName
,
fontSize
,
0
,
fontStyle
,
0
)
)
height
+=
printerManager
.
drawTextEx
(
height
+=
printerManager
.
drawTextEx
(
...
@@ -710,7 +721,7 @@ object PrintUtils {
...
@@ -710,7 +721,7 @@ object PrintUtils {
height
+=
printerManager
.
drawTextEx
(
height
+=
printerManager
.
drawTextEx
(
getAmountCenterSpace
(
getAmountCenterSpace
(
"应付款:${posBuy.
pay
Amount}"
,
"应付款:${posBuy.
total
Amount}"
,
"数量:${posBuy.buyNumber}"
"数量:${posBuy.buyNumber}"
),
),
0
,
0
,
...
@@ -723,10 +734,14 @@ object PrintUtils {
...
@@ -723,10 +734,14 @@ object PrintUtils {
fontStyle
,
fontStyle
,
0
0
)
)
val
minus
=
BigDecimal
.
valueOf
(
posBuy
.
totalAmount
)
.
minus
(
BigDecimal
.
valueOf
(
posBuy
.
roundPrice
))
val
scale1
=
minus
.
plus
(
BigDecimal
.
valueOf
(
posBuy
.
changeAmount
))
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toDouble
()
height
+=
printerManager
.
drawTextEx
(
height
+=
printerManager
.
drawTextEx
(
getAmountCenterSpace
(
getAmountCenterSpace
(
"实付款:${
posBuy.payAmount
}"
,
"实付款:${
scale1
}"
,
"找零金额:${posBuy.changeAmount}"
"找零金额:${posBuy.changeAmount}"
),
),
0
,
0
,
...
@@ -746,26 +761,30 @@ object PrintUtils {
...
@@ -746,26 +761,30 @@ object PrintUtils {
var
payMethod
=
""
var
payMethod
=
""
var
total
=
""
var
total
=
""
if
(
posBuyPayment
!=
null
)
{
payMethod
=
if
(
posBuyPayment
==
null
)
{
total
=
posBuyPayment
.
total
.
toString
()
"现金支付"
payMethod
=
when
(
posBuyPayment
.
payMethod
)
{
}
else
{
when
(
posBuyPayment
.
payMethod
)
{
PosPayMethod
.
CCB_BAR_PAY
.
name
,
PosPayMethod
.
LCSW_BAR_PAY
.
name
->
{
PosPayMethod
.
CCB_BAR_PAY
.
name
,
PosPayMethod
.
LCSW_BAR_PAY
.
name
->
{
"扫码支付"
"扫码支付"
}
}
PosPayMethod
.
CARDPAY
.
name
->
{
PosPayMethod
.
CARDPAY
.
name
->
{
"会员余额支付"
"会员余额支付"
}
}
PosPayMethod
.
CASHPAY
.
name
->
{
"现金支付"
}
else
->
{
else
->
{
""
""
}
}
}
}
}
}
height
+=
printerManager
.
drawTextEx
(
height
+=
printerManager
.
drawTextEx
(
"付款方式:$payMethod $
total
"
,
0
,
height
,
384
,
-
1
,
fontName
,
fontSize
,
0
,
fontStyle
,
0
"付款方式:$payMethod $
{posBuy.totalAmount}
"
,
0
,
height
,
384
,
-
1
,
fontName
,
fontSize
,
0
,
fontStyle
,
0
)
)
val
scale
=
minus
.
setScale
(
2
).
toDouble
()
height
+=
printerManager
.
drawTextEx
(
height
+=
printerManager
.
drawTextEx
(
" 实际扣款:${
total
}"
,
0
,
height
,
384
,
-
1
,
fontName
,
fontSize
,
0
,
fontStyle
,
0
" 实际扣款:${
scale
}"
,
0
,
height
,
384
,
-
1
,
fontName
,
fontSize
,
0
,
fontStyle
,
0
)
)
height
+=
printerManager
.
drawTextEx
(
height
+=
printerManager
.
drawTextEx
(
...
...
app/src/main/java/com/ypsx/yppos/viewmodel/request/RequestMainViewModel.kt
View file @
197c8c9d
...
@@ -7,7 +7,6 @@ import com.ypsx.base.ext.launch
...
@@ -7,7 +7,6 @@ import com.ypsx.base.ext.launch
import
com.ypsx.base.ext.request
import
com.ypsx.base.ext.request
import
com.ypsx.base.ext.requestNoCheck
import
com.ypsx.base.ext.requestNoCheck
import
com.ypsx.base.ext.util.toJson
import
com.ypsx.base.ext.util.toJson
import
com.ypsx.base.network.AppException
import
com.ypsx.base.util.dXLog
import
com.ypsx.base.util.dXLog
import
com.ypsx.yppos.http.apiService
import
com.ypsx.yppos.http.apiService
import
com.ypsx.yppos.http.data.bean.*
import
com.ypsx.yppos.http.data.bean.*
...
@@ -44,6 +43,7 @@ class RequestMainViewModel : BaseViewModel() {
...
@@ -44,6 +43,7 @@ class RequestMainViewModel : BaseViewModel() {
var
payState
=
MutableLiveData
<
UpdateUiState
<
UploadOrderResponse
>>()
var
payState
=
MutableLiveData
<
UpdateUiState
<
UploadOrderResponse
>>()
val
paySuccessState
=
MutableLiveData
<
UpdateUiState
<
String
>>()
val
paySuccessState
=
MutableLiveData
<
UpdateUiState
<
String
>>()
val
paySuccessStateCash
=
MutableLiveData
<
UpdateUiState
<
CashPaySuccess
>>()
init
{
init
{
...
@@ -132,7 +132,7 @@ class RequestMainViewModel : BaseViewModel() {
...
@@ -132,7 +132,7 @@ class RequestMainViewModel : BaseViewModel() {
if
(
posProduct
?.
style
==
PosProductStyle
.
WEIGHT
.
name
)
{
if
(
posProduct
?.
style
==
PosProductStyle
.
WEIGHT
.
name
)
{
listNum
+=
1
listNum
+=
1
}
else
if
(
posProduct
?.
style
==
PosProductStyle
.
SINGLE
.
name
)
{
}
else
if
(
posProduct
?.
style
==
PosProductStyle
.
SINGLE
.
name
)
{
listNum
+=
product
.
quantity
.
toInt
()
listNum
+=
product
.
quantity
.
toInt
()
}
}
val
amount
:
Double
=
product
.
price
.
times
(
product
.
quantity
)
?:
0.0
val
amount
:
Double
=
product
.
price
.
times
(
product
.
quantity
)
?:
0.0
...
@@ -237,11 +237,11 @@ class RequestMainViewModel : BaseViewModel() {
...
@@ -237,11 +237,11 @@ class RequestMainViewModel : BaseViewModel() {
}
}
if
(
posProduct
?.
style
==
PosProductStyle
.
WEIGHT
.
name
)
{
if
(
posProduct
?.
style
==
PosProductStyle
.
WEIGHT
.
name
)
{
listNum
+=
1
listNum
+=
1
}
else
if
(
posProduct
?.
style
==
PosProductStyle
.
SINGLE
.
name
)
{
}
else
if
(
posProduct
?.
style
==
PosProductStyle
.
SINGLE
.
name
)
{
listNum
+=
product
.
quantity
.
toInt
()
listNum
+=
product
.
quantity
.
toInt
()
}
}
var
activityInfo
=
product
.
activityInfo
var
activityInfo
=
product
.
activityInfo
var
activitys
:
ArrayList
<
ActivityInfoDTO
>
=
arrayListOf
()
var
activitys
:
ArrayList
<
ActivityInfoDTO
>
=
arrayListOf
()
if
(
activityInfo
!=
null
)
{
if
(
activityInfo
!=
null
)
{
activitys
.
add
(
activityInfo
)
activitys
.
add
(
activityInfo
)
}
}
...
@@ -283,7 +283,7 @@ class RequestMainViewModel : BaseViewModel() {
...
@@ -283,7 +283,7 @@ class RequestMainViewModel : BaseViewModel() {
payAmountBean
.
postValue
(
payAmountBean
.
postValue
(
PayAmountBean
(
PayAmountBean
(
BigDecimalUtils
.
forPlus
(
discountTotal
),
BigDecimalUtils
.
forPlus
(
discountTotal
),
BigDecimalUtils
.
forPlus
(
payApportionAmount
),
BigDecimalUtils
.
forPlus
(
payApportionAmount
),
BigDecimalUtils
.
forPlus
(
discountMoney
),
BigDecimalUtils
.
forPlus
(
discountMoney
),
BigDecimalUtils
.
forPlus
(
discountTime
),
BigDecimalUtils
.
forPlus
(
discountTime
),
BigDecimalUtils
.
forPlus
(
discountSpecial
),
BigDecimalUtils
.
forPlus
(
discountSpecial
),
...
@@ -305,12 +305,19 @@ class RequestMainViewModel : BaseViewModel() {
...
@@ -305,12 +305,19 @@ class RequestMainViewModel : BaseViewModel() {
discountTotal
:
Double
,
discountTotal
:
Double
,
productList
:
List
<
InsertOrderProductDTO
>,
productList
:
List
<
InsertOrderProductDTO
>,
payMethod
:
PosPayMethod
,
payMethod
:
PosPayMethod
,
barcode
:
String
barcode
:
String
,
roundMoney
:
Double
=
0.0
,
changeMoney
:
Double
=
0.0
)
{
)
{
val
status
=
when
(
payMethod
)
{
PosPayMethod
.
CASHPAY
->
"FINISHED"
else
->
"CREATED"
}
val
loginResponse
=
CacheUtil
.
getLoginResponse
()
val
loginResponse
=
CacheUtil
.
getLoginResponse
()
val
dataTime
=
DateUtil
.
getTodayDateTime
()
val
insertOrderRequest
=
InsertOrderRequest
(
val
insertOrderRequest
=
InsertOrderRequest
(
activitys
=
orderPromotions
,
activitys
=
orderPromotions
,
createTime
=
DateUtil
.
getTodayDateTime
()
,
createTime
=
dataTime
,
creatorId
=
loginResponse
!!
.
loginUser
.
username
?:
""
,
creatorId
=
loginResponse
!!
.
loginUser
.
username
?:
""
,
creatorName
=
loginResponse
.
loginUser
.
realName
?:
""
,
creatorName
=
loginResponse
.
loginUser
.
realName
?:
""
,
orderNo
=
orderNo
,
orderNo
=
orderNo
,
...
@@ -319,18 +326,36 @@ class RequestMainViewModel : BaseViewModel() {
...
@@ -319,18 +326,36 @@ class RequestMainViewModel : BaseViewModel() {
mobile
=
""
,
mobile
=
""
,
posId
=
posConfig
?.
id
?:
""
,
posId
=
posConfig
?.
id
?:
""
,
storeId
=
posConfig
?.
storeId
?:
""
,
storeId
=
posConfig
?.
storeId
?:
""
,
status
=
"CREATED"
,
status
=
status
,
products
=
productList
,
products
=
productList
,
totalAmount
=
totalAmount
,
totalAmount
=
totalAmount
,
promotionOnSaleTotal
=
promotionOnSaleTotal
,
promotionOnSaleTotal
=
promotionOnSaleTotal
,
discountTotal
=
discountTotal
,
discountTotal
=
discountTotal
,
payAmount
=
payAmount
,
payAmount
=
payAmount
,
roundPrice
=
roundMoney
,
changeAmount
=
changeMoney
,
payments
=
if
(
payMethod
==
PosPayMethod
.
CASHPAY
)
arrayListOf
(
OrderPayment
(
payMethod
=
payMethod
.
name
,
payTime
=
dataTime
,
total
=
totalAmount
)
)
else
null
)
)
requestNoCheck
({
requestNoCheck
({
HttpRequestCoroutine
.
createOrder
(
insertOrderRequest
,
barcode
,
payMethod
)
HttpRequestCoroutine
.
createOrder
(
insertOrderRequest
,
barcode
,
payMethod
)
},
{
},
{
val
uiState
=
UpdateUiState
(
isSuccess
=
true
,
it
)
if
(
it
.
payMethod
==
PosPayMethod
.
CASHPAY
.
name
)
{
payState
.
postValue
(
uiState
)
getOrderDetailById
(
it
.
orderId
,
""
)
val
cashPaySuccess
=
CashPaySuccess
(
payAmount
,
changeMoney
,
roundMoney
,
orderNo
)
val
uiState
=
UpdateUiState
(
isSuccess
=
true
,
cashPaySuccess
)
paySuccessStateCash
.
postValue
(
uiState
)
}
else
{
val
uiState
=
UpdateUiState
(
isSuccess
=
true
,
it
)
payState
.
postValue
(
uiState
)
}
},
{
},
{
val
uiState
=
UpdateUiState
(
isSuccess
=
false
,
data
=
""
,
it
.
errorMsg
)
val
uiState
=
UpdateUiState
(
isSuccess
=
false
,
data
=
""
,
it
.
errorMsg
)
paySuccessState
.
postValue
(
uiState
)
paySuccessState
.
postValue
(
uiState
)
...
@@ -393,7 +418,4 @@ class RequestMainViewModel : BaseViewModel() {
...
@@ -393,7 +418,4 @@ class RequestMainViewModel : BaseViewModel() {
}
}
}
}
\ No newline at end of file
app/src/main/java/com/ypsx/yppos/viewmodel/state/CashPayViewModel.kt
0 → 100644
View file @
197c8c9d
package
com.ypsx.yppos.viewmodel.state
import
com.ypsx.base.base.viewmodel.BaseViewModel
import
com.ypsx.base.callback.databind.DoubleObservableField
import
com.ypsx.base.callback.databind.StringObservableField
class
CashPayViewModel
:
BaseViewModel
()
{
//
var
receivables
=
DoubleObservableField
()
var
receivables2
=
StringObservableField
(
"¥"
+
receivables
.
get
())
var
actuallyPaid
=
StringObservableField
()
//找零借
var
changeMoney
=
DoubleObservableField
(
0.0
)
var
change2
=
StringObservableField
(
"¥${changeMoney.get()}"
)
}
\ No newline at end of file
app/src/main/java/com/ypsx/yppos/viewmodel/state/OrderPayAmountViewModel.kt
View file @
197c8c9d
...
@@ -19,8 +19,10 @@ class OrderPayAmountViewModel : BaseViewModel() {
...
@@ -19,8 +19,10 @@ class OrderPayAmountViewModel : BaseViewModel() {
var
scanOffline
=
BooleanObservableField
(
false
)
var
scanOffline
=
BooleanObservableField
(
false
)
var
scanCardPay
=
BooleanObservableField
(
false
)
var
scanCardPay
=
BooleanObservableField
(
false
)
var
scanCashPay
=
BooleanObservableField
(
false
)
var
payName
=
StringObservableField
(
""
)
var
payName
=
StringObservableField
(
""
)
var
firstName
=
StringObservableField
(
""
)
var
offlineVisible
=
object
:
ObservableInt
(
scanOffline
)
{
var
offlineVisible
=
object
:
ObservableInt
(
scanOffline
)
{
...
@@ -33,6 +35,16 @@ class OrderPayAmountViewModel : BaseViewModel() {
...
@@ -33,6 +35,16 @@ class OrderPayAmountViewModel : BaseViewModel() {
}
}
}
}
var
cashVisible
=
object
:
ObservableInt
(
scanCashPay
)
{
override
fun
get
():
Int
{
return
if
(
scanCashPay
.
get
())
{
View
.
VISIBLE
}
else
{
View
.
GONE
}
}
}
var
cardPayVisible
=
object
:
ObservableInt
(
scanCardPay
)
{
var
cardPayVisible
=
object
:
ObservableInt
(
scanCardPay
)
{
override
fun
get
():
Int
{
override
fun
get
():
Int
{
return
if
(
scanCardPay
.
get
())
{
return
if
(
scanCardPay
.
get
())
{
...
@@ -53,13 +65,36 @@ class OrderPayAmountViewModel : BaseViewModel() {
...
@@ -53,13 +65,36 @@ class OrderPayAmountViewModel : BaseViewModel() {
for
(
str
in
payMethod
)
{
for
(
str
in
payMethod
)
{
when
(
str
)
{
when
(
str
)
{
PosPayMethod
.
CCB_BAR_PAY
.
name
,
PosPayMethod
.
CCB_BAR_PAY
.
name
,
PosPayMethod
.
LCSW_BAR_PAY
.
name
->
{
PosPayMethod
.
LCSW_BAR_PAY
.
name
->
{
payName
.
set
(
str
)
payName
.
set
(
str
)
scanOffline
.
set
(
true
)
scanOffline
.
set
(
true
)
}
}
PosPayMethod
.
CARDPAY
.
name
->
scanCardPay
.
set
(
true
)
PosPayMethod
.
CARDPAY
.
name
->
scanCardPay
.
set
(
true
)
PosPayMethod
.
CASHPAY
.
name
->
scanCashPay
.
set
(
true
)
}
}
}
}
when
{
payMethods
.
contains
(
PosPayMethod
.
CASHPAY
.
name
)
->
{
firstName
.
set
(
PosPayMethod
.
CASHPAY
.
name
)
return
@launch
}
payMethods
.
contains
(
PosPayMethod
.
CCB_BAR_PAY
.
name
)
->
{
firstName
.
set
(
PosPayMethod
.
CCB_BAR_PAY
.
name
)
return
@launch
}
payMethods
.
contains
(
PosPayMethod
.
LCSW_BAR_PAY
.
name
)
->
{
firstName
.
set
(
PosPayMethod
.
LCSW_BAR_PAY
.
name
)
return
@launch
}
payMethods
.
contains
(
PosPayMethod
.
CARDPAY
.
name
)
->
{
firstName
.
set
(
PosPayMethod
.
CARDPAY
.
name
)
return
@launch
}
}
}
}
}
}
...
...
app/src/main/java/com/ypsx/yppos/viewmodel/state/PaySuccessViewModel.kt
View file @
197c8c9d
...
@@ -6,6 +6,8 @@ import com.ypsx.base.callback.databind.StringObservableField
...
@@ -6,6 +6,8 @@ import com.ypsx.base.callback.databind.StringObservableField
class
PaySuccessViewModel
:
BaseViewModel
()
{
class
PaySuccessViewModel
:
BaseViewModel
()
{
var
amount
=
StringObservableField
()
var
amount
=
StringObservableField
()
var
payAmount
=
StringObservableField
()
var
changeAmount
=
StringObservableField
()
...
...
app/src/main/res/drawable/btn_confirm_bg.xml
0 → 100644
View file @
197c8c9d
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"#ffa14eff"
/>
<corners
android:radius=
"4dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/edit_bg.xml
0 → 100644
View file @
197c8c9d
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<stroke
android:width=
"1dp"
android:color=
"#ffd8d8d8"
/>
<corners
android:radius=
"2dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/popup_cash_pay.xml
0 → 100644
View file @
197c8c9d
<?xml version="1.0" encoding="utf-8"?>
<layout
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"
>
<data>
<variable
name=
"vm"
type=
"com.ypsx.yppos.viewmodel.state.CashPayViewModel"
/>
<variable
name=
"click"
type=
"com.ypsx.yppos.ui.popup.CashPayPopupWindow.ProxyClick"
/>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/bg_dialog"
>
<TextView
android:id=
"@+id/tv_title"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:paddingTop=
"@dimen/dp_10"
android:paddingBottom=
"@dimen/dp_10"
android:text=
"@string/cash_pay"
android:textColor=
"@color/black"
android:textSize=
"22sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<ImageView
android:id=
"@+id/iv_popup_close"
android:layout_width=
"20dp"
android:layout_height=
"20dp"
android:layout_marginEnd=
"15dp"
android:onClick=
"@{()->click.close()}"
app:layout_constraintBottom_toBottomOf=
"@+id/tv_title"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_popup_close"
/>
<TextView
android:id=
"@+id/textView18"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingVertical=
"15dp"
android:paddingStart=
"20dp"
android:text=
"应收款:"
android:textColor=
"#969696"
android:textSize=
"20sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/tv_title"
/>
<TextView
android:id=
"@+id/textView19"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:paddingVertical=
"15dp"
android:paddingEnd=
"20dp"
android:text=
"@{vm.receivables2}"
android:textColor=
"#FF4400"
android:textSize=
"20sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/textView18"
app:layout_constraintTop_toBottomOf=
"@+id/tv_title"
tools:text=
"¥12.34"
/>
<TextView
android:id=
"@+id/textView17"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingVertical=
"15dp"
android:paddingStart=
"20dp"
android:text=
"实付款:"
android:textColor=
"#969696"
android:textSize=
"20sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView18"
/>
<EditText
android:id=
"@+id/textView20"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"20dp"
android:background=
"@drawable/edit_bg"
android:paddingVertical=
"15dp"
android:paddingStart=
"10dp"
android:imeOptions=
"actionDone"
android:hint=
"@{String.valueOf(vm.receivables)}"
android:inputType=
"numberDecimal"
android:digits=
"0123456789."
android:text=
"@={vm.actuallyPaid}"
android:textColor=
"#333333"
android:textColorHint=
"#999999"
android:textSize=
"20sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/textView17"
app:layout_constraintTop_toBottomOf=
"@+id/textView19"
/>
<TextView
android:id=
"@+id/textView21"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingVertical=
"15dp"
android:paddingStart=
"20dp"
android:text=
"找零: "
android:textColor=
"#969696"
android:textSize=
"20sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView17"
/>
<TextView
android:id=
"@+id/textView22"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:paddingVertical=
"15dp"
android:paddingEnd=
"20dp"
android:maxLength=
"6"
android:text=
"@{vm.change2}"
android:textColor=
"#333333"
android:textSize=
"20sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/textView21"
app:layout_constraintTop_toBottomOf=
"@+id/textView20"
tools:text=
"123"
/>
<TextView
android:id=
"@+id/textView23"
android:layout_width=
"0dp"
android:layout_height=
"50dp"
android:layout_marginHorizontal=
"20dp"
android:text=
"确认"
android:onClick=
"@{()->click.confirm()}"
android:layout_marginVertical=
"15dp"
android:background=
"@drawable/btn_confirm_bg"
android:textColor=
"@color/white"
android:textSize=
"20sp"
android:gravity=
"center"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView22"
app:layout_constraintVertical_bias=
"1.0"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
app/src/main/res/layout/popup_cash_pay_success.xml
0 → 100644
View file @
197c8c9d
<?xml version="1.0" encoding="utf-8"?>
<layout
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"
tools:ignore=
"MissingDefaultResource"
>
<data>
<variable
name=
"vm"
type=
"com.ypsx.yppos.viewmodel.state.PaySuccessViewModel"
/>
<variable
name=
"click"
type=
"com.ypsx.yppos.ui.popup.CashPaySuccessPopWindow.ProxyClick"
/>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/bg_popup_pay"
>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/imageView6"
android:layout_width=
"70dp"
android:layout_height=
"70dp"
android:layout_marginTop=
"25dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_pay_success"
/>
<TextView
android:id=
"@+id/textView3"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"15dp"
android:gravity=
"center"
android:text=
"@string/pay_success"
android:textColor=
"@color/black_333"
android:textSize=
"18sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/imageView6"
/>
<LinearLayout
android:id=
"@+id/linearLayout2"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_marginTop=
"5dp"
android:gravity=
"center_horizontal"
android:orientation=
"horizontal"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView3"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/black_333"
android:textSize=
"22dp"
android:text=
"收款:"
/>
<TextView
android:id=
"@+id/textView4"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/rmb"
android:textSize=
"22dp"
android:textColor=
"@color/red"
/>
<TextView
android:id=
"@+id/tv_amount"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@{vm.payAmount}"
android:textColor=
"@color/red"
android:textSize=
"22dp"
tools:text=
"112.32"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/linearLayout3"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_marginTop=
"5dp"
android:gravity=
"center_horizontal"
android:orientation=
"horizontal"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/linearLayout2"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/black_333"
android:textSize=
"22dp"
android:text=
"找零:"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/rmb"
android:textSize=
"22dp"
android:textColor=
"@color/red"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@{vm.changeAmount}"
android:textColor=
"@color/red"
android:textSize=
"22dp"
tools:text=
"12.32"
/>
</LinearLayout>
<TextView
android:id=
"@+id/textView9"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"14dp"
android:text=
"5s后自动关闭"
android:textColor=
"@color/colorAccent"
android:textSize=
"14sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/linearLayout3"
/>
<View
android:id=
"@+id/view2"
android:layout_width=
"0dp"
android:layout_height=
"0.5dp"
android:layout_marginTop=
"20dp"
android:background=
"@color/black_333"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView9"
/>
<TextView
android:id=
"@+id/textView10"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/close"
android:onClick=
"@{()->click.close()}"
android:textColor=
"@color/black_333"
android:gravity=
"center"
android:textSize=
"18sp"
android:paddingTop=
"12dp"
android:paddingBottom=
"12dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/view2"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
app/src/main/res/layout/popup_order_pay_amount.xml
View file @
197c8c9d
...
@@ -138,6 +138,23 @@
...
@@ -138,6 +138,23 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"@id/constraintLayout4"
>
app:layout_constraintTop_toTopOf=
"@id/constraintLayout4"
>
<RadioButton
android:id=
"@+id/rb_cash"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:layout_marginBottom=
"5dp"
android:background=
"@drawable/bg_pay_amount_check"
android:button=
"@null"
android:checked=
"true"
android:drawableEnd=
"@drawable/bg_pay_amount"
android:paddingStart=
"15dp"
android:paddingEnd=
"15dp"
android:text=
"@string/cash_pay"
android:visibility=
"@{vm.cashVisible}"
android:textColor=
"#4D4D4D"
android:textSize=
"16sp"
/>
<RadioButton
<RadioButton
android:id=
"@+id/rb_offline"
android:id=
"@+id/rb_offline"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
app/src/main/res/values/strings.xml
View file @
197c8c9d
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
<string
name=
"total_discount_amount"
>
总优惠金额:
</string>
<string
name=
"total_discount_amount"
>
总优惠金额:
</string>
<string
name=
"checkout_counter"
>
收银台
</string>
<string
name=
"checkout_counter"
>
收银台
</string>
<string
name=
"order_no"
>
小票流水号
</string>
<string
name=
"order_no"
>
小票流水号
</string>
<string
name=
"cash_pay"
>
现金
</string>
<string
name=
"scan_qr_pay"
>
扫码支付
</string>
<string
name=
"scan_qr_pay"
>
扫码支付
</string>
<string
name=
"member_balance_pay"
>
会员余额
</string>
<string
name=
"member_balance_pay"
>
会员余额
</string>
<string
name=
"receive_payment_now"
>
立即收款
</string>
<string
name=
"receive_payment_now"
>
立即收款
</string>
...
...
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