Commit 7b141454 by 杨树贤

特殊供应商人民币是否含税并且展示数据库价格

parent 94765a4c
......@@ -40,7 +40,9 @@ type LySku struct {
BrandId int64 `json:"brand_id"`
//系数相关
Coefficient interface{} `json:"coefficient,omitempty"`
Original interface{} `json:"original_price,omitempty"`
OriginalPrice interface{} `json:"original_price,omitempty"`
//数据库存的价格,因为数据库存的是什么币种都有可能,但是也要展示数据库存的,所以要有这个字段
DatabasePrice interface{} `json:"database_price,omitempty"`
SuppExtendFee interface{} `json:"supp_extend_fee"`
IsBuy int `json:"is_buy"`
//spu信息
......@@ -230,7 +232,7 @@ func InitSkuData(sku string) (data LySku) {
LadderPriceStr := gjson.Get(sku, "ladder_price").String()
data.LadderPrice = getLadderPrice(LadderPriceStr)
data.Original = getOriginPrice(LadderPriceStr)
data.OriginalPrice = getOriginPrice(LadderPriceStr)
return
}
......
......@@ -283,8 +283,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sku = priceService.GetDiscountRatio(sku)
data = make([]model.LadderPrice, len(ladderPrice))
sku = priceService.TransformSpecialSupplierPrice(sku)
for key, price := range ladderPrice {
price.PriceUs = priceService.TransformSpecialSupplierPrice(sku, price.PriceUs)
if price.Purchases == 0 {
continue
}
......@@ -392,11 +392,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
tax := 1.13
sku = priceService.TransformSpecialSupplierPrice(sku)
var showPriceRatioList []model.PriceRatio
for key, price := range sku.LadderPrice {
//这里有个前置条件处理美金价,因为element(6)存到美金字段里面的是港币,rs(21)存到美金字段里的是人民币,buerklin(1676)是欧元
//所以要全部先转成正确的美金价才能显示,目前先写死汇率,因为目前没有地方能获取实时的各种转美金的汇率
price.PriceUs = priceService.TransformSpecialSupplierPrice(sku, price.PriceUs)
originalPrice = append(originalPrice, model.OriginPrice{
PriceUs: price.PriceUs,
Purchases: price.Purchases,
......@@ -491,7 +491,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
//判断原始价格有变化,那就要覆盖
if len(originalPrice) > 0 {
sku.Original = originalPrice
sku.OriginalPrice = originalPrice
}
//输出税费到前端
......
......@@ -639,7 +639,7 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
// 这里有个前置条件处理美金价,因为element(6)存到美金字段里面的是港币,rs(21)存到美金字段里的是人民币,buerklin(1676)是欧元
// 所以要全部先转成正确的美金价才能显示
func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku, priceUs float64) float64 {
func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LySku {
//去redis获取价格
redisCon := gredis.Conn("default_r")
defer func() {
......@@ -647,22 +647,37 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku, priceUs f
}()
usRatio, _ := redis.Float64(redisCon.Do("HGET", "erp_rate", 2))
var currency int
var currencyConfig string
if sku.SupplierId != 17 {
currency, _ = redis.Int(redisCon.Do("HGET", "magic_cube_supplier_currency", sku.SupplierId))
currencyConfig, _ = redis.String(redisCon.Do("HGET", "magic_cube_supplier_currency", sku.SupplierId))
} else {
currency, _ = redis.Int(redisCon.Do("HGET", "magic_cube_supplier_currency", sku.Canal))
currencyConfig, _ = redis.String(redisCon.Do("HGET", "magic_cube_supplier_currency", sku.Canal))
}
//fmt.Println("进来的美金价格:", priceUs)
if currency > 0 {
hasTax := false
if currencyConfig != "" {
sku.DatabasePrice = sku.OriginalPrice
currency = int(gjson.Get(currencyConfig, "currency").Int())
if currency == 0 {
return sku
}
hasTax = gjson.Get(currencyConfig, "has_tax").Bool()
//这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要
//先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率
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
}
return priceUs
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