浅谈 SAP 软件里的价格折扣设计原理

Pricing(定价)在 SAP 任何产品里都从来不是一个简单的话题,无论是客户在实际业务处理中对定价策略使用场景的变化多端,还是 SAP 产品里定价引擎本身实现的复杂程度,都超出了很多从业者的想象。
Pricing 一词广泛用于描述价格(供客户或供应商外部使用)和成本(用于内部目的,例如成本会计)的计算。Pricing 在绝大多数情况下总是和特定的上下文联系起来,这种上下文称之为 Condition(条件).条件表示在计算价格时适用的一组上下文信息。例如,特定客户在特定日期订购特定数量的特定产品。这里的可变因素——客户、产品、订单数量、日期——决定了客户得到的最终价格。关于这些因素中的每一个的信息都可以作为主数据存储在系统中。此主数据以条件记录的形式存储在数据库表中。

笔者认识的一位在 SAP 德国总部工作的同事,从大学毕业起就在 SAP ERP 里做 Pricing 实现,在这个领域深耕了 20 多年,从 ERP Pricing 一直做到现在的 S/4HANA Pricing,而且将一直做下去,如果不出意外的话,我估计他做 Pricing 会做到在 SAP 退休。从这位同事身上,笔者很容易联想起“德国制造”,“工匠精神”,“精益求精”这些关键词。


Pricing 到底是什么?当一个新的业务文档(销售订单,服务订单,报价单)被创建出来时,我们期望系统能够基于已有的配置,针对某个特定的客户,自动计算出正确的价格信息,包括总价(Gross Price),折扣(Discount),额外费用(Surcharge)等等。
以基于 ABAP 技术栈实现的 SAP CRM Pricing 为例,“已有的配置”,在 CRM 里称为 condition record,实际就是 Pricing 相关的各种配置表的条目。项目实施的时候,顾问根据某企业实际的计价场景,维护不同的 condition record,在运行时,计价引擎会按照不同的优先级处理这些记录,有点类似 ABAP 编程语言里 CASE ... WHEN XXX. WHEN YYY. WHEN OTHERS.这种处理思想。

如上图所示,SAP CRM 里引入了一个叫做 Pricing Procedure 的逻辑概念,作为计价引擎的输入,统一关联了 condition record 等计价相关的信息。

通过销售组织,分销渠道,部门,Document Pricing Procedure 和 Customer Pricing Procedure 这五个参数可以唯一确定一个 Pricing Procedure:

上面的配置页面其实就是 Pricing Procedure determination 这个函数的五个输入参数,输出则就是匹配的 Pricing procedure:

再来看 Hybris Commerce 的 Pricing 设计。在 SAP 官网上是这样介绍的:

由此可见,Hybris Commerce 的 Pricing 引擎工作原理和 SAP CRM 类似,即预先在系统配置好满足各种条件的 PriceRow(即 SAP CRM 的 condition record), 然后在运行时,根据订单字段的实际内容,找到匹配的 PriceRow.

SAP 官网上给出的 Pricing 引擎工作流程图:

最后介绍笔者在最近一个工作中从事的原型项目中用到的几种 Hybris Commerce 里常见的维护价格折扣的方法。
价格折扣组
在我们的原型项目里,给用户设计了一系列的任务。当用户完成了这些任务后,我们的 React-Native 应用会调用 Hybris Commerce API,将这个用户分配到 Hybris 一个特定的用户折扣组里,组内用户在特定的时间段里可以享受某种购物优惠。
在 BackofficeCustomer Discount Groups 里创建折扣组:

在 Discount 菜单里维护一条 8 折的折扣记录:

新建一条 PriceRow,将上述的 Customer Discount Group 和 8 折的折扣记录关联起来:

最后创建一个 user Group,id 为 ambassador_discount, 这个组里的所有用户都能享受 20%的折扣。

把之前创建的 Customer Discount Group 分配给这个 User group:

当用户完成任务时,调用下图这个 Commerce API,将其分配到折扣组里:

原价 130.65 元的商品,8 折就是省 26.13 元. 下单时,观察到省掉了 26.13 元,说明 8 折优惠生效了。

使用 Hybris Commerce 的 Promotion Rule 实现价格折扣
新建一条 Promotion Rule(促销规则):


Promotion 的条件,设置成仅当客户购买 Hybris 商城里的数码相机时,才触发该促销规则:

再添加一条触发规则,这条规则和上面的规则逻辑上是 AND 的关系,即两条同时满足,才能享受折扣。
这条规则的类型是 Qualifying coupons,即用户必须持有 id 为 jerrycoupon 的优惠券。

如果这两条规则都满足,在 Actions 区域维护优惠信息:享受 10%的优惠

同样,当用户在我们的 React-Native 应用里同其好友互动,完成了我们指定的任务后,React-Native 应用调用 Hybris Commerce 的 Coupon API,将 jerrycoupon 这个优惠券分配给该用户。

这样该用户能在 My Coupons 界面看到自己完成任务后赢得的这个优惠券:

最后下单时,购买这个 3607 元的数码相机,节省了 10%也就是 360.7 元。

在 Hybris Commerce 里要实现价格折扣,方法当然不仅限于本文介绍的这两种方式。要实现折扣效果,除了 Price Row 之外,我们还可以利用更加直接的 DiscountRow,将产品和 Discount 记录关联起来。

最后同样能实现折扣效果:

总结
本文首先给出了 SAP 软件中 Pricing 的一般性定义和使用场景,接着以 SAP CRM 和 Hybris Commerce 这两个产品为例,实际介绍了 Pricing 设计思想在二者里的体现,贯彻和实施。希望这篇文章能帮助大家对 SAP 产品的 Pricing 设计和使用场景有个最基础的认识,感谢阅读。
版权声明: 本文为 InfoQ 作者【Jerry Wang】的原创文章。
原文链接:【http://xie.infoq.cn/article/10dfef5b2e433d0caacfeabdf】。文章转载请联系作者。
评论