feat:称增加促销价逻辑
This commit is contained in:
1 parent
87ff651b93
commit
38d2ec2292
1 file changed
+13
-3
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user