Commit 434aa3a2 by mushishixian

价格修改

parent dd0c2dac
...@@ -15,6 +15,7 @@ type Activity struct { ...@@ -15,6 +15,7 @@ type Activity struct {
Canals string `json:"canals"` Canals string `json:"canals"`
CanalList []string CanalList []string
Ratio float64 `json:"ratio"` Ratio float64 `json:"ratio"`
RatioUs float64 `json:"ratio_us"`
StartTime int `json:"start_time"` StartTime int `json:"start_time"`
EndTime int `json:"end_time"` EndTime int `json:"end_time"`
AddTime int `json:"add_time"` AddTime int `json:"add_time"`
......
...@@ -6,12 +6,16 @@ type LyResponse struct { ...@@ -6,12 +6,16 @@ type LyResponse struct {
ErrorMsg string `json:"error_msg"` ErrorMsg string `json:"error_msg"`
Data interface{} `json:"data"` Data interface{} `json:"data"`
} }
//原始sku梯度 //原始sku梯度
type LadderPrice struct { type LadderPrice struct {
Purchases int64 `json:"purchases"` //购买数量 Purchases int64 `json:"purchases"` //购买数量
PriceUs float64 `json:"price_us,omitempty"` //数量对应的英文价格 PriceUs float64 `json:"price_us,omitempty"` //数量对应的英文价格
PriceCn float64 `json:"price_cn"` //数量对应的中文价格 PriceCn float64 `json:"price_cn"` //数量对应的中文价格
PriceAc float64 `json:"price_ac,omitempty"` PriceCostUs float64 `json:"price_cost_us"` //成本价美金
PriceCostCn float64 `json:"price_cost_cn"` //成本价人民币
PriceAc float64 `json:"price_ac,omitempty"` //活动价人民币
PriceAcUs float64 `json:"price_ac_us"` //活动价美金
CostPrice float64 `json:"-"` CostPrice float64 `json:"-"`
} }
......
...@@ -60,6 +60,7 @@ type LySku struct { ...@@ -60,6 +60,7 @@ type LySku struct {
ClassName2 string `json:"class_name2,omitempty"` ClassName2 string `json:"class_name2,omitempty"`
ClassName3 string `json:"class_name3,omitempty"` ClassName3 string `json:"class_name3,omitempty"`
Ratio float64 `json:"ratio,omitempty"` Ratio float64 `json:"ratio,omitempty"`
RatioUs float64 `json:"ratio_us,omitempty"`
SpuDetail string `json:"spu_detail,omitempty"` SpuDetail string `json:"spu_detail,omitempty"`
AcType int `json:"ac_type"` AcType int `json:"ac_type"`
...@@ -76,6 +77,7 @@ type LySku struct { ...@@ -76,6 +77,7 @@ type LySku struct {
type PriceActivity struct { type PriceActivity struct {
ActivityCommon ActivityCommon
Ratio float64 `json:"ratio,omitempty"` Ratio float64 `json:"ratio,omitempty"`
RatioUs float64 `json:"ratio_us,omitempty"`
SignText string `json:"sign_text,omitempty"` SignText string `json:"sign_text,omitempty"`
Sign string `json:"sign,omitempty"` Sign string `json:"sign,omitempty"`
ShowName string `json:"show_name,omitempty"` ShowName string `json:"show_name,omitempty"`
......
...@@ -198,6 +198,11 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a ...@@ -198,6 +198,11 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
UserScope: activity.UserScope, UserScope: activity.UserScope,
}, },
} }
if activity.RatioUs > 0 {
priceActivity.RatioUs = activity.RatioUs
} else {
priceActivity.RatioUs = 1
}
break break
} }
} }
......
...@@ -133,6 +133,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -133,6 +133,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.AllowCoupon = 1 sku.AllowCoupon = 1
sku.BrandId = brandId sku.BrandId = brandId
//这里获取活动价格和活动类型
sku = ls.GetActivity(sku) sku = ls.GetActivity(sku)
//处理阶梯价数据 //处理阶梯价数据
...@@ -146,7 +147,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -146,7 +147,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
} }
} }
//获取系数 //获取系数
sku = ls.GetCoefficient(sku) sku = ls.GetCoefficientAndPrice(sku)
//仅提供价格和库存 //仅提供价格和库存
if fast != "1" { if fast != "1" {
...@@ -215,6 +216,8 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku { ...@@ -215,6 +216,8 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
if priceActivity.HasActivity { if priceActivity.HasActivity {
sku.AcType = 10 sku.AcType = 10
sku.Ratio = priceActivity.Ratio sku.Ratio = priceActivity.Ratio
sku.RatioUs = priceActivity.RatioUs
sku.ActivityInfo = priceActivity sku.ActivityInfo = priceActivity
} }
if giftActivity.HasActivity { if giftActivity.HasActivity {
......
...@@ -182,7 +182,7 @@ func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} { ...@@ -182,7 +182,7 @@ func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} {
} }
//获取系数 //获取系数
func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku { func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if len(sku.LadderPrice) == 0 { if len(sku.LadderPrice) == 0 {
sku.Original = nil sku.Original = nil
return sku return sku
...@@ -225,7 +225,7 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku { ...@@ -225,7 +225,7 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
//先去读取渠道折扣 //先去读取成本折扣系数
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的 //找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
isDefaultDiscoutRatio := false isDefaultDiscoutRatio := false
discountRatio, _ := redis.String(redisCon.Do("HGET", "magic_cube_channel_discount_daigou", sku.SupplierId)) discountRatio, _ := redis.String(redisCon.Do("HGET", "magic_cube_channel_discount_daigou", sku.SupplierId))
...@@ -236,7 +236,7 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku { ...@@ -236,7 +236,7 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
} }
var cnDiscountRatio float64 var cnDiscountRatio float64
var usDiscountRatio float64 var usDiscountRatio float64
//如果有默认系数,那么就去找默认系数 //如果有默认系数,那么就去找默认系数
if isDefaultDiscoutRatio { if isDefaultDiscoutRatio {
cnDiscountRatio = gjson.Get(discountRatio, "ration").Float() cnDiscountRatio = gjson.Get(discountRatio, "ration").Float()
usDiscountRatio = gjson.Get(discountRatio, "ration_usd").Float() usDiscountRatio = gjson.Get(discountRatio, "ration_usd").Float()
...@@ -358,7 +358,6 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku { ...@@ -358,7 +358,6 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
} }
} }
} }
fmt.Print(priceRatioList)
//这里是供应商系数,先保留这块逻辑 //这里是供应商系数,先保留这块逻辑
ratio, _ := redis.String(redisCon.Do("HGET", "pool_supplier_ratio", sku.SupplierId)) ratio, _ := redis.String(redisCon.Do("HGET", "pool_supplier_ratio", sku.SupplierId))
...@@ -366,7 +365,6 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku { ...@@ -366,7 +365,6 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
logger.Select("sku_query").Error("系数获取异常,供应商:" + common.ToString(sku.SupplierId)) logger.Select("sku_query").Error("系数获取异常,供应商:" + common.ToString(sku.SupplierId))
return sku return sku
} }
ratios := gjson.Parse(ratio).Array() ratios := gjson.Parse(ratio).Array()
var defaultCoefficient, coefficient model.Coefficient var defaultCoefficient, coefficient model.Coefficient
var hasDefault, hasCoefficient bool var hasDefault, hasCoefficient bool
...@@ -408,12 +406,12 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku { ...@@ -408,12 +406,12 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
logger.Select("sku_query").Error("系数获取异常,供应商:" + common.ToString(sku.SupplierId)) logger.Select("sku_query").Error("系数获取异常,供应商:" + common.ToString(sku.SupplierId))
return sku return sku
} }
if !hasCoefficient { if !hasCoefficient {
coefficient = defaultCoefficient coefficient = defaultCoefficient
} }
//下面是计算价格 //下面是计算价格
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可 // 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
//$tax = config('website.tax'); //$tax = config('website.tax');
tax := 1.13 tax := 1.13
...@@ -422,10 +420,31 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku { ...@@ -422,10 +420,31 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
continue continue
} }
data[key].Purchases = price.Purchases data[key].Purchases = price.Purchases
//根据系数处理美金 //找出对应的阶梯,从$priceRatioList找到对应的售价组系数
data[key].PriceUs = common.MyRound(price.PriceUs*coefficient.ExtraRatio*coefficient.Hk, 4) //这个是为了怕后台存的数据格式不对导致无法获取到对应的系数
var priceRatio PriceRatio
if len(priceRatioList) > key {
priceRatio = priceRatioList[key]
} else {
priceRatio = PriceRatio{
Ratio: 1,
RatioUsd: 1,
}
}
//美金成本价
priceCostUs := price.PriceUs * usDiscountRatio
//美金售价
priceUs := priceCostUs * priceRatio.RatioUsd
//人民币成本价
priceCostCn := price.PriceUs * coefficient.Ratio * cnDiscountRatio
//人民币售价
priceCn := priceCostCn * priceRatio.Ratio * tax
data[key].PriceUs = common.MyRound(priceUs, 4)
data[key].PriceCostUs = common.MyRound(priceCostUs, 4)
//处理人民币 //处理人民币
data[key].PriceCn = common.MyRound(price.PriceUs*coefficient.ExtraRatio*coefficient.Cn*coefficient.Ratio*tax, 4) data[key].PriceCn = common.MyRound(priceCn, 4)
data[key].PriceCostCn = common.MyRound(priceCostCn, 4)
fmt.Println(data[key])
//处理mouser的成本价 //处理mouser的成本价
//mouser成本价是什么,斌哥同步过来的成本价 //mouser成本价是什么,斌哥同步过来的成本价
//sku.LadderPrice[key].CostPrice是专门针对贸泽(mouser)的 //sku.LadderPrice[key].CostPrice是专门针对贸泽(mouser)的
...@@ -443,6 +462,8 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku { ...@@ -443,6 +462,8 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
if (sku.GoodsType == 1 || sku.GoodsType == 2) && sku.AcType > 1 && sku.Ratio > 0 { if (sku.GoodsType == 1 || sku.GoodsType == 2) && sku.AcType > 1 && sku.Ratio > 0 {
priceAc := common.MyRound(data[key].PriceCn*(sku.Ratio/100), 4) priceAc := common.MyRound(data[key].PriceCn*(sku.Ratio/100), 4)
data[key].PriceAc = priceAc data[key].PriceAc = priceAc
priceAcUs := common.MyRound(data[key].PriceCn*(sku.RatioUs/100), 4)
data[key].PriceAcUs = priceAcUs
if priceAc <= 0 { if priceAc <= 0 {
sku.AcType = 0 sku.AcType = 0
......
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