/** 解析商品行数量（checkout 协议 product_num 语义 = 当前行 num） */
export declare function resolveSafeProductNum(num?: number | null): number;
/**
 * 将 discount_list 中 type=product 项的 product_num 同步为当前商品数量。
 *
 * @example
 * syncManualProductDiscountProductNum(line.discount_list, line.num);
 */
export declare function syncManualProductDiscountProductNum(discountList: any[] | undefined | null, productNum?: number | null): any[];
/** 从多源解析改价前行总价（与 cacheItem._extend.origin_total 语义一致） */
export declare function resolveManualDiscountOriginTotal(sources: {
    originTotal?: unknown;
    extendOriginTotal?: unknown;
    originExtendOriginTotal?: unknown;
    sourceExtendOriginTotal?: unknown;
    catalogUnitPrice?: unknown;
    quantity?: number;
}): number;
/** 从 payload / extend / origin 解析手动折扣原因 */
export declare function resolveManualDiscountReasonFromSources(sources: {
    discountReason?: unknown;
    extendDiscountReason?: unknown;
    originExtendDiscountReason?: unknown;
}): string;
/** 是否带手动改价标记（price_override / is_manual_discount） */
export declare function hasManualProductDiscountFlag(metadata?: Record<string, any> | null): boolean;
/**
 * normalize 兜底：手动改价但 discount_list 缺 type=product 时，按行级原价/折后价补写。
 *
 * @example
 * ensureManualProductDiscountList({
 *   discountList: [],
 *   metadata: { price_override: '5', is_manual_discount: 1 },
 *   originalPrice: '11.00',
 *   sellingPrice: '5.00',
 *   quantity: 1,
 * });
 */
export declare function ensureManualProductDiscountList(params: {
    discountList?: any[] | null;
    metadata?: Record<string, any> | null;
    originalPrice: string | number;
    sellingPrice: string | number;
    quantity?: number;
}): any[];
/** 商品手动折扣 discount_list 项（checkout 协议，type = product） */
export interface ManualProductDiscountItem {
    amount: number;
    type: 'product';
    discount: {
        message: string;
        discountway: string;
        product_num: number;
        discount_per: string;
        discount_type: 'discount' | 'change_price';
    };
}
/**
 * 从 discount_list 中取手动改价项（type = product）。
 *
 * @example
 * const manual = findManualProductDiscountItem(product.discount_list);
 * manual?.discount.message; // 折扣原因
 */
export declare function findManualProductDiscountItem(discountList?: any[] | null): ManualProductDiscountItem | undefined;
/**
 * 解析折扣原因：优先 discount_list[type=product].discount.message。
 *
 * @example
 * resolveManualDiscountMessage(line.discount_list, line.metadata?.legacy_reason);
 */
export declare function resolveManualDiscountMessage(discountList?: any[] | null, fallback?: string): string;
/** 去掉 discount_list 中已有的手动改价项，避免重复叠加 */
export declare function stripManualProductDiscountItems(discountList?: any[] | null): any[];
/**
 * 由改价前后行总价构建手动折扣项；amount = |originTotal - sellingTotal|（行级差额）。
 *
 * @example
 * buildManualProductDiscountItem({
 *   originTotal: 11,
 *   sellingTotal: 4,
 *   quantity: 1,
 *   message: 'VIP',
 * });
 */
export declare function buildManualProductDiscountItem(params: {
    originTotal: number;
    sellingTotal: number;
    quantity?: number;
    message?: string;
    discountway?: string;
    discount_per?: string;
}): ManualProductDiscountItem;
/**
 * 将手动改价项合并进 discount_list（替换已有 type=product 项）。
 *
 * @example
 * mergeManualProductDiscountIntoList(coupons, manualItem);
 */
export declare function mergeManualProductDiscountIntoList(discountList: any[] | undefined | null, manualItem: ManualProductDiscountItem | null | undefined): any[];
/** 是否应写入手动改价 discount_list 项 */
export declare function shouldBuildManualProductDiscount(params: {
    hasPriceOverride?: boolean;
    originTotal?: number;
    sellingTotal?: number;
}): boolean;
