From 3a7ca1e5befc608fbf5847038fd90f60c08367dc Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Thu, 14 Aug 2025 20:05:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=8C=BB=E9=99=A2=E6=94=AF=E4=BB=98?= =?UTF-8?q?=EF=BC=8C=E9=80=89=E6=8B=A9=E6=94=AF=E4=BB=98=E9=92=B1=E5=8C=85?= =?UTF-8?q?=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/api/wallet_api.dart | 12 + lib/common/models/api/wallet_api_models.dart | 40 +++ .../models/api/wallet_api_models.g.dart | 21 ++ .../models/database/database_models.g.dart | 1 - lib/common/models/mq/mq_enum_models.dart | 1 + lib/common/models/mq/mq_models.g.dart | 1 + .../models/page/order_page_enum_models.dart | 44 ++- lib/common/utils/app/app_mq_tool.dart | 4 + lib/common/utils/app/app_user_tool.dart | 19 +- lib/common/utils/sync/sync_product_tool.dart | 28 ++ lib/common/values/constants.dart | 2 +- .../widgets/app/app_wallet_selector.dart | 97 +++++++ lib/common/widgets/index.dart | 1 + .../widgets/order/select_pay_type_dialog.dart | 261 ++++++++++++------ lib/common/widgets/user/user_info.dart | 2 +- lib/pages/supermarket_order/controller.dart | 12 +- lib/pages/supermarket_order/view.dart | 12 +- 17 files changed, 441 insertions(+), 117 deletions(-) create mode 100644 lib/common/widgets/app/app_wallet_selector.dart diff --git a/lib/common/api/wallet_api.dart b/lib/common/api/wallet_api.dart index 5c4a1cc..5972fc6 100644 --- a/lib/common/api/wallet_api.dart +++ b/lib/common/api/wallet_api.dart @@ -63,4 +63,16 @@ abstract class WalletApi { ?.map((e) => ServiceMchRule.fromJson(e)) .toList(); } + + /// 获取钱包规则(android离线计算展示使用) + static Future?> getWalletList(dynamic pa) async { + final res = await HttpManage().dio.get( + "/wallet/wallet-manage/ad/wallet/list", + queryParameters: pa, + ); + if (res.data == null) return null; + return res.data + ?.map((e) => ServiceWallet.fromJson(e)) + .toList(); + } } diff --git a/lib/common/models/api/wallet_api_models.dart b/lib/common/models/api/wallet_api_models.dart index c806518..0372007 100644 --- a/lib/common/models/api/wallet_api_models.dart +++ b/lib/common/models/api/wallet_api_models.dart @@ -94,3 +94,43 @@ class ServiceMchRule { Map toJson() => _$ServiceMchRuleToJson(this); } + +@JsonSerializable() +class ServiceWallet { + /// 钱包id + String id; + + /// 唯一编号 + String walletTypeUniqueCode; + + /// 用户id + String userId; + + /// 钱包类型 + String walletTypeId; + + /// 余额(单位分) + int balance = 0; + + /// 卡号 + String? cardNumber; + + /// 是否冻结饭卡 + @JsonKey(fromJson: JsonTool.stringToBoolean, toJson: JsonTool.booleanToString) + bool? walletIsFreeze; + + ServiceWallet({ + required this.id, + required this.walletTypeUniqueCode, + required this.userId, + required this.walletTypeId, + required this.balance, + this.cardNumber, + this.walletIsFreeze, + }); + + factory ServiceWallet.fromJson(Map json) => + _$ServiceWalletFromJson(json); + + Map toJson() => _$ServiceWalletToJson(this); +} diff --git a/lib/common/models/api/wallet_api_models.g.dart b/lib/common/models/api/wallet_api_models.g.dart index e6da0b1..59054ea 100644 --- a/lib/common/models/api/wallet_api_models.g.dart +++ b/lib/common/models/api/wallet_api_models.g.dart @@ -58,3 +58,24 @@ Map _$ServiceMchRuleToJson(ServiceMchRule instance) => 'basePrice': JsonTool.intToString(instance.basePrice), 'multiple': JsonTool.intToString(instance.multiple), }; + +ServiceWallet _$ServiceWalletFromJson(Map json) => + ServiceWallet( + id: json['id'] as String, + walletTypeUniqueCode: json['walletTypeUniqueCode'] as String, + userId: json['userId'] as String, + walletTypeId: json['walletTypeId'] as String, + balance: (json['balance'] as num).toInt(), + walletIsFreeze: + JsonTool.stringToBoolean(json['walletIsFreeze'] as String), + ); + +Map _$ServiceWalletToJson(ServiceWallet instance) => + { + 'id': instance.id, + 'walletTypeUniqueCode': instance.walletTypeUniqueCode, + 'userId': instance.userId, + 'walletTypeId': instance.walletTypeId, + 'balance': instance.balance, + 'walletIsFreeze': JsonTool.booleanToString(instance.walletIsFreeze), + }; diff --git a/lib/common/models/database/database_models.g.dart b/lib/common/models/database/database_models.g.dart index 0fe479f..7690bf3 100644 --- a/lib/common/models/database/database_models.g.dart +++ b/lib/common/models/database/database_models.g.dart @@ -132,7 +132,6 @@ const _$OrderPayDisplayTypeEnumMap = { OrderPayDisplayType.cash: 'cash', OrderPayDisplayType.zyy: 'zyy', OrderPayDisplayType.rmyy: 'rmyy', - OrderPayDisplayType.qrCodeScan: 'qrCodeScan', }; UserSetting _$UserSettingFromJson(Map json) => UserSetting( diff --git a/lib/common/models/mq/mq_enum_models.dart b/lib/common/models/mq/mq_enum_models.dart index ac13d18..4399989 100644 --- a/lib/common/models/mq/mq_enum_models.dart +++ b/lib/common/models/mq/mq_enum_models.dart @@ -6,6 +6,7 @@ enum MqtActionEnum implements BaseEnum { CANTEEN_CLASSIFY("30", "食堂分类变化"), SUPERMARKET_PRODUCT("40", "超市商品变化"), SUPERMARKET_CLASSIFY("50", "超市分类变化"), + SUPERMARKET("51", "超市分类变化"), PRINT("60", "打印变化"), FACE("70", "人脸变化"), TAKE_FOOD_BROADCAST("80", "定餐广播"), diff --git a/lib/common/models/mq/mq_models.g.dart b/lib/common/models/mq/mq_models.g.dart index 276c35e..54af4c0 100644 --- a/lib/common/models/mq/mq_models.g.dart +++ b/lib/common/models/mq/mq_models.g.dart @@ -20,6 +20,7 @@ const _$MqtActionEnumEnumMap = { MqtActionEnum.CANTEEN_CLASSIFY: 'CANTEEN_CLASSIFY', MqtActionEnum.SUPERMARKET_PRODUCT: 'SUPERMARKET_PRODUCT', MqtActionEnum.SUPERMARKET_CLASSIFY: 'SUPERMARKET_CLASSIFY', + MqtActionEnum.SUPERMARKET: 'SUPERMARKET', MqtActionEnum.PRINT: 'PRINT', MqtActionEnum.FACE: 'FACE', MqtActionEnum.TAKE_FOOD_BROADCAST: 'TAKE_FOOD_BROADCAST', diff --git a/lib/common/models/page/order_page_enum_models.dart b/lib/common/models/page/order_page_enum_models.dart index aaeadc4..12a2054 100644 --- a/lib/common/models/page/order_page_enum_models.dart +++ b/lib/common/models/page/order_page_enum_models.dart @@ -1,13 +1,12 @@ import 'package:pj_supermarket_cloud/common/index.dart'; enum OrderPayDisplayType implements BaseEnum { - qrCode("1", "二维码支付", false), - walletCard("2", "饭卡支付", true), - face("3", "人脸支付", true), - cash("4", "现金支付", true), - zyy("12", "中医院", true), - rmyy("13", "人民医院", true), - qrCodeScan("22", "钱包扫一扫", false), + qrCode("1", "二维码支付", false, 1), + walletCard("2", "饭卡支付", true, 2), + face("3", "人脸支付", true, 3), + cash("4", "现金支付", true, 4), + zyy("12", "中医院", true, 5), + rmyy("13", "人民医院", true, 6), ; @override @@ -16,6 +15,35 @@ enum OrderPayDisplayType implements BaseEnum { final String title; // 是否支离线支付 final bool supportOffLine; + // 是否支离线支付 + final int order; - const OrderPayDisplayType(this.code, this.title, this.supportOffLine); + // 线下支付的订单类型(现金支付,其他渠道支付如中医院、人民医院) + static const List offlinePayTypeList = [ + OrderPayDisplayType.cash, + OrderPayDisplayType.zyy, + OrderPayDisplayType.rmyy, + ]; + + // 是否为线下支付 + static bool isOffline(OrderPayDisplayType type) { + return offlinePayTypeList.contains(type); + } + + // 需要选择钱包 + static const List selectWalletPayTypeList = [ + OrderPayDisplayType.face, + ]; + + // 是否需要选择钱包 + static bool isSelectWalletPayType(OrderPayDisplayType type) { + return selectWalletPayTypeList.contains(type); + } + + const OrderPayDisplayType( + this.code, + this.title, + this.supportOffLine, + this.order, + ); } diff --git a/lib/common/utils/app/app_mq_tool.dart b/lib/common/utils/app/app_mq_tool.dart index 5cead93..ed52b3f 100644 --- a/lib/common/utils/app/app_mq_tool.dart +++ b/lib/common/utils/app/app_mq_tool.dart @@ -89,6 +89,10 @@ class AppMqTool { await SyncProductTool.syncProduct(); mqUpdateEventBus.fire(MqtActionEnum.SUPERMARKET_PRODUCT); break; + case MqtActionEnum.SUPERMARKET: + await SyncProductTool.syncSupermarket(); + mqUpdateEventBus.fire(MqtActionEnum.SUPERMARKET); + break; case MqtActionEnum.CANTEEN_CLASSIFY: await SyncProductTool.syncClassify(); mqUpdateEventBus.fire(MqtActionEnum.CANTEEN_CLASSIFY); diff --git a/lib/common/utils/app/app_user_tool.dart b/lib/common/utils/app/app_user_tool.dart index 8078c43..64533d8 100644 --- a/lib/common/utils/app/app_user_tool.dart +++ b/lib/common/utils/app/app_user_tool.dart @@ -25,16 +25,19 @@ abstract class AppUserTool { } // 生成外部用户 - static ServiceUser generateExternalUser({ - String userId = "-1", - String userName = "外部用户", - String cardNumber = "-1", - }) { + static ServiceUser generateExternalUser() { return ServiceUser( - userId: userId, - username: userName, - walletCardNumber: cardNumber, + userId: "-1", + username: "外部用户", userMobile: "外部用户", + walletIsFreeze: null, ); } + + // 是否为外部用户 + static bool isGenerateExternalUser(ServiceUser user) { + return user.userId == "-1" && + user.userMobile == "外部用户" && + user.username == "外部用户"; + } } diff --git a/lib/common/utils/sync/sync_product_tool.dart b/lib/common/utils/sync/sync_product_tool.dart index 831a0d6..1861bd6 100644 --- a/lib/common/utils/sync/sync_product_tool.dart +++ b/lib/common/utils/sync/sync_product_tool.dart @@ -1,4 +1,5 @@ import 'package:common_utils/common_utils.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:pinyin/pinyin.dart'; @@ -167,6 +168,33 @@ abstract class SyncProductTool { // 同步商品分类 spu end // ************************************************************************** + /// 同步超市所有数据 + /// 1-删除所有商品分类 + /// 2-删除所有商品 + /// 3-同步商品分类 + /// 4-同步商品 + static Future syncSupermarket() async { + final stopwatch = Stopwatch()..start(); + EasyLoading.show( + status: '原创同步数据中...', + maskType: EasyLoadingMaskType.black, + ); + try { + // 删除 + await delDatabase(); + // 同步 + await syncClassify(); + await syncProduct(); + } catch (error, stack) { + logger.e( + "|$_tag|同步|${SysType.SUPERMARKET.title}|商品信息意外的错误error:|$error|,stack:|$stack|"); + } finally { + stopwatch.stop(); + logger.i('|$_tag|同步超市数据总耗时: ${stopwatch.elapsedMilliseconds}ms'); + EasyLoading.dismiss(); + } + } + /// 同步商品 static Future syncProduct() async { final sysSetting = await AppSettingTool.getSysSetting(); diff --git a/lib/common/values/constants.dart b/lib/common/values/constants.dart index 722a8a9..c55bdf6 100644 --- a/lib/common/values/constants.dart +++ b/lib/common/values/constants.dart @@ -12,7 +12,7 @@ class Constants { /// 服务 url static const apiUrl = 'https://stgl.pj.gov.cn/api'; - // static const apiUrl = 'http://192.168.101.139:9999'; + // static const apiUrl = 'http://192.168.101.174:9999'; /// 静态资源 url static const ossUrl = apiUrl; diff --git a/lib/common/widgets/app/app_wallet_selector.dart b/lib/common/widgets/app/app_wallet_selector.dart new file mode 100644 index 0000000..175d762 --- /dev/null +++ b/lib/common/widgets/app/app_wallet_selector.dart @@ -0,0 +1,97 @@ +import 'package:common_utils/common_utils.dart'; +import 'package:ducafe_ui_core/ducafe_ui_core.dart'; +import 'package:flutter/material.dart'; +import 'package:forui/forui.dart'; +import 'package:get/get.dart'; +import 'package:pj_supermarket_cloud/common/index.dart'; + +final _successColor = Colors.greenAccent[200]; + +Widget AppWalletSelector( + BuildContext context, { + required List list, + required Function(ServiceWallet) onChange, + ServiceWallet? selector, +}) { + if (ObjectUtil.isEmpty(list)) { + return const SizedBox(); + } + final currentSelector = selector ?? list[0]; + final theme = FTheme.of(context); + return list + .map((v) { + // 钱包类型映射 + final walletTypeStr = WalletType.values + .firstWhereOrNull( + (item) => item.code == v.walletTypeUniqueCode, + ) + ?.title ?? + "未知钱包"; + // 是否选中 + final isSelect = + v.walletTypeUniqueCode == currentSelector.walletTypeUniqueCode; + + return [ + FIcon( + FAssets.icons.walletMinimal, + size: theme.typography.xl.fontSize, + ), + SizedBox(width: 10.w), + Text( + walletTypeStr, + style: theme.typography.xl.copyWith(height: 1), + ), + SizedBox(width: 10.w), + appPrice(context, v.balance), + const Spacer(), + FIcon( + FAssets.icons.circleCheck, + color: Colors.green, + size: theme.typography.xl2.fontSize, + ).offstage( + offstage: !isSelect, + ), + ] + .toRow() + .padding( + vertical: 15.h, + horizontal: 20.w, + ) + .decorated( + color: !isSelect ? theme.colorScheme.background : _successColor, + border: Border.all( + color: theme.colorScheme.primary, + width: 1, + ), + borderRadius: theme.style.borderRadius / 2, + ) + .onTap(() => onChange(v)); + }) + .toList() + .toColumnSpace(space: 10.w) + .padding( + vertical: 10.h, + horizontal: 10.w, + ); +} + + + +// list.add( +// ServiceWallet( +// id: "1", +// walletTypeUniqueCode: "1", +// userId: "1", +// walletTypeId: "1", +// balance: 100, +// ), +// ); +// list.add( +// ServiceWallet( +// id: "2", +// walletTypeUniqueCode: "2", +// userId: "2", +// walletTypeId: "2", +// balance: 200, +// ), +// ); \ No newline at end of file diff --git a/lib/common/widgets/index.dart b/lib/common/widgets/index.dart index f597cf0..d0ecf00 100644 --- a/lib/common/widgets/index.dart +++ b/lib/common/widgets/index.dart @@ -16,6 +16,7 @@ export './app/app_page.dart'; export './app/app_price.dart'; export './app/app_radio_hour_type_dialog.dart'; export './app/app_title.dart'; +export './app/app_wallet_selector.dart'; export './card/card_common.dart'; diff --git a/lib/common/widgets/order/select_pay_type_dialog.dart b/lib/common/widgets/order/select_pay_type_dialog.dart index 182cfe0..0b84644 100644 --- a/lib/common/widgets/order/select_pay_type_dialog.dart +++ b/lib/common/widgets/order/select_pay_type_dialog.dart @@ -59,6 +59,12 @@ class SelectPayTypeDialogController extends GetxController { StreamSubscription? faceDiscernListen; + // 钱包类标 + RxList userWalletList = RxList([]); + + // 当前选择的钱包 + Rx currentWallet = Rx(null); + // 二维码识别结果 ServiceQRCode? globalQrCode; @@ -78,6 +84,22 @@ class SelectPayTypeDialogController extends GetxController { if (payType == null || payType == orderPayDisplayType.value) { return; } + final isOffline = OrderPayDisplayType.isOffline(payType); + if (isOffline) { + payUser.value = AppUserTool.generateExternalUser(); + if (payType == OrderPayDisplayType.cash) { + orderPayType.value = OrderPayType.CASH; + } else if (payType == OrderPayDisplayType.zyy) { + orderPayType.value = OrderPayType.ZYY; + } else if (payType == OrderPayDisplayType.rmyy) { + orderPayType.value = OrderPayType.RMYY; + } + } else if (payUser.value != null) { + if (AppUserTool.isGenerateExternalUser(payUser.value!)) { + payUser.value = null; + } + } + orderPayDisplayType.value = payType; orderPayDisplayType.refresh(); }); @@ -98,12 +120,14 @@ class SelectPayTypeDialogController extends GetxController { final isNetwork = AppNetworkTool.isAutoNetwork(); // 过滤一下不支持离线的支付方式 if (isNetwork) { - usePayDisplayTypeList.value = appSetting.usePayDisplayType!; + usePayDisplayTypeList.value = appSetting.usePayDisplayType!.toList() + ..sort((a, b) => a.order.compareTo(b.order)); } else { final supportPayTypeList = appSetting.usePayDisplayType! .where((i) => i.supportOffLine) .toList(); - usePayDisplayTypeList.value = supportPayTypeList; + usePayDisplayTypeList.value = supportPayTypeList.toList() + ..sort((a, b) => a.order.compareTo(b.order)); } } } @@ -138,9 +162,6 @@ class SelectPayTypeDialogController extends GetxController { case OrderPayDisplayType.face: await _dispatchFace(); break; - case OrderPayDisplayType.cash: - await _dispatchCash(); - break; default: } onRecognition?.call(); @@ -151,6 +172,12 @@ class SelectPayTypeDialogController extends GetxController { if (payUser.value == null) { return; } + // 判断是否为线下支付 + final isOffline = OrderPayDisplayType.isOffline(orderPayDisplayType.value!); + if (isOffline) { + orderType = OrderType.BELOW; + onDiscernUser?.call(payUser.value); + } await onSubmit?.call( payUser.value!, orderType, @@ -373,25 +400,15 @@ class SelectPayTypeDialogController extends GetxController { } // ************************************************************************** - // 现金支付 start + // 线下支付 start // ************************************************************************** - Future _dispatchCash() async { + Future _dispatchWalletScanCode() async { orderPayType.value = OrderPayType.CASH; orderType = OrderType.BELOW; - payUser.value = ServiceUser( - userId: "-1", - username: "未知用户", - deptId: "-1", - userMobile: "??????", - userAvatar: "", - walletId: "-1", - walletTypeId: "-1", - walletBalance: 1000 * 100, - ); onDiscernUser?.call(payUser.value); } // ************************************************************************** - // 现金支付 end + // 线下支付 end // ************************************************************************** // android人脸识别成功回调 @@ -414,6 +431,7 @@ class SelectPayTypeDialogController extends GetxController { payUser.value = data; logger.i("|_tag|人脸识别|有网络|,用户信息:|${payUser.toJson()}|"); await SyncUserTool.storageUser(user: payUser.value!); + await _getWalletList(); } else { // 没有网络去本地数据库查询 final user = await SyncUserTool.storageUserByUserId(event.userId!); @@ -471,6 +489,31 @@ class SelectPayTypeDialogController extends GetxController { } return success.contains(type); } + + /// 获取用户钱包列表 + Future _getWalletList() async { + // 如果选择了需要选择钱包的支付方式 + if (appSetting.sysType != SysType.SUPERMARKET) { + return; + } + final isSelectWallet = OrderPayDisplayType.isSelectWalletPayType( + orderPayDisplayType.value!, + ); + if (!isSelectWallet) return; + try { + if (payUser.value == null) return; + if (AppUserTool.isGenerateExternalUser(payUser.value!)) return; + + final userId = payUser.value?.userId; + if (userId == null) return; + + final data = await WalletApi.getWalletList({"userId": userId}); + if (data == null) throw Error(); + userWalletList.value = data; + } catch (error, stack) { + logger.e("|$_tag|获取用户钱包列表,意外的错误error:|$error|stack:|$stack|"); + } + } } Future selectPayTypeDialog() async { @@ -480,46 +523,80 @@ Future selectPayTypeDialog() async { final theme = FTheme.of(Get.context!); final width = Get.context!.width; final height = Get.context!.height; + final dialogWidth = width * 0.55; + final dialogHeight = height * 0.7; return showDialog( context: context, barrierDismissible: false, builder: (BuildContext _) { - return PopScope( - child: FDialog( - direction: Axis.vertical, - title: Text("选择支付方式", style: theme.typography.lg), - body: [ - Obx( - () => FSelectGroup( - enabled: payTypeC.payUser.value == null, - controller: payTypeC.payTypeRadioC, - style: theme.selectGroupStyle.copyWith( - labelLayoutStyle: - theme.selectGroupStyle.labelLayoutStyle.copyWith( - childPadding: EdgeInsets.symmetric( - vertical: 10.h, - ), - ), - radioStyle: theme.selectGroupStyle.radioStyle.copyWith( - padding: EdgeInsets.symmetric( - vertical: 10.h, - ), + return FDialog( + title: + Text("选择支付方式", style: theme.typography.lg).marginOnly(bottom: 20.h), + style: theme.dialogStyle.copyWith( + insetPadding: EdgeInsets.zero, + maxWidth: dialogWidth, + minWidth: dialogWidth, + horizontalStyle: theme.dialogStyle.horizontalStyle.copyWith( + padding: EdgeInsets.all(20.w), + ), + ), + body: [ + Obx( + () => FSelectGroup( + enabled: payTypeC.payUser.value == null, + controller: payTypeC.payTypeRadioC, + style: theme.selectGroupStyle.copyWith( + labelLayoutStyle: + theme.selectGroupStyle.labelLayoutStyle.copyWith( + childPadding: EdgeInsets.symmetric( + vertical: 10.h, + horizontal: 10.w, + ), + ), + radioStyle: theme.selectGroupStyle.radioStyle.copyWith( + padding: EdgeInsets.symmetric( + vertical: 10.h, ), ), - items: payTypeC.usePayDisplayTypeList - .map>( - (v) => FSelectGroupItem.radio( - value: v, - label: Text( - v.title, - style: theme.typography.xl, - ), - ), - ) - .toList(), ), + items: payTypeC.usePayDisplayTypeList + .map>( + (v) => FSelectGroupItem.radio( + value: v, + label: Text( + v.title, + style: theme.typography.xl, + ), + ), + ) + .toList(), + ), + ).expanded(), + [ + Obx( + () => AppWalletSelector( + context, + list: payTypeC.userWalletList, + selector: payTypeC.currentWallet.value, + onChange: (wallet) { + payTypeC.currentWallet.value = wallet; + // 设置payUser + final payUser = payTypeC.payUser.value; + if (payUser == null) return; + payUser.walletId = wallet.id; + payUser.walletTypeId = wallet.walletTypeId; + payUser.walletBalance = wallet.balance; + payUser.walletCardNumber = wallet.cardNumber; + payUser.walletIsFreeze = wallet.walletIsFreeze; + }, + ).width(double.infinity).height(200.h).offstage( + offstage: + !(payTypeC.appSetting.sysType == SysType.SUPERMARKET && + payTypeC.userWalletList.isNotEmpty && + OrderPayDisplayType.isSelectWalletPayType( + payTypeC.orderPayDisplayType.value!)), + ), ), - SizedBox(height: 20.h), Obx( () => Visibility( visible: payTypeC.payUser.value == null, @@ -533,45 +610,55 @@ Future selectPayTypeDialog() async { isLoading: payTypeC.isRecognition.value, ), ), - ).center().expanded(), - ].toColumn().width(width * 0.7).height(height * 0.7), - actions: [ - [ - Obx( - () => FButton( - label: Text( - payTypeC.payUser.value == null ? "开始识别" : "确定支付", - style: theme.typography.xl.copyWith( - color: theme.colorScheme.secondary, - ), - ), - onPress: payTypeC.isRecognition.value - ? null - : () { - if (payTypeC.payUser.value == null) { - payTypeC.doRecognition(); - } else { - payTypeC.doSubmit(); - } - }, + ).flexible(flex: 1), + ] + .toColumn() + .paddingAll(5.w) + .decorated( + border: Border.all( + color: theme.colorScheme.primary, + width: 1, ), - ).flexible(flex: 1), - SizedBox(width: 20.w), - FButton( - style: FButtonStyle.destructive, + borderRadius: theme.style.borderRadius / 3, + ) + .expanded(), + ].toRow().width(double.infinity).height(dialogHeight), + actions: [ + [ + Obx( + () => FButton( label: Text( - "取消", + payTypeC.payUser.value == null ? "开始识别" : "确定支付", style: theme.typography.xl.copyWith( color: theme.colorScheme.secondary, ), ), - onPress: () { - payTypeC.doCancel(); - }, - ).flexible(flex: 1), - ].toRow(), - ], - ), + onPress: payTypeC.isRecognition.value + ? null + : () { + if (payTypeC.payUser.value == null) { + payTypeC.doRecognition(); + } else { + payTypeC.doSubmit(); + } + }, + ), + ).flexible(flex: 1), + SizedBox(width: 20.w), + FButton( + style: FButtonStyle.destructive, + label: Text( + "取消", + style: theme.typography.xl.copyWith( + color: theme.colorScheme.secondary, + ), + ), + onPress: () { + payTypeC.doCancel(); + }, + ).flexible(flex: 1), + ].toRow(), + ], ); }, ); @@ -632,11 +719,11 @@ Widget selectPayTypeUser(ServiceUser? user, OrderPayType? payType) { prefixIcon: FIcon(FAssets.icons.ban), title: Text('是否冻结', style: textStyle), details: Text(isFree ? "是" : "否", style: textStyle), - ).offstage(offstage: user.walletCardNumber == null), + ).offstage(offstage: user.walletIsFreeze == null), ]); } return widgets - .toColumn(mainAxisAlignment: MainAxisAlignment.center) + .toColumn(mainAxisAlignment: MainAxisAlignment.start) .height(double.infinity); } @@ -650,10 +737,6 @@ Widget selectPayTypeHint( String msg = ""; SvgAsset icon = FAssets.icons.bird; switch (type) { - case OrderPayDisplayType.qrCodeScan: - msg = "$baseMsg,并让用户扫一扫二维码"; - icon = FAssets.icons.qrCode; - break; case OrderPayDisplayType.qrCode: msg = "$baseMsg,并让用户出示二维码"; icon = FAssets.icons.qrCode; diff --git a/lib/common/widgets/user/user_info.dart b/lib/common/widgets/user/user_info.dart index c5739ff..ca96459 100644 --- a/lib/common/widgets/user/user_info.dart +++ b/lib/common/widgets/user/user_info.dart @@ -35,7 +35,7 @@ Widget appUserInfo( [ Text("姓名:$username", style: style), [ - Text("饭卡余额:", style: style), + Text("余额:", style: style), appPrice(context, balance), ].toRow().offstage(offstage: !visibleMoney), ].toColumn(crossAxisAlignment: CrossAxisAlignment.start), diff --git a/lib/pages/supermarket_order/controller.dart b/lib/pages/supermarket_order/controller.dart index 5302556..3b445aa 100644 --- a/lib/pages/supermarket_order/controller.dart +++ b/lib/pages/supermarket_order/controller.dart @@ -167,8 +167,9 @@ class SupermarketOrderController extends GetxController with OrderMixin { } // |+|或者|-|点击更改商品数量 - void doComputedInputChange(int number, int index) async { - final current = shopCardList[index]; + void doComputedInputChange(int number, String productCard) async { + final current = shopCardList + .firstWhere((item) => item.productServiceUniqueCode == productCard); // 称重商品在购物车就直接删除 if (current.nature == ProductNature.WEIGHT) { final shopCard = _findShopProductByCode(current.productServiceUniqueCode); @@ -190,8 +191,9 @@ class SupermarketOrderController extends GetxController with OrderMixin { } // |购买商品|点击称重 - Future computedPanelWidget(double widget, int i) async { - final current = shopCardList[i]; + Future computedPanelWidget(double widget, String productCode) async { + final current = shopCardList + .firstWhere((item) => item.productServiceUniqueCode == productCode); // 直接查数据库 final skuDao = appC.dataBase.getSupermarketSkuDao; final targetProduct = await skuDao.getBySkuCode( @@ -335,7 +337,7 @@ class SupermarketOrderController extends GetxController with OrderMixin { scanProduct.serviceUniqueCode, ); if (target != -1) { - await computedPanelWidget(0, target); + await computedPanelWidget(0, scanProduct.serviceUniqueCode); return; } else { // 商品添加到购物车 diff --git a/lib/pages/supermarket_order/view.dart b/lib/pages/supermarket_order/view.dart index 378edfd..80651fd 100644 --- a/lib/pages/supermarket_order/view.dart +++ b/lib/pages/supermarket_order/view.dart @@ -250,10 +250,14 @@ class SupermarketOrderPage extends GetView { index: index, showPlus: current.nature == ProductNature.DEFAULT, showWidget: current.nature == ProductNature.WEIGHT, - onPlusChange: (number, i) => - controller.doComputedInputChange(number, i), - onWidgetChange: (widget, i) => - controller.computedPanelWidget(widget, i), + onPlusChange: (number, i) => controller.doComputedInputChange( + number, + current.productServiceUniqueCode, + ), + onWidgetChange: (widget, i) => controller.computedPanelWidget( + widget, + current.productServiceUniqueCode, + ), ).marginOnly(bottom: 10.h); }, ),