修复发布冷缓存时店铺筛选退回大范围扫描

This commit is contained in:
WuYongJie 2026-10-19 18:07:12 +08:00
parent e4d82dab2a
commit d735de7864
2 changed files with 12 additions and 1 deletions

View File

@ -495,7 +495,8 @@ class OrderDataMirrorRepository
$shopNames = $this->selectedShopNames($filters);
if ($shopNames !== []) {
$known = (array) Cache::get(self::SHOP_NAMES_CACHE_KEY, []);
// A release clears the complete cache; the small shop directory remains valid.
$known = $this->shopNames();
if (! empty($filters['shop_names_exact']) && array_diff($shopNames, $known) === []) {
$query->whereIn('o.shop_name', $shopNames);
} else {

View File

@ -141,6 +141,16 @@ class OrderDataMirrorRepositoryTest extends TestCase
$selected = $repository->afterSales(array_replace($base, ['shop_names' => ['拼多多-甲店'], 'shop_names_exact' => true]), 1, 25);
$this->assertSame(['拼多多-甲店'], $this->sortedShops($selected['rows']));
$this->assertDoesNotMatchRegularExpression('/shop_name\s+LIKE/i', collect($db->getQueryLog())->pluck('query')->implode("\n"));
Cache::forget(OrderDataMirrorRepository::SHOP_NAMES_CACHE_KEY);
$db->table('ops_jst_shop_info')->insert(['shop_id' => 1, 'shop_name' => '拼多多-甲店']);
$db->flushQueryLog();
$selected = $repository->afterSales(array_replace($base, ['shop_names' => ['拼多多-甲店'], 'shop_names_exact' => true]), 1, 25);
$this->assertSame(['拼多多-甲店'], $this->sortedShops($selected['rows']));
$this->assertDoesNotMatchRegularExpression('/shop_name\s+LIKE/i', collect($db->getQueryLog())->pluck('query')->implode("\n"));
// Array inputs containing partial names still retain the original contains semantics.
$partial = $repository->afterSales(array_replace($base, ['shop_names' => ['甲店'], 'shop_names_exact' => true]), 1, 25);
$this->assertSame(['拼多多-甲店'], $this->sortedShops($partial['rows']));
}
public function test_shop_names_lists_distinct_shops_from_the_order_mirror(): void