diff --git a/README.md b/README.md index 7931564..f3fa73a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ flutter pub run build_runner build --delete-conflicting-outputs~ ``` ## flutter打包 ``` -flutter build apk --build-name 1.1.0 --build-number 110 +flutter build apk --build-name 1.3.0 --build-number 130 --build-name为版本号(展示) --build-number为版本号(内部比较) ``` \ No newline at end of file diff --git a/lib/common/services/database/database.dart b/lib/common/services/database/database.dart index 873f9b6..87c5f8b 100644 --- a/lib/common/services/database/database.dart +++ b/lib/common/services/database/database.dart @@ -33,6 +33,7 @@ const typeConverters = [ OrderPayTypeConverter, SysTypeConverter, PrintStatusConverter, + ProductHourTypeConverter, SupermarketNatureConverter, DiscountsTypeConverter, ListDiscountsConverter, diff --git a/lib/common/utils/discounts/discounts_tool.dart b/lib/common/utils/discounts/discounts_tool.dart index 364a8fe..62eea2e 100644 --- a/lib/common/utils/discounts/discounts_tool.dart +++ b/lib/common/utils/discounts/discounts_tool.dart @@ -7,6 +7,14 @@ class DiscountsTool { static Future?> updateUserDiscountsList({ required String userId, }) async { + final app = Get.find(); + final userDao = app.dataBase.getUserDao; + // 没有网络时, 不更新优惠列表 + if (!AppNetworkTool.isAutoNetwork()) { + final userEntity = await userDao.findByUserId(userId); + if (ObjectUtil.isEmpty(userEntity)) return null; + return userEntity?.discountsList ?? []; + } final sysSetting = await AppSettingTool.getSysSetting(); final params = { "userId": userId, @@ -14,8 +22,6 @@ class DiscountsTool { }; final discountsRes = await WalletApi.getDiscountsListByUserId(params); if (ObjectUtil.isEmpty(discountsRes)) return null; - final app = Get.find(); - final userDao = app.dataBase.getUserDao; // 查询用户表 final userEntity = await userDao.findByUserId(userId); if (ObjectUtil.isEmpty(userEntity)) return discountsRes; diff --git a/lib/common/utils/json/json_tool.dart b/lib/common/utils/json/json_tool.dart index eb62bf3..c3bb5fd 100644 --- a/lib/common/utils/json/json_tool.dart +++ b/lib/common/utils/json/json_tool.dart @@ -32,47 +32,67 @@ abstract class JsonTool { } static OrderType? stringToOrderType(String? value) { - return OrderType.values.fromCode(value); + final byCode = OrderType.values.fromCode(value); + if (byCode != null) return byCode; + if (value == null) return null; + final name = value.contains('.') ? value.split('.').last : value; + return OrderType.values.byName(name); } static String? orderTypeToString(OrderType? value) { if (value == null) return null; - return value.toString(); + return value.code; } static OrderPayType? stringToOrderPayType(String? value) { - return OrderPayType.values.fromCode(value); + final byCode = OrderPayType.values.fromCode(value); + if (byCode != null) return byCode; + if (value == null) return null; + final name = value.contains('.') ? value.split('.').last : value; + return OrderPayType.values.byName(name); } static String? orderPayTypeToString(OrderPayType? value) { if (value == null) return null; - return value.toString(); + return value.code; } static WalletActType? stringToWalletActType(String? value) { - return WalletActType.values.fromCode(value); + final byCode = WalletActType.values.fromCode(value); + if (byCode != null) return byCode; + if (value == null) return null; + final name = value.contains('.') ? value.split('.').last : value; + return WalletActType.values.byName(name); } static String? walletActTypeToString(WalletActType? value) { if (value == null) return null; - return value.toString(); + return value.code; } static DiscountsType? stringToDiscountsType(String? value) { - return DiscountsType.values.fromCode(value); + final byCode = DiscountsType.values.fromCode(value); + if (byCode != null) return byCode; + if (value == null) return null; + final name = value.contains('.') ? value.split('.').last : value; + return DiscountsType.values.byName(name); } static String? discountsTypeToString(DiscountsType? value) { if (value == null) return null; - return value.toString(); + return value.code; } static ProductHourType? stringToProductHourType(String? value) { - return ProductHourType.values.fromCode(value); + final byCode = ProductHourType.values.fromCode(value); + if (byCode != null) return byCode; + if (value == null) return null; + final name = value.contains('.') ? value.split('.').last : value; + return ProductHourType.values.byName(name); } static String? productHourTypeToString(ProductHourType? value) { if (value == null) return null; - return value.toString(); + return value.code; } }