📝 完整 Prompt
实现电商系统的价格计算引擎。
规则:
1. 基础定价:product.base_price
2. 会员折扣:
- VIP: 8折
- 金卡: 9折
- 普通: 无折扣
3. 促销规则:
- 满100减10
- 满200减30
- 同时最多只能使用2个促销
4. 优惠券:
- 可以和促销叠加
- 优惠券类型:固定金额、百分比、免运费
- 需要验证优惠券是否过期和库存
5. 运费:
- 默认10元
- 满50元免运费
- 不同地区运费不同(加1-5元)
输入:
{
items: [{product_id, quantity, base_price}, ...],
user_level: "VIP" | "金卡" | "普通",
coupon_codes: [string, ...],
region: string,
promotions: [string, ...] (促销代码)
}
输出:
{
subtotal: 商品总额,
member_discount: 会员折扣,
promotion_discount: 促销折扣,
coupon_discount: 优惠券折扣,
shipping: 运费,
tax: 税费,
total: 最终价格,
breakdown: {...} (详细明细)
}
规则优先级:
- 如果有冲突,用配置决定
- 同一类型的优惠可以叠加吗?
- 最终价格不能低于成本价
请实现:
1. 价格计算引擎(支持规则管理)
2. 各种折扣的应用
3. 验证和边界检查
4. 详细的计算明细
5. 配置示例和测试用例