From 9c82df361740944daab08cc25fd7e1c36e74ce89 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Fri, 15 Aug 2025 17:27:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B6=85=E5=B8=82=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E5=8D=A1=E6=94=AF=E4=BB=98=E3=80=81=E9=80=89=E6=8B=A9=E9=92=B1?= =?UTF-8?q?=E5=8C=85=E3=80=81=E7=A7=B0=E9=87=8D=E5=95=86=E5=93=81=E5=B0=8F?= =?UTF-8?q?=E6=95=B0=E7=B2=BE=E5=BA=A6=E4=B8=8D=E5=A4=9F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/models/api/wallet_api_models.dart | 4 +- .../models/api/wallet_api_models.g.dart | 7 +-- .../models/database/database_enum_models.dart | 2 + .../models/database/database_models.g.dart | 1 + .../models/page/order_page_enum_models.dart | 4 ++ .../database/entity/order_entity.g.dart | 1 + lib/common/utils/sync/sync_product_tool.dart | 2 +- lib/common/values/constants.dart | 4 +- .../widgets/app/app_wallet_selector.dart | 8 ++- .../widgets/order/mixin/order_mixin.dart | 8 ++- .../widgets/order/select_pay_type_dialog.dart | 49 ++++++++++--------- .../widgets/order/steelyard_container.dart | 2 +- lib/pages/supermarket_order/controller.dart | 4 ++ 13 files changed, 61 insertions(+), 35 deletions(-) diff --git a/lib/common/models/api/wallet_api_models.dart b/lib/common/models/api/wallet_api_models.dart index 0372007..3231073 100644 --- a/lib/common/models/api/wallet_api_models.dart +++ b/lib/common/models/api/wallet_api_models.dart @@ -117,7 +117,7 @@ class ServiceWallet { /// 是否冻结饭卡 @JsonKey(fromJson: JsonTool.stringToBoolean, toJson: JsonTool.booleanToString) - bool? walletIsFreeze; + bool? isFreeze; ServiceWallet({ required this.id, @@ -126,7 +126,7 @@ class ServiceWallet { required this.walletTypeId, required this.balance, this.cardNumber, - this.walletIsFreeze, + this.isFreeze, }); factory ServiceWallet.fromJson(Map json) => diff --git a/lib/common/models/api/wallet_api_models.g.dart b/lib/common/models/api/wallet_api_models.g.dart index 59054ea..fecb55f 100644 --- a/lib/common/models/api/wallet_api_models.g.dart +++ b/lib/common/models/api/wallet_api_models.g.dart @@ -66,8 +66,8 @@ ServiceWallet _$ServiceWalletFromJson(Map json) => userId: json['userId'] as String, walletTypeId: json['walletTypeId'] as String, balance: (json['balance'] as num).toInt(), - walletIsFreeze: - JsonTool.stringToBoolean(json['walletIsFreeze'] as String), + cardNumber: json['cardNumber'] as String?, + isFreeze: JsonTool.stringToBoolean(json['isFreeze'] as String), ); Map _$ServiceWalletToJson(ServiceWallet instance) => @@ -77,5 +77,6 @@ Map _$ServiceWalletToJson(ServiceWallet instance) => 'userId': instance.userId, 'walletTypeId': instance.walletTypeId, 'balance': instance.balance, - 'walletIsFreeze': JsonTool.booleanToString(instance.walletIsFreeze), + 'cardNumber': instance.cardNumber, + 'isFreeze': JsonTool.booleanToString(instance.isFreeze), }; diff --git a/lib/common/models/database/database_enum_models.dart b/lib/common/models/database/database_enum_models.dart index 126ce7c..b0336f6 100644 --- a/lib/common/models/database/database_enum_models.dart +++ b/lib/common/models/database/database_enum_models.dart @@ -49,6 +49,7 @@ enum OrderPayType implements BaseEnum { ALI_SELF_QR_CODE_PAY("11", "支付宝付款码支付"), ZYY("12", "中医院"), RMYY("13", "人民医院"), + CSXFK("13", "超市消费卡"), ; @override @@ -58,6 +59,7 @@ enum OrderPayType implements BaseEnum { const OrderPayType(this.code, this.title); + // 是否是外部人员支付 static bool isStrideOrForeign(OrderPayType payType) { return [ OrderPayType.STRIDE_DEPT_QR_CODE, diff --git a/lib/common/models/database/database_models.g.dart b/lib/common/models/database/database_models.g.dart index 7690bf3..3c0a5e1 100644 --- a/lib/common/models/database/database_models.g.dart +++ b/lib/common/models/database/database_models.g.dart @@ -132,6 +132,7 @@ const _$OrderPayDisplayTypeEnumMap = { OrderPayDisplayType.cash: 'cash', OrderPayDisplayType.zyy: 'zyy', OrderPayDisplayType.rmyy: 'rmyy', + OrderPayDisplayType.csxfk: 'csxfk', }; UserSetting _$UserSettingFromJson(Map json) => UserSetting( diff --git a/lib/common/models/page/order_page_enum_models.dart b/lib/common/models/page/order_page_enum_models.dart index 12a2054..6449ad4 100644 --- a/lib/common/models/page/order_page_enum_models.dart +++ b/lib/common/models/page/order_page_enum_models.dart @@ -7,6 +7,7 @@ enum OrderPayDisplayType implements BaseEnum { cash("4", "现金支付", true, 4), zyy("12", "中医院", true, 5), rmyy("13", "人民医院", true, 6), + csxfk("14", "超市消费卡", true, 7), ; @override @@ -23,6 +24,7 @@ enum OrderPayDisplayType implements BaseEnum { OrderPayDisplayType.cash, OrderPayDisplayType.zyy, OrderPayDisplayType.rmyy, + OrderPayDisplayType.csxfk, ]; // 是否为线下支付 @@ -32,7 +34,9 @@ enum OrderPayDisplayType implements BaseEnum { // 需要选择钱包 static const List selectWalletPayTypeList = [ + OrderPayDisplayType.qrCode, OrderPayDisplayType.face, + OrderPayDisplayType.walletCard, ]; // 是否需要选择钱包 diff --git a/lib/common/services/database/entity/order_entity.g.dart b/lib/common/services/database/entity/order_entity.g.dart index f61c250..63cbbca 100644 --- a/lib/common/services/database/entity/order_entity.g.dart +++ b/lib/common/services/database/entity/order_entity.g.dart @@ -92,4 +92,5 @@ const _$OrderPayTypeEnumMap = { OrderPayType.ALI_SELF_QR_CODE_PAY: 'ALI_SELF_QR_CODE_PAY', OrderPayType.ZYY: 'ZYY', OrderPayType.RMYY: 'RMYY', + OrderPayType.CSXFK: 'CSXFK', }; diff --git a/lib/common/utils/sync/sync_product_tool.dart b/lib/common/utils/sync/sync_product_tool.dart index 1861bd6..6f5d4bb 100644 --- a/lib/common/utils/sync/sync_product_tool.dart +++ b/lib/common/utils/sync/sync_product_tool.dart @@ -176,7 +176,7 @@ abstract class SyncProductTool { static Future syncSupermarket() async { final stopwatch = Stopwatch()..start(); EasyLoading.show( - status: '原创同步数据中...', + status: '远程同步数据中...', maskType: EasyLoadingMaskType.black, ); try { diff --git a/lib/common/values/constants.dart b/lib/common/values/constants.dart index c55bdf6..ea4099a 100644 --- a/lib/common/values/constants.dart +++ b/lib/common/values/constants.dart @@ -10,9 +10,9 @@ class Constants { static const pwdEncKey = 'pigxpigxpigxpigx'; /// 服务 url - static const apiUrl = 'https://stgl.pj.gov.cn/api'; + // static const apiUrl = 'https://stgl.pj.gov.cn/api'; - // static const apiUrl = 'http://192.168.101.174:9999'; + static const apiUrl = 'http://192.168.101.185: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 index 175d762..f495ebb 100644 --- a/lib/common/widgets/app/app_wallet_selector.dart +++ b/lib/common/widgets/app/app_wallet_selector.dart @@ -16,7 +16,11 @@ Widget AppWalletSelector( if (ObjectUtil.isEmpty(list)) { return const SizedBox(); } - final currentSelector = selector ?? list[0]; + ServiceWallet? currentSelector = selector; + if (currentSelector == null) { + currentSelector = list[0]; + onChange(currentSelector); + } final theme = FTheme.of(context); return list .map((v) { @@ -29,7 +33,7 @@ Widget AppWalletSelector( "未知钱包"; // 是否选中 final isSelect = - v.walletTypeUniqueCode == currentSelector.walletTypeUniqueCode; + v.walletTypeUniqueCode == currentSelector!.walletTypeUniqueCode; return [ FIcon( diff --git a/lib/common/widgets/order/mixin/order_mixin.dart b/lib/common/widgets/order/mixin/order_mixin.dart index 4ae9f7b..98bb68c 100644 --- a/lib/common/widgets/order/mixin/order_mixin.dart +++ b/lib/common/widgets/order/mixin/order_mixin.dart @@ -315,8 +315,14 @@ mixin OrderMixin { "list": shopList, }; if (orderPayType.value != null && - orderPayType.value == OrderPayType.WALLET_QR_CODE) { + appSetting.sysType == SysType.CANTEEN && + (orderPayType.value == OrderPayType.WALLET_QR_CODE)) { pa["walletId"] = globalQrCode?.id; + } else if (OrderPayDisplayType.isSelectWalletPayType( + orderPayDisplayType.value!)) { + if (payUser.value?.walletId != null) { + pa["walletId"] = payUser.value?.walletId; + } } logger.i("|$_tag|创建api订单,下单参数:|${json.encode(pa)}|"); try { diff --git a/lib/common/widgets/order/select_pay_type_dialog.dart b/lib/common/widgets/order/select_pay_type_dialog.dart index 0b84644..afd6e46 100644 --- a/lib/common/widgets/order/select_pay_type_dialog.dart +++ b/lib/common/widgets/order/select_pay_type_dialog.dart @@ -4,6 +4,7 @@ import 'dart:convert'; import 'package:common_utils/common_utils.dart'; import 'package:ducafe_ui_core/ducafe_ui_core.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_subscreen_plugin/flutter_subscreen_plugin.dart'; import 'package:forui/forui.dart'; @@ -93,6 +94,8 @@ class SelectPayTypeDialogController extends GetxController { orderPayType.value = OrderPayType.ZYY; } else if (payType == OrderPayDisplayType.rmyy) { orderPayType.value = OrderPayType.RMYY; + } else if (payType == OrderPayDisplayType.csxfk) { + orderPayType.value = OrderPayType.CSXFK; } } else if (payUser.value != null) { if (AppUserTool.isGenerateExternalUser(payUser.value!)) { @@ -134,6 +137,7 @@ class SelectPayTypeDialogController extends GetxController { _closeStatus() { payUser.value = null; + userWalletList.value = []; isRecognition.value = false; globalQrCode = null; _faceCallbackLock = false; @@ -251,6 +255,7 @@ class SelectPayTypeDialogController extends GetxController { if (payUser.value != null) { await SyncUserTool.storageUser(user: payUser.value!); } + await _getWalletList(); logger.i("|$_tag|二维码识别|有网络|,用户信息:|${payUser.toJson()}|"); } else { if (ObjectUtil.isNotEmpty(serviceCode.extra)) { @@ -324,6 +329,7 @@ class SelectPayTypeDialogController extends GetxController { isRecognition.value = false; orderPayType.value = OrderPayType.WALLET_CARD; orderType = OrderType.BELOW; + await _getWalletList(); onDiscernUser?.call(payUser.value); break; case SerialCardResStatus.warning: @@ -399,18 +405,6 @@ class SelectPayTypeDialogController extends GetxController { } } - // ************************************************************************** - // 线下支付 start - // ************************************************************************** - Future _dispatchWalletScanCode() async { - orderPayType.value = OrderPayType.CASH; - orderType = OrderType.BELOW; - onDiscernUser?.call(payUser.value); - } - // ************************************************************************** - // 线下支付 end - // ************************************************************************** - // android人脸识别成功回调 Future _faceDiscernAfter(FaceStream event) async { try { @@ -490,6 +484,21 @@ class SelectPayTypeDialogController extends GetxController { return success.contains(type); } + /// 选择钱包 + void appSelectorChange(ServiceWallet wallet) { + currentWallet.value = wallet; + // 设置payUser + if (payUser.value == null) return; + SchedulerBinding.instance.addPostFrameCallback((_) { + payUser.value?.walletId = wallet.id; + payUser.value?.walletTypeId = wallet.walletTypeId; + payUser.value?.walletBalance = wallet.balance; + payUser.value?.walletCardNumber = wallet.cardNumber; + payUser.value?.walletIsFreeze = wallet.isFreeze; + payUser.refresh(); + }); + } + /// 获取用户钱包列表 Future _getWalletList() async { // 如果选择了需要选择钱包的支付方式 @@ -578,17 +587,7 @@ Future selectPayTypeDialog() async { 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; - }, + onChange: (wallet) => payTypeC.appSelectorChange(wallet), ).width(double.infinity).height(200.h).offstage( offstage: !(payTypeC.appSetting.sysType == SysType.SUPERMARKET && @@ -761,6 +760,10 @@ Widget selectPayTypeHint( msg = "人民医院支付,请点击支付按钮"; icon = FAssets.icons.circleDollarSign; break; + case OrderPayDisplayType.csxfk: + msg = "超市消费卡支付,请点击支付按钮"; + icon = FAssets.icons.circleDollarSign; + break; } return appEmpty( context, diff --git a/lib/common/widgets/order/steelyard_container.dart b/lib/common/widgets/order/steelyard_container.dart index 9b120e8..a89d1d1 100644 --- a/lib/common/widgets/order/steelyard_container.dart +++ b/lib/common/widgets/order/steelyard_container.dart @@ -154,7 +154,7 @@ class SteelyardController extends GetxController { widget.value = callbackWidget.value; // 获取价格 final productPrice = _getProudctPrice(_product!); - final p = (callbackWidget.value * productPrice).ceil(); + final p = (callbackWidget.value * productPrice).truncate().ceil(); price.value = p; logger.i( "|$_tag|重量|${widget.value}|单价|$productPrice|总价|${price.value}|", diff --git a/lib/pages/supermarket_order/controller.dart b/lib/pages/supermarket_order/controller.dart index 3b445aa..e12fe00 100644 --- a/lib/pages/supermarket_order/controller.dart +++ b/lib/pages/supermarket_order/controller.dart @@ -444,6 +444,10 @@ class SupermarketOrderController extends GetxController with OrderMixin { // 校验支付用户 bool _validatePayUser() { bool flag = true; + if (orderPayDisplayType.value == null) return false; + final isOffline = OrderPayDisplayType.isOffline(orderPayDisplayType.value!); + if (isOffline) return true; + if (ObjectUtil.isEmpty(payUser.value?.walletBalance)) { TtsManage.speak("用户钱包不存在"); Toast.error(msg: "校验购物车失败,用户钱包不存在");