diff --git a/structs/utils/calculate-process.go b/structs/utils/calculate-process.go index 5890c0e..d6da1a1 100644 --- a/structs/utils/calculate-process.go +++ b/structs/utils/calculate-process.go @@ -6,7 +6,7 @@ import ( v2 "gitea.timerzz.com/kedaya_haitao/common/structs/v2" ) -func CalculateProviderPrice(calculates []v2.CalculateProcess, env map[string]int) (p v2.ProviderPrice) { +func CalculateProviderPrice(calculates []v2.CalculateProcess, env map[string]float64) (p v2.ProviderPrice) { var calculateStrings = make([]string, 0, len(calculates)) for _, c := range calculates { process, price := c.Run(env) @@ -22,7 +22,7 @@ func CalculateProviderPrice(calculates []v2.CalculateProcess, env map[string]int return } -func CalculateSellerPrice(calculates []v2.CalculateProcess, env map[string]int) (p v2.SellerPrice) { +func CalculateSellerPrice(calculates []v2.CalculateProcess, env map[string]float64) (p v2.SellerPrice) { var calculateStrings = make([]string, 0, len(calculates)) for _, c := range calculates { process, price := c.Run(env) diff --git a/structs/v2/article.go b/structs/v2/article.go index ad30542..9e5a11f 100644 --- a/structs/v2/article.go +++ b/structs/v2/article.go @@ -31,12 +31,12 @@ type Article struct { Available bool `json:"available"` // 排除 Exclude bool `json:"exclude"` - // 最低成本价(单位为分) - CostPrice int `json:"costPrice"` + // 最低成本价 + CostPrice float64 `json:"costPrice"` // 供应商报价列表 Providers []ProviderArticle `json:"providers" gorm:"foreignKey:ArticleID"` - // 最低出售价 (单位为分) - SellPrice int `json:"sellPrice"` + // 最低出售价 + SellPrice float64 `json:"sellPrice"` // 销售商报价列表 Sellers []SellerArticle `json:"sellers" gorm:"foreignKey:ArticleID"` // 利润率 diff --git a/structs/v2/calculate-process.go b/structs/v2/calculate-process.go index ce89eb8..2816eb8 100644 --- a/structs/v2/calculate-process.go +++ b/structs/v2/calculate-process.go @@ -25,7 +25,7 @@ type CalculateProcess struct { } // 计算过程 -func (c *CalculateProcess) Run(env map[string]int) (string, int) { +func (c *CalculateProcess) Run(env map[string]float64) (string, float64) { if c.Condition != "" { condition, err := expr.Compile(c.Condition, expr.AsBool()) if err != nil { @@ -48,9 +48,9 @@ func (c *CalculateProcess) Run(env map[string]int) (string, int) { } var replaceList = make([]string, 0, 2*len(env)) for k, v := range env { - replaceList = append(replaceList, k, fmt.Sprintf("%.2f", float64(v/100))) + replaceList = append(replaceList, k, fmt.Sprintf("%.2f", v)) } replacer := strings.NewReplacer(replaceList...) - var resp = output.(int) - return replacer.Replace(fmt.Sprintf("【%s】 %s = %.2f", c.Name, c.Process, float64(resp/100))), resp + var resp = output.(float64) + return replacer.Replace(fmt.Sprintf("【%s】 %s = %.2f", c.Name, c.Process, resp)), resp } diff --git a/structs/v2/provider.go b/structs/v2/provider.go index 3bf6395..381d092 100644 --- a/structs/v2/provider.go +++ b/structs/v2/provider.go @@ -79,9 +79,9 @@ type ProviderPrice struct { CreatedAt time.Time `json:"createdAt"` ProviderArticleID uint `gorm:"index"` - // 供应商原始价格,美元、人名币、加元,单位为分 - OriginalPrice int `json:"originalPrice"` + // 供应商原始价格,美元、人名币、加元 + OriginalPrice float64 `json:"originalPrice"` // 计算优惠后最终价格,人名币,单位为分 - FinalPrice int `json:"finalPrice"` // 计算完优惠的最终的价格 - CalMark string `json:"calMark"` //计算优惠的过程 + FinalPrice float64 `json:"finalPrice"` // 计算完优惠的最终的价格 + CalMark string `json:"calMark"` //计算优惠的过程 } diff --git a/structs/v2/seller.go b/structs/v2/seller.go index ab044a3..3f3d17b 100644 --- a/structs/v2/seller.go +++ b/structs/v2/seller.go @@ -76,10 +76,10 @@ type SellerPrice struct { ID uint `gorm:"primary_key" json:"-"` CreatedAt time.Time `json:"createdAt"` SellerArticleID uint `gorm:"index"` - // 出售最低价,单位为分 - OriginalPrice int `json:"originalPrice"` - // 能拿到手的最终价格,单位为分 - FinalPrice int `json:"finalPrice"` + // 出售最低价 + OriginalPrice float64 `json:"originalPrice"` + // 能拿到手的最终价格 + FinalPrice float64 `json:"finalPrice"` //计算过程 CalMark string `json:"calMark"` }