计算价格的业务规则

发布于 2024-07-17 00:59:38 字数 606 浏览 10 评论 0原文

我工作的公司是一家在线零售商,我目前正在开展一个项目,其中包括计算产品的客户价格。 我们可能会创建一个看起来像这样的服务...

public interface IPriceService
{
  decimal CalculateCustomerPrice(ISupplierPriceProvider product);
}

public interface ISupplierPriceProvider
{
    decimal SupplierPrice { get; }
    string Currency { get; }
}

不用担心它看起来不会完全像那样,但您已经了解了总体思路。 在我们实现此服务时,将有许多用于计算此价格的规则,这些规则可能会经常更改,并且我们将来可能想做的是为这些规则创建某种 DSL。 目前,虽然我们不太确定销售部门等实际会要求进行哪些更改,所以我正在考虑托管 DLR 并拥有一个包含大量价格计算的 Iron Python 或 Iron Ruby 脚本文件。 这样我们就可以快速更新价格计算规则,也可以了解商务人士需要什么类型的DSL。 这听起来是不是一个明智的想法,是否有人有任何有关如何托管 DLR 并让脚本文件与 CLR 对象交互并返回值的链接文章/教程?

The business I work for is an on-line retailer, I'm currently working on a project that among other things involves calculating the customer prices for products. We will probably create a service that looks something like...

public interface IPriceService
{
  decimal CalculateCustomerPrice(ISupplierPriceProvider product);
}

public interface ISupplierPriceProvider
{
    decimal SupplierPrice { get; }
    string Currency { get; }
}

Don't worry it will not look exactly like that, but you get the general idea. In our implementation of this service there will be a number of rules for calculating this price, these rules can change quite often and what we probably want to do sometime down the line is to create some sort of DSL for these rules. At the moment though we're not quite sure what changes will actually be requested by sales department and so forth so I'm thinking about hosting the DLR and having an Iron Python or Iron Ruby script file that contains a lot of the price calculation. This way we can rapidly update the price calculation rules and also get a feel for what type DSL the business people needs. Does this at all sound like a sane idea and also does anyone have any links articles/tutorials on how to host the DLR and letting the script files interact with CLR-objects and return values?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝礼 2024-07-24 00:59:39

对我来说,这绝对是一个明智的想法。 您可以从 IronPython 轻松访问 CLR 内部结构(对象和返回值),我不了解 IronRuby。 IronPython in Action 的第 1 章和第 7 章可在线获取,可能会有所帮助。 上还有一个“hello world”风格的教程。学习Python博客。

It definitely sounds like a sane idea to me. You can trivially access CLR internals (objects and return values) from IronPython, I don't know about IronRuby. Chapters 1 and 7 of IronPython in Action are available online and would probably be helpful. There is also a "hello world" style tutorial available at the learning python blog.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文