feat:适配离线订单
This commit is contained in:
1 parent
48c1ee8cb2
commit
593aa39b78
4 files changed
+40
-13
No files matched your search
@@ -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为版本号(内部比较)
|
||||
```
|
||||
@@ -33,6 +33,7 @@ const typeConverters = <Type>[
|
||||
OrderPayTypeConverter,
|
||||
SysTypeConverter,
|
||||
PrintStatusConverter,
|
||||
ProductHourTypeConverter,
|
||||
SupermarketNatureConverter,
|
||||
DiscountsTypeConverter,
|
||||
ListDiscountsConverter,
|
||||
|
||||
@@ -7,6 +7,14 @@ class DiscountsTool {
|
||||
static Future<List<DiscountsItem>?> updateUserDiscountsList({
|
||||
required String userId,
|
||||
}) async {
|
||||
final app = Get.find<AppControl>();
|
||||
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<AppControl>();
|
||||
final userDao = app.dataBase.getUserDao;
|
||||
// 查询用户表
|
||||
final userEntity = await userDao.findByUserId(userId);
|
||||
if (ObjectUtil.isEmpty(userEntity)) return discountsRes;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user