Commit e0717e04 by 杨树贤

Merge branch 'ysx-特殊币种自定义汇率-20231129' into dev

parents 996804f0 d0f2e6bf
......@@ -81,6 +81,8 @@ type LySku struct {
PriceRatio []PriceRatio `json:"price_ratio"`
Source int `json:"source"`
OriginCurrencySymbol string `json:"origin_currency_symbol,omitempty"`
CustomizeRateRMB float64
CustomizeRateUs float64
}
type DiscountRatio struct {
......
......@@ -66,6 +66,11 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku = ls.GetGoodsImages(sku, spu)
sku = ls.GetPdf(sku, spu)
//todo 2023.11.20 DGK商品的包装若为“Tape & Reel (TR)”,则递增量=起订量
if sku.SupplierId == 7 && sku.Packing == "Tape & Reel (TR)"{
sku.Multiple = sku.Moq
}
//获取商品名称
//1688就是mro的sku spuName和GoodsName不是一个东西,不能公用
if sku.GoodsName != "" && sku.SupplierId == 1688 {
......
......@@ -266,7 +266,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
return sku
}
priceService := PriceService{}
//flag := 0
flag := 0
var data []model.LadderPrice
var originalPrice []model.OriginPrice
sort.Sort(sorter.OriginPriceSorter(sku.OriginalPrice))
......@@ -314,7 +314,19 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//联营或者专卖 同时 存在活动价格
if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
if sku.Ratio == 100 {
sku.AcType = 0
continue
}
tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, sku.Ratio/100), 4)
//价格与原价一样
if data[key].PriceCn == tempAcPrice && key < 2 {
flag++
if flag >= 2 || (len(ladderPrice) < 2) {
sku.AcType = 0
continue
}
}
data[key].PriceAc = tempAcPrice
priceAcUs := c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 4)
data[key].PriceAcUs = priceAcUs
......@@ -323,13 +335,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if tempAcPrice <= 0 && priceAcUs <= 0 {
sku.AcType = 0
}
//价格与原价一样
//if data[key].PriceCn == tempAcPrice && key < 2 {
// flag++
// if flag >= 2 || (len(ladderPrice) < 2) {
// sku.AcType = 0
// }
//}
}
}
} else {
......@@ -445,7 +451,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if sku.SupplierId == 1688 {
priceCostCn = c.MulFloat(price.PriceCn, 1)
} 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(c.MyRound(priceCostCn, 4), sku.DiscountRatio.Ratio)
......@@ -464,7 +476,30 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sku.PriceRatio = showPriceRatioList
//处理活动价和原价相同的情况
if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
if sku.Ratio == 100 {
sku.AcType = 0
continue
}
priceAc := c.MyRound(c.MulFloat(data[key].PriceCn, (sku.Ratio/100)), 4)
//为什么$kp < 2,如果第一阶梯或第二阶梯价格和活动价一样,就不输出活动价了
//活动价都是有样式的和平时不一样,如果价格一样,但是样子是活动价,客户会迷惑,所以不输出即可,保持原来的样式
if data[key].PriceCn == priceAc && key < 2 {
flag++
if flag >= 2 {
sku.AcType = 0
continue
}
if len(data) > 1 {
if data[1].PriceCn == 0 {
sku.AcType = 0
continue
}
}
}
data[key].PriceAc = priceAc
var priceAcUs float64
if sku.RatioUs > 0 {
......@@ -481,19 +516,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sku.AcType = 0
}
}
//为什么$kp < 2,如果第一阶梯或第二阶梯价格和活动价一样,就不输出活动价了
//活动价都是有样式的和平时不一样,如果价格一样,但是样子是活动价,客户会迷惑,所以不输出即可,保持原来的样式
//if data[key].PriceCn == priceAc && key < 2 {
// flag++
// if flag >= 2 {
// sku.AcType = 0
// }
// if len(data) > 1 {
// if data[1].PriceCn == 0 {
// sku.AcType = 0
// }
// }
//}
}
}
//判断原始价格有变化,那就要覆盖
......
......@@ -663,22 +663,46 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
}
hasTax = gjson.Get(currencyConfig, "has_tax").Bool()
symbol = gjson.Get(currencyConfig, "symbol").String()
//这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要
//先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率
rmbRatio, _ := redis.Float64(redisCon.Do("HGET", "erp_rate", currency))
//fmt.Println("特殊转换", rmbRatio)
//fmt.Println(rmbRatio, usRatio)
//人民币汇率转美金汇率
usRatio = c.MyRound(c.DivFloat(rmbRatio, usRatio), 10)
for index, price := range sku.LadderPrice {
priceUs := price.PriceUs
priceUs = c.MyRound(c.MulFloat(priceUs, usRatio), 4)
if hasTax {
priceUs = c.MyRound(c.DivFloat(priceUs, 1.13), 4)
//自定义汇率优先级最高
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
}
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))
//fmt.Println("特殊转换", rmbRatio)
//fmt.Println(rmbRatio, usRatio)
//人民币汇率转美金汇率
usRatio = c.MyRound(c.DivFloat(rmbRatio, usRatio), 10)
for index, price := range sku.LadderPrice {
priceUs := price.PriceUs
priceUs = c.MyRound(c.MulFloat(priceUs, usRatio), 4)
if hasTax {
priceUs = c.MyRound(c.DivFloat(priceUs, 1.13), 4)
}
sku.LadderPrice[index].PriceUs = priceUs
sku.OriginalPrice[index].PriceUs = priceUs
}
}
}
sku.OriginCurrencySymbol = symbol
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