feat:特色菜收费
This commit is contained in:
1 parent
e5e24231e7
commit
3729e3b896
18 files changed
+93
-26
No files matched your search
@@ -40,7 +40,7 @@ const typeConverters = <Type>[
|
||||
BoolConverter,
|
||||
];
|
||||
|
||||
@Database(version: 6, entities: entities)
|
||||
@Database(version: 7, entities: entities)
|
||||
@TypeConverters(typeConverters)
|
||||
abstract class AppDatabase extends FloorDatabase {
|
||||
BroadcastDao get getBroadcastDao;
|
||||
|
||||
@@ -104,7 +104,7 @@ class _$AppDatabase extends AppDatabase {
|
||||
Callback? callback,
|
||||
]) async {
|
||||
final databaseOptions = sqflite.OpenDatabaseOptions(
|
||||
version: 5,
|
||||
version: 7,
|
||||
onConfigure: (database) async {
|
||||
await database.execute('PRAGMA foreign_keys = ON');
|
||||
await callback?.onConfigure?.call(database);
|
||||
@@ -134,7 +134,7 @@ class _$AppDatabase extends AppDatabase {
|
||||
await database.execute(
|
||||
'CREATE TABLE IF NOT EXISTS `supermarket_code` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `spuId` TEXT NOT NULL, `unitId` TEXT NOT NULL, `barCode` TEXT 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, `nature` TEXT 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, `nature` TEXT NOT NULL, `productNumber` INTEGER NOT NULL, `productWidget` REAL NOT NULL, `totalPrice` INTEGER NOT NULL, `isPriceIncreased` INTEGER NOT NULL)');
|
||||
await database.execute(
|
||||
'CREATE TABLE IF NOT EXISTS `classify` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `sysType` TEXT NOT NULL, `name` TEXT NOT NULL, `categoryType` TEXT NOT NULL, `sort` INTEGER NOT NULL, `createTime` TEXT NOT NULL, `updateTime` TEXT NOT NULL, `delFlag` INTEGER NOT NULL)');
|
||||
await database.execute(
|
||||
@@ -1164,7 +1164,9 @@ class _$ShopCardDao extends ShopCardDao {
|
||||
'nature': _supermarketNatureConverter.encode(item.nature),
|
||||
'productNumber': item.productNumber,
|
||||
'productWidget': item.productWidget,
|
||||
'totalPrice': item.totalPrice
|
||||
'totalPrice': item.totalPrice,
|
||||
'isPriceIncreased':
|
||||
_boolConverter.encode(item.isPriceIncreased)
|
||||
}),
|
||||
_shopCardEntityUpdateAdapter = UpdateAdapter(
|
||||
database,
|
||||
@@ -1180,7 +1182,9 @@ class _$ShopCardDao extends ShopCardDao {
|
||||
'nature': _supermarketNatureConverter.encode(item.nature),
|
||||
'productNumber': item.productNumber,
|
||||
'productWidget': item.productWidget,
|
||||
'totalPrice': item.totalPrice
|
||||
'totalPrice': item.totalPrice,
|
||||
'isPriceIncreased':
|
||||
_boolConverter.encode(item.isPriceIncreased)
|
||||
}),
|
||||
_shopCardEntityDeletionAdapter = DeletionAdapter(
|
||||
database,
|
||||
@@ -1196,7 +1200,9 @@ class _$ShopCardDao extends ShopCardDao {
|
||||
'nature': _supermarketNatureConverter.encode(item.nature),
|
||||
'productNumber': item.productNumber,
|
||||
'productWidget': item.productWidget,
|
||||
'totalPrice': item.totalPrice
|
||||
'totalPrice': item.totalPrice,
|
||||
'isPriceIncreased':
|
||||
_boolConverter.encode(item.isPriceIncreased)
|
||||
});
|
||||
|
||||
final sqflite.DatabaseExecutor database;
|
||||
@@ -1225,7 +1231,9 @@ class _$ShopCardDao extends ShopCardDao {
|
||||
nature: _supermarketNatureConverter.decode(row['nature'] as String),
|
||||
productNumber: row['productNumber'] as int,
|
||||
productWidget: row['productWidget'] as double,
|
||||
totalPrice: row['totalPrice'] as int),
|
||||
totalPrice: row['totalPrice'] as int,
|
||||
isPriceIncreased:
|
||||
_boolConverter.decode(row['isPriceIncreased'] as int)),
|
||||
arguments: [orderId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,13 +167,30 @@ abstract class DatabaseMigration {
|
||||
}
|
||||
});
|
||||
|
||||
static Migration migration6To7 = Migration(6, 7, (database) async {
|
||||
final columns = await database.rawQuery("PRAGMA table_info(shop_card)");
|
||||
bool hasIsPriceIncreased = false;
|
||||
for (final c in columns) {
|
||||
if (c['name'] == 'isPriceIncreased') {
|
||||
hasIsPriceIncreased = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasIsPriceIncreased) {
|
||||
await database.execute(
|
||||
"ALTER TABLE shop_card ADD COLUMN isPriceIncreased INTEGER NOT NULL DEFAULT 0",
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
static List<Migration> getDatabaseMigrations() {
|
||||
return [
|
||||
migration1To2,
|
||||
migration2To3,
|
||||
migration3To4,
|
||||
migration4To5,
|
||||
migration5To6
|
||||
migration5To6,
|
||||
migration6To7,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,9 @@ class ShopCardEntity {
|
||||
/// 单商品总价(分)
|
||||
int totalPrice;
|
||||
|
||||
/// 是否涨价
|
||||
bool isPriceIncreased;
|
||||
|
||||
ShopCardEntity({
|
||||
this.id,
|
||||
required this.orderId,
|
||||
@@ -49,6 +52,7 @@ class ShopCardEntity {
|
||||
required this.productNumber,
|
||||
required this.productWidget,
|
||||
required this.totalPrice,
|
||||
required this.isPriceIncreased,
|
||||
});
|
||||
|
||||
factory ShopCardEntity.fromJson(Map<String, dynamic> json) =>
|
||||
|
||||
@@ -18,6 +18,7 @@ ShopCardEntity _$ShopCardEntityFromJson(Map<String, dynamic> json) =>
|
||||
productNumber: (json['productNumber'] as num).toInt(),
|
||||
productWidget: (json['productWidget'] as num).toDouble(),
|
||||
totalPrice: (json['totalPrice'] as num).toInt(),
|
||||
isPriceIncreased: json['isPriceIncreased'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ShopCardEntityToJson(ShopCardEntity instance) =>
|
||||
@@ -32,6 +33,7 @@ Map<String, dynamic> _$ShopCardEntityToJson(ShopCardEntity instance) =>
|
||||
'productNumber': instance.productNumber,
|
||||
'productWidget': instance.productWidget,
|
||||
'totalPrice': instance.totalPrice,
|
||||
'isPriceIncreased': instance.isPriceIncreased,
|
||||
};
|
||||
|
||||
const _$ProductNatureEnumMap = {
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:equatable/equatable.dart';
|
||||
import 'package:floor/floor.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
import 'package:pj_supermarket_cloud/common/models/index.dart';
|
||||
|
||||
part 'user_entity.g.dart';
|
||||
|
||||
@@ -30,6 +29,13 @@ class DiscountsItem {
|
||||
/// 基础金额(分),超过了这个基数`extraPer`就生效
|
||||
int basePrice;
|
||||
|
||||
/// 特色菜是否额外收费
|
||||
@JsonKey(
|
||||
fromJson: JsonTool.stringToBoolean,
|
||||
toJson: JsonTool.booleanToString,
|
||||
)
|
||||
bool specialDishEnable;
|
||||
|
||||
/// 打折(8折->0.8)
|
||||
double? extraPer;
|
||||
|
||||
@@ -38,6 +44,7 @@ class DiscountsItem {
|
||||
required this.hourType,
|
||||
required this.type,
|
||||
required this.basePrice,
|
||||
required this.specialDishEnable,
|
||||
required this.extraPer,
|
||||
});
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ DiscountsItem _$DiscountsItemFromJson(Map<String, dynamic> json) =>
|
||||
hourType: JsonTool.stringToProductHourType(json['hourType'] as String?),
|
||||
type: JsonTool.stringToDiscountsType(json['type'] as String?),
|
||||
basePrice: (json['basePrice'] as num).toInt(),
|
||||
specialDishEnable:
|
||||
JsonTool.stringToBoolean(json['specialDishEnable'] as String?),
|
||||
extraPer: (json['extraPer'] as num?)?.toDouble(),
|
||||
);
|
||||
|
||||
@@ -21,6 +23,7 @@ Map<String, dynamic> _$DiscountsItemToJson(DiscountsItem instance) =>
|
||||
'hourType': JsonTool.productHourTypeToString(instance.hourType),
|
||||
'type': JsonTool.discountsTypeToString(instance.type),
|
||||
'basePrice': instance.basePrice,
|
||||
'specialDishEnable': JsonTool.booleanToString(instance.specialDishEnable),
|
||||
'extraPer': instance.extraPer,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user