feat:预约页面

This commit is contained in:
dzc committed 2025-04-23 12:31:25 +08:00
1 parent 17914f5d10
commit 2d53ed5622
8 files changed
+279 -9

No files matched your search

@@ -20,4 +20,27 @@ abstract class BroadcastDao {
AND strftime('%Y-%m-%d', createTime) = strftime('%Y-%m-%d', 'now', 'localtime')
""")
Future<List<BroadcastEntity>> getAll();
@Query("""
SELECT * FROM broadcast
WHERE
strftime('%Y-%m-%d', createTime) = strftime('%Y-%m-%d', 'now', 'localtime')
AND (:hourType = '-1' OR hourType = :hourType)
LIMIT :pageSize OFFSET :offset
""")
Future<List<BroadcastEntity>> findAllPage(
String hourType,
int pageSize,
int offset,
);
@Query("""
SELECT COUNT(0) FROM broadcast
WHERE
strftime('%Y-%m-%d', createTime) = strftime('%Y-%m-%d', 'now', 'localtime')
AND (:hourType = '-1' OR hourType = :hourType)
""")
Future<int?> count(
String hourType,
);
}
+22 -1
View File
@@ -118,7 +118,7 @@ class _$AppDatabase extends AppDatabase {
},
onCreate: (database, version) async {
await database.execute(
'CREATE TABLE IF NOT EXISTS `broadcast` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `content` TEXT NOT NULL, `broadcastCount` INTEGER NOT NULL, `broadcastMaxCount` INTEGER NOT NULL, `isBroadcast` INTEGER NOT NULL, `isDone` INTEGER NOT NULL, `isDoneTime` TEXT, `serviceCode` TEXT NOT NULL, `userId` TEXT NOT NULL, `username` TEXT NOT NULL, `userMobile` TEXT NOT NULL, `productDesc` TEXT NOT NULL, `payPrice` INTEGER NOT NULL, `enable` INTEGER NOT NULL, `createTime` TEXT NOT NULL)');
'CREATE TABLE IF NOT EXISTS `broadcast` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `content` TEXT NOT NULL, `broadcastCount` INTEGER NOT NULL, `broadcastMaxCount` INTEGER NOT NULL, `isBroadcast` INTEGER NOT NULL, `isDone` INTEGER NOT NULL, `isDoneTime` TEXT, `serviceCode` TEXT NOT NULL, `userId` TEXT NOT NULL, `username` TEXT NOT NULL, `userMobile` TEXT NOT NULL, `productDesc` TEXT NOT NULL, `payPrice` INTEGER NOT NULL, `hourType` INTEGER, `enable` INTEGER NOT NULL, `createTime` TEXT NOT NULL)');
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(
@@ -237,6 +237,7 @@ class _$BroadcastDao extends BroadcastDao {
'userMobile': item.userMobile,
'productDesc': item.productDesc,
'payPrice': item.payPrice,
'hourType': item.hourType?.index,
'enable': _boolConverter.encode(item.enable),
'createTime': _dateTimeConverter.encode(item.createTime)
});
@@ -267,6 +268,26 @@ class _$BroadcastDao extends BroadcastDao {
payPrice: row['payPrice'] as int));
}
@override
Future<List<BroadcastEntity>> findAllPage(
String hourType,
int pageSize,
int offset,
) async {
return _queryAdapter.queryList(
'SELECT * FROM broadcast WHERE strftime(\'%Y-%m-%d\', createTime) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\') AND (?1 = \'-1\' OR hourType = ?1) LIMIT ?2 OFFSET ?3',
mapper: (Map<String, Object?> row) => BroadcastEntity(id: row['id'] as int?, content: row['content'] as String, broadcastMaxCount: row['broadcastMaxCount'] as int, isBroadcast: _boolConverter.decode(row['isBroadcast'] as int), createTime: _dateTimeConverter.decode(row['createTime'] as String), serviceCode: row['serviceCode'] as String, userId: row['userId'] as String, username: row['username'] as String, userMobile: row['userMobile'] as String, productDesc: row['productDesc'] as String, payPrice: row['payPrice'] as int),
arguments: [hourType, pageSize, offset]);
}
@override
Future<int?> count(String hourType) async {
return _queryAdapter.query(
'SELECT COUNT(0) FROM broadcast WHERE strftime(\'%Y-%m-%d\', createTime) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\') AND (?1 = \'-1\' OR hourType = ?1)',
mapper: (Map<String, Object?> row) => row.values.first as int,
arguments: [hourType]);
}
@override
Future<void> save(BroadcastEntity entity) async {
await _broadcastEntityInsertionAdapter.insert(
@@ -1,5 +1,6 @@
import 'package:floor/floor.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:pj_supermarket_cloud/common/index.dart';
part 'broadcast_entity.g.dart';
@@ -46,6 +47,9 @@ class BroadcastEntity {
/// 支付价格
int payPrice;
/// 菜品时间类型
ProductHourType? hourType;
/// 手动开关
bool enable = true;
@@ -25,6 +25,8 @@ BroadcastEntity _$BroadcastEntityFromJson(Map<String, dynamic> json) =>
..isDoneTime = json['isDoneTime'] == null
? null
: DateTime.parse(json['isDoneTime'] as String)
..hourType =
$enumDecodeNullable(_$ProductHourTypeEnumMap, json['hourType'])
..enable = json['enable'] as bool;
Map<String, dynamic> _$BroadcastEntityToJson(BroadcastEntity instance) =>
@@ -42,6 +44,14 @@ Map<String, dynamic> _$BroadcastEntityToJson(BroadcastEntity instance) =>
'userMobile': instance.userMobile,
'productDesc': instance.productDesc,
'payPrice': instance.payPrice,
'hourType': _$ProductHourTypeEnumMap[instance.hourType],
'enable': instance.enable,
'createTime': instance.createTime.toIso8601String(),
};
const _$ProductHourTypeEnumMap = {
ProductHourType.TOTAL: 'TOTAL',
ProductHourType.MORNING: 'MORNING',
ProductHourType.NOON: 'NOON',
ProductHourType.NIGHT: 'NIGHT',
};