Commit 76981993 by 杨树贤

Merge branch 'ysx-特殊币种人民币是否含税-20230828' into dev

parents 6475ae3e c1c3d29f
......@@ -27,6 +27,14 @@ type OriginPrice struct {
CostPrice float64 `json:"cost_price"`
}
type DatabasePrice struct {
Purchases int64 `json:"purchases"` //购买数量
PriceUs float64 `json:"price_us"` //数量对应的英文价格
PriceCn float64 `json:"price_cn"` //数量对应的中文价格
PriceAc float64 `json:"price_ac,omitempty"`
CostPrice float64 `json:"cost_price"`
}
// 立创价格梯度
type LadderPriceLc struct {
Purchases int64 `json:"purchases"` //购买数量
......
......@@ -237,6 +237,7 @@ func InitSkuData(sku string) (data LySku) {
LadderPriceStr := gjson.Get(sku, "ladder_price").String()
data.LadderPrice = getLadderPrice(LadderPriceStr)
data.OriginalPrice = getOriginPrice(LadderPriceStr)
data.DatabasePrice = getDatabasePrice(LadderPriceStr)
return
}
......@@ -281,3 +282,23 @@ func getOriginPrice(ladderPriceStr string) (ladderPrice []OriginPrice) {
return
}
// 获取原始价格
func getDatabasePrice(ladderPriceStr string) (ladderPrice []DatabasePrice) {
ladderPriceArr := gjson.Parse(ladderPriceStr).Array()
for _, price := range ladderPriceArr {
ladderPrice = append(ladderPrice, DatabasePrice{
Purchases: price.Get("purchases").Int(),
PriceUs: price.Get("price_us").Float(),
PriceCn: price.Get("price_cn").Float(),
PriceAc: price.Get("price_ac").Float(),
CostPrice: price.Get("cost_price").Float(),
})
}
if len(ladderPrice) == 0 {
ladderPrice = []DatabasePrice{}
return
}
return
}
......@@ -270,6 +270,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
var data []model.LadderPrice
var originalPrice []model.OriginPrice
sort.Sort(sorter.OriginPriceSorter(sku.OriginalPrice))
//专卖价格获取
if sku.SupplierId == 17 {
ladderPrice := sku.LadderPrice
......@@ -287,6 +288,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data = make([]model.LadderPrice, len(ladderPrice))
sku = priceService.TransformSpecialSupplierPrice(sku)
for key, price := range ladderPrice {
if price.Purchases == 0 {
continue
......
......@@ -655,7 +655,6 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
} else {
currencyConfig, _ = redis.String(redisCon.Do("HGET", "magic_cube_supplier_currency", sku.Canal))
}
sku.DatabasePrice = sku.OriginalPrice
hasTax := false
symbol := "$"
if currencyConfig != "" {
......@@ -679,9 +678,9 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
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