This commit is contained in:
dzc committed 2025-05-08 15:10:55 +08:00
1 parent 43db60d4e7
commit e4d670fd34
7 files changed
+33 -23

No files matched your search

@@ -1,6 +1,4 @@
import 'package:common_utils/common_utils.dart';
import 'package:floor/floor.dart';
import 'package:get/get.dart';
import 'package:pj_supermarket_cloud/common/index.dart';
@@ -28,10 +26,10 @@ abstract class CanteenSpuDao {
@Query("""
UPDATE canteen_spu SET isDefault = :isDefault
WHERE
serviceUniqueCode = :uniqueCode AND hourType = :hourType
AND strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime')
serviceUniqueCode = :uniqueCode
AND hourType = :hourType
""")
Future<void> edit(bool isDefault, String uniqueCode, String hourType);
Future<void> editDefault(bool isDefault, String uniqueCode, String hourType);
@update
Future<void> batchEdit(List<CanteenSpuEntity> entitys);
@@ -59,7 +57,7 @@ abstract class CanteenSpuDao {
@Query('''
SELECT canteen_spu.*
FROM canteen_spu
LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode
LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode AND classify.delFlag = 0
WHERE
(:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode)
AND (:hourType = '-1' OR INSTR(',' || hourType || ',', ',' || :hourType || ',') > 0)
@@ -75,7 +73,7 @@ abstract class CanteenSpuDao {
@Query('''
SELECT canteen_spu.*
FROM canteen_spu
LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode
LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode AND classify.delFlag = 0
WHERE
(:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode)
AND (:hourType = '-1' OR INSTR(',' || canteen_spu.hourType || ',', ',' || :hourType || ',') > 0)
@@ -95,6 +93,7 @@ abstract class CanteenSpuDao {
WHERE
isDefault = 1
AND (:hourType = '-1' OR hourType = :hourType)
AND strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime')
''')
Future<List<CanteenSpuEntity>> getDefault(String hourType);
}
@@ -10,7 +10,7 @@ abstract class SupermarketSpuDao {
@Query('''
SELECT supermarket_spu.*
FROM supermarket_spu
LEFT JOIN classify ON supermarket_spu.classifyServiceUniqueCode = classify.serviceUniqueCode
LEFT JOIN classify ON supermarket_spu.classifyServiceUniqueCode = classify.serviceUniqueCode AND classify.delFlag = 0
WHERE
supermarket_spu.delFlag = 0
AND (:classifyServiceUniqueCode = '-1' OR supermarket_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode)
@@ -28,7 +28,7 @@ abstract class SupermarketSpuDao {
@Query('''
SELECT supermarket_spu.*
FROM supermarket_spu
LEFT JOIN classify ON supermarket_spu.classifyServiceUniqueCode = classify.serviceUniqueCode
LEFT JOIN classify ON supermarket_spu.classifyServiceUniqueCode = classify.serviceUniqueCode AND classify.delFlag = 0
WHERE
supermarket_spu.delFlag = 0
AND (:classifyServiceUniqueCode = '-1' OR supermarket_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode)
+7 -7
View File
@@ -679,13 +679,13 @@ class _$CanteenSpuDao extends CanteenSpuDao {
}
@override
Future<void> edit(
Future<void> editDefault(
bool isDefault,
String uniqueCode,
String hourType,
) async {
await _queryAdapter.queryNoReturn(
'UPDATE canteen_spu SET isDefault = ?1 WHERE serviceUniqueCode = ?2 AND hourType = ?3 AND strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')',
'UPDATE canteen_spu SET isDefault = ?1 WHERE serviceUniqueCode = ?2 AND hourType = ?3',
arguments: [_boolConverter.encode(isDefault), uniqueCode, hourType]);
}
@@ -715,7 +715,7 @@ class _$CanteenSpuDao extends CanteenSpuDao {
String saleDate,
) async {
return _queryAdapter.queryList(
'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE (?1 = \'-1\' OR canteen_spu.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', ?3)) ORDER BY classify.sort, canteen_spu.price',
'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode AND classify.delFlag = 0 WHERE (?1 = \'-1\' OR canteen_spu.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', ?3)) 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: _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)),
arguments: [classifyServiceUniqueCode, hourType, saleDate]);
}
@@ -728,7 +728,7 @@ class _$CanteenSpuDao extends CanteenSpuDao {
int offset,
) async {
return _queryAdapter.queryList(
'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE (?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',
'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode AND classify.delFlag = 0 WHERE (?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: _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)),
arguments: [classifyServiceUniqueCode, hourType, pageSize, offset]);
}
@@ -736,7 +736,7 @@ class _$CanteenSpuDao extends CanteenSpuDao {
@override
Future<List<CanteenSpuEntity>> getDefault(String hourType) async {
return _queryAdapter.queryList(
'SELECT * FROM canteen_spu WHERE isDefault = 1 AND (?1 = \'-1\' OR hourType = ?1)',
'SELECT * FROM canteen_spu WHERE 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: _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)),
arguments: [hourType]);
}
@@ -921,7 +921,7 @@ class _$SupermarketSpuDao extends SupermarketSpuDao {
Future<List<SupermarketSpuEntity>> getAll(
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',
'SELECT supermarket_spu.* FROM supermarket_spu LEFT JOIN classify ON supermarket_spu.classifyServiceUniqueCode = classify.serviceUniqueCode AND classify.delFlag = 0 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), 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]);
}
@@ -940,7 +940,7 @@ class _$SupermarketSpuDao extends SupermarketSpuDao {
int offset,
) 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',
'SELECT supermarket_spu.* FROM supermarket_spu LEFT JOIN classify ON supermarket_spu.classifyServiceUniqueCode = classify.serviceUniqueCode AND classify.delFlag = 0 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), 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]);
}