Commit b1819aac authored by UIUANG\Zsc's avatar UIUANG\Zsc

修改DT40和高版本的bug

parent 21d3c2dd
......@@ -15,8 +15,8 @@ android {
applicationId "com.ypsx.yppos"
minSdkVersion 21
targetSdkVersion 30
versionCode 100014
versionName "1.00.014"
versionCode 100017
versionName "1.00.017"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
......
......@@ -10,9 +10,9 @@
{
"type": "SINGLE",
"filters": [],
"versionCode": 100014,
"versionName": "1.00.014",
"outputFile": "yppos_v100014-1.00.014-release-2021-12-22.apk"
"versionCode": 100017,
"versionName": "1.00.017",
"outputFile": "yppos_v100017-1.00.017-release-2021-12-28.apk"
}
]
}
\ No newline at end of file
......@@ -10,6 +10,7 @@
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE "/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application
android:name=".PosApp"
......
......@@ -8,7 +8,7 @@ import com.ypsx.base.network.BaseResponse
* 描述 :服务器返回数据的基类
* 如果你的项目中有基类,那美滋滋,可以继承BaseResponse,请求时框架可以帮你自动脱壳,自动判断是否请求成功,怎么做:
* 1.继承 BaseResponse
* 2.重写isSucces 方法,编写你的业务需求,根据自己的条件判断数据是否请求成功
* 2.重写isSuccess 方法,编写你的业务需求,根据自己的条件判断数据是否请求成功
* 3.重写 getResponseCode、getResponseData、getResponseMsg方法,传入你的 code data msg
*/
data class ApiResponse<T>(
......
package com.ypsx.yppos.http.data.bean
/**
* 版本信息
*/
data class AppVersionResponse(
val desciption: String? = null,
val downloadUrl: String,
......
package com.ypsx.yppos.http.data.bean
/**
* 付款成功
*/
data class CashPaySuccess(
var payAmount: Double,
var changeAmount: Double,
......
package com.ypsx.yppos.http.data.bean
data class InsertOrderProductDTO(
var activityPrice: Double = 0.0,
var activitys: List<ActivityInfoDTO>? = null,
//成交价
......
package com.ypsx.yppos.http.data.bean
/**
* 登录信息
*/
data class LoginResponse(
var accessToken:String,
var currentTime:String,
......
package com.ypsx.yppos.http.data.bean
/**
* 配置信息
*/
data class OptionsResponse(
var id: String,
val key: String,
......
package com.ypsx.yppos.http.data.bean
class PluRelation(var plu: String, var id: String)
/**
* 扫描13位或18条码对应关系
*/
data class PluRelation(var plu: String, var id: String)
package com.ypsx.yppos.http.data.bean
/**
* 获取pos配置
*/
data class PosConfigResponse(
//小票底部文字,最多144个汉字
var ticketBottom: String? = null,
......
package com.ypsx.yppos.http.data.bean
/**
* pos命令
*/
data class SimplePosCommandResponse(
//命令ID
var id: Long,
......
package com.ypsx.yppos.http.data.bean
/**
* 上传订单返回的结果
*/
data class UploadOrderResponse(
// 错误消息
var errorMessage: String,
......
package com.ypsx.yppos.http.data.entity
/**
* 订单状态
*/
enum class OrderStatusEnum {
//待付款
CREATED,
......
package com.ypsx.yppos.http.data.entity
/**
* pos命令状态
*/
enum class PosCommandStatus{
CREATE, CANCELED, PROCESSING, FAILED, SUCCESS
}
package com.ypsx.yppos.http.data.entity
/**
* pos命令类型
*/
enum class PosCommandType {
UPLOAD_LOG,UPLOAD_DB
}
\ No newline at end of file
package com.ypsx.yppos.http.data.entity
/**
* 付款方式
*/
enum class PosPayMethod {
CARDPAY,
//扫码聚合支付
......
package com.ypsx.yppos.http.data.entity
/**
* 商品规格
*/
enum class PosProductStyle {
/**
*单品
......
......@@ -2,7 +2,7 @@ package com.ypsx.yppos.http.data.entity
/**
* string
POS门店商品状态
POS门店商品上下架状态
*/
enum class PosShelvesStatus {
ON, OFF, DELETED
......
package com.ypsx.yppos.http.data.entity
/**
* pos机状态
*/
enum class PosStatus{
/**
* 申请中
......
package com.ypsx.yppos.http.data.entity
/**
* 商品活动状态
*/
enum class ProductActivityType {
UNKNOWN_ACTIVITY_TYPE, TIMESHARE_ACTIVITY, OTHER_ACTIVITY, UNRECOGNIZED
}
\ No newline at end of file
......@@ -21,16 +21,4 @@ data class ApplyPosMachineRequest(
//安装目录
var installationDirectory: String
// {
// "brand": "string",
// "installDiskCapacity": "string",
// "installationDirectory": "string",
// "ip": "string",
// "macAddress": "string",
// "port": 0,
// "remark": "string",
// "specification": "string",
// "version": "string"
// }
)
package com.ypsx.yppos.http.data.request
/**
* pos机登录
*/
data class PosLoginRequest(
//门店id
var workingOrgId: String,
......
package com.ypsx.yppos.http.data.request
/**
* 刷新token
*/
data class RefreshTokenRequest(
var refreshToken:String
)
package com.ypsx.yppos.http.data.request
/**
* 回复命令
*/
data class ReplyCommandListRequest(
var commandIds: List<String>
)
......@@ -53,6 +53,7 @@ class LogService : Service() {
HttpRequestCoroutine.uploadLog(posConfig?.code!!)
}
} catch (e: Exception) {
job?.cancel()
e.message?.eXLog()
}
......
......@@ -55,6 +55,7 @@ class SyncProductService: Service() {
val storeId = posConfig?.storeId!!
HttpRequestCoroutine.syncProduct(storeId)
} catch (e: Exception) {
job?.cancel()
e.message?.eXLog()
}
}
......
......@@ -66,6 +66,7 @@ class PosBuyRepository {
getPosBuyDao().insert(posBuy)
for (payment in orderResponse.payments) {
payment.payCode = authCode
payment.toJson().dXLog()
getPosBuyPaymentDao().insert(payment)
}
orderResponse.products.toJson().dXLog()
......
......@@ -9,12 +9,15 @@ import com.ypsx.yppos.R
import com.ypsx.yppos.http.data.bean.InsertOrderProductDTO
import com.ypsx.yppos.http.data.entity.PosProductStyle
import com.ypsx.yppos.utils.RoundBackgroundColorSpan
import java.text.DecimalFormat
class OrderProductAdapter(data: ArrayList<InsertOrderProductDTO>) :
BaseQuickAdapter<InsertOrderProductDTO, BaseViewHolder>(
R.layout.item_pos_product, data
) {
private var decimalFormat: DecimalFormat = DecimalFormat("###################.###########")
override fun convert(holder: BaseViewHolder, item: InsertOrderProductDTO) {
item.run {
when (style) {
......@@ -53,7 +56,7 @@ class OrderProductAdapter(data: ArrayList<InsertOrderProductDTO>) :
PosProductStyle.WEIGHT.name -> {
holder.setGone(R.id.ll_count, false)
holder.setGone(R.id.tv_weight, true)
holder.setText(R.id.tv_count, "$quantity")
holder.setText(R.id.tv_count, decimalFormat.format(quantity))
}
else -> {
......
......@@ -18,6 +18,7 @@ import com.ypsx.yppos.utils.toast
import com.ypsx.yppos.viewmodel.state.ChangeQuantityViewModel
import razerdp.basepopup.BasePopupWindow
import java.math.BigDecimal
import java.text.DecimalFormat
class ChangeQuantityPopupWindow(context: Context) : BasePopupWindow(context) {
lateinit var bind: PopupChangeQuantityBinding
......@@ -25,6 +26,7 @@ class ChangeQuantityPopupWindow(context: Context) : BasePopupWindow(context) {
var onChangeClick: OnChangeClick? =null
private var posProduct: PosProduct? = null
private var insertOrderProductDTO: InsertOrderProductDTO?=null
private var decimalFormat: DecimalFormat = DecimalFormat("###################.###########")
......@@ -92,15 +94,14 @@ class ChangeQuantityPopupWindow(context: Context) : BasePopupWindow(context) {
}
bind.vm?.purchaseQuantityName?.set(purchaseQuantityName)
bind.vm?.purchaseQuantity?.set(spec)
bind.etPurchaseQuantity.setText(spec)
val length = bind.etPurchaseQuantity.text.toString().length
bind.etPurchaseQuantity.setSelection(length)
// bind.etPurchaseQuantity.setText(spec)
// val length = bind.etPurchaseQuantity.text.toString().length
// bind.etPurchaseQuantity.setSelection(length)
bind.etPurchaseQuantity.isFocusable = true;
bind.etPurchaseQuantity.isFocusableInTouchMode = true;
bind.etPurchaseQuantity.requestFocus() //获取焦点
}
fun setOrderProduct(insertOrderProductDTO: InsertOrderProductDTO) {
this.type = 1
this.insertOrderProductDTO = insertOrderProductDTO
......@@ -110,7 +111,8 @@ class ChangeQuantityPopupWindow(context: Context) : BasePopupWindow(context) {
when (insertOrderProductDTO.style) {
PosProductStyle.WEIGHT.name -> {
purchaseQuantityName = "修改重量"
spec = insertOrderProductDTO.quantity.toString()
spec = decimalFormat.format(insertOrderProductDTO.quantity)
// spec = insertOrderProductDTO.quantity.toString()
bind.vm?.productBarCode?.set("PLU:" + insertOrderProductDTO.mnemonicCode)
bind.etPurchaseQuantity.filters = arrayOf(WeighInputFilter())
}
......@@ -126,11 +128,11 @@ class ChangeQuantityPopupWindow(context: Context) : BasePopupWindow(context) {
}
bind.vm?.purchaseQuantityName?.set(purchaseQuantityName)
bind.vm?.purchaseQuantity?.set(spec)
bind.etPurchaseQuantity.setText(spec)
val length = bind.etPurchaseQuantity.text.toString().length
bind.etPurchaseQuantity.setSelection(length)
bind.etPurchaseQuantity.isFocusable = true;
bind.etPurchaseQuantity.isFocusableInTouchMode = true;
// bind.etPurchaseQuantity.setText(spec)
// val length = bind.etPurchaseQuantity.text.toString().length
// bind.etPurchaseQuantity.setSelection(length)
// bind.etPurchaseQuantity.isFocusable = true;
// bind.etPurchaseQuantity.isFocusableInTouchMode = true;
bind.etPurchaseQuantity.requestFocus() //获取焦点
}
......@@ -143,8 +145,16 @@ class ChangeQuantityPopupWindow(context: Context) : BasePopupWindow(context) {
fun confirm() {
val purchaseQuantity: String = bind.etPurchaseQuantity.text.toString()
var purchaseQuantityHint = bind.etPurchaseQuantity.hint.toString()
if (purchaseQuantity.isEmpty()) {
"重量/数据不能为空".toast()
dismiss()
if (type == 0) {
posProduct?.spec = purchaseQuantityHint
onChangeClick?.confirm(posProduct!!,null)
}else{
insertOrderProductDTO?.quantity = purchaseQuantityHint.toDouble()
onChangeClick?.confirm(null,insertOrderProductDTO!!)
}
return
}
if (BigDecimal(purchaseQuantity) == BigDecimal.ZERO) {
......
......@@ -38,8 +38,12 @@ object PrintUtils {
private const val PRNSTS_ERR_DRIVER = -257 //Printer Driver error
private lateinit var printerManager: PrinterManager
fun init() {
printerManager = PrinterManager()
printerManager.open()
try {
printerManager = PrinterManager()
printerManager.open()
} catch (e: Exception) {
"打印机打开失败"
}
}
......@@ -398,7 +402,11 @@ object PrintUtils {
fun close() {
printerManager.close()
try {
printerManager.close()
} catch (e: Exception) {
}
}
private fun getSpace(content: String): String? {
......@@ -689,7 +697,7 @@ object PrintUtils {
product.quantity,
product.price,
product.amount
), 0, height, 384, -1, fontName, fontSize, 0, fontStyle, 0
), 0, height, 384, -1, fontName, 22, 0, 0, 0
)
}
}
......
......@@ -108,11 +108,24 @@ class RequestMainViewModel : BaseViewModel() {
"没找到该商品".toastSign()
} else {
it.toJson().dXLog()
posProduct.postValue(it)
// val productItem =
// ProductItem(it.merchantItemId!!, it.id, it.spec.toDouble(), it.sellPrice)
// productItem.toJson().dXLog()
// productItemData.postValue(productItem)
when {
it.mnemonicCode.isEmpty() -> {
val productItem =
ProductItem(it.merchantItemId!!, it.id, it.spec.toDouble(), it.sellPrice)
productItem.toJson().dXLog()
productItemData.postValue(productItem)
}
it.mnemonicCode == key -> {
posProduct.postValue(it)
}
else -> {
val productItem =
ProductItem(it.merchantItemId!!, it.id, it.spec.toDouble(), it.sellPrice)
productItem.toJson().dXLog()
productItemData.postValue(productItem)
}
}
}
}, {
......@@ -170,10 +183,10 @@ class RequestMainViewModel : BaseViewModel() {
}
val amount: Double = product.price.times(product.quantity) ?: 0.0
amountTotal = BigDecimalUtils.forPlus(amountTotal.plus(amount))
var weightCode=""
var weightCode = ""
if (pluList.size > index) {
weightCode =
weightCode =
if (pluList[index].id == posProduct?.id) pluList[index].plu else ""
}
......@@ -192,7 +205,7 @@ class RequestMainViewModel : BaseViewModel() {
price = product.price ?: 0.0,
quantity = product.quantity ?: 0.0,
tailAmount = 0,
weightCode =weightCode,
weightCode = weightCode,
name = posProduct.name,
spec = posProduct.spec,
unit = posProduct.unit,
......@@ -255,7 +268,7 @@ class RequestMainViewModel : BaseViewModel() {
var posProduct: PosProduct? = null
var listNum = 0
for ((index,product) in productPromotions.withIndex()) {
for ((index, product) in productPromotions.withIndex()) {
for (item in it) {
if (product.productId == item.id) {
posProduct = item
......@@ -285,7 +298,7 @@ class RequestMainViewModel : BaseViewModel() {
}
var activityPrice = activityInfo?.activityPrice ?: 0.0
var weightCode=""
var weightCode = ""
if (pluList.size > index) {
weightCode =
......@@ -436,8 +449,10 @@ class RequestMainViewModel : BaseViewModel() {
"${CacheUtil.getRealName()}付款成功,保存数据库并打印".dXLog()
pluList.clear()
launch({
val currentTimeMillis = System.currentTimeMillis()
PrintUtils.print(posConfig!!, it)
PosBuyRepository.getInstance().savePosBuy(it, authCode)
"打印和保存数据库使用耗时::${System.currentTimeMillis()-currentTimeMillis}".dXLog()
}, {
"打印完成".dXLog()
"打印完成".toastSuccess()
......
......@@ -77,7 +77,7 @@
android:lines="1"
android:paddingVertical="10dp"
android:paddingStart="10dp"
android:text="@{vm.purchaseQuantity}"
android:text=""
android:textColor="#333333"
android:textColorHint="#999999"
android:textSize="20sp"
......
package com.ypsx.common.app.ext
import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.SingleChoiceListener
......@@ -16,6 +17,7 @@ private val hostMap = mapOf(
private val hosts = hostMap.values.toTypedArray()
private val names = hostMap.keys.toList()
@SuppressLint("StaticFieldLeak")
private var materialDialog: MaterialDialog? = null
fun AppCompatActivity.showServerHostExt(host:String,success: (String) -> Unit) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment