C端SKU数量小于等于1不展示chip
后端修复规格轴数据错乱显示问题
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
} from '../../common/test-whitelist/test-whitelist.service';
|
||||
import { groupResourcesByProductId, mapProductMedia } from './catalog.mapper';
|
||||
import {
|
||||
catalogSpecPickerEnabled,
|
||||
flattenSkuOntoProduct,
|
||||
listMinOnSalePrice,
|
||||
mapSkuDto,
|
||||
@@ -133,7 +134,7 @@ export class CatalogService {
|
||||
allowOnSitePickup: flat.allowOnSitePickup,
|
||||
allowOnlinePurchase: flat.allowOnlinePurchase,
|
||||
allowCrossCityDelivery: flat.allowCrossCityDelivery,
|
||||
specEnabled: specAttrs.length > 0 || skus.length > 1,
|
||||
specEnabled: catalogSpecPickerEnabled(skus, specAttrs.length),
|
||||
saleUnit: flat.saleUnit,
|
||||
...media,
|
||||
};
|
||||
@@ -196,7 +197,7 @@ export class CatalogService {
|
||||
allowOnlinePurchase: flat.allowOnlinePurchase,
|
||||
allowCrossCityDelivery: flat.allowCrossCityDelivery,
|
||||
saleUnit: flat.saleUnit,
|
||||
specEnabled: specAttrs.length > 0 || skus.length > 1,
|
||||
specEnabled: catalogSpecPickerEnabled(skus, specAttrs.length),
|
||||
specAttrs: mapSpecAttrsDto(specAttrs),
|
||||
skus: cSkus,
|
||||
defaultSkuId: defaultSku?.id.toString(),
|
||||
|
||||
@@ -18,6 +18,14 @@ export function isSkuOnSale(sku: { status: string }): boolean {
|
||||
return sku.status === 'ON_SALE';
|
||||
}
|
||||
|
||||
/** C 端是否展示规格选择:可售 SKU 多于 1 且已配规格轴 */
|
||||
export function catalogSpecPickerEnabled(
|
||||
skus: Array<{ status: string }>,
|
||||
specAttrCount: number,
|
||||
): boolean {
|
||||
return skus.filter(isSkuOnSale).length > 1 && specAttrCount > 0;
|
||||
}
|
||||
|
||||
export function buildSpecKey(valueIds: bigint[]): string {
|
||||
if (!valueIds.length) return '';
|
||||
return [...valueIds]
|
||||
|
||||
Reference in New Issue
Block a user