Data Structure Design of E-commerce Freight Template

  node.js, question

I want to design a data structure similar to the one that praised YouShop for calculating freight by region, but my design always has various defects.

The logic is as follows

1. A freight template can be generated and used for multiple commodities.
一个运费模板可用于多个商品
2. The template can add specific areas to the area and set the corresponding freight.
具体到地区的配送范围
设置与地区对应的价格
3. When the user inquires about a given region, only the commodities in that region are displayed in the distribution range.

May I ask how a great god should realize this logic?
Is there a ready-made third-party library? Js environment)

Sincerely ask for help, thank you! ! !

I am also doing this, referring to Taobao