UNPKG

@pisell/pisellos

Version:

一个可扩展的前端模块化SDK框架,支持插件系统

111 lines (110 loc) 3.34 kB
import Decimal from 'decimal.js'; import { ProductData } from '../../Product/types'; import { CartItem } from '../types'; /** * @title 处理组合商品 * @description 组合商品需要直接修改 product 里的价格和 is_charge_tax * @param product 商品 * @returns 处理后的商品 */ export declare const handleVariantProduct: (product: ProductData) => ProductData; /** * 格式化商品到购物车 * @param product 商品 * @returns 格式化后的商品 */ export declare const formatProductToCartItem: (params: { cartItem: CartItem; product: ProductData; bundle?: any; options?: any; product_variant_id?: number; quantity?: number; discounts?: any[]; }) => CartItem; export declare const formatProductToCartItemOrigin: (params: { cartItem: CartItem; product: ProductData; bundle?: any; options?: any; product_variant_id?: number; quantity?: number; }) => any; /** * 获取商品总价 * @description 当前总价计算基于商品数量为1 * @param item 商品 * @returns 商品总价 */ export declare const getProductTotalPrice: (params: { product: ProductData; bundle?: any; options?: any; num?: number; discounts?: any[]; }) => number; /** * 获取商品原始总价 * @description 当前总价计算基于商品数量为1 * @param item 商品 * @returns 商品原始总价 */ export declare const getProductOriginTotalPrice: (params: { product: ProductData; bundle?: any; options?: any; num?: number; discounts?: any[]; }) => number | undefined; /** * 格式化套餐规格信息 * @param options 套餐规格信息 * @returns 格式化后的套餐规格信息 */ export declare const formatOptions: (options: any) => any; export declare const formatOptionsToOrigin: (options: any) => any; /** * 格式化商品套餐信息 * @param bundle 商品套餐信息 * @returns 格式化后的商品套餐信息 */ export declare const formatBundle: (bundle: any) => any; export declare const formatBundleToOrigin: (bundle: any) => any; /** * 获取商品定金 * @description 定金基于商品售价来算,最终乘商品数量 * 1、如果套餐主商品有定金规则,则定金为:(套餐商品总售价 * 定金百分比 + 定金固定金额)* 商品数量 * 2、如果套餐主商品没有定金规则,子商品有定金规则,则定金为:(套餐子商品售价 * 套餐子商品定金百分比 + 套餐子商品定金固定金额)* 商品数量,最终将所有子商品定金相加 * 3、普通商品/单规格商品/组合规则商品,定金规则:(商品总售价 * 定金百分比 + 定金固定金额)* 商品数量 * @param params 参数 * @returns 商品定金 */ export declare const getProductDeposit: (params: { cartItem: CartItem; product: ProductData; bundle?: any; options?: any; num?: number; }) => { total: number; protocols: { id: number; title: string; }[]; } | null; /** * 计算商品定金 * @param params 参数 * @returns 商品定金 */ export declare const handleProductDeposit: (params: { depositData: { deposit_fixed?: string; deposit_percentage?: string; }; total: string | number; num: number; }) => { result: boolean; depositTotal: Decimal; };