Commit 9bfa6db8 by mushishixian

返回更多额外的信息

parent 434aa3a2
Showing with 26 additions and 9 deletions
......@@ -72,6 +72,19 @@ type LySku struct {
GoodsTag GoodsTag `json:"goods_tag"`
StockInfo interface{} `json:"stock_info"`
Eccn string `json:"eccn"`
DiscountRatio DiscountRatio `json:"discount_ratio"`
PriceRatioSort int `json:"price_ratio_sort"`
PriceRatio []PriceRatio `json:"price_ratio"`
}
type DiscountRatio struct {
Ratio float64 `json:"ratio"`
RatioUsd float64 `json:"ratio_usd"`
}
type PriceRatio struct {
Ratio float64 `json:"ratio"`
RatioUsd float64 `json:"ratio_usd"`
}
type PriceActivity struct {
......
......@@ -280,6 +280,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
cnDiscountRatio += 1
usDiscountRatio += 1
sku.DiscountRatio.Ratio = cnDiscountRatio
sku.DiscountRatio.RatioUsd = usDiscountRatio
//再去找售价组系数
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
......@@ -290,22 +292,21 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
isDefaultPriceRatio = true
priceRatioCache, _ = redis.String(redisCon.Do("GET", "magic_cube_price_rule_channel_default"))
}
type PriceRatio struct {
Ratio float64
RatioUsd float64
}
var priceRatioSort int
//这个就是最终要获取到的价格系数
var priceRatioList []PriceRatio
var priceRatioList []model.PriceRatio
//如果只有默认系数,那么就去找默认系数
if isDefaultPriceRatio {
priceRatioArr := gjson.Get(priceRatioCache, "ladder_price").Array()
for _, value := range priceRatioArr {
priceRatioList = nil
var priceRatio PriceRatio
var priceRatio model.PriceRatio
priceRatio.Ratio = gjson.Get(value.String(), "ratio").Float()
priceRatio.RatioUsd = gjson.Get(value.String(), "ratio_usd").Float()
priceRatioList = append(priceRatioList, priceRatio)
}
priceRatioSort = -1
} else {
//拿到系数以后,就要去计算
//拿出里面的所有排序
......@@ -319,11 +320,12 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sortNumbers = sorter.IntSliceSortDesc(sortNumbers)
//确定排序以后,就可以进行按排序(从大到小)取系数
for _, sortNumber := range sortNumbers {
priceRatioSort = sortNumber
priceRatioList = nil
sortString := strconv.Itoa(sortNumber)
priceRatioArr := gjson.Get(priceRatioCache, "ladder_price."+sortString).Array()
for _, value := range priceRatioArr {
var priceRatio PriceRatio
var priceRatio model.PriceRatio
priceRatio.Ratio = gjson.Get(value.String(), "ratio").Float()
priceRatio.RatioUsd = gjson.Get(value.String(), "ratio_usd").Float()
priceRatioList = append(priceRatioList, priceRatio)
......@@ -358,6 +360,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
}
sku.PriceRatio = priceRatioList
sku.PriceRatioSort = priceRatioSort
//这里是供应商系数,先保留这块逻辑
ratio, _ := redis.String(redisCon.Do("HGET", "pool_supplier_ratio", sku.SupplierId))
......@@ -422,11 +426,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data[key].Purchases = price.Purchases
//找出对应的阶梯,从$priceRatioList找到对应的售价组系数
//这个是为了怕后台存的数据格式不对导致无法获取到对应的系数
var priceRatio PriceRatio
var priceRatio model.PriceRatio
if len(priceRatioList) > key {
priceRatio = priceRatioList[key]
} else {
priceRatio = PriceRatio{
priceRatio = model.PriceRatio{
Ratio: 1,
RatioUsd: 1,
}
......
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