联合支付余量计量模式订单显示当前取餐信息
This commit is contained in:
@@ -24,9 +24,11 @@ import androidx.camera.lifecycle.ProcessCameraProvider
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.common.util.concurrent.ListenableFuture
|
import com.google.common.util.concurrent.ListenableFuture
|
||||||
import com.sw.dualscreen.GlobalData
|
import com.sw.dualscreen.GlobalData
|
||||||
import com.sw.dualscreen.GlobalKey
|
import com.sw.dualscreen.GlobalKey
|
||||||
|
import com.sw.dualscreen.adapter.FoodOrderAdapter
|
||||||
import com.sw.dualscreen.adapter.MainFoodListAdapter
|
import com.sw.dualscreen.adapter.MainFoodListAdapter
|
||||||
import com.sw.dualscreen.databinding.ActivityMainBinding
|
import com.sw.dualscreen.databinding.ActivityMainBinding
|
||||||
import com.sw.dualscreen.dialog.RemindDialog
|
import com.sw.dualscreen.dialog.RemindDialog
|
||||||
@@ -290,11 +292,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||||
//秤上重量过小,显示识别中页面
|
//秤上重量过小,显示识别中页面
|
||||||
presentation?.step1FoodRecognizing()
|
presentation?.step1FoodRecognizing()
|
||||||
|
lastWeight = weight
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//余量计量+联合支付人脸查询订单完成
|
//余量计量+联合支付人脸查询订单完成
|
||||||
if (presentation!!.jointPaymentQueryFinish) {
|
if (presentation!!.jointPaymentQueryFinish) {
|
||||||
presentation?.updateWeight(weight)
|
presentation?.updateWeight(weight)
|
||||||
|
lastWeight = weight
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val isWeightChange = weight - lastWeight > WEIGHT_CHANGE_VALUE
|
val isWeightChange = weight - lastWeight > WEIGHT_CHANGE_VALUE
|
||||||
@@ -303,12 +307,15 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
|
|
||||||
private fun readWeight(weight: Int) {
|
private fun readWeight(weight: Int) {
|
||||||
log("registerDataChange weight = $weight")
|
log("registerDataChange weight = $weight")
|
||||||
runOnUiThread {
|
binding.tvShowWeight.let {
|
||||||
binding.tvShowWeight.let {
|
if (it.text.toString() != weight.toString()) {
|
||||||
if (it.text.toString() == weight.toString()) return@runOnUiThread
|
|
||||||
it.text = "$weight"
|
it.text = "$weight"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||||
|
//检测到秤上没有东西,重新启动识别菜品 && presentation?.mealPickupMode == 1
|
||||||
|
checkedItem = null
|
||||||
|
}
|
||||||
if (settlementMode == 0) {
|
if (settlementMode == 0) {
|
||||||
//联合支付-------------------------------------------
|
//联合支付-------------------------------------------
|
||||||
//0-即放即取,1-余量计量
|
//0-即放即取,1-余量计量
|
||||||
@@ -344,7 +351,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
override fun registerDataChange() {
|
override fun registerDataChange() {
|
||||||
super.registerDataChange()
|
super.registerDataChange()
|
||||||
SensorScaleUtils.addWeightListener { value ->
|
SensorScaleUtils.addWeightListener { value ->
|
||||||
readWeight(value)
|
runOnUiThread {
|
||||||
|
readWeight(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +365,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
presentation?.updateWeight(weight)
|
presentation?.updateWeight(weight)
|
||||||
|
|
||||||
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||||
log("recognizeByWeight---00002,秤重未超过5克")
|
log("recognizeByWeight---00002,秤重未超过${WEIGHT_RESET_RECOGNIZE}克")
|
||||||
//检测到秤上没有东西,重新启动识别菜品 && presentation?.mealPickupMode == 1
|
//检测到秤上没有东西,重新启动识别菜品 && presentation?.mealPickupMode == 1
|
||||||
isRecognitionFood = true
|
isRecognitionFood = true
|
||||||
return
|
return
|
||||||
@@ -364,8 +373,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
|
|
||||||
if (isWeightChange && isRecognitionFood) {
|
if (isWeightChange && isRecognitionFood) {
|
||||||
log("recognizeByWeight---00003,mealPickupMode=${presentation?.mealPickupMode}")
|
log("recognizeByWeight---00003,mealPickupMode=${presentation?.mealPickupMode}")
|
||||||
if (presentation?.mealPickupMode == 1) {
|
if (presentation?.mealPickupMode == 1 && checkedItem != null) {
|
||||||
isRecognitionFood = false
|
isRecognitionFood = false
|
||||||
|
return
|
||||||
}
|
}
|
||||||
debouncer.debounce {
|
debouncer.debounce {
|
||||||
log("recognizeByWeight---00004")
|
log("recognizeByWeight---00004")
|
||||||
@@ -1171,4 +1181,5 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
// ObjectBox.init(this)
|
// ObjectBox.init(this)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ import com.sw.dualscreen.ext.gone
|
|||||||
import com.sw.dualscreen.ext.visible
|
import com.sw.dualscreen.ext.visible
|
||||||
import com.sw.dualscreen.model.response.FoodItem
|
import com.sw.dualscreen.model.response.FoodItem
|
||||||
|
|
||||||
class FoodOrderAdapter(var list: MutableList<FoodItem>) :
|
class FoodOrderAdapter(list: MutableList<FoodItem>) :
|
||||||
BaseQuickAdapter<FoodItem, FoodOrderAdapter.VH>(list) {
|
BaseQuickAdapter<FoodItem, FoodOrderAdapter.VH>(list) {
|
||||||
|
|
||||||
inner class VH(var binding: ListItemFoodOrderBinding) : QuickViewHolder(binding.root)
|
inner class VH(var binding: ListItemFoodOrderBinding) : QuickViewHolder(binding.root)
|
||||||
@@ -33,10 +33,10 @@ class FoodOrderAdapter(var list: MutableList<FoodItem>) :
|
|||||||
val binding = holder.binding
|
val binding = holder.binding
|
||||||
item?.let {
|
item?.let {
|
||||||
binding.tvFoodName.text = it.foodName
|
binding.tvFoodName.text = it.foodName
|
||||||
val foodPrice = it.foodPrice.format2String(2)
|
|
||||||
if (it.orderFrom == 2) {
|
if (it.orderFrom == 2) {
|
||||||
binding.tvPriceNorm.text = "${it.specName}/${it.specWeight}克"
|
binding.tvPriceNorm.text = if (it.specName.isNullOrBlank()) "${it.specWeight}克" else "${it.specName}/${it.specWeight}克"
|
||||||
} else {
|
} else {
|
||||||
|
val foodPrice = it.foodPrice.format2String(2)
|
||||||
binding.tvPriceNorm.text = "${foodPrice}/${it.num}克"
|
binding.tvPriceNorm.text = "${foodPrice}/${it.num}克"
|
||||||
}
|
}
|
||||||
//if (it.specName.isNullOrBlank().not()) {
|
//if (it.specName.isNullOrBlank().not()) {
|
||||||
|
|||||||
@@ -165,22 +165,23 @@ data class WeightRecord(
|
|||||||
)
|
)
|
||||||
|
|
||||||
data class FoodItem(
|
data class FoodItem(
|
||||||
val id: String? = null,
|
var id: String? = null,
|
||||||
val foodId: String? = null,
|
var foodId: String? = null,
|
||||||
val foodName: String? = null,
|
var foodName: String? = null,
|
||||||
val foodMaterialId: String? = null,
|
var foodMaterialId: String? = null,
|
||||||
val specId: String? = null,
|
var specId: String? = null,
|
||||||
val num: Int = 0,
|
var num: Int = 0,
|
||||||
val eatNum: Int = 0,
|
var eatNum: Int = 0,
|
||||||
val price: Double = 0.0,
|
var price: Double = 0.0,
|
||||||
val foodPrice: Double = 0.0,
|
var foodPrice: Double = 0.0,
|
||||||
val discount: Double = 0.0,
|
var discount: Double = 0.0,
|
||||||
val income: Double = 0.0,
|
var income: Double = 0.0,
|
||||||
val foodDifferenceId: Long = 0,
|
var foodDifferenceId: Long = 0,
|
||||||
val createTime: String? = null,
|
var createTime: String? = null,
|
||||||
val specName: String? = null,
|
var specName: String? = null,
|
||||||
val specWeight: Int = 0,
|
var specWeight: Int = 0,
|
||||||
val orderFrom: Int = 0
|
var orderFrom: Int = 0,
|
||||||
|
var isLocalData: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
data class FoodOrderModel(
|
data class FoodOrderModel(
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ interface ApiService {
|
|||||||
): ApiResponse<Any?>
|
): ApiResponse<Any?>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 档口机向量数据分页查询
|
* 查询就餐数据
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
suspend fun getFoodOrderList(
|
suspend fun getFoodOrderList(
|
||||||
|
|||||||
@@ -670,12 +670,63 @@ class MainScreenPresentation(
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var lastAddWeight = 0
|
||||||
|
private fun addFoodToOrder(weight: Int, foodInfo: FoodInfo) {
|
||||||
|
if (weight == lastAddWeight) return
|
||||||
|
lastAddWeight = weight
|
||||||
|
if (weight <= 10) {
|
||||||
|
if (foodOrderList.isNotEmpty()) {
|
||||||
|
val last = foodOrderList.last()
|
||||||
|
if (last.isLocalData) {
|
||||||
|
foodOrderList.remove(last)
|
||||||
|
foodOrderAdapter.submitList(foodOrderList)
|
||||||
|
//foodOrderAdapter.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val foodPrice = if (isMember) foodInfo.vipPrice else foodInfo.specPrice
|
||||||
|
val eatNum = activity.getEatNum(weight.toDouble(), foodInfo.specWeight)
|
||||||
|
val price = eatNum * (foodPrice?:0.0)
|
||||||
|
if (foodOrderList.isNotEmpty()) {
|
||||||
|
val last = foodOrderList.last()
|
||||||
|
if (last.isLocalData) {
|
||||||
|
last.eatNum = eatNum
|
||||||
|
last.num = weight
|
||||||
|
last.price = price
|
||||||
|
foodOrderAdapter.submitList(foodOrderList)
|
||||||
|
//foodOrderAdapter.notifyItemChanged(foodOrderList.lastIndex)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foodOrderList.add(FoodItem(
|
||||||
|
id = System.currentTimeMillis().toString(),
|
||||||
|
foodId = foodInfo.foodId,
|
||||||
|
foodName = foodInfo.foodName,
|
||||||
|
price = price,
|
||||||
|
specId = foodInfo.specId,
|
||||||
|
foodMaterialId = foodInfo.foodMaterialId,
|
||||||
|
specWeight = foodInfo.specWeight?.toInt() ?: 0,
|
||||||
|
orderFrom = 2,
|
||||||
|
num = weight,
|
||||||
|
eatNum = eatNum,
|
||||||
|
isLocalData = true
|
||||||
|
))
|
||||||
|
foodOrderAdapter.submitList(foodOrderList)
|
||||||
|
//foodOrderAdapter.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
private fun calculateNutrition(value: Int) {
|
private fun calculateNutrition(value: Int) {
|
||||||
if (currentFood == null || userNutrition == null) {
|
if (currentFood == null || userNutrition == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var weight = value
|
var weight = value
|
||||||
if (weight < 0) weight = 0
|
if (weight < 0) weight = 0
|
||||||
|
if (activity.settlementMode == 0) {
|
||||||
|
activity.runOnUiThread {
|
||||||
|
addFoodToOrder(weight, currentFood!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
debouncer.debounce {
|
debouncer.debounce {
|
||||||
Timber.tag(TAG)
|
Timber.tag(TAG)
|
||||||
.d("calculateNutrition weight = $weight, recognitionWeight = $recognitionWeight")
|
.d("calculateNutrition weight = $weight, recognitionWeight = $recognitionWeight")
|
||||||
@@ -1341,7 +1392,7 @@ class MainScreenPresentation(
|
|||||||
it.root.updateLayoutParams {
|
it.root.updateLayoutParams {
|
||||||
height = activity.screenSize[1] / 2 + 120.dp
|
height = activity.screenSize[1] / 2 + 120.dp
|
||||||
}
|
}
|
||||||
it.tvFoodList.run {
|
it.rvFoodList.run {
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
layoutManager =
|
layoutManager =
|
||||||
LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
|
LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
|
||||||
@@ -1349,16 +1400,17 @@ class MainScreenPresentation(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
userViewModel.getFoodOrderList(userId) { model ->
|
userViewModel.getFoodOrderList(userId) { model ->
|
||||||
if (model == null) return@getFoodOrderList
|
activity.runOnUiThread {
|
||||||
foodOrderList.clear()
|
if (model == null) return@runOnUiThread
|
||||||
model.list?.let {
|
foodOrderList.clear()
|
||||||
foodOrderList.addAll(model.list)
|
foodOrderList.addAll(model.list?:emptyList())
|
||||||
}
|
foodOrderAdapter.submitList(foodOrderList)
|
||||||
foodOrderAdapter.notifyDataSetChanged()
|
//foodOrderAdapter.notifyDataSetChanged()
|
||||||
binding.detailInclude.tvTotalWeight.text = "总重量:${model.eatWeightSum}克"
|
binding.detailInclude.tvTotalWeight.text = "总重量:${model.eatWeightSum}克"
|
||||||
binding.detailInclude.tvTotalCalorie.text =
|
binding.detailInclude.tvTotalCalorie.text =
|
||||||
"总热量:${model.calorie.roundToInt()}千卡"
|
"总热量:${model.calorie.roundToInt()}千卡"
|
||||||
jointPaymentQueryFinish = true
|
jointPaymentQueryFinish = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<solid android:color="@android:color/darker_gray"/>
|
<solid android:color="#F2F2F2"/>
|
||||||
<stroke android:color="#cdcdcd" android:width="1dp"/>
|
<!-- <stroke android:color="#cdcdcd" android:width="1dp"/>-->
|
||||||
<corners android:radius="5dp"/>
|
<corners android:radius="5dp"/>
|
||||||
</shape>
|
</shape>
|
||||||
@@ -51,10 +51,11 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvShowWeight"
|
android:id="@+id/tvShowWeight"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:textSize="40sp"
|
android:textSize="20sp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:maxLines="1"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
tools:text="100克"/>
|
tools:text="100克"/>
|
||||||
|
|
||||||
@@ -87,6 +88,7 @@
|
|||||||
android:layout_margin="27dp"
|
android:layout_margin="27dp"
|
||||||
android:background="@drawable/ic_camera_rect" />
|
android:background="@drawable/ic_camera_rect" />
|
||||||
<!-- preview_border-->
|
<!-- preview_border-->
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
android:background="#FFDDE5F0" />
|
android:background="#FFDDE5F0" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/tvFoodList"
|
android:id="@+id/rvFoodList"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
|||||||
Reference in New Issue
Block a user