diff --git a/android/app/src/main/java/io/flutter/plugins/facediscern/flutter/FlutterTool.java b/android/app/src/main/java/io/flutter/plugins/facediscern/flutter/FlutterTool.java index a1e4f96..534fc99 100644 --- a/android/app/src/main/java/io/flutter/plugins/facediscern/flutter/FlutterTool.java +++ b/android/app/src/main/java/io/flutter/plugins/facediscern/flutter/FlutterTool.java @@ -240,7 +240,7 @@ public class FlutterTool { Log.e(TAG, "registerFaceByDatabase,方法错误,file读取错误error:" + e.getMessage() + "json:" + new Gson().toJson(v), e); continue; } - if (bytes == null) { + if (bytes == null || bytes.length == 0) { errorSampleIdList.add(v.getSampleId()); Log.e(TAG, "registerFaceByDatabase,方法错误" + v.getUserName() + "bytes is null," + "json:" + new Gson().toJson(v)); continue; diff --git a/lib/common/models/database/database_models.dart b/lib/common/models/database/database_models.dart index 4908bcc..f2bd1d3 100644 --- a/lib/common/models/database/database_models.dart +++ b/lib/common/models/database/database_models.dart @@ -100,6 +100,9 @@ class SysSetting extends Equatable { // 默认支付方式 OrderPayDisplayType? defaultPayDisplayType; + // 租户列表 + List? tenantList; + SysSetting({ required this.sysType, this.androidId, @@ -109,6 +112,7 @@ class SysSetting extends Equatable { this.sqlAddress, this.logAddress, this.hardGroupId, + this.tenantList, }); factory SysSetting.fromJson(Map json) => @@ -149,6 +153,7 @@ class SysSetting extends Equatable { globalFontSize, usePayDisplayType, defaultPayDisplayType, + tenantList, ]; } diff --git a/lib/common/models/database/database_models.g.dart b/lib/common/models/database/database_models.g.dart index df44938..756dd66 100644 --- a/lib/common/models/database/database_models.g.dart +++ b/lib/common/models/database/database_models.g.dart @@ -15,6 +15,9 @@ SysSetting _$SysSettingFromJson(Map json) => SysSetting( sqlAddress: json['sqlAddress'] as String?, logAddress: json['logAddress'] as String?, hardGroupId: json['hardGroupId'] as String?, + tenantList: (json['tenantList'] as List?) + ?.map((e) => ServiceTenant.fromJson(e as Map)) + .toList(), ) ..serviceName = json['serviceName'] as String? ..serviceMerchantId = json['serviceMerchantId'] as String? @@ -100,6 +103,7 @@ Map _$SysSettingToJson(SysSetting instance) => .toList(), 'defaultPayDisplayType': _$OrderPayDisplayTypeEnumMap[instance.defaultPayDisplayType], + 'tenantList': instance.tenantList, }; const _$SysTypeEnumMap = { diff --git a/lib/common/services/database/dao/canteen_spu_dao.dart b/lib/common/services/database/dao/canteen_spu_dao.dart index c9eee36..6eae38a 100644 --- a/lib/common/services/database/dao/canteen_spu_dao.dart +++ b/lib/common/services/database/dao/canteen_spu_dao.dart @@ -12,33 +12,23 @@ abstract class CanteenSpuDao { @insert Future batchSave(List entitys); - Future delByIds(List codes) async { - if (ObjectUtil.isEmptyList(codes)) return -1; - final app = Get.find(); - final database = app.dataBase.database; - final placeholders = List.generate(codes.length, (index) => '?').join(', '); - final sql = ''' - UPDATE canteen_spu SET delFlag = 1 - WHERE - serviceUniqueCode IN ($placeholders) - AND strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime') - '''; - return await database.rawUpdate(sql, [...codes]); - } - @Query(''' DELETE FROM canteen_spu ''') Future delAllByType(); + @Query(''' + DELETE FROM canteen_spu WHERE strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', :dayStr) + ''') + Future delAllByDay(String dayStr); + @delete Future batchDel(List entitys); @Query(""" UPDATE canteen_spu SET isDefault = :isDefault WHERE - delFlag = 0 - AND serviceUniqueCode = :uniqueCode AND hourType = :hourType + serviceUniqueCode = :uniqueCode AND hourType = :hourType AND strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime') """) Future edit(bool isDefault, String uniqueCode, String hourType); @@ -49,8 +39,7 @@ abstract class CanteenSpuDao { @Query(""" SELECT DISTINCT COUNT(0) FROM canteen_spu WHERE - delFlag = 0 - AND (:hourType = '-1' OR INSTR(',' || hourType || ',', ',' || :hourType || ',') > 0) + (:hourType = '-1' OR INSTR(',' || hourType || ',', ',' || :hourType || ',') > 0) AND strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime') """) Future getCount(String hourType); @@ -58,8 +47,7 @@ abstract class CanteenSpuDao { @Query(''' SELECT * FROM canteen_spu WHERE - delFlag = 0 - AND serviceUniqueCode = :code + serviceUniqueCode = :code AND (:saleDate = '-1' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', :saleDate)) LIMIT 1 ''') @@ -73,8 +61,7 @@ abstract class CanteenSpuDao { FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE - canteen_spu.delFlag = 0 - AND (:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode) + (:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND (:hourType = '-1' OR INSTR(',' || hourType || ',', ',' || :hourType || ',') > 0) AND (:saleDate = '-1' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', :saleDate)) ORDER BY classify.sort, canteen_spu.price @@ -90,8 +77,7 @@ abstract class CanteenSpuDao { FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE - canteen_spu.delFlag = 0 - AND (:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode) + (:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND (:hourType = '-1' OR INSTR(',' || canteen_spu.hourType || ',', ',' || :hourType || ',') > 0) AND strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime') ORDER BY classify.sort, classify.id, canteen_spu.price @@ -107,10 +93,8 @@ abstract class CanteenSpuDao { @Query(''' SELECT * FROM canteen_spu WHERE - delFlag = 0 - AND isDefault = 1 + isDefault = 1 AND (:hourType = '-1' OR hourType = :hourType) - AND strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime') ''') Future> getDefault(String hourType); } diff --git a/lib/common/services/database/database.g.dart b/lib/common/services/database/database.g.dart index d73f4dc..ec5f988 100644 --- a/lib/common/services/database/database.g.dart +++ b/lib/common/services/database/database.g.dart @@ -122,7 +122,7 @@ class _$AppDatabase extends AppDatabase { await database.execute( 'CREATE TABLE IF NOT EXISTS `order_record` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `uniqueCode` TEXT NOT NULL, `serviceUniqueCode` TEXT NOT NULL, `sysType` TEXT NOT NULL, `userCode` TEXT NOT NULL, `username` TEXT, `hourType` TEXT, `price` INTEGER NOT NULL, `extraPrice` INTEGER NOT NULL, `payPrice` INTEGER NOT NULL, `walletId` TEXT, `orderSourceTypeId` TEXT, `type` TEXT NOT NULL, `status` TEXT NOT NULL, `payType` TEXT NOT NULL, `productDesc` TEXT, `count` INTEGER NOT NULL, `weight` REAL NOT NULL, `payTime` TEXT, `createTime` TEXT NOT NULL)'); await database.execute( - 'CREATE TABLE IF NOT EXISTS `canteen_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `hourType` INTEGER, `saleDate` TEXT NOT NULL, `name` TEXT NOT NULL, `price` INTEGER NOT NULL, `image` TEXT, `isDefault` INTEGER NOT NULL, `status` INTEGER NOT NULL, `sort` INTEGER NOT NULL, `createTime` TEXT NOT NULL, `updateTime` TEXT NOT NULL, `delFlag` INTEGER NOT NULL)'); + 'CREATE TABLE IF NOT EXISTS `canteen_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `hourType` INTEGER, `saleDate` TEXT NOT NULL, `name` TEXT NOT NULL, `price` INTEGER NOT NULL, `image` TEXT, `isDefault` INTEGER NOT NULL, `status` INTEGER NOT NULL, `sort` INTEGER NOT NULL, `createTime` TEXT NOT NULL, `updateTime` TEXT NOT NULL)'); await database.execute( 'CREATE TABLE IF NOT EXISTS `supermarket_sku` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `spuId` TEXT NOT NULL, `barCode` TEXT NOT NULL, `spec` TEXT NOT NULL, `unit` TEXT NOT NULL, `packageNum` INTEGER NOT NULL, `purchasePrice` INTEGER NOT NULL, `retailPrice` INTEGER NOT NULL, `promotionPrice` INTEGER NOT NULL)'); await database.execute( @@ -613,8 +613,7 @@ class _$CanteenSpuDao extends CanteenSpuDao { 'status': item.status, 'sort': item.sort, 'createTime': _dateTimeConverter.encode(item.createTime), - 'updateTime': _dateTimeConverter.encode(item.updateTime), - 'delFlag': _boolConverter.encode(item.delFlag) + 'updateTime': _dateTimeConverter.encode(item.updateTime) }), _canteenSpuEntityUpdateAdapter = UpdateAdapter( database, @@ -633,8 +632,7 @@ class _$CanteenSpuDao extends CanteenSpuDao { 'status': item.status, 'sort': item.sort, 'createTime': _dateTimeConverter.encode(item.createTime), - 'updateTime': _dateTimeConverter.encode(item.updateTime), - 'delFlag': _boolConverter.encode(item.delFlag) + 'updateTime': _dateTimeConverter.encode(item.updateTime) }), _canteenSpuEntityDeletionAdapter = DeletionAdapter( database, @@ -653,8 +651,7 @@ class _$CanteenSpuDao extends CanteenSpuDao { 'status': item.status, 'sort': item.sort, 'createTime': _dateTimeConverter.encode(item.createTime), - 'updateTime': _dateTimeConverter.encode(item.updateTime), - 'delFlag': _boolConverter.encode(item.delFlag) + 'updateTime': _dateTimeConverter.encode(item.updateTime) }); final sqflite.DatabaseExecutor database; @@ -674,6 +671,13 @@ class _$CanteenSpuDao extends CanteenSpuDao { await _queryAdapter.queryNoReturn('DELETE FROM canteen_spu'); } + @override + Future delAllByDay(String dayStr) async { + await _queryAdapter.queryNoReturn( + 'DELETE FROM canteen_spu WHERE strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', ?1)', + arguments: [dayStr]); + } + @override Future edit( bool isDefault, @@ -681,14 +685,14 @@ class _$CanteenSpuDao extends CanteenSpuDao { String hourType, ) async { await _queryAdapter.queryNoReturn( - 'UPDATE canteen_spu SET isDefault = ?1 WHERE delFlag = 0 AND serviceUniqueCode = ?2 AND hourType = ?3 AND strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')', + 'UPDATE canteen_spu SET isDefault = ?1 WHERE serviceUniqueCode = ?2 AND hourType = ?3 AND strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')', arguments: [_boolConverter.encode(isDefault), uniqueCode, hourType]); } @override Future getCount(String hourType) async { return _queryAdapter.query( - 'SELECT DISTINCT COUNT(0) FROM canteen_spu WHERE delFlag = 0 AND (?1 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?1 || \',\') > 0) AND strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')', + 'SELECT DISTINCT COUNT(0) FROM canteen_spu WHERE (?1 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?1 || \',\') > 0) AND strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')', mapper: (Map row) => row.values.first as int, arguments: [hourType]); } @@ -699,8 +703,8 @@ class _$CanteenSpuDao extends CanteenSpuDao { String saleDate, ) async { return _queryAdapter.query( - 'SELECT * FROM canteen_spu WHERE delFlag = 0 AND serviceUniqueCode = ?1 AND (?2 = \'-1\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', ?2)) LIMIT 1', - mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), + 'SELECT * FROM canteen_spu WHERE serviceUniqueCode = ?1 AND (?2 = \'-1\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', ?2)) LIMIT 1', + mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String)), arguments: [code, saleDate]); } @@ -711,8 +715,8 @@ class _$CanteenSpuDao extends CanteenSpuDao { String saleDate, ) async { return _queryAdapter.queryList( - 'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE canteen_spu.delFlag = 0 AND (?1 = \'-1\' OR canteen_spu.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', ?3)) ORDER BY classify.sort, canteen_spu.price', - mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), + 'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE (?1 = \'-1\' OR canteen_spu.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', ?3)) ORDER BY classify.sort, canteen_spu.price', + mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String)), arguments: [classifyServiceUniqueCode, hourType, saleDate]); } @@ -724,16 +728,16 @@ class _$CanteenSpuDao extends CanteenSpuDao { int offset, ) async { return _queryAdapter.queryList( - 'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE canteen_spu.delFlag = 0 AND (?1 = \'-1\' OR canteen_spu.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || canteen_spu.hourType || \',\', \',\' || ?2 || \',\') > 0) AND strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\') ORDER BY classify.sort, classify.id, canteen_spu.price LIMIT ?3 OFFSET ?4', - mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), + 'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE (?1 = \'-1\' OR canteen_spu.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || canteen_spu.hourType || \',\', \',\' || ?2 || \',\') > 0) AND strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\') ORDER BY classify.sort, classify.id, canteen_spu.price LIMIT ?3 OFFSET ?4', + mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String)), arguments: [classifyServiceUniqueCode, hourType, pageSize, offset]); } @override Future> getDefault(String hourType) async { return _queryAdapter.queryList( - 'SELECT * FROM canteen_spu WHERE delFlag = 0 AND isDefault = 1 AND (?1 = \'-1\' OR hourType = ?1) AND strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')', - mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), + 'SELECT * FROM canteen_spu WHERE isDefault = 1 AND (?1 = \'-1\' OR hourType = ?1)', + mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String)), arguments: [hourType]); } diff --git a/lib/common/services/database/entity/canteen_spu_entity.dart b/lib/common/services/database/entity/canteen_spu_entity.dart index f07f3aa..7c2284d 100644 --- a/lib/common/services/database/entity/canteen_spu_entity.dart +++ b/lib/common/services/database/entity/canteen_spu_entity.dart @@ -49,9 +49,6 @@ class CanteenSpuEntity extends Equatable { /// 同步时间 DateTime updateTime; - /// 是否删除 - bool delFlag; - CanteenSpuEntity({ this.id, required this.serviceUniqueCode, @@ -66,7 +63,6 @@ class CanteenSpuEntity extends Equatable { required this.sort, required this.createTime, required this.updateTime, - required this.delFlag, }); factory CanteenSpuEntity.fromJson(Map json) => diff --git a/lib/common/services/database/entity/canteen_spu_entity.g.dart b/lib/common/services/database/entity/canteen_spu_entity.g.dart index ec13364..555df1c 100644 --- a/lib/common/services/database/entity/canteen_spu_entity.g.dart +++ b/lib/common/services/database/entity/canteen_spu_entity.g.dart @@ -21,7 +21,6 @@ CanteenSpuEntity _$CanteenSpuEntityFromJson(Map json) => sort: (json['sort'] as num).toInt(), createTime: DateTime.parse(json['createTime'] as String), updateTime: DateTime.parse(json['updateTime'] as String), - delFlag: json['delFlag'] as bool, ); Map _$CanteenSpuEntityToJson(CanteenSpuEntity instance) => @@ -39,7 +38,6 @@ Map _$CanteenSpuEntityToJson(CanteenSpuEntity instance) => 'sort': instance.sort, 'createTime': instance.createTime.toIso8601String(), 'updateTime': instance.updateTime.toIso8601String(), - 'delFlag': instance.delFlag, }; const _$ProductHourTypeEnumMap = { diff --git a/lib/common/utils/app/app_face_tool.dart b/lib/common/utils/app/app_face_tool.dart index 80960f4..12ca8fa 100644 --- a/lib/common/utils/app/app_face_tool.dart +++ b/lib/common/utils/app/app_face_tool.dart @@ -67,6 +67,8 @@ abstract class AppFaceTool { // 是否激活人脸sdk static Future isActiveSdk() async { + final isNetwork = AppNetworkTool.isAutoNetwork(); + if (!isNetwork) return true; var faceConfig = await FaceDiscernPlugs.getConfig(); if (faceConfig == null || faceConfig.isActive == false) { final sysSetting = await AppSettingTool.getSysSetting(); diff --git a/lib/common/utils/sync/sync_order_tool.dart b/lib/common/utils/sync/sync_order_tool.dart index 1465431..95e7496 100644 --- a/lib/common/utils/sync/sync_order_tool.dart +++ b/lib/common/utils/sync/sync_order_tool.dart @@ -47,6 +47,12 @@ abstract class SyncOrderTool { List> uploadList = []; for (final OrderEntity v in list) { Map item = v.toJson(); + if (ObjectUtil.isNotEmpty(v.createTime)) { + item["createTime"] = DateUtil.formatDate(v.createTime); + } + if (ObjectUtil.isNotEmpty(v.payTime)) { + item["payTime"] = DateUtil.formatDate(v.payTime!); + } if (v.id != null) { final carList = await shopCardDao.findByOrderId(v.id!); if (!ObjectUtil.isEmptyList(carList)) { diff --git a/lib/common/utils/sync/sync_product_tool.dart b/lib/common/utils/sync/sync_product_tool.dart index 7e341f7..fb0b834 100644 --- a/lib/common/utils/sync/sync_product_tool.dart +++ b/lib/common/utils/sync/sync_product_tool.dart @@ -251,44 +251,21 @@ abstract class SyncProductTool { final app = Get.find(); final dataBase = app.dataBase; final productDao = dataBase.getCanteenSpuDao; + // 查询当天全部数据 final productList = await productDao.getAll( "-1", "-1", dayStr, ); - if (ObjectUtil.isEmpty(productList)) { - await _batchAddOrUpdateCaneenProduct( - list: list, - isUpdate: false, - ); - return; - } - final apiServiceCodes = list.map((e) => e.spuId.toString()).toSet(); - final dbServiceCodes = productList.map((e) => e.serviceUniqueCode).toSet(); - - final addCodes = apiServiceCodes.difference(dbServiceCodes).toList(); - final deleteCodes = dbServiceCodes.difference(apiServiceCodes).toList(); - final updateCodes = apiServiceCodes.intersection(dbServiceCodes).toList(); - if (ObjectUtil.isNotEmpty(addCodes)) { - await _batchAddOrUpdateCaneenProduct( - list: _filterCaneenProductListByCodes(list, addCodes), - isUpdate: false, - ); - } - if (ObjectUtil.isNotEmpty(deleteCodes)) { - await productDao.delByIds(deleteCodes); - } - if (ObjectUtil.isNotEmpty(updateCodes)) { - await _batchAddOrUpdateCaneenProduct( - list: _filterCaneenProductListByCodes(list, updateCodes), - isUpdate: true, - ); - } + // 删除当天全部数据 + await productDao.delAllByDay(dayStr); + // 插入 + await _batchAddOrUpdateCaneenProduct(list: list, productList: productList); } static Future _batchAddOrUpdateCaneenProduct({ required List list, - required bool isUpdate, + required List productList, }) async { if (ObjectUtil.isEmpty(list)) return; final app = Get.find(); @@ -310,36 +287,22 @@ abstract class SyncProductTool { hourType: ProductHourType.values.fromCode(v.hourType), saleDate: v.saleDate ?? DateTime.now(), isDefault: false, - delFlag: false, ); - if (isUpdate) { - final saleDateStr = DateUtil.formatDate(item.saleDate); - final detail = await productDao.getByCode( - item.serviceUniqueCode, - saleDateStr, - ); - if (ObjectUtil.isEmpty(detail)) continue; - if (detail == item) continue; - item.id = detail?.id; + if (!ObjectUtil.isEmptyList(productList)) { + final targetProduct = productList.firstWhereOrNull((i) => + i.serviceUniqueCode == item.serviceUniqueCode && + i.isDefault == true); + if (targetProduct != null) { + item.isDefault = true; + } } changeList.add(item); } if (ObjectUtil.isNotEmpty(changeList)) { - isUpdate - ? await productDao.batchEdit(changeList) - : await productDao.batchSave(changeList); + await productDao.batchSave(changeList); } } - static List _filterCaneenProductListByCodes( - List sourceList, - List codes, - ) { - return sourceList - .where((item) => codes.contains(item.spuId.toString())) - .toList(); - } - // ************************************************************************** // 同步食堂商品 spu end // ************************************************************************** diff --git a/lib/common/widgets/order/mixin/order_mixin.dart b/lib/common/widgets/order/mixin/order_mixin.dart index c4829b3..af038c7 100644 --- a/lib/common/widgets/order/mixin/order_mixin.dart +++ b/lib/common/widgets/order/mixin/order_mixin.dart @@ -146,7 +146,7 @@ mixin OrderMixin { final list = await appC.dataBase.getCanteenSpuDao.getAll( classifyCode, hourType.value.code, - "2025-05-08 11:40:08", + saleDateStr, ); canteenSpuList.value = list; canteenSpuList.refresh(); @@ -158,7 +158,7 @@ mixin OrderMixin { Future createSqlOrder() async { final orderSourceTypeId = getOrderSourceTypeId(); try { - final isNetwork = appC.isNetwork.value; + final isNetwork = AppNetworkTool.isAutoNetwork(); final order = OrderEntity( uniqueCode: await _getUniqueCode(), serviceUniqueCode: '001', diff --git a/lib/common/widgets/order/select_pay_type_dialog.dart b/lib/common/widgets/order/select_pay_type_dialog.dart index fe090a2..071dc4f 100644 --- a/lib/common/widgets/order/select_pay_type_dialog.dart +++ b/lib/common/widgets/order/select_pay_type_dialog.dart @@ -258,7 +258,6 @@ class SelectPayTypeDialogController extends GetxController { switch (status) { case SerialCardResStatus.success: if (ObjectUtil.isEmpty(card)) return; - TtsManage.speak("识别饭卡成功"); final isNetwork = AppNetworkTool.isAutoNetwork(); if (isNetwork) { final pa = {"card": card}; @@ -274,12 +273,16 @@ class SelectPayTypeDialogController extends GetxController { if (payUser.value != null) { await SyncUserTool.storageUser(user: payUser.value!); } + TtsManage.speak("识别饭卡成功"); } else { final user = await SyncUserTool.storageUserByCarNumber(card); - if (user == null && - ObjectUtil.isNotEmpty(user?.walletCardNumber)) { + if (user == null || + ObjectUtil.isNotEmpty(user.walletCardNumber)) { logger.e("|$_tag|,饭卡识别,离线获取本地用户失败"); - Toast.error(msg: "查询不到此用户"); + Toast.error(msg: "离线模式下查询不到此用户"); + TtsManage.speak("离线模式下查询不到此用户"); + app.serialCardManage.close(); + isRecognition.value = false; return; } payUser.value = SyncUserTool.parsePayUser(user: user!); diff --git a/lib/pages/canteen_product/controller.dart b/lib/pages/canteen_product/controller.dart index 430223b..ae37f81 100644 --- a/lib/pages/canteen_product/controller.dart +++ b/lib/pages/canteen_product/controller.dart @@ -281,7 +281,7 @@ class CanteenProductController extends GetxController with OrderMixin { // 获取默认商品 Future _getDefaultProduct() async { - final sysType = appSetting.sysType.name; + final sysType = appSetting.hourType?.code ?? ProductHourType.MORNING.code; final productDao = appC.dataBase.getCanteenSpuDao; List list = await productDao.getDefault(sysType); if (ObjectUtil.isEmptyList(list)) return; diff --git a/lib/pages/canteen_product/view.dart b/lib/pages/canteen_product/view.dart index f562b24..79fda21 100644 --- a/lib/pages/canteen_product/view.dart +++ b/lib/pages/canteen_product/view.dart @@ -31,6 +31,7 @@ class CanteenProductPage extends GetView { ), ).scrollable(scrollDirection: Axis.horizontal).expanded(), appRadioHourTypeDialog(context, controller.hourTypeC).width(300.w), + SizedBox(width: 15.w), ].toRow().decorated( color: theme.colorScheme.background, boxShadow: [ @@ -232,6 +233,7 @@ class CanteenProductPage extends GetView { ), borderRadius: theme.style.borderRadius, ), + SizedBox(width: 15.w), ].toRow().marginOnly(bottom: 20.h); } diff --git a/lib/pages/login/controller.dart b/lib/pages/login/controller.dart index 73f144e..a6e70ae 100644 --- a/lib/pages/login/controller.dart +++ b/lib/pages/login/controller.dart @@ -89,7 +89,7 @@ class LoginController extends GetxController { userSetting.sysType = sysSetting.sysType; userSetting.username = usernameC.value.text; userSetting.password = passwordC.value.text; - userSetting.tenantId = currentTenant.id; + userSetting.tenantId = currentTenant.code; await AppSettingTool.setUserSetting(userSetting); await TtsManage.speak("登录成功"); if (visibleMsg) { @@ -146,16 +146,26 @@ class LoginController extends GetxController { Future getTenantList() async { try { - final list = await UserApi.getTenantList(); + final isNetwork = AppNetworkTool.isAutoNetwork(); + List? list = []; + if (isNetwork) { + list = await UserApi.getTenantList(); + } else { + sysSetting = await AppSettingTool.getSysSetting(); + list = sysSetting.tenantList; + } if (list == null) return; tenantList.value = list; if (ObjectUtil.isNotEmpty(userSetting.tenantId)) { - tenantC.value = {list.first.code!}; + tenantC.value = {userSetting.tenantId!}; } else { if (!ObjectUtil.isEmptyList(list)) { tenantC.value = {list.first.code!}; } } + // 存储租户列表 + sysSetting.tenantList = list; + await AppSettingTool.setSysSetting(sysSetting); } catch (e) { logger.e("|$_tag|获取租户列表错误error:|$e|"); }