feat(catalog): product visibility whitelist by phone

Admin can limit ON_SALE products to test phones; C-end filters by user phone.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-29 15:08:57 +08:00
parent bf9cd1bffd
commit ed7fd4e013
8 changed files with 321 additions and 28 deletions
@@ -57,7 +57,8 @@ export class TradeService {
userId: bigint,
body: { productId: string; quantity: number; addressId?: string; onSitePickup?: boolean },
) {
const product = await this.catalogService.getProduct(BigInt(body.productId));
const viewerPhone = await this.catalogService.resolveUserPhone(userId);
const product = await this.catalogService.getProduct(BigInt(body.productId), { phone: viewerPhone });
if (!product || product.status !== 'ON_SALE') {
throw new BadRequestException('商品不可购买');
}
@@ -1035,7 +1036,7 @@ export class TradeService {
async getPartnerProxyOrderOptions(partnerAccountId: bigint) {
const primary = await this.partnerCityService.resolvePrimaryAccount(partnerAccountId);
const [products, promoCodes, stores] = await Promise.all([
this.catalogService.listProducts(),
this.catalogService.listProducts(undefined, undefined, { bypassWhitelist: true }),
this.promoCodeService.listActiveOptions(),
this.prisma.store.findMany({
where: { partnerAccountId: primary.id },
@@ -1083,7 +1084,9 @@ export class TradeService {
receiverCity?: string;
receiverDistrict?: string;
}) {
const product = await this.catalogService.getProduct(BigInt(body.productId));
const product = await this.catalogService.getProduct(BigInt(body.productId), {
bypassWhitelist: true,
});
if (!product || product.status !== 'ON_SALE') {
throw new BadRequestException('商品不可购买');
}