Commit 434aa3a2 by mushishixian

价格修改

parent dd0c2dac
......@@ -4,17 +4,18 @@ type Activity struct {
Id int64 `json:"id"`
SupplierIds string `json:"supplier_ids"`
SupplierIdList []string
SupplierType int `json:"supplier_type"`
UserScope int `json:"user_scope"`
CanAdminOrder interface{} `json:"can_admin_order"`
SignText string `json:"sign_text"`
BrandIds string `json:"brand_ids"`
SupplierType int `json:"supplier_type"`
UserScope int `json:"user_scope"`
CanAdminOrder interface{} `json:"can_admin_order"`
SignText string `json:"sign_text"`
BrandIds string `json:"brand_ids"`
BrandIdList []string
ClassIds string `json:"class_ids"`
ClassIdList []string
Canals string `json:"canals"`
CanalList []string
Ratio float64 `json:"ratio"`
RatioUs float64 `json:"ratio_us"`
StartTime int `json:"start_time"`
EndTime int `json:"end_time"`
AddTime int `json:"add_time"`
......
......@@ -2,21 +2,25 @@ package model
//联营统一返回格式
type LyResponse struct {
ErrorCode int `json:"error_code"`
ErrorMsg string `json:"error_msg"`
Data interface{} `json:"data"`
ErrorCode int `json:"error_code"`
ErrorMsg string `json:"error_msg"`
Data interface{} `json:"data"`
}
//原始sku梯度
type LadderPrice struct {
Purchases int64 `json:"purchases"` //购买数量
PriceUs float64 `json:"price_us,omitempty"` //数量对应的英文价格
PriceCn float64 `json:"price_cn"` //数量对应的中文价格
PriceAc float64 `json:"price_ac,omitempty"`
CostPrice float64 `json:"-"`
Purchases int64 `json:"purchases"` //购买数量
PriceUs float64 `json:"price_us,omitempty"` //数量对应的英文价格
PriceCn float64 `json:"price_cn"` //数量对应的中文价格
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:"-"`
}
type OriginPrice struct {
Purchases int64 `json:"purchases"` //购买数量
Purchases int64 `json:"purchases"` //购买数量
PriceUs float64 `json:"price_us"` //数量对应的英文价格
PriceCn float64 `json:"price_cn"` //数量对应的中文价格
PriceAc float64 `json:"price_ac,omitempty"`
......@@ -25,12 +29,12 @@ type OriginPrice struct {
//立创价格梯度
type LadderPriceLc struct {
Purchases int64 `json:"purchases"` //购买数量
Price float64 `json:"price"` //立创价格,人民币
Purchases int64 `json:"purchases"` //购买数量
Price float64 `json:"price"` //立创价格,人民币
}
//自营属性列表
type Attrs struct {
AttrName string `json:"attr_name"` //属性名称
AttrValue string `json:"attr_value"` //属性值
}
\ No newline at end of file
AttrName string `json:"attr_name"` //属性名称
AttrValue string `json:"attr_value"` //属性值
}
......@@ -60,6 +60,7 @@ type LySku struct {
ClassName2 string `json:"class_name2,omitempty"`
ClassName3 string `json:"class_name3,omitempty"`
Ratio float64 `json:"ratio,omitempty"`
RatioUs float64 `json:"ratio_us,omitempty"`
SpuDetail string `json:"spu_detail,omitempty"`
AcType int `json:"ac_type"`
......@@ -76,6 +77,7 @@ type LySku struct {
type PriceActivity struct {
ActivityCommon
Ratio float64 `json:"ratio,omitempty"`
RatioUs float64 `json:"ratio_us,omitempty"`
SignText string `json:"sign_text,omitempty"`
Sign string `json:"sign,omitempty"`
ShowName string `json:"show_name,omitempty"`
......
......@@ -198,6 +198,11 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
UserScope: activity.UserScope,
},
}
if activity.RatioUs > 0 {
priceActivity.RatioUs = activity.RatioUs
} else {
priceActivity.RatioUs = 1
}
break
}
}
......
......@@ -133,6 +133,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.AllowCoupon = 1
sku.BrandId = brandId
//这里获取活动价格和活动类型
sku = ls.GetActivity(sku)
//处理阶梯价数据
......@@ -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" {
......@@ -215,6 +216,8 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
if priceActivity.HasActivity {
sku.AcType = 10
sku.Ratio = priceActivity.Ratio
sku.RatioUs = priceActivity.RatioUs
sku.ActivityInfo = priceActivity
}
if giftActivity.HasActivity {
......
......@@ -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 {
sku.Original = nil
return sku
......@@ -225,7 +225,7 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
redisCon := gredis.Conn("default_r")
defer redisCon.Close()
//先去读取渠道折扣
//先去读取成本折扣系数
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
isDefaultDiscoutRatio := false
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 {
}
var cnDiscountRatio float64
var usDiscountRatio float64
//如果有默认系数,那么就去找默认系数
//如果有默认系数,那么就去找默认系数
if isDefaultDiscoutRatio {
cnDiscountRatio = gjson.Get(discountRatio, "ration").Float()
usDiscountRatio = gjson.Get(discountRatio, "ration_usd").Float()
......@@ -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))
......@@ -366,7 +365,6 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
logger.Select("sku_query").Error("系数获取异常,供应商:" + common.ToString(sku.SupplierId))
return sku
}
ratios := gjson.Parse(ratio).Array()
var defaultCoefficient, coefficient model.Coefficient
var hasDefault, hasCoefficient bool
......@@ -408,12 +406,12 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
logger.Select("sku_query").Error("系数获取异常,供应商:" + common.ToString(sku.SupplierId))
return sku
}
if !hasCoefficient {
coefficient = defaultCoefficient
}
//下面是计算价格
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
//$tax = config('website.tax');
tax := 1.13
......@@ -422,10 +420,31 @@ func (ls *LyService) GetCoefficient(sku model.LySku) model.LySku {
continue
}
data[key].Purchases = price.Purchases
//根据系数处理美金
data[key].PriceUs = common.MyRound(price.PriceUs*coefficient.ExtraRatio*coefficient.Hk, 4)
//找出对应的阶梯,从$priceRatioList找到对应的售价组系数
//这个是为了怕后台存的数据格式不对导致无法获取到对应的系数
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成本价是什么,斌哥同步过来的成本价
//sku.LadderPrice[key].CostPrice是专门针对贸泽(mouser)的
......@@ -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 {
priceAc := common.MyRound(data[key].PriceCn*(sku.Ratio/100), 4)
data[key].PriceAc = priceAc
priceAcUs := common.MyRound(data[key].PriceCn*(sku.RatioUs/100), 4)
data[key].PriceAcUs = priceAcUs
if priceAc <= 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