feat:超市数据库

This commit is contained in:
dzc committed 2025-03-17 12:07:11 +08:00
1 parent 9a98ac8e1c
commit fa4bb78f8b
25 files changed
+307 -185

No files matched your search

+2 -2
View File
@@ -34,7 +34,7 @@ abstract class ProductApi {
dynamic pa, dynamic pa,
) async { ) async {
final res = await HttpManage().dio.get( final res = await HttpManage().dio.get(
"/supermarket-classify", "/supermarket/supermarketCategory/simpleAll",
queryParameters: pa, queryParameters: pa,
); );
if (res.data == null) return null; if (res.data == null) return null;
@@ -46,7 +46,7 @@ abstract class ProductApi {
/// 超市商品 /// 超市商品
static Future<List<ServiceProduct>?> supermarketProduct(dynamic pa) async { static Future<List<ServiceProduct>?> supermarketProduct(dynamic pa) async {
final res = await HttpManage().dio.get( final res = await HttpManage().dio.get(
"/supermarket-product", "supermarket/supermarketSpu/ad/selectListAll",
queryParameters: pa, queryParameters: pa,
); );
if (res.data == null) return null; if (res.data == null) return null;
@@ -7,10 +7,10 @@ import 'package:pj_supermarket_cloud/common/index.dart';
@dao @dao
abstract class ProductDao { abstract class ProductDao {
@insert @insert
Future<void> save(ProductEntity entity); Future<void> save(CanteenSpuEntity entity);
@insert @insert
Future<void> batchSave(List<ProductEntity> entitys); Future<void> batchSave(List<CanteenSpuEntity> entitys);
Future<int> delByIds(List<String> codes) async { Future<int> delByIds(List<String> codes) async {
if (ObjectUtil.isEmptyList(codes)) return -1; if (ObjectUtil.isEmptyList(codes)) return -1;
@@ -18,26 +18,22 @@ abstract class ProductDao {
final database = app.dataBase.database; final database = app.dataBase.database;
final placeholders = List.generate(codes.length, (index) => '?').join(', '); final placeholders = List.generate(codes.length, (index) => '?').join(', ');
final sql = ''' final sql = '''
UPDATE product SET delFlag = 1 WHERE serviceUniqueCode IN ($placeholders) UPDATE canteen_spu SET delFlag = 1 WHERE serviceUniqueCode IN ($placeholders)
AND (sysType = 'CANTEEN' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime')) AND (sysType = 'CANTEEN' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
'''; ''';
return await database.rawUpdate(sql, [...codes]); return await database.rawUpdate(sql, [...codes]);
} }
@Query(''' @Query('''
DELETE FROM product DELETE FROM canteen_spu
WHERE
(:sysType = '-1' OR sysType = :sysType)
''') ''')
Future<void> delAllByType( Future<void> delAllByType();
String sysType,
);
@delete @delete
Future<void> batchDel(List<ProductEntity> entitys); Future<void> batchDel(List<CanteenSpuEntity> entitys);
@Query(""" @Query("""
UPDATE product SET isDefault = :isDefault UPDATE canteen_spu SET isDefault = :isDefault
WHERE WHERE
delFlag = 0 delFlag = 0
AND serviceUniqueCode = :uniqueCode AND hourType = :hourType AND serviceUniqueCode = :uniqueCode AND hourType = :hourType
@@ -46,10 +42,10 @@ abstract class ProductDao {
Future<void> edit(bool isDefault, String uniqueCode, String hourType); Future<void> edit(bool isDefault, String uniqueCode, String hourType);
@update @update
Future<void> batchEdit(List<ProductEntity> entitys); Future<void> batchEdit(List<CanteenSpuEntity> entitys);
@Query(""" @Query("""
SELECT DISTINCT COUNT(0) FROM product SELECT DISTINCT COUNT(0) FROM canteen_spu
WHERE WHERE
delFlag = 0 delFlag = 0
AND (:sysType = '-1' OR sysType = :sysType) AND (:sysType = '-1' OR sysType = :sysType)
@@ -62,42 +58,42 @@ abstract class ProductDao {
); );
@Query(''' @Query('''
SELECT * FROM product WHERE delFlag = 0 AND serviceUniqueCode = :code SELECT * FROM canteen_spu WHERE delFlag = 0 AND serviceUniqueCode = :code
''') ''')
Future<ProductEntity?> getByCode(String code); Future<CanteenSpuEntity?> getByCode(String code);
@Query(''' @Query('''
SELECT product.* SELECT canteen_spu.*
FROM product FROM canteen_spu
LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode
WHERE WHERE
product.delFlag = 0 AND canteen_spu.delFlag = 0 AND
(:classifyServiceUniqueCode = '-1' OR product.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND (:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND
(:hourType = '-1' OR INSTR(',' || hourType || ',', ',' || :hourType || ',') > 0) AND (:hourType = '-1' OR INSTR(',' || hourType || ',', ',' || :hourType || ',') > 0) AND
(:sysType = '-1' OR product.sysType = :sysType) (:sysType = '-1' OR canteen_spu.sysType = :sysType)
ORDER BY classify.sort, product.price ORDER BY classify.sort, canteen_spu.price
''') ''')
Future<List<ProductEntity>> getAll( Future<List<CanteenSpuEntity>> getAll(
String classifyServiceUniqueCode, String classifyServiceUniqueCode,
String hourType, String hourType,
String sysType, String sysType,
); );
// GROUP BY product.serviceUniqueCode // GROUP BY canteen_spu.serviceUniqueCode
@Query(''' @Query('''
SELECT product.* SELECT canteen_spu.*
FROM product FROM canteen_spu
LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode
WHERE WHERE
product.delFlag = 0 AND canteen_spu.delFlag = 0 AND
(:classifyServiceUniqueCode = '-1' OR product.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND (:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND
(:hourType = '-1' OR INSTR(',' || product.hourType || ',', ',' || :hourType || ',') > 0) AND (:hourType = '-1' OR INSTR(',' || canteen_spu.hourType || ',', ',' || :hourType || ',') > 0) AND
(:sysType = '-1' OR product.sysType = :sysType) AND (:sysType = '-1' OR canteen_spu.sysType = :sysType) AND
(:sysType = 'CANTEEN' OR strftime('%Y-%m-%d', product.saleDate) = strftime('%Y-%m-%d', 'now', 'localtime')) (:sysType = 'CANTEEN' OR strftime('%Y-%m-%d', canteen_spu.saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
ORDER BY classify.sort, classify.id, product.price ORDER BY classify.sort, classify.id, canteen_spu.price
LIMIT :pageSize OFFSET :offset LIMIT :pageSize OFFSET :offset
''') ''')
Future<List<ProductEntity>> getAllPage( Future<List<CanteenSpuEntity>> getAllPage(
String classifyServiceUniqueCode, String classifyServiceUniqueCode,
String hourType, String hourType,
String sysType, String sysType,
@@ -106,7 +102,7 @@ abstract class ProductDao {
); );
@Query(''' @Query('''
SELECT * FROM product SELECT * FROM canteen_spu
WHERE WHERE
delFlag = 0 delFlag = 0
AND isDefault = 1 AND isDefault = 1
@@ -114,5 +110,5 @@ abstract class ProductDao {
AND (:hourType = '-1' OR hourType = :hourType) AND (:hourType = '-1' OR hourType = :hourType)
AND (:sysType = 'CANTEEN' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime')) AND (:sysType = 'CANTEEN' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
''') ''')
Future<List<ProductEntity>> getDefault(String sysType, String hourType); Future<List<CanteenSpuEntity>> getDefault(String sysType, String hourType);
} }
@@ -0,0 +1,6 @@
import 'package:floor/floor.dart';
import 'package:pj_supermarket_cloud/common/index.dart';
@dao
abstract class SupermarketSkuDao {}
@@ -0,0 +1,6 @@
import 'package:floor/floor.dart';
import 'package:pj_supermarket_cloud/common/index.dart';
@dao
abstract class SupermarketSpuDao {}
+3 -1
View File
@@ -9,7 +9,9 @@ part 'database.g.dart';
const entities = <Type>[ const entities = <Type>[
OrderEntity, OrderEntity,
ProductEntity, CanteenSpuEntity,
SupermarketSkuEntity,
SupermarketSpuEntity,
ShopCardEntity, ShopCardEntity,
ClassifyEntity, ClassifyEntity,
PrintHistoryEntity, PrintHistoryEntity,
+41 -60
View File
@@ -112,7 +112,11 @@ class _$AppDatabase extends AppDatabase {
await database.execute( 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)'); '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( await database.execute(
'CREATE TABLE IF NOT EXISTS `product` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `sysType` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `hourType` INTEGER, `saleDate` TEXT, `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, `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)');
await database.execute(
'CREATE TABLE IF NOT EXISTS `supermarket_sku` (`id` INTEGER PRIMARY KEY AUTOINCREMENT)');
await database.execute(
'CREATE TABLE IF NOT EXISTS `supermarket_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT)');
await database.execute( await database.execute(
'CREATE TABLE IF NOT EXISTS `shop_card` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `orderId` INTEGER NOT NULL, `productServiceUniqueCode` TEXT NOT NULL, `productName` TEXT NOT NULL, `productPic` TEXT NOT NULL, `productPrice` INTEGER NOT NULL, `productNumber` INTEGER NOT NULL, `productWidget` REAL NOT NULL, `totalPrice` INTEGER NOT NULL)'); 'CREATE TABLE IF NOT EXISTS `shop_card` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `orderId` INTEGER NOT NULL, `productServiceUniqueCode` TEXT NOT NULL, `productName` TEXT NOT NULL, `productPic` TEXT NOT NULL, `productPrice` INTEGER NOT NULL, `productNumber` INTEGER NOT NULL, `productWidget` REAL NOT NULL, `totalPrice` INTEGER NOT NULL)');
await database.execute( await database.execute(
@@ -443,13 +447,12 @@ class _$ProductDao extends ProductDao {
this.database, this.database,
this.changeListener, this.changeListener,
) : _queryAdapter = QueryAdapter(database), ) : _queryAdapter = QueryAdapter(database),
_productEntityInsertionAdapter = InsertionAdapter( _canteenSpuEntityInsertionAdapter = InsertionAdapter(
database, database,
'product', 'canteen_spu',
(ProductEntity item) => <String, Object?>{ (CanteenSpuEntity item) => <String, Object?>{
'id': item.id, 'id': item.id,
'serviceUniqueCode': item.serviceUniqueCode, 'serviceUniqueCode': item.serviceUniqueCode,
'sysType': _sysTypeConverter.encode(item.sysType),
'classifyServiceUniqueCode': item.classifyServiceUniqueCode, 'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
'hourType': item.hourType?.index, 'hourType': item.hourType?.index,
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate), 'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
@@ -463,14 +466,13 @@ class _$ProductDao extends ProductDao {
'updateTime': _dateTimeConverter.encode(item.updateTime), 'updateTime': _dateTimeConverter.encode(item.updateTime),
'delFlag': _boolConverter.encode(item.delFlag) 'delFlag': _boolConverter.encode(item.delFlag)
}), }),
_productEntityUpdateAdapter = UpdateAdapter( _canteenSpuEntityUpdateAdapter = UpdateAdapter(
database, database,
'product', 'canteen_spu',
['id'], ['id'],
(ProductEntity item) => <String, Object?>{ (CanteenSpuEntity item) => <String, Object?>{
'id': item.id, 'id': item.id,
'serviceUniqueCode': item.serviceUniqueCode, 'serviceUniqueCode': item.serviceUniqueCode,
'sysType': _sysTypeConverter.encode(item.sysType),
'classifyServiceUniqueCode': item.classifyServiceUniqueCode, 'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
'hourType': item.hourType?.index, 'hourType': item.hourType?.index,
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate), 'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
@@ -484,14 +486,13 @@ class _$ProductDao extends ProductDao {
'updateTime': _dateTimeConverter.encode(item.updateTime), 'updateTime': _dateTimeConverter.encode(item.updateTime),
'delFlag': _boolConverter.encode(item.delFlag) 'delFlag': _boolConverter.encode(item.delFlag)
}), }),
_productEntityDeletionAdapter = DeletionAdapter( _canteenSpuEntityDeletionAdapter = DeletionAdapter(
database, database,
'product', 'canteen_spu',
['id'], ['id'],
(ProductEntity item) => <String, Object?>{ (CanteenSpuEntity item) => <String, Object?>{
'id': item.id, 'id': item.id,
'serviceUniqueCode': item.serviceUniqueCode, 'serviceUniqueCode': item.serviceUniqueCode,
'sysType': _sysTypeConverter.encode(item.sysType),
'classifyServiceUniqueCode': item.classifyServiceUniqueCode, 'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
'hourType': item.hourType?.index, 'hourType': item.hourType?.index,
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate), 'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
@@ -512,17 +513,15 @@ class _$ProductDao extends ProductDao {
final QueryAdapter _queryAdapter; final QueryAdapter _queryAdapter;
final InsertionAdapter<ProductEntity> _productEntityInsertionAdapter; final InsertionAdapter<CanteenSpuEntity> _canteenSpuEntityInsertionAdapter;
final UpdateAdapter<ProductEntity> _productEntityUpdateAdapter; final UpdateAdapter<CanteenSpuEntity> _canteenSpuEntityUpdateAdapter;
final DeletionAdapter<ProductEntity> _productEntityDeletionAdapter; final DeletionAdapter<CanteenSpuEntity> _canteenSpuEntityDeletionAdapter;
@override @override
Future<void> delAllByType(String sysType) async { Future<void> delAllByType() async {
await _queryAdapter.queryNoReturn( await _queryAdapter.queryNoReturn('DELETE FROM canteen_spu');
'DELETE FROM product WHERE (?1 = \'-1\' OR sysType = ?1)',
arguments: [sysType]);
} }
@override @override
@@ -532,7 +531,7 @@ class _$ProductDao extends ProductDao {
String hourType, String hourType,
) async { ) async {
await _queryAdapter.queryNoReturn( await _queryAdapter.queryNoReturn(
'UPDATE product SET isDefault = ?1 WHERE delFlag = 0 AND serviceUniqueCode = ?2 AND hourType = ?3 AND (sysType = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))', 'UPDATE canteen_spu SET isDefault = ?1 WHERE delFlag = 0 AND serviceUniqueCode = ?2 AND hourType = ?3 AND (sysType = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))',
arguments: [_boolConverter.encode(isDefault), uniqueCode, hourType]); arguments: [_boolConverter.encode(isDefault), uniqueCode, hourType]);
} }
@@ -542,51 +541,33 @@ class _$ProductDao extends ProductDao {
String hourType, String hourType,
) async { ) async {
return _queryAdapter.query( return _queryAdapter.query(
'SELECT DISTINCT COUNT(0) FROM product WHERE delFlag = 0 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))', 'SELECT DISTINCT COUNT(0) FROM canteen_spu WHERE delFlag = 0 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))',
mapper: (Map<String, Object?> row) => row.values.first as int, mapper: (Map<String, Object?> row) => row.values.first as int,
arguments: [sysType, hourType]); arguments: [sysType, hourType]);
} }
@override @override
Future<ProductEntity?> getByCode(String code) async { Future<CanteenSpuEntity?> getByCode(String code) async {
return _queryAdapter.query( return _queryAdapter.query(
'SELECT * FROM product WHERE delFlag = 0 AND serviceUniqueCode = ?1', 'SELECT * FROM canteen_spu WHERE delFlag = 0 AND serviceUniqueCode = ?1',
mapper: (Map<String, Object?> row) => ProductEntity( 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: _dateTimeEmptyConverter.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)),
id: row['id'] as int?,
serviceUniqueCode: row['serviceUniqueCode'] as String,
sysType: _sysTypeConverter.decode(row['sysType'] as String),
classifyServiceUniqueCode:
row['classifyServiceUniqueCode'] as String,
hourType: row['hourType'] == null
? null
: ProductHourType.values[row['hourType'] as int],
saleDate: _dateTimeEmptyConverter.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)),
arguments: [code]); arguments: [code]);
} }
@override @override
Future<List<ProductEntity>> getAll( Future<List<CanteenSpuEntity>> getAll(
String classifyServiceUniqueCode, String classifyServiceUniqueCode,
String hourType, String hourType,
String sysType, String sysType,
) async { ) async {
return _queryAdapter.queryList( return _queryAdapter.queryList(
'SELECT product.* FROM product LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE product.delFlag = 0 AND (?1 = \'-1\' OR product.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR product.sysType = ?3) ORDER BY classify.sort, product.price', '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 canteen_spu.sysType = ?3) ORDER BY classify.sort, canteen_spu.price',
mapper: (Map<String, Object?> row) => ProductEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, sysType: _sysTypeConverter.decode(row['sysType'] as String), classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.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)), 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: _dateTimeEmptyConverter.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)),
arguments: [classifyServiceUniqueCode, hourType, sysType]); arguments: [classifyServiceUniqueCode, hourType, sysType]);
} }
@override @override
Future<List<ProductEntity>> getAllPage( Future<List<CanteenSpuEntity>> getAllPage(
String classifyServiceUniqueCode, String classifyServiceUniqueCode,
String hourType, String hourType,
String sysType, String sysType,
@@ -594,8 +575,8 @@ class _$ProductDao extends ProductDao {
int offset, int offset,
) async { ) async {
return _queryAdapter.queryList( return _queryAdapter.queryList(
'SELECT product.* FROM product LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE product.delFlag = 0 AND (?1 = \'-1\' OR product.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || product.hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR product.sysType = ?3) AND (?3 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', product.saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')) ORDER BY classify.sort, classify.id, product.price LIMIT ?4 OFFSET ?5', '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 (?3 = \'-1\' OR canteen_spu.sysType = ?3) AND (?3 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', canteen_spu.saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')) ORDER BY classify.sort, classify.id, canteen_spu.price LIMIT ?4 OFFSET ?5',
mapper: (Map<String, Object?> row) => ProductEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, sysType: _sysTypeConverter.decode(row['sysType'] as String), classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.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)), 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: _dateTimeEmptyConverter.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)),
arguments: [ arguments: [
classifyServiceUniqueCode, classifyServiceUniqueCode,
hourType, hourType,
@@ -606,37 +587,37 @@ class _$ProductDao extends ProductDao {
} }
@override @override
Future<List<ProductEntity>> getDefault( Future<List<CanteenSpuEntity>> getDefault(
String sysType, String sysType,
String hourType, String hourType,
) async { ) async {
return _queryAdapter.queryList( return _queryAdapter.queryList(
'SELECT * FROM product WHERE delFlag = 0 AND isDefault = 1 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR hourType = ?2) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))', 'SELECT * FROM canteen_spu WHERE delFlag = 0 AND isDefault = 1 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR hourType = ?2) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))',
mapper: (Map<String, Object?> row) => ProductEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, sysType: _sysTypeConverter.decode(row['sysType'] as String), classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.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)), 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: _dateTimeEmptyConverter.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)),
arguments: [sysType, hourType]); arguments: [sysType, hourType]);
} }
@override @override
Future<void> save(ProductEntity entity) async { Future<void> save(CanteenSpuEntity entity) async {
await _productEntityInsertionAdapter.insert( await _canteenSpuEntityInsertionAdapter.insert(
entity, OnConflictStrategy.abort); entity, OnConflictStrategy.abort);
} }
@override @override
Future<void> batchSave(List<ProductEntity> entitys) async { Future<void> batchSave(List<CanteenSpuEntity> entitys) async {
await _productEntityInsertionAdapter.insertList( await _canteenSpuEntityInsertionAdapter.insertList(
entitys, OnConflictStrategy.abort); entitys, OnConflictStrategy.abort);
} }
@override @override
Future<void> batchEdit(List<ProductEntity> entitys) async { Future<void> batchEdit(List<CanteenSpuEntity> entitys) async {
await _productEntityUpdateAdapter.updateList( await _canteenSpuEntityUpdateAdapter.updateList(
entitys, OnConflictStrategy.abort); entitys, OnConflictStrategy.abort);
} }
@override @override
Future<void> batchDel(List<ProductEntity> entitys) async { Future<void> batchDel(List<CanteenSpuEntity> entitys) async {
await _productEntityDeletionAdapter.deleteList(entitys); await _canteenSpuEntityDeletionAdapter.deleteList(entitys);
} }
} }
@@ -4,11 +4,11 @@ import 'package:json_annotation/json_annotation.dart';
import 'package:pj_supermarket_cloud/common/models/index.dart'; import 'package:pj_supermarket_cloud/common/models/index.dart';
part 'product_entity.g.dart'; part 'canteen_spu_entity.g.dart';
@JsonSerializable() @JsonSerializable()
@Entity(tableName: "product") @Entity(tableName: "canteen_spu")
class ProductEntity extends Equatable { class CanteenSpuEntity extends Equatable {
/// 自增ID /// 自增ID
@PrimaryKey(autoGenerate: true) @PrimaryKey(autoGenerate: true)
int? id; int? id;
@@ -16,9 +16,6 @@ class ProductEntity extends Equatable {
/// 服务端唯一标识 /// 服务端唯一标识
String serviceUniqueCode; String serviceUniqueCode;
/// 平台类型
SysType sysType;
/// 分类 serviceID /// 分类 serviceID
String classifyServiceUniqueCode; String classifyServiceUniqueCode;
@@ -55,10 +52,9 @@ class ProductEntity extends Equatable {
/// 是否删除 /// 是否删除
bool delFlag; bool delFlag;
ProductEntity({ CanteenSpuEntity({
this.id, this.id,
required this.serviceUniqueCode, required this.serviceUniqueCode,
required this.sysType,
required this.classifyServiceUniqueCode, required this.classifyServiceUniqueCode,
this.hourType, this.hourType,
this.saleDate, this.saleDate,
@@ -73,15 +69,14 @@ class ProductEntity extends Equatable {
required this.delFlag, required this.delFlag,
}); });
factory ProductEntity.fromJson(Map<String, dynamic> json) => factory CanteenSpuEntity.fromJson(Map<String, dynamic> json) =>
_$ProductEntityFromJson(json); _$CanteenSpuEntityFromJson(json);
Map<String, dynamic> toJson() => _$ProductEntityToJson(this); Map<String, dynamic> toJson() => _$CanteenSpuEntityToJson(this);
@override @override
List<Object?> get props => [ List<Object?> get props => [
serviceUniqueCode, serviceUniqueCode,
sysType,
classifyServiceUniqueCode, classifyServiceUniqueCode,
hourType, hourType,
name, name,
@@ -1,16 +1,15 @@
// GENERATED CODE - DO NOT MODIFY BY HAND // GENERATED CODE - DO NOT MODIFY BY HAND
part of 'product_entity.dart'; part of 'canteen_spu_entity.dart';
// ************************************************************************** // **************************************************************************
// JsonSerializableGenerator // JsonSerializableGenerator
// ************************************************************************** // **************************************************************************
ProductEntity _$ProductEntityFromJson(Map<String, dynamic> json) => CanteenSpuEntity _$CanteenSpuEntityFromJson(Map<String, dynamic> json) =>
ProductEntity( CanteenSpuEntity(
id: (json['id'] as num?)?.toInt(), id: (json['id'] as num?)?.toInt(),
serviceUniqueCode: json['serviceUniqueCode'] as String, serviceUniqueCode: json['serviceUniqueCode'] as String,
sysType: $enumDecode(_$SysTypeEnumMap, json['sysType']),
classifyServiceUniqueCode: json['classifyServiceUniqueCode'] as String, classifyServiceUniqueCode: json['classifyServiceUniqueCode'] as String,
hourType: $enumDecodeNullable(_$ProductHourTypeEnumMap, json['hourType']), hourType: $enumDecodeNullable(_$ProductHourTypeEnumMap, json['hourType']),
saleDate: json['saleDate'] == null saleDate: json['saleDate'] == null
@@ -27,11 +26,10 @@ ProductEntity _$ProductEntityFromJson(Map<String, dynamic> json) =>
delFlag: json['delFlag'] as bool, delFlag: json['delFlag'] as bool,
); );
Map<String, dynamic> _$ProductEntityToJson(ProductEntity instance) => Map<String, dynamic> _$CanteenSpuEntityToJson(CanteenSpuEntity instance) =>
<String, dynamic>{ <String, dynamic>{
'id': instance.id, 'id': instance.id,
'serviceUniqueCode': instance.serviceUniqueCode, 'serviceUniqueCode': instance.serviceUniqueCode,
'sysType': _$SysTypeEnumMap[instance.sysType]!,
'classifyServiceUniqueCode': instance.classifyServiceUniqueCode, 'classifyServiceUniqueCode': instance.classifyServiceUniqueCode,
'hourType': _$ProductHourTypeEnumMap[instance.hourType], 'hourType': _$ProductHourTypeEnumMap[instance.hourType],
'saleDate': instance.saleDate?.toIso8601String(), 'saleDate': instance.saleDate?.toIso8601String(),
@@ -46,11 +44,6 @@ Map<String, dynamic> _$ProductEntityToJson(ProductEntity instance) =>
'delFlag': instance.delFlag, 'delFlag': instance.delFlag,
}; };
const _$SysTypeEnumMap = {
SysType.SUPERMARKET: 'SUPERMARKET',
SysType.CANTEEN: 'CANTEEN',
};
const _$ProductHourTypeEnumMap = { const _$ProductHourTypeEnumMap = {
ProductHourType.TOTAL: 'TOTAL', ProductHourType.TOTAL: 'TOTAL',
ProductHourType.MORNING: 'MORNING', ProductHourType.MORNING: 'MORNING',
@@ -0,0 +1,21 @@
import 'package:floor/floor.dart';
import 'package:json_annotation/json_annotation.dart';
part 'supermarket_sku_entity.g.dart';
@JsonSerializable()
@Entity(tableName: "supermarket_sku")
class SupermarketSkuEntity {
/// 自增ID
@PrimaryKey(autoGenerate: true)
int? id;
SupermarketSkuEntity({
this.id,
});
factory SupermarketSkuEntity.fromJson(Map<String, dynamic> json) =>
_$SupermarketSkuEntityFromJson(json);
Map<String, dynamic> toJson() => _$SupermarketSkuEntityToJson(this);
}
@@ -0,0 +1,19 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'supermarket_sku_entity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
SupermarketSkuEntity _$SupermarketSkuEntityFromJson(
Map<String, dynamic> json) =>
SupermarketSkuEntity(
id: (json['id'] as num?)?.toInt(),
);
Map<String, dynamic> _$SupermarketSkuEntityToJson(
SupermarketSkuEntity instance) =>
<String, dynamic>{
'id': instance.id,
};
@@ -0,0 +1,21 @@
import 'package:floor/floor.dart';
import 'package:json_annotation/json_annotation.dart';
part 'supermarket_spu_entity.g.dart';
@JsonSerializable()
@Entity(tableName: "supermarket_spu")
class SupermarketSpuEntity {
/// 自增ID
@PrimaryKey(autoGenerate: true)
int? id;
SupermarketSpuEntity({
this.id,
});
factory SupermarketSpuEntity.fromJson(Map<String, dynamic> json) =>
_$SupermarketSpuEntityFromJson(json);
Map<String, dynamic> toJson() => _$SupermarketSpuEntityToJson(this);
}
@@ -0,0 +1,19 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'supermarket_spu_entity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
SupermarketSpuEntity _$SupermarketSpuEntityFromJson(
Map<String, dynamic> json) =>
SupermarketSpuEntity(
id: (json['id'] as num?)?.toInt(),
);
Map<String, dynamic> _$SupermarketSpuEntityToJson(
SupermarketSpuEntity instance) =>
<String, dynamic>{
'id': instance.id,
};
+6 -2
View File
@@ -8,16 +8,20 @@ export './database/dao/classify_dao.dart';
export './database/dao/face_dao.dart'; export './database/dao/face_dao.dart';
export './database/dao/order_dao.dart'; export './database/dao/order_dao.dart';
export './database/dao/print_history_dao.dart'; export './database/dao/print_history_dao.dart';
export './database/dao/product_dao.dart'; export './database/dao/canteen_spu_dao.dart';
export './database/dao/setting_dao.dart'; export './database/dao/setting_dao.dart';
export './database/dao/shop_card_dao.dart'; export './database/dao/shop_card_dao.dart';
export './database/dao/supermarket_sku_dao.dart';
export './database/dao/supermarket_spu_dao.dart';
export './database/dao/user_dao.dart'; export './database/dao/user_dao.dart';
export './database/entity/classify_entity.dart'; export './database/entity/classify_entity.dart';
export './database/entity/face_entity.dart'; export './database/entity/face_entity.dart';
export './database/entity/order_entity.dart'; export './database/entity/order_entity.dart';
export './database/entity/print_history_entity.dart'; export './database/entity/print_history_entity.dart';
export './database/entity/product_entity.dart'; export './database/entity/canteen_spu_entity.dart';
export './database/entity/setting_entity.dart'; export './database/entity/setting_entity.dart';
export './database/entity/shop_card_entity.dart'; export './database/entity/shop_card_entity.dart';
export './database/entity/supermarket_sku_entity.dart';
export './database/entity/supermarket_spu_entity.dart';
export './database/entity/user_entity.dart'; export './database/entity/user_entity.dart';
+2 -3
View File
@@ -227,13 +227,12 @@ abstract class SyncProductTool {
final app = Get.find<AppControl>(); final app = Get.find<AppControl>();
final dataBase = app.dataBase; final dataBase = app.dataBase;
final productDao = dataBase.getProductDao; final productDao = dataBase.getProductDao;
List<ProductEntity> changeList = []; List<CanteenSpuEntity> changeList = [];
for (final v in list) { for (final v in list) {
ProductEntity item = ProductEntity( CanteenSpuEntity item = CanteenSpuEntity(
serviceUniqueCode: sysType == SysType.CANTEEN serviceUniqueCode: sysType == SysType.CANTEEN
? v.spuId.toString() ? v.spuId.toString()
: v.spuId.toString(), : v.spuId.toString(),
sysType: sysType,
classifyServiceUniqueCode: classifyServiceUniqueCode:
v.categoryId != null ? v.categoryId.toString() : "-1", v.categoryId != null ? v.categoryId.toString() : "-1",
name: v.name!, name: v.name!,
+1 -1
View File
@@ -12,5 +12,5 @@ Widget appBack(
return FIcon( return FIcon(
FAssets.icons.chevronLeft, FAssets.icons.chevronLeft,
size: theme.typography.xl4.fontSize, size: theme.typography.xl4.fontSize,
).alignLeft().width(height).onTap(() => onTap()); ).center().width(height).height(height).onTap(() => onTap());
} }
-1
View File
@@ -1,4 +1,3 @@
import 'package:common_utils/common_utils.dart';
import 'package:ducafe_ui_core/ducafe_ui_core.dart'; import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:forui/forui.dart'; import 'package:forui/forui.dart';
@@ -28,10 +28,7 @@ mixin OrderMixin {
RxList<ClassifyEntity> classifyList = RxList([]); RxList<ClassifyEntity> classifyList = RxList([]);
// 商品 // 商品
RxList<ProductEntity> productList = RxList([]); RxList<CanteenSpuEntity> productList = RxList([]);
// 商品分类ids
RxList<String> productClassifyList = RxList([]);
// 总价 // 总价
RxInt totalPrice = RxInt(0); RxInt totalPrice = RxInt(0);
@@ -96,7 +93,6 @@ mixin OrderMixin {
_sysType.name, _sysType.name,
hourType.value.code, hourType.value.code,
); );
productClassifyList.value = list.map((v) => v.serviceUniqueCode).toList();
list.insert( list.insert(
0, 0,
ClassifyEntity( ClassifyEntity(
@@ -123,7 +119,7 @@ mixin OrderMixin {
); );
productList.value = list; productList.value = list;
productList.refresh(); productList.refresh();
productClassifyList.refresh(); classifyList.refresh();
} }
// 创建本地订单 // 创建本地订单
+26 -13
View File
@@ -160,20 +160,33 @@ Widget orderRowClassify(
.map((v) { .map((v) {
final target = classifyList[currentTabIndex]; final target = classifyList[currentTabIndex];
final active = target.id == v.id; final active = target.id == v.id;
return FButton( return Text(
style: active ? FButtonStyle.primary : FButtonStyle.secondary, v.name,
label: Text( textAlign: TextAlign.center,
v.name, maxLines: 1,
textAlign: TextAlign.center, overflow: TextOverflow.ellipsis,
maxLines: 1, style: theme.typography.xl2.copyWith(
overflow: TextOverflow.ellipsis, height: 1,
style: theme.typography.xl.copyWith( color: active
? theme.colorScheme.background
: theme.colorScheme.primary,
),
)
.center()
.width(180.w)
.height(60.h)
.decorated(
color: active color: active
? theme.colorScheme.secondary ? theme.colorScheme.primary
: theme.colorScheme.primary, : theme.colorScheme.background,
), border: Border.all(
).center().width(120.w), color: theme.colorScheme.primary,
onPress: () { width: 1,
),
borderRadius: theme.style.borderRadius / 2,
)
.onTap(
() {
final index = classifyList.indexWhere((i) => i.id == v.id); final index = classifyList.indexWhere((i) => i.id == v.id);
onChange(index); onChange(index);
}, },
@@ -22,7 +22,7 @@ class SteelyardController extends GetxController {
final app = Get.find<AppControl>(); final app = Get.find<AppControl>();
// 称重商品 // 称重商品
Rxn<ProductEntity?> _widgetProduct = Rxn(null); Rxn<CanteenSpuEntity?> _widgetProduct = Rxn(null);
// 重量 // 重量
RxDouble widget = RxDouble(0); RxDouble widget = RxDouble(0);
@@ -65,7 +65,7 @@ class SteelyardController extends GetxController {
} }
// 打开称重 // 打开称重
bool open(ProductEntity current) { bool open(CanteenSpuEntity current) {
final isOpen = _openSerial(); final isOpen = _openSerial();
if (!isOpen) { if (!isOpen) {
_closeStatus(); _closeStatus();
+3 -3
View File
@@ -121,7 +121,7 @@ class CanteenProductController extends GetxController with OrderMixin {
} }
// 点击商品 // 点击商品
void doProduct(ProductEntity current) async { void doProduct(CanteenSpuEntity current) async {
final target = shopCardList.firstWhereOrNull((e) { final target = shopCardList.firstWhereOrNull((e) {
return e.productServiceUniqueCode == current.serviceUniqueCode; return e.productServiceUniqueCode == current.serviceUniqueCode;
}); });
@@ -248,12 +248,12 @@ class CanteenProductController extends GetxController with OrderMixin {
Future<void> _getDefaultProduct() async { Future<void> _getDefaultProduct() async {
final sysType = appSetting.sysType.name; final sysType = appSetting.sysType.name;
final productDao = appC.dataBase.getProductDao; final productDao = appC.dataBase.getProductDao;
List<ProductEntity> list = await productDao.getDefault( List<CanteenSpuEntity> list = await productDao.getDefault(
sysType, sysType,
hourType.value.code, hourType.value.code,
); );
if (ObjectUtil.isEmptyList(list)) return; if (ObjectUtil.isEmptyList(list)) return;
for (final ProductEntity v in list) { for (final CanteenSpuEntity v in list) {
final shopCard = shopCardList.firstWhereOrNull((i) { final shopCard = shopCardList.firstWhereOrNull((i) {
return int.tryParse(i.productServiceUniqueCode) == v.id; return int.tryParse(i.productServiceUniqueCode) == v.id;
}); });
+37 -20
View File
@@ -17,21 +17,39 @@ class CanteenProductPage extends GetView<CanteenProductController> {
final context = Get.context!; final context = Get.context!;
final theme = FTheme.of(context); final theme = FTheme.of(context);
return <Widget>[ return <Widget>[
appBack( <Widget>[
context, appBack(
height: headerHeight,
onTap: () => Get.offAndToNamed(RouteNames.panel),
),
Obx(
() => orderRowClassify(
context, context,
classifyList: controller.classifyList, height: headerHeight,
currentTabIndex: controller.currentTabIndex, onTap: () => Get.offAndToNamed(RouteNames.panel),
onChange: (tabIndex) => controller.doTab(tabIndex),
), ),
).scrollable(scrollDirection: Axis.horizontal).expanded(), Obx(
appRadioHourTypeDialog(context, controller.hourTypeC).width(300.w), () => orderRowClassify(
].toRow(); context,
classifyList: controller.classifyList,
currentTabIndex: controller.currentTabIndex,
onChange: (tabIndex) => controller.doTab(tabIndex),
),
).scrollable(scrollDirection: Axis.horizontal).expanded(),
appRadioHourTypeDialog(context, controller.hourTypeC).width(300.w),
].toRow(),
FDivider(
style: theme.dividerStyles.horizontalStyle.copyWith(
padding: EdgeInsets.zero,
),
),
].toColumn().decorated(
color: theme.colorScheme.background,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
offset: const Offset(0, 2),
blurRadius: 6,
spreadRadius: 0,
),
],
);
;
} }
// 商品 // 商品
@@ -47,13 +65,13 @@ class CanteenProductPage extends GetView<CanteenProductController> {
return Obx( return Obx(
() => ListView.builder( () => ListView.builder(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
itemCount: controller.productClassifyList.length, itemCount: controller.classifyList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (ObjectUtil.isEmpty(controller.productClassifyList) || if (ObjectUtil.isEmpty(controller.classifyList) ||
ObjectUtil.isEmpty(controller.productList)) { ObjectUtil.isEmpty(controller.productList)) {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
final current = controller.productClassifyList[index]; final current = controller.classifyList[index].serviceUniqueCode;
final currentStr = controller.classifyList final currentStr = controller.classifyList
.firstWhereOrNull((v) => v.serviceUniqueCode == current); .firstWhereOrNull((v) => v.serviceUniqueCode == current);
final currentList = controller.productList final currentList = controller.productList
@@ -79,7 +97,7 @@ class CanteenProductPage extends GetView<CanteenProductController> {
/// 商品项 /// 商品项
Widget _buildProductItem( Widget _buildProductItem(
BuildContext context, { BuildContext context, {
required List<ProductEntity> productList, required List<CanteenSpuEntity> productList,
required double productSpacing, required double productSpacing,
required Size productSize, required Size productSize,
String? title = "", String? title = "",
@@ -212,6 +230,7 @@ class CanteenProductPage extends GetView<CanteenProductController> {
final width = context.width; final width = context.width;
final theme = FTheme.of(context); final theme = FTheme.of(context);
return <Widget>[ return <Widget>[
SizedBox(width: 15.w),
_buildProduct().expanded(), _buildProduct().expanded(),
SizedBox(width: 15.w), SizedBox(width: 15.w),
_buildUser().width(width * 0.25).decorated( _buildUser().width(width * 0.25).decorated(
@@ -232,9 +251,7 @@ class CanteenProductPage extends GetView<CanteenProductController> {
id: "canteen_product", id: "canteen_product",
builder: (_) { builder: (_) {
return FScaffold( return FScaffold(
header: _buildHeader(height.h) header: _buildHeader(height.h).height(height.h).paddingVertical(30.h),
.height(height.h)
.padding(vertical: 30.h, horizontal: 10.w),
content: _buildView(), content: _buildView(),
contentPad: true, contentPad: true,
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
+1 -1
View File
@@ -22,7 +22,7 @@ class FaceManageController extends GetxController {
RxInt pageSize = RxInt(15); RxInt pageSize = RxInt(15);
final TextEditingController usernameC = TextEditingController(); final usernameC = TextEditingController();
late StreamSubscription mqUpdateListen; late StreamSubscription mqUpdateListen;
@@ -10,7 +10,7 @@ import 'package:pj_supermarket_cloud/common/index.dart';
class ProductManageController extends GetxController { class ProductManageController extends GetxController {
static const _tag = "商品管理 Controller"; static const _tag = "商品管理 Controller";
RxList<ProductEntity> productList = <ProductEntity>[].obs; RxList<CanteenSpuEntity> productList = <CanteenSpuEntity>[].obs;
ProductHourType hourType = ProductHourType.MORNING; ProductHourType hourType = ProductHourType.MORNING;
@@ -110,7 +110,7 @@ class ProductManageController extends GetxController {
} }
// 切换是否默认 // 切换是否默认
Future<void> trigger(ProductEntity v) async { Future<void> trigger(CanteenSpuEntity v) async {
try { try {
final isSure = await appMessageDialog( final isSure = await appMessageDialog(
Get.context!, Get.context!,
@@ -123,7 +123,7 @@ class ProductManageController extends GetxController {
); );
final app = Get.find<AppControl>(); final app = Get.find<AppControl>();
final productDao = app.dataBase.getProductDao; final productDao = app.dataBase.getProductDao;
final editObj = ProductEntity.fromJson(v.toJson()); final editObj = CanteenSpuEntity.fromJson(v.toJson());
editObj.isDefault = !editObj.isDefault; editObj.isDefault = !editObj.isDefault;
await productDao.edit( await productDao.edit(
editObj.isDefault, editObj.isDefault,
@@ -1,4 +1,5 @@
import 'package:common_utils/common_utils.dart'; import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_subscreen_plugin/flutter_subscreen_plugin.dart'; import 'package:flutter_subscreen_plugin/flutter_subscreen_plugin.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -12,6 +13,8 @@ class SupermarketOrderController extends GetxController with OrderMixin {
final appC = Get.find<AppControl>(); final appC = Get.find<AppControl>();
final selfCodeC = TextEditingController();
late SysSetting appSetting; late SysSetting appSetting;
RxInt currentPage = RxInt(1); RxInt currentPage = RxInt(1);
@@ -43,6 +46,7 @@ class SupermarketOrderController extends GetxController with OrderMixin {
// 读卡器 // 读卡器
appC.serialCardManage.readerClose(); appC.serialCardManage.readerClose();
appC.serialCardManage.close(); appC.serialCardManage.close();
selfCodeC.dispose();
} }
Future<void> _initState() async { Future<void> _initState() async {
@@ -54,6 +58,7 @@ class SupermarketOrderController extends GetxController with OrderMixin {
// 打开副屏 // 打开副屏
SubScreenPlugin.sendMsgToViceScreen(SubScreenAction.jumpSubPage.name); SubScreenPlugin.sendMsgToViceScreen(SubScreenAction.jumpSubPage.name);
// 组件初始化 // 组件初始化
hourType.value = ProductHourType.TOTAL;
sysType = SysType.SUPERMARKET; sysType = SysType.SUPERMARKET;
_listenPayTypeSelectCallback(); _listenPayTypeSelectCallback();
// 获取分类和商品 // 获取分类和商品
+38 -8
View File
@@ -33,7 +33,38 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
onChange: (tabIndex) => controller.doTab(tabIndex), onChange: (tabIndex) => controller.doTab(tabIndex),
), ),
).scrollable(scrollDirection: Axis.horizontal).expanded(), ).scrollable(scrollDirection: Axis.horizontal).expanded(),
].toRow(); <Widget>[
FTextField(
controller: controller.selfCodeC,
hint: '请输入自编码',
maxLines: 1,
).width(300.w),
SizedBox(width: 10.w),
FButton(
prefix: FIcon(
FAssets.icons.search,
size: theme.typography.base.fontSize,
),
label: Text(
'搜索',
style: theme.typography.base.copyWith(
color: theme.colorScheme.secondary,
),
),
onPress: () => controller.doPage(),
),
].toRow().padding(horizontal: 10.w),
].toRow(crossAxisAlignment: CrossAxisAlignment.center).decorated(
color: theme.colorScheme.background,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
offset: const Offset(0, 2),
blurRadius: 6,
spreadRadius: 0,
),
],
);
} }
// ************************************************************************** // **************************************************************************
@@ -46,7 +77,7 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
Widget _buildProductItem( Widget _buildProductItem(
BuildContext context, { BuildContext context, {
required List<ProductEntity> productList, required List<CanteenSpuEntity> productList,
required double productSpacing, required double productSpacing,
required Size productSize, required Size productSize,
String? title = "", String? title = "",
@@ -65,13 +96,13 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
double itemHeight = (maxHeight - (runSpacing + 30) * 3) / 3; double itemHeight = (maxHeight - (runSpacing + 30) * 3) / 3;
return ListView.builder( return ListView.builder(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
itemCount: controller.productClassifyList.length, itemCount: controller.classifyList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (ObjectUtil.isEmpty(controller.productClassifyList) || if (ObjectUtil.isEmpty(controller.classifyList) ||
ObjectUtil.isEmpty(controller.productList)) { ObjectUtil.isEmpty(controller.productList)) {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
final current = controller.productClassifyList[index]; final current = controller.classifyList[index].serviceUniqueCode;
final currentStr = controller.classifyList final currentStr = controller.classifyList
.firstWhereOrNull((v) => v.serviceUniqueCode == current); .firstWhereOrNull((v) => v.serviceUniqueCode == current);
final currentList = controller.productList final currentList = controller.productList
@@ -188,6 +219,7 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
final width = context.width; final width = context.width;
final theme = FTheme.of(context); final theme = FTheme.of(context);
return <Widget>[ return <Widget>[
SizedBox(width: 15.w),
_buildProductArea().expanded(), _buildProductArea().expanded(),
SizedBox(width: 15.w), SizedBox(width: 15.w),
_buildUser().width(width * 0.25).decorated( _buildUser().width(width * 0.25).decorated(
@@ -208,9 +240,7 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
id: "supermarket_order", id: "supermarket_order",
builder: (_) { builder: (_) {
return FScaffold( return FScaffold(
header: _buildHeader(height.h) header: _buildHeader(height.h).height(height.h).paddingVertical(30.h),
.height(height.h)
.padding(vertical: 30.h, horizontal: 10.w),
content: _buildView(context), content: _buildView(context),
contentPad: true, contentPad: true,
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,