feat:交易记录、日期组建
This commit is contained in:
1 parent
08ad1c2d81
commit
88e73ad950
32 files changed
+672
-279
No files matched your search
@@ -33,7 +33,7 @@ abstract class OrderDao {
|
||||
(:status == "-1" OR status = :status) AND
|
||||
(:sysType = '-1' OR sysType = :sysType) AND
|
||||
(:hourType = '-1' OR hourType = :hourType) AND
|
||||
createTime >= :startCreateOrderTime AND createTime <= :endCreateOrderTime
|
||||
strftime('%Y-%m-%d', createTime) >= strftime('%Y-%m-%d', :startCreateOrderTime) AND strftime('%Y-%m-%d', createTime) <= strftime('%Y-%m-%d', :endCreateOrderTime)
|
||||
ORDER BY createTime DESC
|
||||
LIMIT :pageSize OFFSET :offset
|
||||
''')
|
||||
@@ -53,7 +53,7 @@ abstract class OrderDao {
|
||||
(:status == "-1" OR status = :status) AND
|
||||
(:sysType = '-1' OR sysType = :sysType) AND
|
||||
(:hourType = '-1' OR hourType = :hourType) AND
|
||||
createTime >= :startCreateOrderTime AND createTime <= :endCreateOrderTime
|
||||
strftime('%Y-%m-%d', createTime) >= strftime('%Y-%m-%d', :startCreateOrderTime) AND strftime('%Y-%m-%d', createTime) <= strftime('%Y-%m-%d', :endCreateOrderTime)
|
||||
''')
|
||||
Future<int?> count(
|
||||
String status,
|
||||
|
||||
@@ -19,6 +19,7 @@ abstract class ProductDao {
|
||||
final placeholders = List.generate(codes.length, (index) => '?').join(', ');
|
||||
final sql = '''
|
||||
UPDATE product SET delFlag = 1 WHERE serviceUniqueCode IN ($placeholders)
|
||||
AND (sysType = 'canteen' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
|
||||
''';
|
||||
return await database.rawUpdate(sql, [...codes]);
|
||||
}
|
||||
@@ -38,7 +39,9 @@ abstract class ProductDao {
|
||||
@Query("""
|
||||
UPDATE product SET isDefault = :isDefault
|
||||
WHERE
|
||||
delFlag = 0 AND serviceUniqueCode = :uniqueCode AND hourType = :hourType
|
||||
delFlag = 0
|
||||
AND serviceUniqueCode = :uniqueCode AND hourType = :hourType
|
||||
AND (sysType = 'canteen' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
|
||||
""")
|
||||
Future<void> edit(bool isDefault, String uniqueCode, String hourType);
|
||||
|
||||
@@ -51,6 +54,7 @@ abstract class ProductDao {
|
||||
delFlag = 0
|
||||
AND (:sysType = '-1' OR sysType = :sysType)
|
||||
AND (:hourType = '-1' OR INSTR(',' || hourType || ',', ',' || :hourType || ',') > 0)
|
||||
AND (:sysType = 'canteen' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
|
||||
""")
|
||||
Future<int?> getCount(
|
||||
String sysType,
|
||||
@@ -88,11 +92,12 @@ abstract class ProductDao {
|
||||
product.delFlag = 0 AND
|
||||
(:classifyServiceUniqueCode = '-1' OR product.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND
|
||||
(:hourType = '-1' OR INSTR(',' || product.hourType || ',', ',' || :hourType || ',') > 0) AND
|
||||
(:sysType = '-1' OR product.sysType = :sysType)
|
||||
(:sysType = '-1' OR product.sysType = :sysType) AND
|
||||
(:sysType = 'canteen' OR strftime('%Y-%m-%d', product.saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
|
||||
ORDER BY classify.sort, classify.id, product.price
|
||||
LIMIT :pageSize OFFSET :offset
|
||||
''')
|
||||
Future<List<ProductEntity>> getCurrentDayAllPage(
|
||||
Future<List<ProductEntity>> getAllPage(
|
||||
String classifyServiceUniqueCode,
|
||||
String hourType,
|
||||
String sysType,
|
||||
@@ -103,10 +108,11 @@ abstract class ProductDao {
|
||||
@Query('''
|
||||
SELECT * FROM product
|
||||
WHERE
|
||||
product.delFlag = 0
|
||||
delFlag = 0
|
||||
AND isDefault = 1
|
||||
AND (:sysType = '-1' OR sysType = :sysType)
|
||||
AND (:hourType = '-1' OR hourType = :hourType)
|
||||
AND (:sysType = 'canteen' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
|
||||
''')
|
||||
Future<List<ProductEntity>> getDefault(String sysType, String hourType);
|
||||
}
|
||||
@@ -112,7 +112,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 `product` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `sysType` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `hourType` INTEGER, `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 `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)');
|
||||
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)');
|
||||
await database.execute(
|
||||
@@ -287,7 +287,7 @@ class _$OrderDao extends OrderDao {
|
||||
String hourType,
|
||||
) async {
|
||||
return _queryAdapter.queryList(
|
||||
'SELECT * FROM order_record WHERE (?1 == \"-1\" OR status = ?1) AND (?6 = \'-1\' OR sysType = ?6) AND (?7 = \'-1\' OR hourType = ?7) AND createTime >= ?2 AND createTime <= ?3 ORDER BY createTime DESC LIMIT ?4 OFFSET ?5',
|
||||
'SELECT * FROM order_record WHERE (?1 == \"-1\" OR status = ?1) AND (?6 = \'-1\' OR sysType = ?6) AND (?7 = \'-1\' OR hourType = ?7) AND strftime(\'%Y-%m-%d\', createTime) >= strftime(\'%Y-%m-%d\', ?2) AND strftime(\'%Y-%m-%d\', createTime) <= strftime(\'%Y-%m-%d\', ?3) ORDER BY createTime DESC LIMIT ?4 OFFSET ?5',
|
||||
mapper: (Map<String, Object?> row) => OrderEntity(
|
||||
id: row['id'] as int?,
|
||||
uniqueCode: row['uniqueCode'] as String,
|
||||
@@ -329,7 +329,7 @@ class _$OrderDao extends OrderDao {
|
||||
String hourType,
|
||||
) async {
|
||||
return _queryAdapter.query(
|
||||
'SELECT COUNT(0) FROM order_record WHERE (?1 == \"-1\" OR status = ?1) AND (?4 = \'-1\' OR sysType = ?4) AND (?5 = \'-1\' OR hourType = ?5) AND createTime >= ?2 AND createTime <= ?3',
|
||||
'SELECT COUNT(0) FROM order_record WHERE (?1 == \"-1\" OR status = ?1) AND (?4 = \'-1\' OR sysType = ?4) AND (?5 = \'-1\' OR hourType = ?5) AND strftime(\'%Y-%m-%d\', createTime) >= strftime(\'%Y-%m-%d\', ?2) AND strftime(\'%Y-%m-%d\', createTime) <= strftime(\'%Y-%m-%d\', ?3)',
|
||||
mapper: (Map<String, Object?> row) => row.values.first as int,
|
||||
arguments: [
|
||||
status,
|
||||
@@ -452,6 +452,7 @@ class _$ProductDao extends ProductDao {
|
||||
'sysType': _sysTypeConverter.encode(item.sysType),
|
||||
'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
|
||||
'hourType': item.hourType?.index,
|
||||
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
|
||||
'name': item.name,
|
||||
'price': item.price,
|
||||
'image': item.image,
|
||||
@@ -472,6 +473,7 @@ class _$ProductDao extends ProductDao {
|
||||
'sysType': _sysTypeConverter.encode(item.sysType),
|
||||
'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
|
||||
'hourType': item.hourType?.index,
|
||||
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
|
||||
'name': item.name,
|
||||
'price': item.price,
|
||||
'image': item.image,
|
||||
@@ -492,6 +494,7 @@ class _$ProductDao extends ProductDao {
|
||||
'sysType': _sysTypeConverter.encode(item.sysType),
|
||||
'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
|
||||
'hourType': item.hourType?.index,
|
||||
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
|
||||
'name': item.name,
|
||||
'price': item.price,
|
||||
'image': item.image,
|
||||
@@ -529,7 +532,7 @@ class _$ProductDao extends ProductDao {
|
||||
String hourType,
|
||||
) async {
|
||||
await _queryAdapter.queryNoReturn(
|
||||
'UPDATE product SET isDefault = ?1 WHERE delFlag = 0 AND serviceUniqueCode = ?2 AND hourType = ?3',
|
||||
'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\'))',
|
||||
arguments: [_boolConverter.encode(isDefault), uniqueCode, hourType]);
|
||||
}
|
||||
|
||||
@@ -539,7 +542,7 @@ class _$ProductDao extends ProductDao {
|
||||
String hourType,
|
||||
) async {
|
||||
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)',
|
||||
'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\'))',
|
||||
mapper: (Map<String, Object?> row) => row.values.first as int,
|
||||
arguments: [sysType, hourType]);
|
||||
}
|
||||
@@ -557,6 +560,7 @@ class _$ProductDao extends ProductDao {
|
||||
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?,
|
||||
@@ -577,12 +581,12 @@ class _$ProductDao extends ProductDao {
|
||||
) async {
|
||||
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',
|
||||
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], 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) => 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)),
|
||||
arguments: [classifyServiceUniqueCode, hourType, sysType]);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<ProductEntity>> getCurrentDayAllPage(
|
||||
Future<List<ProductEntity>> getAllPage(
|
||||
String classifyServiceUniqueCode,
|
||||
String hourType,
|
||||
String sysType,
|
||||
@@ -590,8 +594,8 @@ class _$ProductDao extends ProductDao {
|
||||
int offset,
|
||||
) async {
|
||||
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) ORDER BY classify.sort, classify.id, product.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], 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 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',
|
||||
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)),
|
||||
arguments: [
|
||||
classifyServiceUniqueCode,
|
||||
hourType,
|
||||
@@ -607,8 +611,8 @@ class _$ProductDao extends ProductDao {
|
||||
String hourType,
|
||||
) async {
|
||||
return _queryAdapter.queryList(
|
||||
'SELECT * FROM product WHERE product.delFlag = 0 AND isDefault = 1 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR hourType = ?2)',
|
||||
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], 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 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\'))',
|
||||
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)),
|
||||
arguments: [sysType, hourType]);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ class ProductEntity extends Equatable {
|
||||
/// 菜品时间类型
|
||||
ProductHourType? hourType;
|
||||
|
||||
/// 菜品上架日期
|
||||
DateTime? saleDate;
|
||||
|
||||
/// 商品名
|
||||
String name;
|
||||
|
||||
@@ -57,7 +60,8 @@ class ProductEntity extends Equatable {
|
||||
required this.serviceUniqueCode,
|
||||
required this.sysType,
|
||||
required this.classifyServiceUniqueCode,
|
||||
required this.hourType,
|
||||
this.hourType,
|
||||
this.saleDate,
|
||||
required this.name,
|
||||
required this.price,
|
||||
this.image,
|
||||
|
||||
@@ -13,6 +13,9 @@ ProductEntity _$ProductEntityFromJson(Map<String, dynamic> json) =>
|
||||
sysType: $enumDecode(_$SysTypeEnumMap, json['sysType']),
|
||||
classifyServiceUniqueCode: json['classifyServiceUniqueCode'] as String,
|
||||
hourType: $enumDecodeNullable(_$ProductHourTypeEnumMap, json['hourType']),
|
||||
saleDate: json['saleDate'] == null
|
||||
? null
|
||||
: DateTime.parse(json['saleDate'] as String),
|
||||
name: json['name'] as String,
|
||||
price: (json['price'] as num).toInt(),
|
||||
image: json['image'] as String?,
|
||||
@@ -31,6 +34,7 @@ Map<String, dynamic> _$ProductEntityToJson(ProductEntity instance) =>
|
||||
'sysType': _$SysTypeEnumMap[instance.sysType]!,
|
||||
'classifyServiceUniqueCode': instance.classifyServiceUniqueCode,
|
||||
'hourType': _$ProductHourTypeEnumMap[instance.hourType],
|
||||
'saleDate': instance.saleDate?.toIso8601String(),
|
||||
'name': instance.name,
|
||||
'price': instance.price,
|
||||
'image': instance.image,
|
||||
|
||||
Reference in new issue
Block a user