feat:超市商品管理
This commit is contained in:
1 parent
d0ecbfbc53
commit
e7c2fcd733
17 files changed
+297
-99
No files matched your search
@@ -25,4 +25,48 @@ abstract class SupermarketSkuDao {
|
||||
|
||||
@insert
|
||||
Future<void> batchSave(List<SupermarketSkuEntity> changeList);
|
||||
|
||||
@Query("""
|
||||
SELECT DISTINCT COUNT(0) FROM supermarket_sku
|
||||
INNER JOIN supermarket_spu ON supermarket_sku.spuId = supermarket_spu.serviceUniqueCode AND supermarket_spu.delFlag = 0
|
||||
""")
|
||||
Future<int?> getCount();
|
||||
|
||||
@Query('''
|
||||
SELECT
|
||||
supermarket_sku.id,
|
||||
supermarket_sku.serviceUniqueCode,
|
||||
supermarket_sku.spuId,
|
||||
supermarket_spu.productCode,
|
||||
supermarket_spu.classifyServiceUniqueCode,
|
||||
supermarket_spu.productName,
|
||||
supermarket_spu.picUrl,
|
||||
supermarket_spu.productNature,
|
||||
supermarket_spu.salesCount,
|
||||
supermarket_spu.stock,
|
||||
supermarket_spu.sort,
|
||||
supermarket_spu.createTime,
|
||||
supermarket_spu.updateTime,
|
||||
supermarket_spu.delFlag,
|
||||
supermarket_sku.barCode,
|
||||
supermarket_sku.promotionPrice,
|
||||
supermarket_sku.purchasePrice,
|
||||
supermarket_sku.retailPrice,
|
||||
supermarket_sku.spec,
|
||||
supermarket_sku.packageNum,
|
||||
supermarket_sku.unit,
|
||||
supermarket_sku.packageNum
|
||||
FROM supermarket_sku
|
||||
INNER JOIN supermarket_spu ON supermarket_sku.spuId = supermarket_spu.serviceUniqueCode AND supermarket_spu.delFlag = 0
|
||||
WHERE
|
||||
1 = 1
|
||||
AND (:barCode = '-1' OR supermarket_sku.barCode = :barCode)
|
||||
ORDER BY supermarket_sku.spuId
|
||||
LIMIT :pageSize OFFSET :offset
|
||||
''')
|
||||
Future<List<SupermarketSpuEntity>> getAllPage(
|
||||
String barCode,
|
||||
int pageSize,
|
||||
int offset,
|
||||
);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class _$AppDatabase extends AppDatabase {
|
||||
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(
|
||||
'CREATE TABLE IF NOT EXISTS `supermarket_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `productCode` TEXT NOT NULL, `productName` TEXT NOT NULL, `productNature` TEXT NOT NULL, `unit` TEXT NOT NULL, `spec` TEXT NOT NULL, `picUrl` TEXT, `stock` REAL, `salesCount` REAL, `retailPrice` INTEGER NOT NULL, `promotionPrice` INTEGER NOT NULL, `sort` INTEGER NOT NULL, `createTime` TEXT NOT NULL, `updateTime` TEXT NOT NULL, `delFlag` INTEGER NOT NULL)');
|
||||
'CREATE TABLE IF NOT EXISTS `supermarket_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `productCode` TEXT NOT NULL, `productName` TEXT NOT NULL, `productNature` TEXT NOT NULL, `barCode` TEXT, `packageNum` INTEGER NOT NULL, `unit` TEXT NOT NULL, `spec` TEXT NOT NULL, `picUrl` TEXT, `stock` REAL, `salesCount` REAL, `purchasePrice` INTEGER NOT NULL, `retailPrice` INTEGER NOT NULL, `promotionPrice` 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_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(
|
||||
@@ -638,7 +638,8 @@ class _$SupermarketSkuDao extends SupermarketSkuDao {
|
||||
_$SupermarketSkuDao(
|
||||
this.database,
|
||||
this.changeListener,
|
||||
) : _supermarketSkuEntityInsertionAdapter = InsertionAdapter(
|
||||
) : _queryAdapter = QueryAdapter(database),
|
||||
_supermarketSkuEntityInsertionAdapter = InsertionAdapter(
|
||||
database,
|
||||
'supermarket_sku',
|
||||
(SupermarketSkuEntity item) => <String, Object?>{
|
||||
@@ -658,9 +659,30 @@ class _$SupermarketSkuDao extends SupermarketSkuDao {
|
||||
|
||||
final StreamController<String> changeListener;
|
||||
|
||||
final QueryAdapter _queryAdapter;
|
||||
|
||||
final InsertionAdapter<SupermarketSkuEntity>
|
||||
_supermarketSkuEntityInsertionAdapter;
|
||||
|
||||
@override
|
||||
Future<int?> getCount() async {
|
||||
return _queryAdapter.query(
|
||||
'SELECT DISTINCT COUNT(0) FROM supermarket_sku INNER JOIN supermarket_spu ON supermarket_sku.spuId = supermarket_spu.serviceUniqueCode AND supermarket_spu.delFlag = 0',
|
||||
mapper: (Map<String, Object?> row) => row.values.first as int);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<SupermarketSpuEntity>> getAllPage(
|
||||
String barCode,
|
||||
int pageSize,
|
||||
int offset,
|
||||
) async {
|
||||
return _queryAdapter.queryList(
|
||||
'SELECT supermarket_sku.id, supermarket_sku.serviceUniqueCode, supermarket_sku.spuId, supermarket_spu.productCode, supermarket_spu.classifyServiceUniqueCode, supermarket_spu.productName, supermarket_spu.picUrl, supermarket_spu.productNature, supermarket_spu.salesCount, supermarket_spu.stock, supermarket_spu.sort, supermarket_spu.createTime, supermarket_spu.updateTime, supermarket_spu.delFlag, supermarket_sku.barCode, supermarket_sku.promotionPrice, supermarket_sku.purchasePrice, supermarket_sku.retailPrice, supermarket_sku.spec, supermarket_sku.packageNum, supermarket_sku.unit, supermarket_sku.packageNum FROM supermarket_sku INNER JOIN supermarket_spu ON supermarket_sku.spuId = supermarket_spu.serviceUniqueCode AND supermarket_spu.delFlag = 0 WHERE 1 = 1 AND (?1 = \'-1\' OR supermarket_sku.barCode = ?1) ORDER BY supermarket_sku.spuId LIMIT ?2 OFFSET ?3',
|
||||
mapper: (Map<String, Object?> row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), barCode: row['barCode'] as String?, packageNum: row['packageNum'] as int, unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, purchasePrice: row['purchasePrice'] as int, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] 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: [barCode, pageSize, offset]);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> batchSave(List<SupermarketSkuEntity> changeList) async {
|
||||
await _supermarketSkuEntityInsertionAdapter.insertList(
|
||||
@@ -684,11 +706,14 @@ class _$SupermarketSpuDao extends SupermarketSpuDao {
|
||||
'productName': item.productName,
|
||||
'productNature':
|
||||
_supermarketNatureConverter.encode(item.productNature),
|
||||
'barCode': item.barCode,
|
||||
'packageNum': item.packageNum,
|
||||
'unit': item.unit,
|
||||
'spec': item.spec,
|
||||
'picUrl': item.picUrl,
|
||||
'stock': item.stock,
|
||||
'salesCount': item.salesCount,
|
||||
'purchasePrice': item.purchasePrice,
|
||||
'retailPrice': item.retailPrice,
|
||||
'promotionPrice': item.promotionPrice,
|
||||
'sort': item.sort,
|
||||
@@ -708,11 +733,14 @@ class _$SupermarketSpuDao extends SupermarketSpuDao {
|
||||
'productName': item.productName,
|
||||
'productNature':
|
||||
_supermarketNatureConverter.encode(item.productNature),
|
||||
'barCode': item.barCode,
|
||||
'packageNum': item.packageNum,
|
||||
'unit': item.unit,
|
||||
'spec': item.spec,
|
||||
'picUrl': item.picUrl,
|
||||
'stock': item.stock,
|
||||
'salesCount': item.salesCount,
|
||||
'purchasePrice': item.purchasePrice,
|
||||
'retailPrice': item.retailPrice,
|
||||
'promotionPrice': item.promotionPrice,
|
||||
'sort': item.sort,
|
||||
@@ -737,7 +765,7 @@ class _$SupermarketSpuDao extends SupermarketSpuDao {
|
||||
String classifyServiceUniqueCode) async {
|
||||
return _queryAdapter.queryList(
|
||||
'SELECT supermarket_spu.* FROM supermarket_spu LEFT JOIN classify ON supermarket_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE supermarket_spu.delFlag = 0 AND (?1 = \'-1\' OR supermarket_spu.classifyServiceUniqueCode = ?1) ORDER BY classify.sort',
|
||||
mapper: (Map<String, Object?> row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] 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) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), barCode: row['barCode'] as String?, packageNum: row['packageNum'] as int, unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, purchasePrice: row['purchasePrice'] as int, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] 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]);
|
||||
}
|
||||
|
||||
@@ -756,7 +784,7 @@ class _$SupermarketSpuDao extends SupermarketSpuDao {
|
||||
) async {
|
||||
return _queryAdapter.queryList(
|
||||
'SELECT supermarket_spu.* FROM supermarket_spu LEFT JOIN classify ON supermarket_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE supermarket_spu.delFlag = 0 AND (?1 = \'-1\' OR supermarket_spu.classifyServiceUniqueCode = ?1) ORDER BY classify.sort LIMIT ?2 OFFSET ?3',
|
||||
mapper: (Map<String, Object?> row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] 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) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), barCode: row['barCode'] as String?, packageNum: row['packageNum'] as int, unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, purchasePrice: row['purchasePrice'] as int, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] 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, pageSize, offset]);
|
||||
}
|
||||
|
||||
@@ -764,7 +792,7 @@ class _$SupermarketSpuDao extends SupermarketSpuDao {
|
||||
Future<SupermarketSpuEntity?> getByCode(String code) async {
|
||||
return _queryAdapter.query(
|
||||
'SELECT * FROM supermarket_spu WHERE delFlag = 0 AND serviceUniqueCode = ?1',
|
||||
mapper: (Map<String, Object?> row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] 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) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), barCode: row['barCode'] as String?, packageNum: row['packageNum'] as int, unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, purchasePrice: row['purchasePrice'] as int, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] 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]);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,12 @@ class SupermarketSpuEntity {
|
||||
/// 商品性质(字典)
|
||||
SupermarketNature productNature;
|
||||
|
||||
/// 条码
|
||||
String? barCode;
|
||||
|
||||
/// 内装数量
|
||||
int packageNum;
|
||||
|
||||
/// 单位
|
||||
String unit;
|
||||
|
||||
@@ -41,10 +47,13 @@ class SupermarketSpuEntity {
|
||||
/// 销量
|
||||
double? salesCount;
|
||||
|
||||
/// 零售价
|
||||
/// 进价/单位分
|
||||
int purchasePrice;
|
||||
|
||||
/// 零售价/单位分
|
||||
int retailPrice;
|
||||
|
||||
/// 促销价
|
||||
/// 促销价/单位分
|
||||
int promotionPrice;
|
||||
|
||||
/// 排序 倒序排列
|
||||
@@ -66,11 +75,14 @@ class SupermarketSpuEntity {
|
||||
required this.productCode,
|
||||
required this.productName,
|
||||
required this.productNature,
|
||||
this.barCode,
|
||||
required this.packageNum,
|
||||
required this.unit,
|
||||
required this.spec,
|
||||
required this.picUrl,
|
||||
required this.stock,
|
||||
required this.salesCount,
|
||||
required this.purchasePrice,
|
||||
required this.retailPrice,
|
||||
required this.promotionPrice,
|
||||
required this.sort,
|
||||
|
||||
@@ -16,11 +16,14 @@ SupermarketSpuEntity _$SupermarketSpuEntityFromJson(
|
||||
productName: json['productName'] as String,
|
||||
productNature:
|
||||
$enumDecode(_$SupermarketNatureEnumMap, json['productNature']),
|
||||
barCode: json['barCode'] as String?,
|
||||
packageNum: (json['packageNum'] as num).toInt(),
|
||||
unit: json['unit'] as String,
|
||||
spec: json['spec'] as String,
|
||||
picUrl: json['picUrl'] as String?,
|
||||
stock: (json['stock'] as num?)?.toDouble(),
|
||||
salesCount: (json['salesCount'] as num?)?.toDouble(),
|
||||
purchasePrice: (json['purchasePrice'] as num).toInt(),
|
||||
retailPrice: (json['retailPrice'] as num).toInt(),
|
||||
promotionPrice: (json['promotionPrice'] as num).toInt(),
|
||||
sort: (json['sort'] as num).toInt(),
|
||||
@@ -38,11 +41,14 @@ Map<String, dynamic> _$SupermarketSpuEntityToJson(
|
||||
'productCode': instance.productCode,
|
||||
'productName': instance.productName,
|
||||
'productNature': _$SupermarketNatureEnumMap[instance.productNature]!,
|
||||
'barCode': instance.barCode,
|
||||
'packageNum': instance.packageNum,
|
||||
'unit': instance.unit,
|
||||
'spec': instance.spec,
|
||||
'picUrl': instance.picUrl,
|
||||
'stock': instance.stock,
|
||||
'salesCount': instance.salesCount,
|
||||
'purchasePrice': instance.purchasePrice,
|
||||
'retailPrice': instance.retailPrice,
|
||||
'promotionPrice': instance.promotionPrice,
|
||||
'sort': instance.sort,
|
||||
|
||||
Reference in new issue
Block a user