Commit 77e2a838 by mushishixian

修复价格获取的问题

parent 9d0b9c9e
......@@ -45,6 +45,7 @@ require (
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
github.com/shopspring/decimal v1.0.1
)
......
......@@ -38,6 +38,10 @@ type Activity struct {
ActivityId int `json:"activity_id"`
ItemList []ActivityItem `json:"item_list"`
EntireSupplierActivity bool `json:"entire_supplier_activity"`
StandardBrandIds string `json:"standard_brand_ids"`
StandardBrandIdList []string
ExcludeStandardBrandIds string `json:"exclude_standard_brand_ids"`
ExcludeStandardBrandIdList []string
}
type ActivityItem struct {
......@@ -56,6 +60,7 @@ type ActivityItem struct {
type ActivityCheckData struct {
SupplierId int
BrandId int
StandardBrandId int
GoodsId string
Canal string
ClassId int
......
......@@ -21,21 +21,8 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p
supplierId := checkData.SupplierId
redisCon := gredis.Conn("default_r")
defer redisCon.Close()
//处理满赠活动
activityStr, _ := redis.String(redisCon.Do("hget", "lie_gift_activity", supplierId))
if activityStr != "" {
var activities []model.Activity
err := json.Unmarshal([]byte(activityStr), &activities)
if err != nil {
fmt.Println(err)
}
if len(activities) != 0 {
giftActivity = as.GetGiftActivity(checkData, activities)
}
}
//处理单品促销活动(打折活动)
activityStr, _ = redis.String(redisCon.Do("hget", "lie_price_activity", supplierId))
activityStr, _ := redis.String(redisCon.Do("hget", "lie_price_activity", supplierId))
if activityStr != "" {
var activities []model.Activity
err := json.Unmarshal([]byte(activityStr), &activities)
......@@ -135,7 +122,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
}
//判断是否是排除的sku或者品牌,如果是的话,直接返回没活动
if as.CheckExcludeSku(checkData.GoodsId, activity) || as.CheckExcludeBrand(checkData.BrandId, activity) {
if as.CheckExcludeSku(checkData.GoodsId, activity) || as.CheckExcludeStandardBrand(checkData.StandardBrandId, activity) {
continue
}
......@@ -145,7 +132,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
//品牌不为空,还要去判断品牌,是同时满足的关系
if activity.BrandIds != "" {
//判断是否是搞活动的品牌
if as.CheckBrand(checkData.BrandId, activity) {
if as.CheckStandardBrand(checkData.StandardBrandId, activity) {
hasActivity = true
goto INFO
}
......@@ -165,7 +152,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
//品牌不为空,还要去判断品牌,是同时满足的关系
if activity.BrandIds != "" {
//判断是否是搞活动的品牌
if as.CheckBrand(checkData.BrandId, activity) {
if as.CheckStandardBrand(checkData.StandardBrandId, activity) {
hasActivity = true
goto INFO
}
......@@ -175,8 +162,9 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
}
}
} else {
fmt.Println(activity)
//判断是否是搞活动的品牌
if as.CheckBrand(checkData.BrandId, activity) {
if as.CheckStandardBrand(checkData.StandardBrandId, activity) {
hasActivity = true
goto INFO
}
......@@ -226,6 +214,21 @@ func (as *ActivityService) CheckExcludeBrand(brandId int, activity model.Activit
return false
}
//检查是否属于被排除的标准品牌
func (as *ActivityService) CheckExcludeStandardBrand(standardBrandId int, activity model.Activity) bool {
if standardBrandId == 0 {
return false
}
//先去判断品牌
activity.ExcludeStandardBrandIdList = strings.Split(activity.ExcludeStandardBrandIds, ",")
standardBrandIdStr := gconv.String(standardBrandId)
//如果存在于有活动价的品牌,就是有折扣活动了
if php2go.InArray(standardBrandIdStr, activity.ExcludeStandardBrandIdList) {
return true
}
return false
}
//检查是否属于被排除的sku
func (as *ActivityService) CheckExcludeSku(skuId string, activity model.Activity) bool {
if skuId == "" {
......@@ -270,6 +273,21 @@ func (as *ActivityService) CheckBrand(brandId int, activity model.Activity) bool
return false
}
//检测是否属于活动标准品牌
func (as *ActivityService) CheckStandardBrand(standardBrandId int, activity model.Activity) bool {
if standardBrandId == 0 {
return false
}
//先去判断品牌
activity.StandardBrandIdList = strings.Split(activity.StandardBrandIds, ",")
standardBrandIdStr := gconv.String(standardBrandId)
//如果存在于有活动价的品牌,就是有折扣活动了
if php2go.InArray(standardBrandIdStr, activity.StandardBrandIdList) {
return true
}
return false
}
//检查是否属于供应商渠道
func (as *ActivityService) CheckCanal(canal string, activity model.Activity) bool {
if canal == "" {
......
......@@ -207,6 +207,7 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
checkData := model.ActivityCheckData{
SupplierId: int(sku.SupplierId),
BrandId: int(sku.BrandId),
StandardBrandId: int(sku.StandardBrand.StandardBrandId),
GoodsId: sku.GoodsId,
Canal: sku.Canal,
ClassId: sku.ClassID2,
......
......@@ -278,10 +278,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
cnDiscountRatio += 1
usDiscountRatio += 1
cnDiscountRatio = common.MyRound(cnDiscountRatio+1, 3)
usDiscountRatio = common.MyRound(usDiscountRatio+1, 3)
sku.DiscountRatio.Ratio = cnDiscountRatio
sku.DiscountRatio.RatioUsd = usDiscountRatio
fmt.Println("折扣系数 : ", cnDiscountRatio, usDiscountRatio)
//再去找售价组系数
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
......@@ -362,6 +363,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
sku.PriceRatio = priceRatioList
sku.PriceRatioSort = priceRatioSort
fmt.Println("售价组系数 : ", priceRatioList)
//这里是供应商系数,先保留这块逻辑
ratio, _ := redis.String(redisCon.Do("HGET", "pool_supplier_ratio", sku.SupplierId))
......@@ -414,6 +416,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
coefficient = defaultCoefficient
}
fmt.Println("供应商系数 : ", coefficient)
//下面是计算价格
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
......@@ -448,7 +452,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//处理人民币
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)的
......@@ -461,7 +464,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
continue
}
//处理活动价和原价相同的情况
if (sku.GoodsType == 1 || sku.GoodsType == 2) && sku.AcType > 1 && sku.Ratio > 0 {
priceAc := common.MyRound(data[key].PriceCn*(sku.Ratio/100), 4)
......
......@@ -53,6 +53,7 @@ func (qs *ZiyingService) GetActivity(skuInfo string) (priceActivity model.PriceA
checkData := model.ActivityCheckData{
SupplierId: 10000,
BrandId: int(gjson.Get(skuInfo, "brand_id").Int()),
StandardBrandId: int(gjson.Get(skuInfo, "standard_brand.standard_brand_id").Int()),
GoodsId: gjson.Get(skuInfo, "goods_id").String(),
ClassId: int(gjson.Get(skuInfo, "class_id2").Int()),
}
......
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