Commit f0f46c41 by mushishixian

Merge branch 'ysx-魔方改版-20230313' into dev

parents 96c693e0 ef417273
...@@ -9,10 +9,6 @@ import ( ...@@ -9,10 +9,6 @@ import (
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/gin-gonic/gin"
"github.com/gogf/gf/util/gconv"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"go_sku_server/pkg/config" "go_sku_server/pkg/config"
"go_sku_server/pkg/vars" "go_sku_server/pkg/vars"
"math" "math"
...@@ -24,6 +20,12 @@ import ( ...@@ -24,6 +20,12 @@ import (
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/gin-gonic/gin"
"github.com/gogf/gf/util/gconv"
"github.com/shopspring/decimal"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
) )
/* /*
...@@ -601,3 +603,9 @@ func MyRound(x float64, wei int) float64 { ...@@ -601,3 +603,9 @@ func MyRound(x float64, wei int) float64 {
} }
////////////类型转换///////////////////// ////////////类型转换/////////////////////
//浮点数乘法
func MulFloat(x float64, y float64) float64 {
result, _ := decimal.NewFromFloat(x).Mul(decimal.NewFromFloat(y)).Float64()
return result
}
...@@ -420,7 +420,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -420,7 +420,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if !hasCoefficient { if !hasCoefficient {
coefficient = defaultCoefficient coefficient = defaultCoefficient
} }
fmt.Println("供应商系数 : ", coefficient) fmt.Println("供应商系数 : ", coefficient)
//下面是计算价格 //下面是计算价格
...@@ -445,9 +444,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -445,9 +444,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
} }
} }
//美金成本价 //美金成本价
priceCostUs := common.MyRound(price.PriceUs*usDiscountRatio, 4) priceCostUs := common.MulFloat(price.PriceUs, usDiscountRatio)
fmt.Println(priceCostUs)
priceCostUs = common.MyRound(priceCostUs, 4)
//美金售价 //美金售价
priceUs := priceCostUs * priceRatio.RatioUsd priceUs := common.MulFloat(priceCostUs, priceRatio.RatioUsd)
// priceUs := priceCostUs * priceRatio.RatioUsd
fmt.Println(priceUs)
//人民币成本价 //人民币成本价
priceCostCn := common.MyRound(price.PriceUs*coefficient.Ratio*cnDiscountRatio*tax, 4) priceCostCn := common.MyRound(price.PriceUs*coefficient.Ratio*cnDiscountRatio*tax, 4)
//人民币售价 //人民币售价
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment