Commit d0f2e6bf by 杨树贤

自定义汇率

parent 56155c8e
...@@ -81,6 +81,8 @@ type LySku struct { ...@@ -81,6 +81,8 @@ type LySku struct {
PriceRatio []PriceRatio `json:"price_ratio"` PriceRatio []PriceRatio `json:"price_ratio"`
Source int `json:"source"` Source int `json:"source"`
OriginCurrencySymbol string `json:"origin_currency_symbol,omitempty"` OriginCurrencySymbol string `json:"origin_currency_symbol,omitempty"`
CustomizeRateRMB float64
CustomizeRateUs float64
} }
type DiscountRatio struct { type DiscountRatio struct {
......
...@@ -451,7 +451,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -451,7 +451,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if sku.SupplierId == 1688 { if sku.SupplierId == 1688 {
priceCostCn = c.MulFloat(price.PriceCn, 1) priceCostCn = c.MulFloat(price.PriceCn, 1)
} else { } else {
usdRatio, _ := redis.Float64(redisCon.Do("HGET", "erp_rate", 2)) //这里是去取实时美金汇率,并且计算人民币价格
var usdRatio float64
if sku.CustomizeRateRMB != 0 {
usdRatio = sku.CustomizeRateRMB
} else {
usdRatio, _ = redis.Float64(redisCon.Do("HGET", "erp_rate", 2))
}
priceCostCn = c.MulFloat(price.PriceUs, usdRatio, tax) priceCostCn = c.MulFloat(price.PriceUs, usdRatio, tax)
} }
priceCostCn = c.MulFloat(c.MyRound(priceCostCn, 4), sku.DiscountRatio.Ratio) priceCostCn = c.MulFloat(c.MyRound(priceCostCn, 4), sku.DiscountRatio.Ratio)
......
...@@ -663,6 +663,28 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS ...@@ -663,6 +663,28 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
} }
hasTax = gjson.Get(currencyConfig, "has_tax").Bool() hasTax = gjson.Get(currencyConfig, "has_tax").Bool()
symbol = gjson.Get(currencyConfig, "symbol").String() symbol = gjson.Get(currencyConfig, "symbol").String()
//自定义汇率优先级最高
customizeRateRmb := gjson.Get(currencyConfig, "customize_rate_rmb").Float()
customizeRateUsd := gjson.Get(currencyConfig, "customize_rate_usd").Float()
if customizeRateUsd != 0 {
for index, price := range sku.LadderPrice {
priceUs := price.PriceUs
priceUs = c.MyRound(c.MulFloat(priceUs, customizeRateUsd), 4)
if hasTax {
priceUs = c.MyRound(c.DivFloat(priceUs, 1.13), 4)
}
sku.LadderPrice[index].PriceUs = priceUs
sku.OriginalPrice[index].PriceUs = priceUs
}
}
if customizeRateRmb != 0 {
//因为计算人民币价格的逻辑不在这里,所以记录下来,提供给计算人民币价格的逻辑
sku.CustomizeRateRMB = customizeRateRmb
}
if customizeRateUsd == 0 {
//这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要 //这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要
//先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率 //先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率
rmbRatio, _ := redis.Float64(redisCon.Do("HGET", "erp_rate", currency)) rmbRatio, _ := redis.Float64(redisCon.Do("HGET", "erp_rate", currency))
...@@ -680,6 +702,8 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS ...@@ -680,6 +702,8 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
sku.OriginalPrice[index].PriceUs = priceUs sku.OriginalPrice[index].PriceUs = priceUs
} }
} }
}
sku.OriginCurrencySymbol = symbol sku.OriginCurrencySymbol = symbol
return sku return sku
} }
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