From 38d2ec22921ef5d8605f77a5233b3d66f13e8ebf Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Wed, 19 Mar 2025 14:41:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E7=A7=B0=E5=A2=9E=E5=8A=A0=E4=BF=83?= =?UTF-8?q?=E9=94=80=E4=BB=B7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widgets/order/steelyard_container.dart | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/common/widgets/order/steelyard_container.dart b/lib/common/widgets/order/steelyard_container.dart index 86d5449..a5784bb 100644 --- a/lib/common/widgets/order/steelyard_container.dart +++ b/lib/common/widgets/order/steelyard_container.dart @@ -43,7 +43,7 @@ class SteelyardController extends GetxController { // 波动范围 static const double _weightTolerance = 0.05; // 稳定次数 - static const int _requiredStableCount = 5; + static const int _requiredStableCount = 3; // 点击|开始称重| void weightStartCallback() { @@ -153,7 +153,9 @@ class SteelyardController extends GetxController { (callback) { if (_product == null) return; widget.value = callbackWidget.value; - final p = (callbackWidget.value * _product!.retailPrice).ceil(); + // 获取价格 + final productPrice = _getProudctPrice(_product!); + final p = (callbackWidget.value * productPrice).ceil(); price.value = p; if ((widget.value - _lastWeight).abs() <= _weightTolerance) { _stableCount++; @@ -166,7 +168,7 @@ class SteelyardController extends GetxController { } _lastWeight = widget.value; logger.i( - "|$_tag|重量|${widget.value}|单价|${_product!.retailPrice}|总价|${price.value}|稳定次数|$_stableCount|", + "|$_tag|重量|${widget.value}|单价|$productPrice|总价|${price.value}|稳定次数|$_stableCount|", ); }, time: const Duration(milliseconds: 100), @@ -177,6 +179,14 @@ class SteelyardController extends GetxController { logger.e("|$_tag|打开并监听称串口失败error|$e|"); } } + + // 获取当前商品的价格,有促销价先用促销价 + int _getProudctPrice(SupermarketSpuEntity product) { + if (product.promotionPrice != 0) { + return product.promotionPrice; + } + return product.retailPrice; + } } Widget steelyardEmpty(BuildContext context) {