Commit c1c3d29f by 杨树贤

数据库价格问题

parent 682bd95f
......@@ -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"` //购买数量
......
......@@ -236,6 +236,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
}
......@@ -280,3 +281,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
......
......@@ -653,7 +653,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 != "" {
......@@ -677,9 +676,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