简体   繁体   English

使用node.js实现金融微服务| python | [R

[英]implement financial microservice using node.js | python | R

I'm developing a tourist web app with node.js and microservics. 我正在使用node.js和微服务开发旅游网络应用。

I need to develop a pricing service which will do all the calculation for the guest (price for night, taxes, VAT, discounts etc). 我需要开发一个pricing服务,该服务将为客人进行所有计算(每晚价格,税金,增值税,折扣等)。

Moreover, I need those calculation will be easy to dynamically change and control. 而且,我需要那些计算将易于动态更改和控制。

From my past experience, doing those calcs in common web programming languages and/or storing math formulas in the db end with a mess . 根据我过去的经验,用普通的Web编程语言进行这些计算和/或将数学公式存储在db中会导致混乱

Are there any alternative solutions for this? 是否有其他替代解决方案? From what I read so far language like python , R or Java can fit to the job. 从目前为止我所读到的语言,例如pythonRJava都可以胜任。 However, is there any specific library within those which aimed for pricing? 但是,在那些旨在定价的图书馆中是否有任何特定的图书馆?

On can do calulations in (datamodel / class) in javascript 可以在JavaScript中的(数据模型/类)中进行计算

1 : you can create a javascript class 1:您可以创建一个javascript类

   function sales(){
    let self = this
    this.address = '';
    this.personname = '';
    this.totalVat = 0
    this.items = [];
    this.calculateTax = function(){
       let tax = ...compute items array and set 
       self.totalVat = tax
     }   
   }

Note : 注意 :

you can use this data model if you are going to use it only on ui 如果仅在ui上使用它,则可以使用此数据模型

else if 否则,如果

you want to use it on server then you can use same datamodel on server 您要在服务器上使用它,然后可以在服务器上使用相同的数据模型

esle if 如果

you want to use on both server and ui then 您想同时在服务器和ui上使用

(you can maintain only 1 copy of this model shared by server and ui , here you can use require.js bundling to take help of sharing one datamodel , also there are nice articles that show how to share js datamodels) (您只能维护服务器和ui共享的该模型的1个副本,在这里您可以使用require.js捆绑来帮助共享一个数据模型,还有一些不错的文章介绍了如何共享js数据模型)

in Case Of (you want to use on both server and ui then) 万一(您想同时在服务器和ui上使用)

You mentioned database , you create mechanism to store formula in database and you can generate sales_datamodel.js on server whenever any changes are done in datamodel in db 您提到了数据库,创建了将公式存储在数据库中的机制,并且只要在db中的datamodel中进行了任何更改,就可以在服务器上生成sales_datamodel.js

@wizard I would share here something . @wizard我会在这里分享一些东西。

If you have complex calculation or any type of calculation do it in db end if feasible. 如果您有复杂的计算或任何类型的计算,请在db end中进行。

The best approach postgres postgres的最佳方法

to do this type of process is to make function (PL\\SQL) block . 进行这种类型的处理就是使函数(PL \\ SQL)成为块。 If you are using postgres create all calculation in postgres . 如果您使用的是postgres,请在postgres中创建所有计算。

This is why node.js was design , no calculation in node.js end . 这就是为什么设计node.js,而在node.js结束时不进行计算的原因。

mongodb

if you are working with mongodb with this approach then i will recommend you to go with 如果您使用此方法使用mongodb,则我建议您使用

Stored JavaScript in MongoDB

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM