Commit 7285e612 authored by 赵鹏翔's avatar 赵鹏翔

结算打印添加二次确认

parent e3083787
......@@ -2,20 +2,23 @@ package com.miya.fastcashier.ui
import android.content.Intent
import android.os.Bundle
import android.view.Gravity
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.ViewModelProvider
import com.miya.fastcashier.BaseApplication
import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.ActivityMainBinding
import com.miya.fastcashier.service.AccountService
import com.miya.fastcashier.service.PrintService
import com.miya.fastcashier.ui.dialog.AuthorizePasswordInputDialog
import com.miya.fastcashier.ui.dialog.CommonDialog
import com.miya.fastcashier.utils.*
import com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import com.miya.fastcashier.utils.manage.OrderRecordManageKit
import com.miya.fastcashier.viewmodel.MainViewModel
import com.miya.print.utils.PrintLogger
import java.util.*
class MainActivity : BaseActivity() {
......@@ -24,6 +27,7 @@ class MainActivity : BaseActivity() {
private lateinit var binding: ActivityMainBinding
private lateinit var viewModel: MainViewModel
private var dateSelectHelper: DateSelectHelper? = null
private var confirmDialog: CommonDialog? = null
companion object {
@JvmStatic
......@@ -81,27 +85,7 @@ class MainActivity : BaseActivity() {
}
binding.llBalance.clickWithTrigger {
//上次记录的时间,或者当天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)
}
showConfirmBalanceDialog()
}
initData()
......@@ -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() {
dateSelectHelper?.dismiss()
super.onDestroy()
......
......@@ -26,6 +26,7 @@
<string name="sure">确定</string>
<string name="search_order_prompt_text">还没有明细哦~</string>
<string name="app_text_login_out">是否确认退出账号</string>
<string name="app_text_confirm_balance">是否确认结算打印</string>
<string name="text_login_out_sure">确认退出</string>
<string name="app_login_out">退出登录</string>
<string name="text_refund_amount">退款金额¥%s,是否确认退款</string>
......
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