fix:副屏数据传输修改
This commit is contained in:
1 parent
8be476c9f4
commit
1a144d1860
14 files changed
+55
-42
No files matched your search
@@ -14,7 +14,8 @@ class SubScreenProductEvent {
|
||||
SysType sysType;
|
||||
|
||||
// 支付用户
|
||||
ServiceUser? payUser;
|
||||
// ServiceUser
|
||||
Map<String, dynamic>? payUser;
|
||||
|
||||
// 购物车总价
|
||||
int totalPrice;
|
||||
|
||||
@@ -13,9 +13,7 @@ SubScreenProductEvent _$SubScreenProductEventFromJson(
|
||||
.map((e) => e as Map<String, dynamic>)
|
||||
.toList(),
|
||||
sysType: $enumDecode(_$SysTypeEnumMap, json['sysType']),
|
||||
payUser: json['payUser'] == null
|
||||
? null
|
||||
: ServiceUser.fromJson(json['payUser'] as Map<String, dynamic>),
|
||||
payUser: json['payUser'] as Map<String, dynamic>?,
|
||||
totalPrice: (json['totalPrice'] as num).toInt(),
|
||||
amountMealPrice: (json['amountMealPrice'] as num).toInt(),
|
||||
);
|
||||
|
||||
@@ -56,9 +56,17 @@ abstract class CanteenSpuDao {
|
||||
Future<int?> getCount(String hourType);
|
||||
|
||||
@Query('''
|
||||
SELECT * FROM canteen_spu WHERE delFlag = 0 AND serviceUniqueCode = :code
|
||||
SELECT * FROM canteen_spu
|
||||
WHERE
|
||||
delFlag = 0
|
||||
AND serviceUniqueCode = :code
|
||||
AND (:saleDate = '-1' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', :saleDate))
|
||||
LIMIT 1
|
||||
''')
|
||||
Future<CanteenSpuEntity?> getByCode(String code);
|
||||
Future<CanteenSpuEntity?> getByCode(
|
||||
String code,
|
||||
String saleDate,
|
||||
);
|
||||
|
||||
@Query('''
|
||||
SELECT canteen_spu.*
|
||||
|
||||
@@ -118,7 +118,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, `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, `delFlag` INTEGER 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(
|
||||
@@ -482,7 +482,7 @@ class _$CanteenSpuDao extends CanteenSpuDao {
|
||||
'serviceUniqueCode': item.serviceUniqueCode,
|
||||
'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
|
||||
'hourType': item.hourType?.index,
|
||||
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
|
||||
'saleDate': _dateTimeConverter.encode(item.saleDate),
|
||||
'name': item.name,
|
||||
'price': item.price,
|
||||
'image': item.image,
|
||||
@@ -502,7 +502,7 @@ class _$CanteenSpuDao extends CanteenSpuDao {
|
||||
'serviceUniqueCode': item.serviceUniqueCode,
|
||||
'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
|
||||
'hourType': item.hourType?.index,
|
||||
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
|
||||
'saleDate': _dateTimeConverter.encode(item.saleDate),
|
||||
'name': item.name,
|
||||
'price': item.price,
|
||||
'image': item.image,
|
||||
@@ -522,7 +522,7 @@ class _$CanteenSpuDao extends CanteenSpuDao {
|
||||
'serviceUniqueCode': item.serviceUniqueCode,
|
||||
'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
|
||||
'hourType': item.hourType?.index,
|
||||
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
|
||||
'saleDate': _dateTimeConverter.encode(item.saleDate),
|
||||
'name': item.name,
|
||||
'price': item.price,
|
||||
'image': item.image,
|
||||
@@ -571,11 +571,14 @@ class _$CanteenSpuDao extends CanteenSpuDao {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CanteenSpuEntity?> getByCode(String code) async {
|
||||
Future<CanteenSpuEntity?> getByCode(
|
||||
String code,
|
||||
String saleDate,
|
||||
) async {
|
||||
return _queryAdapter.query(
|
||||
'SELECT * FROM canteen_spu WHERE delFlag = 0 AND serviceUniqueCode = ?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: _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]);
|
||||
'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)),
|
||||
arguments: [code, saleDate]);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -585,7 +588,7 @@ class _$CanteenSpuDao extends CanteenSpuDao {
|
||||
) 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) 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: _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: _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)),
|
||||
arguments: [classifyServiceUniqueCode, hourType]);
|
||||
}
|
||||
|
||||
@@ -598,7 +601,7 @@ class _$CanteenSpuDao extends CanteenSpuDao {
|
||||
) 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: _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: _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)),
|
||||
arguments: [classifyServiceUniqueCode, hourType, pageSize, offset]);
|
||||
}
|
||||
|
||||
@@ -606,7 +609,7 @@ class _$CanteenSpuDao extends CanteenSpuDao {
|
||||
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: _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: _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)),
|
||||
arguments: [hourType]);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class CanteenSpuEntity extends Equatable {
|
||||
ProductHourType? hourType;
|
||||
|
||||
/// 菜品上架日期
|
||||
DateTime? saleDate;
|
||||
DateTime saleDate;
|
||||
|
||||
/// 商品名
|
||||
String name;
|
||||
@@ -57,7 +57,7 @@ class CanteenSpuEntity extends Equatable {
|
||||
required this.serviceUniqueCode,
|
||||
required this.classifyServiceUniqueCode,
|
||||
this.hourType,
|
||||
this.saleDate,
|
||||
required this.saleDate,
|
||||
required this.name,
|
||||
required this.price,
|
||||
this.image,
|
||||
|
||||
@@ -12,9 +12,7 @@ CanteenSpuEntity _$CanteenSpuEntityFromJson(Map<String, dynamic> json) =>
|
||||
serviceUniqueCode: json['serviceUniqueCode'] as String,
|
||||
classifyServiceUniqueCode: json['classifyServiceUniqueCode'] as String,
|
||||
hourType: $enumDecodeNullable(_$ProductHourTypeEnumMap, json['hourType']),
|
||||
saleDate: json['saleDate'] == null
|
||||
? null
|
||||
: DateTime.parse(json['saleDate'] as String),
|
||||
saleDate: DateTime.parse(json['saleDate'] as String),
|
||||
name: json['name'] as String,
|
||||
price: (json['price'] as num).toInt(),
|
||||
image: json['image'] as String?,
|
||||
@@ -32,7 +30,7 @@ Map<String, dynamic> _$CanteenSpuEntityToJson(CanteenSpuEntity instance) =>
|
||||
'serviceUniqueCode': instance.serviceUniqueCode,
|
||||
'classifyServiceUniqueCode': instance.classifyServiceUniqueCode,
|
||||
'hourType': _$ProductHourTypeEnumMap[instance.hourType],
|
||||
'saleDate': instance.saleDate?.toIso8601String(),
|
||||
'saleDate': instance.saleDate.toIso8601String(),
|
||||
'name': instance.name,
|
||||
'price': instance.price,
|
||||
'image': instance.image,
|
||||
|
||||
@@ -221,12 +221,8 @@ abstract class AppSettingTool {
|
||||
|
||||
/// 绑定设备信息
|
||||
static Future<bool> bindSys(int serviceId) async {
|
||||
final sysSetting = await AppSettingTool.getSysSetting();
|
||||
var androidId = sysSetting.androidId;
|
||||
if (ObjectUtil.isEmpty(androidId)) {
|
||||
androidId = await AppSysTool.getAndroidId();
|
||||
if (ObjectUtil.isEmpty(androidId)) return false;
|
||||
}
|
||||
var androidId = await AppSysTool.getAndroidId();
|
||||
if (ObjectUtil.isEmpty(androidId)) return false;
|
||||
final pa = {"id": serviceId, "uniqueCode": androidId};
|
||||
try {
|
||||
final data = await HardApi.bind(pa);
|
||||
|
||||
@@ -167,7 +167,7 @@ abstract class SyncProductTool {
|
||||
while (true) {
|
||||
final pa = {
|
||||
"current": currentPage,
|
||||
"size": 100,
|
||||
"size": 50,
|
||||
};
|
||||
final supermarket = await ProductApi.supermarketSpu(
|
||||
pa,
|
||||
@@ -259,12 +259,16 @@ abstract class SyncProductTool {
|
||||
createTime: DateTime.now(),
|
||||
updateTime: DateTime.now(),
|
||||
hourType: ProductHourType.values.fromCode(v.hourType),
|
||||
saleDate: v.saleDate,
|
||||
saleDate: v.saleDate ?? DateTime.now(),
|
||||
isDefault: false,
|
||||
delFlag: false,
|
||||
);
|
||||
if (isUpdate) {
|
||||
final detail = await productDao.getByCode(item.serviceUniqueCode);
|
||||
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;
|
||||
|
||||
@@ -434,7 +434,7 @@ mixin OrderMixin {
|
||||
final json = SubScreenProductEvent(
|
||||
shopList: shopCardList.map((e) => e.toJson()).toList(),
|
||||
sysType: _sysType,
|
||||
payUser: payUser.value,
|
||||
payUser: payUser.value?.toJson(),
|
||||
totalPrice: totalPrice.value,
|
||||
amountMealPrice: amountMealPrice.value,
|
||||
).toJson();
|
||||
|
||||
@@ -84,10 +84,10 @@ Widget orderSelectPanel(
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: theme.typography.lg,
|
||||
).width(maxWidth * 0.3),
|
||||
appPrice(context, price),
|
||||
).width(maxWidth * 0.28),
|
||||
appPrice(context, price).expanded(),
|
||||
].toRow(mainAxisAlignment: MainAxisAlignment.spaceBetween).expanded(),
|
||||
SizedBox(width: 10.w),
|
||||
SizedBox(width: 5.w),
|
||||
showPlus
|
||||
? <Widget>[
|
||||
FIcon(
|
||||
|
||||
@@ -33,7 +33,10 @@ Widget appUserInfo(
|
||||
SizedBox(width: 10.w),
|
||||
<Widget>[
|
||||
Text("姓名:$username", style: style),
|
||||
Text("饭卡余额:$balance", style: style),
|
||||
<Widget>[
|
||||
Text("饭卡余额:", style: style),
|
||||
appPrice(context, balance),
|
||||
].toRow(),
|
||||
].toColumn(crossAxisAlignment: CrossAxisAlignment.start),
|
||||
].toRow(mainAxisAlignment: MainAxisAlignment.center).width(double.infinity);
|
||||
}
|
||||
@@ -68,11 +68,11 @@ class PanelController extends GetxController {
|
||||
switch (type) {
|
||||
case PanelType.supermarketOrder:
|
||||
if (!await _checkIsBind()) return;
|
||||
Get.offAllNamed(RouteNames.supermarketProduct);
|
||||
Get.toNamed(RouteNames.supermarketProduct);
|
||||
break;
|
||||
case PanelType.canteenOrder:
|
||||
if (!await _checkIsBind()) return;
|
||||
Get.offAllNamed(RouteNames.canteenProduct);
|
||||
Get.toNamed(RouteNames.canteenProduct);
|
||||
break;
|
||||
case PanelType.takeFood:
|
||||
if (!await _checkIsBind()) return;
|
||||
|
||||
@@ -17,9 +17,9 @@ Future<void> _bindServiceDialog(BuildContext context, SysSetting sys) async {
|
||||
}
|
||||
if (AppSysTool.isDev()) {
|
||||
// 正式环境-超市
|
||||
// uniqueCodeC.text = "1894303392833716226";
|
||||
uniqueCodeC.text = "1894303392833716226";
|
||||
// 正式环境-测试
|
||||
uniqueCodeC.text = "1896157295523049473";
|
||||
// uniqueCodeC.text = "1896157295523049473";
|
||||
// 测试环境-测试设备
|
||||
// uniqueCodeC.text = "1877592554489143298";
|
||||
}
|
||||
|
||||
@@ -53,7 +53,9 @@ class _SubProductPageState extends State<SubProductPage> {
|
||||
.map((v) => ShopCardEntity.fromJson(v))
|
||||
.toList();
|
||||
_sysType = subScreenEvent.sysType;
|
||||
_payUser = subScreenEvent.payUser;
|
||||
if (subScreenEvent.payUser != null) {
|
||||
_payUser = ServiceUser.fromJson(subScreenEvent.payUser!);
|
||||
}
|
||||
_totalPrice = subScreenEvent.totalPrice;
|
||||
_amountMealPrice = subScreenEvent.amountMealPrice;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user