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) {