使用jbilling作为单独批价引擎

上传人:ji****n 文档编号:48129534 上传时间:2018-07-10 格式:DOC 页数:5 大小:104KB
返回 下载 相关 举报
使用jbilling作为单独批价引擎_第1页
第1页 / 共5页
使用jbilling作为单独批价引擎_第2页
第2页 / 共5页
使用jbilling作为单独批价引擎_第3页
第3页 / 共5页
使用jbilling作为单独批价引擎_第4页
第4页 / 共5页
使用jbilling作为单独批价引擎_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《使用jbilling作为单独批价引擎》由会员分享,可在线阅读,更多相关《使用jbilling作为单独批价引擎(5页珍藏版)》请在金锄头文库上搜索。

1、使用使用 jBilling 作为单独批价引擎作为单独批价引擎HowHow to:to: UsingUsing jBillingjBilling as as a a stand-alonestand-alone ratingrating engineengine任何销售某物的应用程序都需要知道所卖出商品的价格。很多时候这个价格很直觉,但某些 情况下则不是。当你需要计算一个价格时,这并不容易,你最好使用一个计价(Pricing)或批价 (Rating)引擎。这个引擎将考虑许多不同的因素来计算一个产品或服务的价格,例如:日期或时间:是否在周末或是傍晚比较便宜(例如移动电话资费方案)购物车中出现其他商

2、品(例如你买这个产品,你将可以用半价买到另一个产品)任何折扣(10 月份打 5 折)税金(计算很复杂)Any application that sells something needs to know the price of what is being sold. Many times this price is very straight forward, but in some cases it is not. When you need to resolve a price that is not trivial, you will be better of using a pric

3、ing, or “rating”, engine. This engine will take into account a lot of different factors to price a product or service, such as:The date or time: is it cheaper on weekends or evenings? (like a cell phone plan)The presence of other products in the shopping cart (“If you buy this product, you can also

4、purchase that product at half price.”)Any discounts (“50% off in October!”)Taxes (calculating them can get tricky)有两种因素让 jBilling 可作为批价引擎。首先是你可以新增计价规格而不修改代码,增加一个 “10 月份 5 折优惠“的规则是非常简单的因为 jBilling 采用 JBoss rules 来进行计价。其次是 jBilling API 允许另一个系统在任何时间询问 jBilling 关于某产品或一组产品的价格。There are two key factors th

5、at allow jBilling to work as a rating engine. The first is that you can add pricing rules without changing code, it is very simple to add a “50% off in October” rule because jBilling uses JBoss rules to do pricing. The second one is the jBilling API that allows another system to ask jBilling at any

6、time the price of a product, or group of them. 我们来走过几个批价的情境,并找出 jBilling API 中有帮助的方法Lets go over the various rating scenarios, and identify the method from the jBilling API that would help 单一产品价格单一产品价格SingleSingle ProductProduct PricePrice如果你需要的只是为单一产品计价,你可以简单地呼叫Get Item:If all you need is to price

7、a single product, you can simply call Get Item: api.getItem(Integer itemId, Integer userId, PricingFields)api.getProduct(ProductOffering offer, Customer customer, ProductCharacteristicsValues values)如此一来将会传回一个已计价的项目。如果客户对于决定价格不重要的话,你可以只输入 item ID。例如,一个10 月份 5 折优惠的计价规则只要一个 item ID 就可以了,但若你想要只 针对 Pete

8、r 打 5 折,则 user ID 就是必须的了。计价字段将也可允许你传入任意的数据,提供 给 Rule Engine 来建立计算条件。This will return an item that is priced. You can pass only the item ID, this is fine if the customer is not important for resolve the price. For example, a price rule that is 50% off for October will work with just the item ID, but

9、if you want to do 50% for Peter then the user ID is needed. Pricing fields will also allow you to pass arbitrary data that will be made available to the rules engine to build conditions. 多产品价格多产品价格MultipleMultiple ProductProduct PricePrice若你的价格受到采购数量或同一笔交易中的其他采购商品的的影响呢?例如:“买二送一“或“ 买一双鞋,袜子半价“。为了这种情况,

10、我们需要一次传入采购数量与数个项目:What if your price is affected by the quantity or other items being purchased in this same transaction? For example: “Buy two, get the third one free”, or “buy one pair of shoes, get socks at half price”. For this, we need to be able to pass quantity and many items at the same time

11、: api.rateOrder(OrderWS order) 一个订单可以有多个行,每行有一个数量字段。jBilling 将会传回这个订单以及批价插件所做 的变更。如果你传入一行而数量是 3 个,系统可能会改变价格成为两个单位的价格,实现出“ 买二送一“的结果。An order can have multiple lines, and each line has a quantity field. jBilling will return this order with the changes done by the rating plug-ins. If you pass one line

12、with a quantity of 3, the system could change the price to the equivalent of 2 units, implementing then the “buy two, get the third one free”.这类型的呼叫也适合用于计算税金。jBilling 将呼叫一个税金引擎(或透过规则决定税金)且加入这些税金成为传回订单中的新行。This type of call is useful too for calculating taxes. jBilling will call a tax engine (or reso

13、lve the taxes on its own through rules) and add these taxes as new lines in the returned order. 产品价格基于帐户情况产品价格基于帐户情况ProductProduct PricePrice BasedBased in in AccountAccount ContextContext如果价格是决定于客户过去做过的某件事情,如超过了某个临界值而触动了某个折扣?或相 反地,尚未遇到一个承诺数量而接受一个违约金?All good but, what if the price is affected by so

14、mething the customer did in the past, like crossing a certain threshold that triggers a discount? Or the opposite, not meeting a volume commitment and getting a penalty?这在 jBilling 中是平常且容易实作出来的。你甚至不需要使用不同地 API 方法,订单的批价就 可以做到了。唯一的变化只有你会传入 user id 在订单中,这个方法将此作为参数。This is common and easy to implement i

15、n jBilling. You dont even need to use a different API method, rate Order will do. The only change is that you will be passing the user id in the order that this method takes as a parameter.这个魔术是发生在批价插件中。如果使用某种基于规则插件,你可以检查任何客户拥有的历 史性数据以修改价格。这也用来检查客户是某种类别或其他种类,申租某个特定方案与否。The magic is done in the ratin

16、g plug-ins. If using a rules based plug-in, then you can check any historical data that a customer has to alter the price. This also works for checking if the customer is of one type or another, subscribed to a specific plan or not. 对某事件批价对某事件批价PricingPricing anan EventEvent如果你的应用程序知道 User 在买什么,所有上面提到的情况都适用,但有些时候应用程序并 不知道。举例来说,当客户做了某件事情后有事件发生,例如打电话进来,其实应用程序并 不能分辨哪个产品是牵涉其中的。If your application knows what the user is buying then al

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 初中教育

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号