Commit 33bca812 authored by gaodapeng's avatar gaodapeng

修改完成

parent 1a5458da
......@@ -84,6 +84,6 @@ dependencies {
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
implementation 'com.github.d-max:spots-dialog:1.1@aar'
implementation 'com.elvishew:xlog:1.10.1'
implementation 'com.squareup.leakcanary:leakcanary-android:2.7'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
implementation 'com.contrarywind:Android-PickerView:4.1.9'
}
\ No newline at end of file
......@@ -70,12 +70,12 @@ object PrintService {
//检查打印机状态
printer.printerStatus
printer.set58mm()
if (BuildConfig.DEBUG) {
printCashier(printer, payServiceResponse, selfCashierAccountInfo)
} else {
// if (BuildConfig.DEBUG) {
// printCashier(printer, payServiceResponse, selfCashierAccountInfo)
// } else {
printCashier(printer, payServiceResponse, selfCashierAccountInfo)
printCustomer(printer, payServiceResponse, selfCashierAccountInfo)
}
// }
printer.feedPaper()
printer.endPrint()
}
......
......@@ -6,17 +6,11 @@ import android.view.KeyEvent
import android.widget.Toast
import androidx.lifecycle.ViewModelProvider
import com.miya.fastcashier.databinding.ActivityPayBinding
import com.miya.fastcashier.databinding.ActivityRefundBinding
import com.miya.fastcashier.ui.dialog.MessageDialog
import com.miya.fastcashier.ui.dialog.NumberManualDialog
import com.miya.fastcashier.ui.dialog.NumberManualDialog.NumberInputListener
import com.miya.fastcashier.ui.dialog.RefundInfoDialog
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.DateUtils
import com.miya.fastcashier.utils.ScanGunKeyEventHelper
import com.miya.fastcashier.utils.clickWithTrigger
import com.miya.fastcashier.viewmodel.PayViewModel
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import com.tencent.mmkv.MMKV
import java.util.*
......@@ -57,11 +51,7 @@ class PayActivity : BaseActivity() {
startActivity(intent)
}
})
val tvBack = binding.clTitle.tvBack
val ivBack = binding.clTitle.ivBack
tvBack.clickWithTrigger { finish() }
ivBack.clickWithTrigger { finish() }
binding.clTitle.llBack.clickWithTrigger { finish() }
scanGunKeyEventHelper.setOnBarCodeCatchListener {
showProgressDialog("正在支付..")
......
package com.miya.fastcashier.ui
import android.content.Context
import android.graphics.Rect
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
......@@ -20,10 +22,7 @@ import com.miya.fastcashier.dao.PayDataDao
import com.miya.fastcashier.databinding.ActivitySearchOrderBinding
import com.miya.fastcashier.databinding.FragmentSearchOrderBinding
import com.miya.fastcashier.databinding.ItemSearchOrderListBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.MiYaPayPlantformPayWayEnum
import com.miya.fastcashier.utils.StringPriceFormat
import com.miya.fastcashier.utils.clickWithTrigger
import com.miya.fastcashier.utils.*
import com.miya.fastcashier.viewmodel.SearchOrderViewModel
import com.miya.fastcashier.widget.Divider
......@@ -37,8 +36,7 @@ class SearchOrderActivity : BaseActivity() {
super.onCreate(savedInstanceState)
binding = ActivitySearchOrderBinding.inflate(LayoutInflater.from(this))
setContentView(binding.root)
binding.title.tvBack.clickWithTrigger { finish() }
binding.title.ivBack.clickWithTrigger { finish() }
binding.title.llBack.clickWithTrigger { finish() }
binding.vpPage.adapter = object : FragmentStateAdapter(this) {
override fun getItemCount(): Int {
......@@ -98,7 +96,19 @@ class SearchOrderFragment(val payType: MiYaPayPlantformPayWayEnum.MiyaPayType) :
adapter = SearchOrderListAdapter(act, arrayListOf())
rvContent.layoutManager = LinearLayoutManager(act, LinearLayoutManager.VERTICAL, false)
rvContent.adapter = adapter
rvContent.addItemDecoration(Divider(act))
rvContent.addItemDecoration(
object : RecyclerView.ItemDecoration() {
val itemMargin = dp2px(act, 16F)
override fun getItemOffsets(
outRect: Rect,
view: View,
parent: RecyclerView,
state: RecyclerView.State
) {
outRect.set(itemMargin, itemMargin, itemMargin, 0)
}
}
)
rvContent.addOnScrollListener(object : RecyclerView.OnScrollListener() {
//用来标记是否正在向最后一个滑动
var isSlidingToLast = false
......@@ -199,16 +209,35 @@ class SearchOrderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
fun setData(data: ViewPayOrderData) {
binding.tvDate.text = data.chanelOrderTradeTime
binding.tvDateTitle.text = "下单时间"
if (data.refundOrderNo != null && data.refundPrice != null) {
binding.tvRefundTag.visibility = View.VISIBLE
binding.tvPrice.text =
"¥" + StringPriceFormat.transStringPriceToDecimalString(data.refundPrice)
binding.tvOrderNo.text = data.refundOrderNo
binding.tvSerialNo.text = data.tradeNo
binding.tvOrderNoTitle.text = "退款订单号"
binding.tvSerialNoTitle.text = "退款流水号"
binding.tvPriceTitle.text = "退款金额"
binding.tvPrice.setTextColor(
ResourcesCompat.getColor(
itemView.resources,
R.color.color_FF4E33, null
)
)
} else {
binding.tvRefundTag.visibility = View.GONE
binding.tvPrice.text =
"¥" + StringPriceFormat.transStringPriceToDecimalString(data.tradPrice)
binding.tvOrderNo.text = data.orderNo
binding.tvOrderNoTitle.text = "订单号"
binding.tvSerialNoTitle.text = "流水号"
binding.tvPriceTitle.text = "订单金额"
binding.tvSerialNo.text = data.tradeNo
binding.tvPrice.setTextColor(
ResourcesCompat.getColor(
itemView.resources,
R.color.color_333333, null
)
)
}
}
......
......@@ -15,3 +15,11 @@ fun sp2px(context: Context, spValue: Float): Int {
val fontScale: Float = context.resources.displayMetrics.scaledDensity
return (spValue * fontScale + 0.5f).toInt()
}
/**
* 根据分辨率从 dp 的单位 转成为 px(像素)
*/
fun dp2px(context: Context, dpValue: Float): Int {
val scale = context.resources.displayMetrics.density
return (dpValue * scale + 0.5f).toInt()
}
package com.miya.fastcashier.utils
import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.view.View
......@@ -11,7 +12,7 @@ import com.bigkoo.pickerview.view.TimePickerView
import com.miya.fastcashier.R
import java.util.*
class DateSelectHelper(val context: Context, val callback: (Date) -> Unit) {
class DateSelectHelper(val act: Activity, val callback: (Date) -> Unit) {
var timePickerView: TimePickerView? = null
fun showDatePicker() {
......@@ -50,7 +51,7 @@ class DateSelectHelper(val context: Context, val callback: (Date) -> Unit) {
calendar.get(Calendar.HOUR_OF_DAY),
calendar.get(Calendar.MINUTE)
)
timePickerView = TimePickerBuilder(context, OnTimeSelectListener { date, v ->
timePickerView = TimePickerBuilder(act, OnTimeSelectListener { date, v ->
callback(date)
})
.setTitleText("请选择开始时间")
......@@ -60,6 +61,8 @@ class DateSelectHelper(val context: Context, val callback: (Date) -> Unit) {
.setTitleSize(30)
.setSubCalSize(30)
.setRangDate(startDate, endDate)
.setOutSideCancelable(false)
.setDecorView(act.findViewById(android.R.id.content))
.build()
}
......
......@@ -21,6 +21,7 @@ import com.sdy.miya.moblie.component.pay.core.error.ParamInvalidException
import com.sdy.miya.moblie.component.pay.platform.bean.MiyaOrderRefundResponse
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import kotlinx.coroutines.*
import java.lang.RuntimeException
import java.util.*
import kotlin.collections.HashMap
......@@ -87,7 +88,7 @@ class PayViewModel : ViewModel() {
fun generatePayCode(price: String, payType: String) {
XLog.d("开始生成主扫码")
if (TextUtils.isEmpty(price)) {
payServiceResponseLiveData.value = Result.failure(ParamInvalidException("请输入金额!"))
payServiceResponseLiveData.value = Result.failure(RuntimeException("请输入金额!"))
return
}
......@@ -96,7 +97,7 @@ class PayViewModel : ViewModel() {
priceFen = price.toDouble().times(100).toInt().toString()
} catch (e: java.lang.Exception) {
e.printStackTrace()
payServiceResponseLiveData.value = Result.failure(ParamInvalidException("金额有误!"))
payServiceResponseLiveData.value = Result.failure(RuntimeException("金额有误!"))
return
}
......@@ -129,6 +130,8 @@ class PayViewModel : ViewModel() {
val payServiceResponseResult =
PayRepository.payResultQuery(payServiceResponse.shopTradeNo)
XLog.d("支付查询结果:${JSON.toJSONString(payServiceResponseResult)}")
//加入数据库
ViewPayOrderData.insert(payServiceResponseResult)
payResultLiveData.postValue(Result.success(payServiceResponseResult))
break
} catch (e: Exception) {
......@@ -167,12 +170,12 @@ class PayViewModel : ViewModel() {
fun pay(price: String, payCode: String) {
XLog.d("被扫开始")
if (TextUtils.isEmpty(price)) {
payResultLiveData.value = Result.failure(ParamInvalidException("请输入金额!"))
payResultLiveData.value = Result.failure(RuntimeException("请输入金额!"))
return
}
if (TextUtils.isEmpty(payCode)) {
payResultLiveData.value = Result.failure(ParamInvalidException("付款码为空!"))
payResultLiveData.value = Result.failure(RuntimeException("付款码为空!"))
return
}
......@@ -181,7 +184,7 @@ class PayViewModel : ViewModel() {
priceFen = price.toDouble().times(100).toInt().toString()
} catch (e: java.lang.Exception) {
e.printStackTrace()
payResultLiveData.value = Result.failure(ParamInvalidException("金额有误!"))
payResultLiveData.value = Result.failure(RuntimeException("金额有误!"))
return
}
......
......@@ -16,11 +16,12 @@ public class Divider extends RecyclerView.ItemDecoration {
private Paint paint;
private int divideWidth;
public Divider(Context context) {
public Divider(int divideWidth, int color) {
super();
this.paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(context.getResources().getColor(R.color.color_ECECEC));
divideWidth = 1;
paint.setColor(color);
this.divideWidth = divideWidth;
}
@Override
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />
<corners android:radius="16dp" />
</shape>
\ No newline at end of file
......@@ -14,14 +14,15 @@
android:layout_marginStart="46dp"
android:layout_marginTop="475dp"
android:layout_marginEnd="46dp"
android:singleLine="true"
android:hint="请输入用户名"
android:textSize="32sp"
android:imeOptions="actionNext"
android:selectAllOnFocus="true"
android:singleLine="true"
android:textSize="32sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:met_bottomTextSize="26sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/password"
......@@ -32,13 +33,14 @@
android:layout_marginEnd="46dp"
android:hint="请输入密码"
android:imeActionLabel="登录"
android:textSize="32sp"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:selectAllOnFocus="true"
android:textSize="32sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/username" />
app:layout_constraintTop_toBottomOf="@+id/username"
app:met_bottomTextSize="26sp" />
<Button
android:id="@+id/login"
......@@ -46,11 +48,11 @@
android:layout_height="100dp"
android:layout_gravity="start"
android:layout_marginTop="142dp"
android:background="@drawable/app_login_btn"
android:enabled="false"
android:text="登录"
android:background="@drawable/app_login_btn"
android:textSize="32sp"
android:textColor="@color/white"
android:textSize="32sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......@@ -61,55 +63,55 @@
android:id="@+id/ivLogo"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginTop="259dp"
android:layout_marginLeft="39dp"
android:layout_marginStart="39dp"
android:layout_marginLeft="39dp"
android:layout_marginTop="259dp"
android:background="@mipmap/app_store_round_logo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@mipmap/app_store_round_logo" />
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:layout_marginLeft="26dp"
android:text="您好,欢迎登录!"
android:textSize="48sp"
android:textColor="@color/black"
android:layout_marginStart="23dp"
android:textSize="48sp"
app:layout_constraintStart_toEndOf="@+id/ivLogo"
app:layout_constraintTop_toTopOf="@+id/ivLogo"
android:layout_marginLeft="26dp" />
app:layout_constraintTop_toTopOf="@+id/ivLogo" />
<TextView
android:id="@+id/tvSlog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:layout_marginLeft="26dp"
android:text="欢迎使用匡威商米收银"
android:textSize="28sp"
android:textColor="#666666"
android:layout_marginStart="23dp"
app:layout_constraintStart_toEndOf="@+id/ivLogo"
android:textSize="28sp"
app:layout_constraintBottom_toBottomOf="@+id/ivLogo"
android:layout_marginLeft="26dp" />
app:layout_constraintStart_toEndOf="@+id/ivLogo" />
<TextView
android:id="@+id/tvErrInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="账号或密码输入错误,请重新输入"
android:textSize="24sp"
android:textColor="#FF5A59"
android:textSize="24sp"
android:visibility="gone"
app:layout_constraintStart_toStartOf="@+id/username"
app:layout_constraintStart_toEndOf="@+id/ivLogo"
app:layout_constraintStart_toStartOf="@+id/username"
app:layout_constraintTop_toBottomOf="@+id/password" />
<!--封装成一个View-->
<androidx.constraintlayout.widget.ConstraintLayout
android:visibility="gone"
android:id="@+id/loading"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:visibility="gone">
<LinearLayout
android:layout_width="306dp"
......
......@@ -28,7 +28,6 @@
android:id="@+id/vpPage"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/tlIndicator" />
......
......@@ -6,6 +6,6 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvContent"
android:layout_width="match_parent"
android:paddingStart="40dp"
android:background="@color/color_F8F8F8"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -5,15 +5,94 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/vBg"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/app_bg_search_order_card"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvOrderNo"
android:id="@+id/tvSerialNoTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="24dp"
android:textColor="@color/color_333333"
android:textSize="28sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textSize="26sp"
app:layout_constraintStart_toStartOf="@id/vBg"
app:layout_constraintTop_toTopOf="@id/vBg"
app:layout_goneMarginStart="24dp"
tools:text="流水号" />
<TextView
android:id="@+id/tvOrderNoTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="24dp"
android:textColor="@color/color_333333"
android:textSize="26sp"
app:layout_constraintStart_toStartOf="@id/vBg"
app:layout_constraintTop_toBottomOf="@id/tvSerialNoTitle"
app:layout_goneMarginStart="24dp"
tools:text="订单号" />
<TextView
android:id="@+id/tvDateTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="24dp"
android:textColor="@color/color_333333"
android:textSize="26sp"
app:layout_constraintStart_toStartOf="@id/vBg"
app:layout_constraintTop_toBottomOf="@id/tvOrderNoTitle"
app:layout_goneMarginStart="24dp"
tools:text="下单时间" />
<TextView
android:id="@+id/tvPriceTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="24dp"
android:layout_marginBottom="24dp"
android:textColor="@color/color_333333"
android:textSize="26sp"
app:layout_constraintBottom_toBottomOf="@id/vBg"
app:layout_constraintStart_toStartOf="@id/vBg"
app:layout_constraintTop_toBottomOf="@id/tvDateTitle"
app:layout_goneMarginStart="24dp"
tools:text="订单金额" />
<TextView
android:id="@+id/tvSerialNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="24dp"
android:textColor="@color/color_999999"
android:textSize="26sp"
app:layout_constraintBaseline_toBaselineOf="@id/tvSerialNoTitle"
app:layout_constraintEnd_toEndOf="@id/vBg"
tools:text="流水号1" />
<TextView
android:id="@+id/tvOrderNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="24dp"
android:textColor="@color/color_999999"
android:textSize="26sp"
app:layout_constraintBaseline_toBaselineOf="@id/tvOrderNoTitle"
app:layout_constraintEnd_toEndOf="@id/vBg"
tools:text="流水号1" />
<TextView
......@@ -21,12 +100,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="26dp"
android:textColor="@color/color_666666"
android:textColor="@color/color_999999"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/tvOrderNo"
app:layout_constraintTop_toBottomOf="@id/tvOrderNo"
app:layout_constraintBaseline_toBaselineOf="@id/tvDateTitle"
app:layout_constraintEnd_toEndOf="@id/vBg"
tools:text="2022-02-28 13:51:00" />
<TextView
......@@ -35,22 +114,10 @@
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:textColor="@color/color_333333"
android:textSize="32sp"
app:layout_constraintBaseline_toBaselineOf="@id/tvOrderNo"
app:layout_constraintEnd_toEndOf="parent"
android:textSize="30sp"
app:layout_constraintBaseline_toBaselineOf="@id/tvPriceTitle"
app:layout_constraintEnd_toEndOf="@id/vBg"
app:layout_goneMarginEnd="24dp"
tools:text="¥200.99" />
<TextView
android:id="@+id/tvRefundTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textColor="@color/color_FF4E33"
android:textSize="20sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="@id/tvPrice"
app:layout_constraintTop_toBottomOf="@id/tvPrice"
android:text="退款金额"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -11,22 +11,23 @@
android:background="@color/colorPrimary"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvBack"
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/llBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginTop="32dp"
android:text="@string/back"
android:textColor="@color/white"
android:textSize="24sp"
android:layout_height="0dp"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/ivBack"
android:layout_width="24dp"
android:layout_height="48dp"
android:layout_marginStart="32dp"
android:contentDescription="@string/back"
android:padding="6dp"
android:src="@mipmap/ic_left_arrow"
......@@ -35,13 +36,25 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvBack" />
<TextView
android:id="@+id/tvBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@string/back"
android:textColor="@color/white"
android:textSize="24sp" />
</androidx.appcompat.widget.LinearLayoutCompat>
<ImageView
android:layout_width="195dp"
android:layout_height="20dp"
android:layout_marginEnd="32dp"
android:src="@mipmap/ic_logo_white"
app:layout_constraintBottom_toBottomOf="@+id/tvBack"
app:layout_constraintBottom_toBottomOf="@+id/llBack"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvBack" />
app:layout_constraintTop_toTopOf="@+id/llBack" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -11,6 +11,8 @@
<color name="blue">#2E6CFB</color>
<color name="color_333333">#333333</color>
<color name="color_666666">#666666</color>
<color name="color_999999">#999999</color>
<color name="color_FF4E33">#FF4E33</color>
<color name="color_ECECEC">#ECECEC</color>
<color name="color_F8F8F8">#F8F8F8</color>
</resources>
\ No newline at end of file
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