feat:离线支持
This commit is contained in:
1 parent
12597ba258
commit
0af163738f
15 files changed
+89
-112
No files matched your search
@@ -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;
|
||||
|
||||
@@ -100,6 +100,9 @@ class SysSetting extends Equatable {
|
||||
// 默认支付方式
|
||||
OrderPayDisplayType? defaultPayDisplayType;
|
||||
|
||||
// 租户列表
|
||||
List<ServiceTenant>? 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<String, dynamic> json) =>
|
||||
@@ -149,6 +153,7 @@ class SysSetting extends Equatable {
|
||||
globalFontSize,
|
||||
usePayDisplayType,
|
||||
defaultPayDisplayType,
|
||||
tenantList,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ SysSetting _$SysSettingFromJson(Map<String, dynamic> json) => SysSetting(
|
||||
sqlAddress: json['sqlAddress'] as String?,
|
||||
logAddress: json['logAddress'] as String?,
|
||||
hardGroupId: json['hardGroupId'] as String?,
|
||||
tenantList: (json['tenantList'] as List<dynamic>?)
|
||||
?.map((e) => ServiceTenant.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
)
|
||||
..serviceName = json['serviceName'] as String?
|
||||
..serviceMerchantId = json['serviceMerchantId'] as String?
|
||||
@@ -100,6 +103,7 @@ Map<String, dynamic> _$SysSettingToJson(SysSetting instance) =>
|
||||
.toList(),
|
||||
'defaultPayDisplayType':
|
||||
_$OrderPayDisplayTypeEnumMap[instance.defaultPayDisplayType],
|
||||
'tenantList': instance.tenantList,
|
||||
};
|
||||
|
||||
const _$SysTypeEnumMap = {
|
||||
|
||||
@@ -12,33 +12,23 @@ abstract class CanteenSpuDao {
|
||||
@insert
|
||||
Future<void> batchSave(List<CanteenSpuEntity> entitys);
|
||||
|
||||
Future<int> delByIds(List<String> codes) async {
|
||||
if (ObjectUtil.isEmptyList(codes)) return -1;
|
||||
final app = Get.find<AppControl>();
|
||||
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<void> delAllByType();
|
||||
|
||||
@Query('''
|
||||
DELETE FROM canteen_spu WHERE strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', :dayStr)
|
||||
''')
|
||||
Future<void> delAllByDay(String dayStr);
|
||||
|
||||
@delete
|
||||
Future<void> batchDel(List<CanteenSpuEntity> 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<void> 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<int?> 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<List<CanteenSpuEntity>> getDefault(String hourType);
|
||||
}
|
||||
@@ -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<void> 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<void> 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<int?> 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<String, Object?> 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<String, Object?> 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<String, Object?> 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<String, Object?> 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<String, Object?> 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<String, Object?> 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<String, Object?> 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<List<CanteenSpuEntity>> 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<String, Object?> 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<String, Object?> 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]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String, dynamic> json) =>
|
||||
|
||||
@@ -21,7 +21,6 @@ CanteenSpuEntity _$CanteenSpuEntityFromJson(Map<String, dynamic> 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<String, dynamic> _$CanteenSpuEntityToJson(CanteenSpuEntity instance) =>
|
||||
@@ -39,7 +38,6 @@ Map<String, dynamic> _$CanteenSpuEntityToJson(CanteenSpuEntity instance) =>
|
||||
'sort': instance.sort,
|
||||
'createTime': instance.createTime.toIso8601String(),
|
||||
'updateTime': instance.updateTime.toIso8601String(),
|
||||
'delFlag': instance.delFlag,
|
||||
};
|
||||
|
||||
const _$ProductHourTypeEnumMap = {
|
||||
|
||||
@@ -67,6 +67,8 @@ abstract class AppFaceTool {
|
||||
|
||||
// 是否激活人脸sdk
|
||||
static Future<bool> 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();
|
||||
|
||||
@@ -47,6 +47,12 @@ abstract class SyncOrderTool {
|
||||
List<Map<String, dynamic>> uploadList = [];
|
||||
for (final OrderEntity v in list) {
|
||||
Map<String, dynamic> 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)) {
|
||||
|
||||
@@ -251,44 +251,21 @@ abstract class SyncProductTool {
|
||||
final app = Get.find<AppControl>();
|
||||
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<void> _batchAddOrUpdateCaneenProduct({
|
||||
required List<ServiceProduct> list,
|
||||
required bool isUpdate,
|
||||
required List<CanteenSpuEntity> productList,
|
||||
}) async {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
final app = Get.find<AppControl>();
|
||||
@@ -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<ServiceProduct> _filterCaneenProductListByCodes(
|
||||
List<ServiceProduct> sourceList,
|
||||
List<String> codes,
|
||||
) {
|
||||
return sourceList
|
||||
.where((item) => codes.contains(item.spuId.toString()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// 同步食堂商品 spu end
|
||||
// **************************************************************************
|
||||
|
||||
@@ -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<int?> createSqlOrder() async {
|
||||
final orderSourceTypeId = getOrderSourceTypeId();
|
||||
try {
|
||||
final isNetwork = appC.isNetwork.value;
|
||||
final isNetwork = AppNetworkTool.isAutoNetwork();
|
||||
final order = OrderEntity(
|
||||
uniqueCode: await _getUniqueCode(),
|
||||
serviceUniqueCode: '001',
|
||||
|
||||
@@ -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!);
|
||||
|
||||
@@ -281,7 +281,7 @@ class CanteenProductController extends GetxController with OrderMixin {
|
||||
|
||||
// 获取默认商品
|
||||
Future<void> _getDefaultProduct() async {
|
||||
final sysType = appSetting.sysType.name;
|
||||
final sysType = appSetting.hourType?.code ?? ProductHourType.MORNING.code;
|
||||
final productDao = appC.dataBase.getCanteenSpuDao;
|
||||
List<CanteenSpuEntity> list = await productDao.getDefault(sysType);
|
||||
if (ObjectUtil.isEmptyList(list)) return;
|
||||
|
||||
@@ -31,6 +31,7 @@ class CanteenProductPage extends GetView<CanteenProductController> {
|
||||
),
|
||||
).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<CanteenProductController> {
|
||||
),
|
||||
borderRadius: theme.style.borderRadius,
|
||||
),
|
||||
SizedBox(width: 15.w),
|
||||
].toRow().marginOnly(bottom: 20.h);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<void> getTenantList() async {
|
||||
try {
|
||||
final list = await UserApi.getTenantList();
|
||||
final isNetwork = AppNetworkTool.isAutoNetwork();
|
||||
List<ServiceTenant>? 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|");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user