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
30bb8b6a
Commit
30bb8b6a
authored
May 26, 2022
by
赵鹏翔
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'develop'
Dev See merge request
!6
parents
0b38225b
e425d871
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
359 additions
and
289 deletions
+359
-289
BaseApplication.kt
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
+8
-1
EmptyRecyclerView.java
...main/java/com/miya/fastcashier/log/EmptyRecyclerView.java
+0
-62
EmptyRecyclerView.kt
...c/main/java/com/miya/fastcashier/log/EmptyRecyclerView.kt
+55
-0
SystemParameterDialog.kt
...in/java/com/miya/fastcashier/log/SystemParameterDialog.kt
+6
-4
PrintService.kt
...rc/main/java/com/miya/fastcashier/service/PrintService.kt
+212
-186
MainActivity.kt
app/src/main/java/com/miya/fastcashier/ui/MainActivity.kt
+53
-22
SettingActivity.kt
app/src/main/java/com/miya/fastcashier/ui/SettingActivity.kt
+0
-6
BaseFunction.kt
app/src/main/java/com/miya/fastcashier/utils/BaseFunction.kt
+12
-0
PrintViewModel.kt
...ain/java/com/miya/fastcashier/viewmodel/PrintViewModel.kt
+1
-1
dialog_system_parameter.xml
app/src/main/res/layout/dialog_system_parameter.xml
+5
-5
strings.xml
app/src/main/res/values/strings.xml
+1
-0
版本历史.md
doc/版本历史.md
+4
-0
versions.gradle
versions.gradle
+2
-2
No files found.
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
View file @
30bb8b6a
...
@@ -97,7 +97,7 @@ class BaseApplication : MultiDexApplication() {
...
@@ -97,7 +97,7 @@ class BaseApplication : MultiDexApplication() {
LogFileUtils
.
writeLog
(
LogFileUtils
.
writeLog
(
ContextUtils
.
getContext
(),
ContextUtils
.
getContext
(),
DateUtils
.
getDateStringByTimeStamp
(
System
.
currentTimeMillis
())
DateUtils
.
getDateStringByTimeStamp
(
System
.
currentTimeMillis
())
.
toString
()
+
"
"
+
message
+
"\n"
.
toString
()
+
"
$message"
+
"\n"
)
)
}
}
if
(
BuildConfig
.
DEBUG
)
{
if
(
BuildConfig
.
DEBUG
)
{
...
@@ -107,6 +107,13 @@ class BaseApplication : MultiDexApplication() {
...
@@ -107,6 +107,13 @@ class BaseApplication : MultiDexApplication() {
loggingInterceptor
.
level
=
MiyaHttpLoggingInterceptor
.
Level
.
BODY
loggingInterceptor
.
level
=
MiyaHttpLoggingInterceptor
.
Level
.
BODY
}
catch
(
ex
:
Exception
)
{
}
catch
(
ex
:
Exception
)
{
ex
.
printStackTrace
()
ex
.
printStackTrace
()
if
(!
LogFileUtils
.
isProhibitWrite
)
{
LogFileUtils
.
writeLog
(
ContextUtils
.
getContext
(),
DateUtils
.
getDateStringByTimeStamp
(
System
.
currentTimeMillis
())
.
toString
()
+
"异常: ${ex.message}"
+
"\n"
)
}
}
}
MiYaPayMobileApiClient
.
init
(
true
,
loggingInterceptor
)
MiYaPayMobileApiClient
.
init
(
true
,
loggingInterceptor
)
}
}
...
...
app/src/main/java/com/miya/fastcashier/log/EmptyRecyclerView.java
deleted
100644 → 0
View file @
0b38225b
package
com
.
miya
.
fastcashier
.
log
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
androidx.annotation.Nullable
;
import
androidx.recyclerview.widget.RecyclerView
;
/**
* 作者:Leon
* 时间:2017/3/17 13:44
*/
public
class
EmptyRecyclerView
extends
RecyclerView
{
private
View
mEmptyView
;
public
EmptyRecyclerView
(
Context
context
)
{
super
(
context
);
}
public
EmptyRecyclerView
(
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
public
EmptyRecyclerView
(
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyle
)
{
super
(
context
,
attrs
,
defStyle
);
}
/**
* 根据数据源判断是否显示空白view
*/
private
void
checkIfEmpty
()
{
if
(
mEmptyView
!=
null
||
getAdapter
()
!=
null
)
{
mEmptyView
.
setVisibility
(
getAdapter
().
getItemCount
()
>
0
?
GONE
:
VISIBLE
);
}
}
public
void
setmEmptyView
(
View
mEmptyView
)
{
this
.
mEmptyView
=
mEmptyView
;
checkIfEmpty
();
}
@Override
public
void
setAdapter
(
Adapter
adapter
)
{
Adapter
adapterOld
=
getAdapter
();
if
(
adapterOld
!=
null
)
{
adapterOld
.
unregisterAdapterDataObserver
(
observer
);
}
super
.
setAdapter
(
adapter
);
if
(
adapter
!=
null
)
{
adapter
.
registerAdapterDataObserver
(
observer
);
}
}
AdapterDataObserver
observer
=
new
AdapterDataObserver
()
{
@Override
public
void
onChanged
()
{
super
.
onChanged
();
checkIfEmpty
();
}
};
}
app/src/main/java/com/miya/fastcashier/log/EmptyRecyclerView.kt
0 → 100644
View file @
30bb8b6a
package
com.miya.fastcashier.log
import
android.content.Context
import
android.util.AttributeSet
import
android.view.View
import
androidx.recyclerview.widget.RecyclerView
/**
* 作者:Leon
* 时间:2017/3/17 13:44
*/
class
EmptyRecyclerView
:
RecyclerView
{
private
var
mEmptyView
:
View
?
=
null
constructor
(
context
:
Context
?)
:
super
(
context
!!
)
{}
constructor
(
context
:
Context
?,
attrs
:
AttributeSet
?)
:
super
(
context
!!
,
attrs
)
{
}
constructor
(
context
:
Context
?,
attrs
:
AttributeSet
?,
defStyle
:
Int
)
:
super
(
context
!!
,
attrs
,
defStyle
)
{
}
/**
* 根据数据源判断是否显示空白view
*/
private
fun
checkIfEmpty
()
{
if
(
mEmptyView
!=
null
||
adapter
!=
null
)
{
mEmptyView
!!
.
visibility
=
if
(
adapter
!!
.
itemCount
>
0
)
GONE
else
VISIBLE
}
}
fun
setmEmptyView
(
mEmptyView
:
View
?)
{
this
.
mEmptyView
=
mEmptyView
checkIfEmpty
()
}
override
fun
setAdapter
(
adapter
:
Adapter
<
*
>?)
{
val
adapterOld
=
getAdapter
()
adapterOld
?.
unregisterAdapterDataObserver
(
observer
)
super
.
setAdapter
(
adapter
)
adapter
?.
registerAdapterDataObserver
(
observer
)
}
var
observer
:
AdapterDataObserver
=
object
:
AdapterDataObserver
()
{
override
fun
onChanged
()
{
super
.
onChanged
()
checkIfEmpty
()
}
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/log/SystemParameterDialog.kt
View file @
30bb8b6a
...
@@ -3,10 +3,7 @@ package com.miya.fastcashier.log
...
@@ -3,10 +3,7 @@ package com.miya.fastcashier.log
import
android.app.Dialog
import
android.app.Dialog
import
android.content.Context
import
android.content.Context
import
com.miya.fastcashier.service.AccountService.getAccountInfo
import
com.miya.fastcashier.service.AccountService.getAccountInfo
import
com.miya.fastcashier.utils.getVersion
import
com.miya.fastcashier.net.ApiConfig.baseUrl
import
com.miya.fastcashier.net.ApiConfig.baseUrl
import
com.miya.fastcashier.utils.getWifyName
import
com.miya.fastcashier.utils.getNetIp
import
com.miya.fastcashier.R
import
com.miya.fastcashier.R
import
com.miya.fastcashier.beans.SelfCashierAccountInfo
import
com.miya.fastcashier.beans.SelfCashierAccountInfo
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.service.AccountService
...
@@ -19,6 +16,8 @@ import android.view.Gravity
...
@@ -19,6 +16,8 @@ import android.view.Gravity
import
android.view.View
import
android.view.View
import
com.miya.fastcashier.BuildConfig
import
com.miya.fastcashier.BuildConfig
import
com.miya.fastcashier.databinding.DialogSystemParameterBinding
import
com.miya.fastcashier.databinding.DialogSystemParameterBinding
import
com.miya.fastcashier.utils.*
import
java.util.*
class
SystemParameterDialog
(
context
:
Context
)
:
Dialog
(
context
,
R
.
style
.
CommonDialog
)
{
class
SystemParameterDialog
(
context
:
Context
)
:
Dialog
(
context
,
R
.
style
.
CommonDialog
)
{
...
@@ -46,7 +45,10 @@ class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDi
...
@@ -46,7 +45,10 @@ class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDi
setInfo
(
viewBinding
.
tvEquipment
,
"sunmi_v2pro"
)
setInfo
(
viewBinding
.
tvEquipment
,
"sunmi_v2pro"
)
setInfo
(
viewBinding
.
tvServerUrl
,
baseUrl
)
setInfo
(
viewBinding
.
tvServerUrl
,
baseUrl
)
setInfo
(
viewBinding
.
tvWifiName
,
getWifyName
(
context
))
setInfo
(
viewBinding
.
tvWifiName
,
getWifyName
(
context
))
setInfo
(
viewBinding
.
tvNetIp
,
if
(
getNetIp
(
context
)
==
null
)
"未知"
else
getNetIp
(
context
))
setInfo
(
viewBinding
.
tvLog
,
"${getVersionCode(context)}_${DateUtils.format8(Date())}.txt"
)
setInfo
(
setInfo
(
viewBinding
.
tvPrintType
,
viewBinding
.
tvPrintType
,
if
(
PrinterManager
.
getInstance
().
printer
==
null
)
context
.
resources
.
getString
(
R
.
string
.
app_unkown
)
else
PrinterManager
.
getInstance
().
printer
.
printerName
if
(
PrinterManager
.
getInstance
().
printer
==
null
)
context
.
resources
.
getString
(
R
.
string
.
app_unkown
)
else
PrinterManager
.
getInstance
().
printer
.
printerName
...
...
app/src/main/java/com/miya/fastcashier/service/PrintService.kt
View file @
30bb8b6a
...
@@ -13,70 +13,11 @@ import com.miya.print.PrinterManager
...
@@ -13,70 +13,11 @@ import com.miya.print.PrinterManager
import
com.miya.print.utils.Page58MmPrintUtils
import
com.miya.print.utils.Page58MmPrintUtils
import
com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import
com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import
java.util.*
import
java.util.*
import
kotlin.concurrent.schedule
object
PrintService
{
object
PrintService
{
private
var
payServiceResponse
:
PayServiceResponse
?
=
null
;
private
var
payServiceResponse
:
PayServiceResponse
?
=
null
/**
* 退款
*/
fun
refundPrint
(
selfCashierAccountInfo
:
SelfCashierAccountInfo
,
payServiceResponse
:
PayServiceResponse
)
{
val
printer
=
PrinterManager
.
getInstance
().
printer
printer
.
beginPrint
()
//检查打印机状态
printer
.
printerStatus
printer
.
set58mm
()
refundPrintCashier
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
)
refundPrintCustomer
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
)
printer
.
feedPaper
()
printer
.
endPrint
()
}
/**
* 查询订单单项打印
*/
fun
printSearchOrder
(
selfCashierAccountInfo
:
SelfCashierAccountInfo
,
payServiceResponse
:
PayServiceResponse
,
isRefund
:
Boolean
)
{
if
(
isRefund
)
{
refundPrint
(
selfCashierAccountInfo
,
payServiceResponse
)
}
else
{
val
printer
=
PrinterManager
.
getInstance
().
printer
printer
.
beginPrint
()
//检查打印机状态
printer
.
printerStatus
printer
.
set58mm
()
// if (BuildConfig.DEBUG) {
// printCashier(
// printer,
// payServiceResponse,
// selfCashierAccountInfo,
// OrderRecordManageKit.getSerialNoByOrderNo(payServiceResponse.shopTradeNo))
// } else {
printCashier
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
,
OrderRecordManageKit
.
getSerialNoByOrderNo
(
payServiceResponse
.
shopTradeNo
)
)
printCustomer
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
,
OrderRecordManageKit
.
getSerialNoByOrderNo
(
payServiceResponse
.
shopTradeNo
)
)
// }
printer
.
feedPaper
()
printer
.
endPrint
()
}
}
/**
/**
* 打印上一单
* 打印上一单
...
@@ -85,14 +26,14 @@ object PrintService {
...
@@ -85,14 +26,14 @@ object PrintService {
if
(
payServiceResponse
==
null
)
{
if
(
payServiceResponse
==
null
)
{
throw
java
.
lang
.
RuntimeException
(
"暂无上一单信息"
)
throw
java
.
lang
.
RuntimeException
(
"暂无上一单信息"
)
}
else
{
}
else
{
AccountService
.
getAccountInfo
()
?.
let
{
pay
Info
Print
(
payServiceResponse
!!
,
it
)
}
AccountService
.
getAccountInfo
()
?.
let
{
payPrint
(
payServiceResponse
!!
,
it
)
}
}
}
}
}
/**
/**
*
扣款信息
打印
*
收费
打印
*/
*/
fun
pay
Info
Print
(
fun
payPrint
(
payServiceResponse
:
PayServiceResponse
,
payServiceResponse
:
PayServiceResponse
,
selfCashierAccountInfo
:
SelfCashierAccountInfo
selfCashierAccountInfo
:
SelfCashierAccountInfo
)
{
)
{
...
@@ -108,138 +49,38 @@ object PrintService {
...
@@ -108,138 +49,38 @@ object PrintService {
//检查打印机状态
//检查打印机状态
printer
.
printerStatus
printer
.
printerStatus
printer
.
set58mm
()
printer
.
set58mm
()
// if (BuildConfig.DEBUG) {
handlePayPrint
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
,
serialNumber
)
// printCashier(printer, payServiceResponse, selfCashierAccountInfo, serialNumber)
// } else {
printCashier
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
,
serialNumber
)
printCustomer
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
,
serialNumber
)
// }
printer
.
feedPaper
()
printer
.
endPrint
()
}
/**
* 统计,给两个时间,
*/
fun
printStatisticInfo
(
viewOrderStatisticsInfo
:
ViewOrderStatisticsInfo
,
selfCashierAccountInfo
:
SelfCashierAccountInfo
,
isBalance
:
Boolean
)
{
val
printer
=
PrinterManager
.
getInstance
().
printer
printer
.
beginPrint
()
//检查打印机状态
printer
.
printerStatus
printer
.
set58mm
()
doPrintStatisticInfo
(
printer
,
viewOrderStatisticsInfo
,
selfCashierAccountInfo
,
isBalance
)
printer
.
feedPaper
()
printer
.
feedPaper
()
printer
.
endPrint
()
printer
.
endPrint
()
}
}
private
fun
handlePayPrint
(
private
fun
doPrintStatisticInfo
(
printer
:
IPrinter
,
printer
:
IPrinter
,
orderStatisticsInfo
:
ViewOrderStatisticsInfo
,
payServiceResponse
:
PayServiceResponse
,
a
ccountInfo
:
SelfCashierAccountInfo
,
selfCashierA
ccountInfo
:
SelfCashierAccountInfo
,
isBalance
:
Boolean
serialNumber
:
String
)
{
)
{
// if (BuildConfig.DEBUG) {
// printCashier(printer, payServiceResponse, selfCashierAccountInfo, serialNumber)
// } else {
printCashier
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
,
serialNumber
)
if
(
accountInfo
.
shopInfo
==
null
)
{
Timer
().
schedule
(
4000
)
{
throw
RuntimeException
(
"无商户配置数据"
)
printCustomer
(
}
printer
,
val
shopInfo
=
accountInfo
.
shopInfo
payServiceResponse
,
printer
.
printText
(
IPrinter
.
ALIGN_CENTER
,
3
,
accountInfo
.
shopInfo
?.
storeName
?:
""
,
true
)
selfCashierAccountInfo
,
if
(
isBalance
)
{
serialNumber
printer
.
printText
(
IPrinter
.
ALIGN_CENTER
,
3
,
"结算总计单"
,
true
)
}
else
{
printer
.
printText
(
IPrinter
.
ALIGN_CENTER
,
3
,
"交易汇总表"
,
true
)
}
printer
.
setAlign
(
IPrinter
.
ALIGN_LEFT
)
printer
.
printText
(
"商户名称:converse"
)
printer
.
printText
(
"商户编号:${shopInfo.saasid}"
)
printer
.
printText
(
"终端编号:${shopInfo.posId}"
)
printer
.
printText
(
"门店编号:${shopInfo.storeId}"
)
//统计时间
printer
.
printText
(
0
,
0
,
"开始时间:"
+
orderStatisticsInfo
.
beginDate
,
true
)
printer
.
printText
(
0
,
0
,
"结束时间:"
+
orderStatisticsInfo
.
endDate
,
true
)
val
totalStatistics
:
ViewOrderStatisticsInfo
.
StatisticBean
?
=
orderStatisticsInfo
.
totalStatistic
if
(
totalStatistics
!=
null
)
{
var
tradeCount
=
totalStatistics
.
tradeCount
+
totalStatistics
.
refundCount
printer
.
printText
(
0
,
0
,
Page58MmPrintUtils
.
printDivideLineString
(),
true
)
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"总交易笔数"
,
""
+
tradeCount
)
)
var
tradeTotalAmount
=
totalStatistics
.
tradeTotalAmount
-
totalStatistics
.
refundTotalAmount
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"总交易金额"
,
""
+
StringPriceFormat
.
transStringPriceToDecimalString
(
tradeTotalAmount
.
toString
())
)
)
)
}
}
// }
if
(!
isEmpty
(
orderStatisticsInfo
.
typeStatistic
))
{
val
typedStatisticList
:
List
<
ViewOrderStatisticsInfo
.
StatisticBean
>
=
orderStatisticsInfo
.
typeStatistic
var
statisticBean
:
ViewOrderStatisticsInfo
.
StatisticBean
for
(
i
in
typedStatisticList
.
indices
)
{
if
(
typedStatisticList
[
i
]
==
null
)
{
continue
}
statisticBean
=
typedStatisticList
[
i
]
printer
.
printText
(
0
,
0
,
Page58MmPrintUtils
.
printDivideLineString
(),
true
)
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"支付方式"
,
statisticBean
.
payType
)
)
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"交易笔数"
,
""
+
statisticBean
.
tradeCount
)
)
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"交易金额"
,
""
+
StringPriceFormat
.
transStringPriceToDecimalString
(
statisticBean
.
tradeTotalAmount
.
toString
())
)
)
if
(
statisticBean
.
refundCount
>
0
)
{
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"退款笔数"
,
""
+
statisticBean
.
refundCount
)
)
}
if
(
statisticBean
.
refundTotalAmount
>
0
)
{
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"退款金额"
,
""
+
StringPriceFormat
.
transStringPriceToDecimalString
(
statisticBean
.
refundTotalAmount
.
toString
())
)
)
}
}
}
printer
.
printText
(
"\n\n"
)
}
}
/**
/**
* 打印收银员联
* 打印收银员联
*/
*/
...
@@ -249,7 +90,6 @@ object PrintService {
...
@@ -249,7 +90,6 @@ object PrintService {
selfCashierAccountInfo
:
SelfCashierAccountInfo
,
selfCashierAccountInfo
:
SelfCashierAccountInfo
,
serialNumber
:
String
serialNumber
:
String
)
{
)
{
val
shopInfo
=
selfCashierAccountInfo
.
shopInfo
val
shopInfo
=
selfCashierAccountInfo
.
shopInfo
printer
.
printText
(
IPrinter
.
ALIGN_CENTER
,
3
,
shopInfo
.
storeName
,
true
)
printer
.
printText
(
IPrinter
.
ALIGN_CENTER
,
3
,
shopInfo
.
storeName
,
true
)
printer
.
setAlign
(
IPrinter
.
ALIGN_LEFT
)
printer
.
setAlign
(
IPrinter
.
ALIGN_LEFT
)
...
@@ -380,6 +220,70 @@ object PrintService {
...
@@ -380,6 +220,70 @@ object PrintService {
}
}
/**
* 查询订单单项打印
*/
fun
printSearchOrder
(
selfCashierAccountInfo
:
SelfCashierAccountInfo
,
payServiceResponse
:
PayServiceResponse
,
isRefund
:
Boolean
)
{
if
(
isRefund
)
{
refundPrint
(
selfCashierAccountInfo
,
payServiceResponse
)
}
else
{
val
printer
=
PrinterManager
.
getInstance
().
printer
printer
.
beginPrint
()
//检查打印机状态
printer
.
printerStatus
printer
.
set58mm
()
handlePayPrint
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
,
OrderRecordManageKit
.
getSerialNoByOrderNo
(
payServiceResponse
.
shopTradeNo
)
)
printer
.
feedPaper
()
printer
.
endPrint
()
}
}
/**
* 退款
*/
fun
refundPrint
(
selfCashierAccountInfo
:
SelfCashierAccountInfo
,
payServiceResponse
:
PayServiceResponse
)
{
val
printer
=
PrinterManager
.
getInstance
().
printer
printer
.
beginPrint
()
//检查打印机状态
printer
.
printerStatus
printer
.
set58mm
()
handleRefundPrint
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
)
printer
.
feedPaper
()
printer
.
endPrint
()
}
fun
handleRefundPrint
(
printer
:
IPrinter
,
payServiceResponse
:
PayServiceResponse
,
selfCashierAccountInfo
:
SelfCashierAccountInfo
)
{
refundPrintCashier
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
)
Timer
().
schedule
(
4000
)
{
refundPrintCustomer
(
printer
,
payServiceResponse
,
selfCashierAccountInfo
)
}
}
/**
/**
* 打印收银员联 - 退款
* 打印收银员联 - 退款
*/
*/
...
@@ -519,4 +423,126 @@ object PrintService {
...
@@ -519,4 +423,126 @@ object PrintService {
}
}
printer
.
printText
(
"\n\n"
)
printer
.
printText
(
"\n\n"
)
}
}
/**
* 统计、结算打印,需要起止时间
*/
fun
printStatisticInfo
(
viewOrderStatisticsInfo
:
ViewOrderStatisticsInfo
,
selfCashierAccountInfo
:
SelfCashierAccountInfo
,
isBalance
:
Boolean
)
{
val
printer
=
PrinterManager
.
getInstance
().
printer
printer
.
beginPrint
()
//检查打印机状态
printer
.
printerStatus
printer
.
set58mm
()
doPrintStatisticInfo
(
printer
,
viewOrderStatisticsInfo
,
selfCashierAccountInfo
,
isBalance
)
printer
.
feedPaper
()
printer
.
endPrint
()
}
private
fun
doPrintStatisticInfo
(
printer
:
IPrinter
,
orderStatisticsInfo
:
ViewOrderStatisticsInfo
,
accountInfo
:
SelfCashierAccountInfo
,
isBalance
:
Boolean
)
{
if
(
accountInfo
.
shopInfo
==
null
)
{
throw
RuntimeException
(
"无商户配置数据"
)
}
val
shopInfo
=
accountInfo
.
shopInfo
printer
.
printText
(
IPrinter
.
ALIGN_CENTER
,
3
,
accountInfo
.
shopInfo
?.
storeName
?:
""
,
true
)
if
(
isBalance
)
{
printer
.
printText
(
IPrinter
.
ALIGN_CENTER
,
3
,
"结算总计单"
,
true
)
}
else
{
printer
.
printText
(
IPrinter
.
ALIGN_CENTER
,
3
,
"交易汇总表"
,
true
)
}
printer
.
setAlign
(
IPrinter
.
ALIGN_LEFT
)
printer
.
printText
(
"商户名称:converse"
)
printer
.
printText
(
"商户编号:${shopInfo.saasid}"
)
printer
.
printText
(
"终端编号:${shopInfo.posId}"
)
printer
.
printText
(
"门店编号:${shopInfo.storeId}"
)
//统计时间
printer
.
printText
(
0
,
0
,
"开始时间:"
+
orderStatisticsInfo
.
beginDate
,
true
)
printer
.
printText
(
0
,
0
,
"结束时间:"
+
orderStatisticsInfo
.
endDate
,
true
)
val
totalStatistics
:
ViewOrderStatisticsInfo
.
StatisticBean
?
=
orderStatisticsInfo
.
totalStatistic
if
(
totalStatistics
!=
null
)
{
var
tradeCount
=
totalStatistics
.
tradeCount
+
totalStatistics
.
refundCount
printer
.
printText
(
0
,
0
,
Page58MmPrintUtils
.
printDivideLineString
(),
true
)
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"总交易笔数"
,
""
+
tradeCount
)
)
var
tradeTotalAmount
=
totalStatistics
.
tradeTotalAmount
-
totalStatistics
.
refundTotalAmount
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"总交易金额"
,
""
+
StringPriceFormat
.
transStringPriceToDecimalString
(
tradeTotalAmount
.
toString
())
)
)
}
if
(!
isEmpty
(
orderStatisticsInfo
.
typeStatistic
))
{
val
typedStatisticList
:
List
<
ViewOrderStatisticsInfo
.
StatisticBean
>
=
orderStatisticsInfo
.
typeStatistic
var
statisticBean
:
ViewOrderStatisticsInfo
.
StatisticBean
for
(
i
in
typedStatisticList
.
indices
)
{
if
(
typedStatisticList
[
i
]
==
null
)
{
continue
}
statisticBean
=
typedStatisticList
[
i
]
printer
.
printText
(
0
,
0
,
Page58MmPrintUtils
.
printDivideLineString
(),
true
)
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"支付方式"
,
statisticBean
.
payType
)
)
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"交易笔数"
,
""
+
statisticBean
.
tradeCount
)
)
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"交易金额"
,
""
+
StringPriceFormat
.
transStringPriceToDecimalString
(
statisticBean
.
tradeTotalAmount
.
toString
())
)
)
if
(
statisticBean
.
refundCount
>
0
)
{
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"退款笔数"
,
""
+
statisticBean
.
refundCount
)
)
}
if
(
statisticBean
.
refundTotalAmount
>
0
)
{
printer
.
printText
(
Page58MmPrintUtils
.
printTwoData
(
"退款金额"
,
""
+
StringPriceFormat
.
transStringPriceToDecimalString
(
statisticBean
.
refundTotalAmount
.
toString
())
)
)
}
}
}
printer
.
printText
(
"\n\n"
)
}
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/ui/MainActivity.kt
View file @
30bb8b6a
...
@@ -2,20 +2,23 @@ package com.miya.fastcashier.ui
...
@@ -2,20 +2,23 @@ package com.miya.fastcashier.ui
import
android.content.Intent
import
android.content.Intent
import
android.os.Bundle
import
android.os.Bundle
import
android.view.Gravity
import
android.widget.Toast
import
android.widget.Toast
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.fragment.app.FragmentManager
import
androidx.fragment.app.FragmentManager
import
androidx.lifecycle.ViewModelProvider
import
androidx.lifecycle.ViewModelProvider
import
com.miya.fastcashier.BaseApplication
import
com.miya.fastcashier.R
import
com.miya.fastcashier.databinding.ActivityMainBinding
import
com.miya.fastcashier.databinding.ActivityMainBinding
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.service.PrintService
import
com.miya.fastcashier.service.PrintService
import
com.miya.fastcashier.ui.dialog.AuthorizePasswordInputDialog
import
com.miya.fastcashier.ui.dialog.AuthorizePasswordInputDialog
import
com.miya.fastcashier.ui.dialog.CommonDialog
import
com.miya.fastcashier.utils.*
import
com.miya.fastcashier.utils.*
import
com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import
com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import
com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import
com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import
com.miya.fastcashier.utils.manage.OrderRecordManageKit
import
com.miya.fastcashier.utils.manage.OrderRecordManageKit
import
com.miya.fastcashier.viewmodel.MainViewModel
import
com.miya.fastcashier.viewmodel.MainViewModel
import
com.miya.print.utils.PrintLogger
import
java.util.*
import
java.util.*
class
MainActivity
:
BaseActivity
()
{
class
MainActivity
:
BaseActivity
()
{
...
@@ -24,6 +27,7 @@ class MainActivity : BaseActivity() {
...
@@ -24,6 +27,7 @@ class MainActivity : BaseActivity() {
private
lateinit
var
binding
:
ActivityMainBinding
private
lateinit
var
binding
:
ActivityMainBinding
private
lateinit
var
viewModel
:
MainViewModel
private
lateinit
var
viewModel
:
MainViewModel
private
var
dateSelectHelper
:
DateSelectHelper
?
=
null
private
var
dateSelectHelper
:
DateSelectHelper
?
=
null
private
var
confirmDialog
:
CommonDialog
?
=
null
companion
object
{
companion
object
{
@JvmStatic
@JvmStatic
...
@@ -81,27 +85,7 @@ class MainActivity : BaseActivity() {
...
@@ -81,27 +85,7 @@ class MainActivity : BaseActivity() {
}
}
binding
.
llBalance
.
clickWithTrigger
{
binding
.
llBalance
.
clickWithTrigger
{
//上次记录的时间,或者当天0点
showConfirmBalanceDialog
()
var
timeMillis
=
LocalKeyDataMKManageKit
.
getBalanceDate
()
if
(
timeMillis
>
0L
&&
timeMillis
<=
System
.
currentTimeMillis
())
{
val
currentDate
=
Date
()
var
daysAgoCurrent
:
Long
=
DateUtils
.
getDaysAgo
(
currentDate
,
1
)
if
(
timeMillis
<=
daysAgoCurrent
)
{
timeMillis
=
daysAgoCurrent
}
viewModel
.
orderStatistics
(
Date
(
timeMillis
),
currentDate
,
true
)
}
else
{
val
startDate
=
Calendar
.
getInstance
()
startDate
.
set
(
startDate
.
get
(
Calendar
.
YEAR
),
startDate
.
get
(
Calendar
.
MONTH
),
startDate
.
get
(
Calendar
.
DAY_OF_MONTH
),
0
,
0
,
0
)
viewModel
.
orderStatistics
(
startDate
.
time
,
Date
(),
true
)
}
}
}
initData
()
initData
()
...
@@ -144,6 +128,53 @@ class MainActivity : BaseActivity() {
...
@@ -144,6 +128,53 @@ class MainActivity : BaseActivity() {
})
})
}
}
private
fun
showConfirmBalanceDialog
(){
if
(
confirmDialog
==
null
||
!
confirmDialog
!!
.
isShowing
)
{
confirmDialog
=
CommonDialog
(
this
)
confirmDialog
!!
.
setCustomMessage
(
getString
(
R
.
string
.
app_text_confirm_balance
))
.
setNegativeStr
(
getString
(
R
.
string
.
cancel
))
.
setPositiveStr
(
getString
(
R
.
string
.
sure
))
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
)
.
setOnClickListener
(
object
:
CommonDialog
.
OnDialogClickListener
{
override
fun
onNegativeClick
()
{
confirmDialog
!!
.
dismiss
()
confirmDialog
=
null
}
override
fun
onPositiveClick
()
{
toBalance
()
confirmDialog
!!
.
dismiss
()
confirmDialog
=
null
}
})
.
show
()
}
}
private
fun
toBalance
(){
//上次记录的时间,或者当天0点
var
timeMillis
=
LocalKeyDataMKManageKit
.
getBalanceDate
()
if
(
timeMillis
>
0L
&&
timeMillis
<=
System
.
currentTimeMillis
())
{
val
currentDate
=
Date
()
var
daysAgoCurrent
:
Long
=
DateUtils
.
getDaysAgo
(
currentDate
,
1
)
if
(
timeMillis
<=
daysAgoCurrent
)
{
timeMillis
=
daysAgoCurrent
}
viewModel
.
orderStatistics
(
Date
(
timeMillis
),
currentDate
,
true
)
}
else
{
val
startDate
=
Calendar
.
getInstance
()
startDate
.
set
(
startDate
.
get
(
Calendar
.
YEAR
),
startDate
.
get
(
Calendar
.
MONTH
),
startDate
.
get
(
Calendar
.
DAY_OF_MONTH
),
0
,
0
,
0
)
viewModel
.
orderStatistics
(
startDate
.
time
,
Date
(),
true
)
}
}
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
dateSelectHelper
?.
dismiss
()
dateSelectHelper
?.
dismiss
()
super
.
onDestroy
()
super
.
onDestroy
()
...
...
app/src/main/java/com/miya/fastcashier/ui/SettingActivity.kt
View file @
30bb8b6a
...
@@ -69,12 +69,6 @@ class SettingActivity : BaseActivity() {
...
@@ -69,12 +69,6 @@ class SettingActivity : BaseActivity() {
// }
// }
// }
// }
if
(
countClick
<
5
)
{
if
(
countClick
<
5
)
{
if
(
countClick
>=
2
&&
countClick
<
5
)
{
Toasty
.
info
(
applicationContext
,
getString
(
R
.
string
.
toast_click_again
,
5
-
countClick
)
).
show
()
}
return
return
}
}
...
...
app/src/main/java/com/miya/fastcashier/utils/BaseFunction.kt
View file @
30bb8b6a
...
@@ -103,6 +103,18 @@ fun getVersion(context: Context): String? {
...
@@ -103,6 +103,18 @@ fun getVersion(context: Context): String? {
return
version
return
version
}
}
fun
getVersionCode
(
context
:
Context
):
String
?
{
val
packageManager
=
context
.
packageManager
val
packageInfo
:
PackageInfo
var
version
=
""
try
{
packageInfo
=
packageManager
.
getPackageInfo
(
context
.
packageName
,
0
)
version
=
"${packageInfo.versionCode}"
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
e
.
printStackTrace
()
}
return
version
}
/**
/**
* 判断是否有网络连接
* 判断是否有网络连接
...
...
app/src/main/java/com/miya/fastcashier/viewmodel/PrintViewModel.kt
View file @
30bb8b6a
...
@@ -18,7 +18,7 @@ class PrintViewModel : ViewModel() {
...
@@ -18,7 +18,7 @@ class PrintViewModel : ViewModel() {
viewModelScope
.
launch
(
Dispatchers
.
IO
){
viewModelScope
.
launch
(
Dispatchers
.
IO
){
try
{
try
{
AccountService
.
getAccountInfo
()
?.
let
{
AccountService
.
getAccountInfo
()
?.
let
{
PrintService
.
pay
Info
Print
(
payServiceResponse
,
it
)
PrintService
.
payPrint
(
payServiceResponse
,
it
)
}
}
printResultLiveData
.
postValue
(
Result
.
success
(
Any
()))
printResultLiveData
.
postValue
(
Result
.
success
(
Any
()))
}
catch
(
e
:
Exception
){
}
catch
(
e
:
Exception
){
...
...
app/src/main/res/layout/dialog_system_parameter.xml
View file @
30bb8b6a
...
@@ -277,18 +277,18 @@
...
@@ -277,18 +277,18 @@
app:layout_constraintTop_toTopOf=
"@id/tv_wifi_name_text"
/>
app:layout_constraintTop_toTopOf=
"@id/tv_wifi_name_text"
/>
<TextView
<TextView
android:id=
"@+id/tv_
net_ip
_text"
android:id=
"@+id/tv_
log
_text"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"20dp"
android:layout_marginTop=
"20dp"
android:text=
"
网络IP
"
android:text=
"
日志名称
"
android:textColor=
"@color/color_333333"
android:textColor=
"@color/color_333333"
android:textSize=
"30sp"
android:textSize=
"30sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/tv_wifi_name_text"
/>
app:layout_constraintTop_toBottomOf=
"@id/tv_wifi_name_text"
/>
<TextView
<TextView
android:id=
"@+id/tv_
net_ip
"
android:id=
"@+id/tv_
log
"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"right"
android:gravity=
"right"
...
@@ -296,7 +296,7 @@
...
@@ -296,7 +296,7 @@
android:textColor=
"@color/color_333333"
android:textColor=
"@color/color_333333"
android:textSize=
"30sp"
android:textSize=
"30sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"@id/tv_
net_ip
_text"
/>
app:layout_constraintTop_toTopOf=
"@id/tv_
log
_text"
/>
<TextView
<TextView
android:id=
"@+id/tv_print_type_text"
android:id=
"@+id/tv_print_type_text"
...
@@ -307,7 +307,7 @@
...
@@ -307,7 +307,7 @@
android:textColor=
"@color/color_333333"
android:textColor=
"@color/color_333333"
android:textSize=
"30sp"
android:textSize=
"30sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/tv_
net_ip
_text"
/>
app:layout_constraintTop_toBottomOf=
"@id/tv_
log
_text"
/>
<TextView
<TextView
android:id=
"@+id/tv_print_type"
android:id=
"@+id/tv_print_type"
...
...
app/src/main/res/values/strings.xml
View file @
30bb8b6a
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
<string
name=
"sure"
>
确定
</string>
<string
name=
"sure"
>
确定
</string>
<string
name=
"search_order_prompt_text"
>
还没有明细哦~
</string>
<string
name=
"search_order_prompt_text"
>
还没有明细哦~
</string>
<string
name=
"app_text_login_out"
>
是否确认退出账号
</string>
<string
name=
"app_text_login_out"
>
是否确认退出账号
</string>
<string
name=
"app_text_confirm_balance"
>
是否确认结算打印
</string>
<string
name=
"text_login_out_sure"
>
确认退出
</string>
<string
name=
"text_login_out_sure"
>
确认退出
</string>
<string
name=
"app_login_out"
>
退出登录
</string>
<string
name=
"app_login_out"
>
退出登录
</string>
<string
name=
"text_refund_amount"
>
退款金额¥%s,是否确认退款
</string>
<string
name=
"text_refund_amount"
>
退款金额¥%s,是否确认退款
</string>
...
...
doc/版本历史.md
View file @
30bb8b6a
# 版本历史
# 版本历史
## tag
####v2.1.5 :
-打印第二联做延时处理、结算打印添加二次确认
## tag
## tag
#### 优化版本:
#### 优化版本:
-添加日志上传功能
-添加日志上传功能
...
...
versions.gradle
View file @
30bb8b6a
ext
{
ext
{
VERSION_CODE
=
2
5
VERSION_CODE
=
2
6
VERSION_NAME
=
'2.1.
4
'
VERSION_NAME
=
'2.1.
5
'
}
}
\ No newline at end of file
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