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
142206b6
Commit
142206b6
authored
3 years ago
by
UIUANG\Zsc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更改数据库,修改打印
parent
02187684
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
160 additions
and
56 deletions
+160
-56
.gitignore
.gitignore
+2
-0
build.gradle
app/build.gradle
+18
-18
InsertOrderProductDTO.kt
...va/com/ypsx/yppos/http/data/bean/InsertOrderProductDTO.kt
+3
-1
OrderProductDTO.kt
...ain/java/com/ypsx/yppos/http/data/bean/OrderProductDTO.kt
+1
-1
UnifiedCashPaySignRequest.kt
...ypsx/yppos/http/data/request/UnifiedCashPaySignRequest.kt
+1
-0
HttpRequestManger.kt
...m/ypsx/yppos/http/repository/request/HttpRequestManger.kt
+7
-2
PosBuyPayment.kt
...src/main/java/com/ypsx/yppos/room/entity/PosBuyPayment.kt
+2
-1
PosBuyRepository.kt
...n/java/com/ypsx/yppos/room/repository/PosBuyRepository.kt
+10
-2
MainActivity.kt
app/src/main/java/com/ypsx/yppos/ui/activity/MainActivity.kt
+1
-1
OrderProductAdapter.kt
...ain/java/com/ypsx/yppos/ui/adapter/OrderProductAdapter.kt
+1
-1
SettingsPopupWindow.kt
.../main/java/com/ypsx/yppos/ui/popup/SettingsPopupWindow.kt
+2
-0
PrintUtils.kt
app/src/main/java/com/ypsx/yppos/utils/PrintUtils.kt
+84
-15
RequestMainViewModel.kt
.../com/ypsx/yppos/viewmodel/request/RequestMainViewModel.kt
+16
-2
ic_launcher.png
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
+0
-0
ic_launcher_round.png
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
+0
-0
build.gradle
base/build.gradle
+12
-12
No files found.
.gitignore
View file @
142206b6
...
...
@@ -15,3 +15,5 @@
local.properties
app/sit/output-metadata.json
app/sit/yppos-v-sit.apk
app/debug/output-metadata.json
app/debug/yppos-v-debug.apk
This diff is collapsed.
Click to expand it.
app/build.gradle
View file @
142206b6
...
...
@@ -38,31 +38,31 @@ android {
}
buildTypes
{
debug
{
buildConfigField
'String'
,
'HOST'
,
DEBUG_HOST
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
signingConfig
signingConfigs
.
config
}
//
debug {
//
buildConfigField 'String', 'HOST', DEBUG_HOST
//
minifyEnabled false
//
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//
signingConfig signingConfigs.config
//
}
sit
{
debug
{
buildConfigField
'String'
,
'HOST'
,
SIT_HOST
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
signingConfig
signingConfigs
.
config
}
pre
{
buildConfigField
'String'
,
'HOST'
,
PRE_HOST
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
release
{
buildConfigField
'String'
,
'HOST'
,
RELEASE_HOST
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
signingConfig
signingConfigs
.
config
}
//
pre {
//
buildConfigField 'String', 'HOST', PRE_HOST
//
minifyEnabled false
//
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//
}
//
release {
//
buildConfigField 'String', 'HOST', RELEASE_HOST
//
minifyEnabled false
//
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//
signingConfig signingConfigs.config
//
}
}
compileOptions
{
sourceCompatibility
JavaVersion
.
VERSION_1_8
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/http/data/bean/InsertOrderProductDTO.kt
View file @
142206b6
...
...
@@ -38,6 +38,8 @@ data class InsertOrderProductDTO(
var
merchantItemId
:
String
?
=
null
,
//称重码
var
weightCode
:
String
?
=
null
,
var
isPromotion
:
Boolean
=
false
)
)
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/http/data/bean/OrderProductDTO.kt
View file @
142206b6
...
...
@@ -36,6 +36,6 @@ data class OrderProductDTO(
var
paymentProductQuantity
:
Double
,
var
paymentProductCode
:
String
,
var
paymentProductName
:
String
,
var
activitys
:
List
<
OrderActivityResponse
>?=
null
,
var
activitys
:
List
<
ActivityInfoDTO
>?=
null
,
)
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/http/data/request/UnifiedCashPaySignRequest.kt
View file @
142206b6
...
...
@@ -7,4 +7,5 @@ data class UnifiedCashPaySignRequest(
var
entry
:
String
?
=
"ORDER"
,
var
roundPrice
:
Double
=
0.0
,
var
total
:
Double
,
var
cardPayPassword
:
String
?=
null
)
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/http/repository/request/HttpRequestManger.kt
View file @
142206b6
...
...
@@ -112,16 +112,21 @@ class HttpRequestManger {
val
data
=
uploadData
[
0
]
val
success
=
data
.
success
if
(
success
)
{
var
cardPayPassword
:
String
?
=
null
if
(
payMethod
==
PosPayMethod
.
CARDPAY
)
{
cardPayPassword
=
""
}
val
unifiedCashPaySignRequest
=
UnifiedCashPaySignRequest
(
authCode
,
data
.
orderId
,
payMethod
.
name
,
total
=
insertOrderRequest
.
totalAmount
total
=
insertOrderRequest
.
payAmount
,
cardPayPassword
=
cardPayPassword
)
val
cashPaySignData
=
apiService
.
getCashPaySign
(
unifiedCashPaySignRequest
)
if
(
cashPaySignData
.
isSuccess
())
{
data
.
total
=
insertOrderRequest
.
total
Amount
data
.
total
=
insertOrderRequest
.
pay
Amount
data
.
authCode
=
authCode
return
data
}
else
{
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/room/entity/PosBuyPayment.kt
View file @
142206b6
...
...
@@ -32,6 +32,7 @@ data class PosBuyPayment(
var
realPayFlowNo
:
String
?
=
null
,
var
payFlowNo
:
String
,
var
status
:
String
,
var
openId
:
String
,
// var openId: String,
var
openId
:
String
?=
null
,
)
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/room/repository/PosBuyRepository.kt
View file @
142206b6
package
com.ypsx.yppos.room.repository
import
com.ypsx.base.base.appContext
import
com.ypsx.base.ext.util.toJson
import
com.ypsx.yppos.http.data.bean.OrderDetailsResponse
import
com.ypsx.yppos.room.dao.PosBuyDao
import
com.ypsx.yppos.room.dao.PosBuyPartDao
...
...
@@ -9,6 +10,8 @@ import com.ypsx.yppos.room.database.PosDatabase
import
com.ypsx.yppos.room.entity.PosBuy
import
com.ypsx.yppos.room.entity.PosBuyPart
import
com.ypsx.yppos.room.entity.PosBuyPayment
import
com.ypsx.yppos.utils.dXLog
import
com.ypsx.yppos.utils.eXLog
class
PosBuyRepository
{
...
...
@@ -33,8 +36,9 @@ class PosBuyRepository {
}
fun
savePosBuy
(
orderResponse
:
OrderDetailsResponse
,
authCode
:
String
)
{
orderResponse
.
toString
().
eXLog
()
val
isEmpty
=
orderResponse
.
activitys
?.
isEmpty
()
?:
true
val
activitys
=
if
(
isEmpty
)
""
else
orderResponse
.
activitys
.
to
String
()
val
activitys
=
if
(
isEmpty
)
""
else
orderResponse
.
activitys
.
to
Json
()
val
posBuy
=
PosBuy
(
id
=
orderResponse
.
id
,
orderNo
=
orderResponse
.
orderNo
,
...
...
@@ -64,9 +68,11 @@ class PosBuyRepository {
payment
.
payCode
=
authCode
getPosBuyPaymentDao
().
insert
(
payment
)
}
orderResponse
.
products
.
toJson
().
dXLog
()
for
(
product
in
orderResponse
.
products
)
{
product
.
toJson
().
dXLog
()
val
isEmpty1
=
product
.
activitys
?.
isEmpty
()
?:
true
val
activity
=
if
(
isEmpty1
)
""
else
product
.
activitys
.
to
String
()
val
activity
=
if
(
isEmpty1
)
""
else
product
.
activitys
.
to
Json
()
val
activityType
=
if
(
isEmpty1
)
""
else
product
.
activitys
?.
get
(
0
)
?.
activityType
val
posBuyPart
=
PosBuyPart
(
id
=
product
.
id
,
...
...
@@ -94,11 +100,13 @@ class PosBuyRepository {
discountTotal
=
product
.
discountTotal
,
payApportionAmount
=
product
.
payApportionAmount
,
)
posBuyPart
.
toJson
().
dXLog
()
getPosBuyPartDao
().
insert
(
posBuyPart
)
}
for
(
deleteProduct
in
orderResponse
.
deleteProducts
)
{
deleteProduct
.
deleted
=
true
deleteProduct
.
orderId
=
orderResponse
.
id
deleteProduct
.
toString
().
dXLog
()
getPosBuyPartDao
().
insert
(
deleteProduct
)
}
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/ui/activity/MainActivity.kt
View file @
142206b6
...
...
@@ -375,7 +375,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),
val
data
=
orderProductAdapter
.
data
for
(
item
in
data
)
{
val
productItem
=
ProductItem
(
""
,
item
.
merchantItemId
?:
""
,
item
.
productId
,
item
.
quantity
,
item
.
price
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/ui/adapter/OrderProductAdapter.kt
View file @
142206b6
...
...
@@ -18,7 +18,7 @@ class OrderProductAdapter(data: ArrayList<InsertOrderProductDTO>) :
override
fun
convert
(
holder
:
BaseViewHolder
,
item
:
InsertOrderProductDTO
)
{
item
.
run
{
holder
.
setText
(
R
.
id
.
tv_barCode
,
"条码:$barCode"
)
if
(
discountTotal
>
0.0
)
{
if
(
discountTotal
>
0.0
||
isPromotion
)
{
val
ssb
=
SpannableStringBuilder
(
"促销 $name"
)
var
roundBackgroundColorSpan
=
RoundBackgroundColorSpan
(
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/ui/popup/SettingsPopupWindow.kt
View file @
142206b6
...
...
@@ -68,9 +68,11 @@ class SettingsPopupWindow(context: Context?) : BasePopupWindow(context) {
}
else
{
val
posBuyParts
=
PosBuyRepository
.
getInstance
().
queryPosBuyPartByOrderNo
(
posBuy
.
id
)
posBuyParts
.
toString
().
dXLog
()
val
posBuyPayment
=
PosBuyRepository
.
getInstance
()
.
queryPosBuyPaymentByOrderNo
(
posBuy
.
id
)
posBuyPayment
.
toString
().
dXLog
()
PrintUtils
.
printLast
(
posConfig
!!
,
posBuyPayment
,
posBuy
,
posBuyParts
)
}
}
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/utils/PrintUtils.kt
View file @
142206b6
package
com.ypsx.yppos.utils
import
android.device.PrinterManager
import
android.widget.Toast
import
com.blankj.utilcode.util.GsonUtils
import
com.blankj.utilcode.util.Utils.runOnUiThread
import
com.google.gson.Gson
import
com.google.gson.reflect.TypeToken
import
com.ypsx.yppos.http.data.bean.ActivityInfoDTO
import
com.ypsx.yppos.http.data.bean.OrderActivityResponse
import
com.ypsx.yppos.http.data.bean.OrderDetailsResponse
import
com.ypsx.yppos.http.data.entity.PosPayMethod
import
com.ypsx.yppos.http.data.entity.ProductActivityType
import
com.ypsx.yppos.room.entity.PosBuy
import
com.ypsx.yppos.room.entity.PosBuyPart
import
com.ypsx.yppos.room.entity.PosBuyPayment
...
...
@@ -113,7 +118,28 @@ object PrintUtils {
height
+=
printerManager
.
drawTextEx
(
"商品名称 数量 单价 成交价"
,
0
,
height
,
384
,
-
1
,
fontName
,
fontSize
,
0
,
fontStyle
,
0
)
var
discountTime
=
0.0
//分时
var
discountSpecial
=
0.0
//特价
var
discountMoney
=
0.0
//满减
orderResponse
.
activitys
?.
forEach
{
item
->
discountMoney
+=
item
.
discountMoney
}
for
((
index
,
product
)
in
orderResponse
.
products
.
withIndex
())
{
if
(
product
.
activitys
!=
null
)
{
product
.
activitys
!!
.
forEach
{
item
->
var
d
=
product
.
price
-
item
.
activityPrice
if
(
item
.
activityType
==
ProductActivityType
.
TIMESHARE_ACTIVITY
.
name
)
{
discountTime
+=
d
}
else
{
if
(
d
>
0.0
)
{
discountSpecial
+=
d
}
}
}
}
height
+=
printerManager
.
drawTextEx
(
"${index + 1} ${product.name}"
,
0
,
...
...
@@ -150,7 +176,7 @@ object PrintUtils {
0
)
height
+=
printerManager
.
drawTextEx
(
"促销特价优惠:${
orderResponse.promotionOnSaleTotal
}"
,
"促销特价优惠:${
BigDecimalUtils.forPlus(discountSpecial)
}"
,
0
,
height
,
384
,
...
...
@@ -163,7 +189,7 @@ object PrintUtils {
)
height
+=
printerManager
.
drawTextEx
(
"分时折扣优惠:${
orderResponse.discountTotal
}"
,
"分时折扣优惠:${
BigDecimalUtils.forPlus(discountTime)
}"
,
0
,
height
,
384
,
...
...
@@ -176,7 +202,7 @@ object PrintUtils {
)
height
+=
printerManager
.
drawTextEx
(
"满金额减免优惠:${
orderResponse.discountTotal
}"
,
"满金额减免优惠:${
BigDecimalUtils.forPlus(discountMoney)
}"
,
0
,
height
,
384
,
...
...
@@ -194,7 +220,7 @@ object PrintUtils {
height
+=
printerManager
.
drawTextEx
(
getAmountCenterSpace
(
"应付款:${orderResponse.
total
Amount}"
,
"应付款:${orderResponse.
pay
Amount}"
,
"数量:${orderResponse.buyNumber}"
),
0
,
...
...
@@ -237,7 +263,7 @@ object PrintUtils {
"扫码支付"
}
PosPayMethod
.
CARDPAY
.
name
->
{
"会员余额"
"会员余额
支付
"
}
else
->
{
""
...
...
@@ -404,22 +430,22 @@ object PrintUtils {
runOnUiThread
(
Runnable
{
when
(
status
)
{
PRNSTS_OUT_OF_PAPER
->
{
"缺纸!!!"
.
toast
()
"缺纸!!!"
.
toast
Sign
()
}
PRNSTS_OVER_HEAT
->
{
"过温保护!!!"
.
toast
()
"过温保护!!!"
.
toast
Sign
()
}
PRNSTS_UNDER_VOLTAGE
->
{
"电池电压过低!!!"
.
toast
()
"电池电压过低!!!"
.
toast
Sign
()
}
PRNSTS_BUSY
->
{
"打印机忙!!!"
.
toast
()
"打印机忙!!!"
.
toast
Sign
()
}
PRNSTS_ERR
->
{
"打印机出错!!!"
.
toast
()
"打印机出错!!!"
.
toast
Sign
()
}
PRNSTS_ERR_DRIVER
->
{
"打印机驱动出错!!!"
.
toast
()
"打印机驱动出错!!!"
.
toast
Sign
()
}
}
})
...
...
@@ -513,8 +539,51 @@ object PrintUtils {
height
+=
printerManager
.
drawTextEx
(
"商品名称 数量 单价 成交价"
,
0
,
height
,
384
,
-
1
,
fontName
,
fontSize
,
0
,
fontStyle
,
0
)
var
discountTime
=
0.0
//分时
var
discountSpecial
=
0.0
//特价
var
discountMoney
=
0.0
//满减
val
list
:
List
<
OrderActivityResponse
>
=
GsonUtils
.
fromJson
(
posBuy
.
activitys
,
object
:
TypeToken
<
List
<
OrderActivityResponse
>>()
{}.
type
)
list
.
forEach
{
item
->
discountMoney
+=
item
.
discountMoney
}
// for ((index, product) in orderResponse.products.withIndex()) {
// if (product.activitys != null) {
// product.activitys!!.forEach { item ->
// if (item.activityType == ProductActivityType.TIMESHARE_ACTIVITY.name) {
// discountTime += item.discountMoney
// } else {
// if (item.discountMoney > 0.0) {
// discountSpecial += item.discountMoney
// }
// }
// }
// }
if
(!
posBuyParts
.
isNullOrEmpty
())
{
for
((
index
,
product
)
in
posBuyParts
.
withIndex
())
{
val
list
:
List
<
ActivityInfoDTO
>
=
GsonUtils
.
fromJson
(
product
.
activitys
,
object
:
TypeToken
<
List
<
ActivityInfoDTO
>>()
{}.
type
)
// if (product.activitys != null) {
list
.
forEach
{
item
->
val
discountMoney
=
product
.
price
-
item
.
activityPrice
if
(
item
.
activityType
==
ProductActivityType
.
TIMESHARE_ACTIVITY
.
name
)
{
discountTime
+=
discountMoney
}
else
{
if
(
discountMoney
>
0.0
)
{
discountSpecial
+=
discountMoney
}
}
}
// }
height
+=
printerManager
.
drawTextEx
(
"${index + 1} ${product.name}"
,
0
,
...
...
@@ -552,7 +621,7 @@ object PrintUtils {
0
)
height
+=
printerManager
.
drawTextEx
(
"促销特价优惠:${
posBuy.promotionOnSaleTotal
}"
,
"促销特价优惠:${
BigDecimalUtils.forPlus(discountSpecial)
}"
,
0
,
height
,
384
,
...
...
@@ -565,7 +634,7 @@ object PrintUtils {
)
height
+=
printerManager
.
drawTextEx
(
"分时折扣优惠:${
posBuy.discountTotal
}"
,
"分时折扣优惠:${
BigDecimalUtils.forPlus(discountTime)
}"
,
0
,
height
,
384
,
...
...
@@ -578,7 +647,7 @@ object PrintUtils {
)
height
+=
printerManager
.
drawTextEx
(
"满金额减免优惠:${
posBuy.discountTotal
}"
,
"满金额减免优惠:${
BigDecimalUtils.forPlus(discountMoney)
}"
,
0
,
height
,
384
,
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ypsx/yppos/viewmodel/request/RequestMainViewModel.kt
View file @
142206b6
...
...
@@ -220,6 +220,18 @@ class RequestMainViewModel : BaseViewModel() {
break
}
}
var
isPromotion
=
false
if
(!
orderPromotions
.
isNullOrEmpty
())
{
for
(
orderPromotion
in
orderPromotions
!!
)
{
for
(
productPromotionDetailDTO
in
orderPromotion
.
productIds
)
{
if
(
productPromotionDetailDTO
.
productId
==
product
.
productId
)
{
isPromotion
=
true
break
}
}
}
}
var
activitys
=
product
.
activityInfo
var
activitysList
:
ArrayList
<
ActivityInfoDTO
>?
=
null
if
(
activitys
!=
null
)
{
...
...
@@ -248,7 +260,9 @@ class RequestMainViewModel : BaseViewModel() {
style
=
posProduct
.
style
,
pluLevel
=
posProduct
.
pluLevel
,
merchantItemId
=
posProduct
.
merchantItemId
,
productNumber
=
posProduct
.
productNumber
productNumber
=
posProduct
.
productNumber
,
isPromotion
=
isPromotion
,
isVirtual
=
posProduct
.
isVirtual
)
posBuyPart
.
toJson
().
dXLog
()
list
.
add
(
posBuyPart
)
...
...
@@ -326,8 +340,8 @@ class RequestMainViewModel : BaseViewModel() {
request
({
apiService
.
getOrderDetailById
(
orderId
)
},
{
"${CacheUtil.getRealName()}付款成功,保存数据库并打印"
.
dXLog
()
launch
({
PosBuyRepository
.
getInstance
().
savePosBuy
(
it
,
authCode
)
PrintUtils
.
print
(
posConfig
!!
,
it
)
PosBuyRepository
.
getInstance
().
savePosBuy
(
it
,
authCode
)
},
{
"打印完成"
.
dXLog
()
"打印完成"
.
toastSuccess
()
...
...
This diff is collapsed.
Click to expand it.
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted
100644 → 0
View file @
02187684
10.4 KB
This diff is collapsed.
Click to expand it.
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted
100644 → 0
View file @
02187684
16.2 KB
This diff is collapsed.
Click to expand it.
base/build.gradle
View file @
142206b6
...
...
@@ -20,22 +20,22 @@ android {
}
buildTypes
{
// debug {
// minifyEnabled false
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// }
debug
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
sit
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
pre
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
release
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
// pre {
// minifyEnabled false
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// }
// release {
// minifyEnabled false
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// }
}
...
...
This diff is collapsed.
Click to expand it.
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