fix:每日菜谱排序和消费机排序一致

This commit is contained in:
dzc committed 2026-10-14 16:59:18 +08:00
1 parent aa4eb7b86e
commit fdfabf7eb7
3 files changed
+12 -9

No files matched your search

@@ -114,15 +114,18 @@ abstract class CanteenSpuDao {
);
/// 查询指定分类、餐段和日期的全部主商品快照。
///
/// 排序与 PC 后台「每日菜谱-列表管理」默认展示一致:商品 sort 升序,同序时按接口
/// 返回顺序(服务端已按餐段、菜谱行 ID 稳定排序)。本地自增 id 在按日原子替换时
/// 保持接口返回顺序,因此作为同序并列键即可复刻后台顺序,不再按分类或价格重排。
@Query('''
SELECT canteen_spu.*
FROM canteen_spu
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)
WHERE
(:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode)
AND (:hourType = '-1' OR INSTR(',' || hourType || ',', ',' || :hourType || ',') > 0)
AND (:saleDate = '-1' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', :saleDate))
ORDER BY classify.sort,canteen_spu.sort desc,canteen_spu.price
ORDER BY canteen_spu.sort asc, canteen_spu.id asc
''')
Future<List<CanteenSpuEntity>> getAll(
String classifyServiceUniqueCode,
+1 -1
View File
@@ -983,7 +983,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 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.sort desc,canteen_spu.price',
'SELECT canteen_spu.* FROM canteen_spu 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 canteen_spu.sort asc, canteen_spu.id asc',
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, stock: row['stock'] as int?, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, isPriceIncreased: _boolConverter.decode(row['isPriceIncreased'] as int), spuType: row['spuType'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String)),
arguments: [classifyServiceUniqueCode, hourType, saleDate]);
}
+3 -3
View File
@@ -15,10 +15,10 @@ class Constants {
static const pwdEncKey = 'pigxpigxpigxpigx';
/// 服务 url 线上
// static const apiUrl = 'https://dzc-test-1.fy.takin.cc';
static const apiUrl = 'https://www.zianxin.com/api';
static const apiUrl = 'https://dzc-test-1.fy.takin.cc';
// static const apiUrl = 'https://www.zianxin.com/api';
// static const apiUrl = 'https://dzc-test-1.fy.takin.cc';
// static const apiUrl = 'https://dzc-test-1.fy.takin.cc';
/// 静态资源 url 497
static const ossUrl = apiUrl;