Commit 5ac25511 by 杨树贤

temp

parent d46316c8
...@@ -41,6 +41,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -41,6 +41,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
redisConnSpu.Close() redisConnSpu.Close()
}() }()
//各种展示条件
//是否快速展示
fast := ctx.Request.FormValue("power[fast]") fast := ctx.Request.FormValue("power[fast]")
//是否展示属性 //是否展示属性
showAttr := ctx.Request.FormValue("show_attr") showAttr := ctx.Request.FormValue("show_attr")
...@@ -67,7 +69,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -67,7 +69,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku := model.InitSkuData(skuStr) sku := model.InitSkuData(skuStr)
sku.GoodsId = goodsId sku.GoodsId = goodsId
spu := spuList[sku.SpuId] spu := spuList[sku.SpuId]
//读取包装字段的缓存 //读取包装字段的缓存(分别是DGK,avnet,mro)
if sku.SupplierId == 7 || sku.SupplierId == 13 || sku.SupplierId == 1688 { if sku.SupplierId == 7 || sku.SupplierId == 13 || sku.SupplierId == 1688 {
//sku_raw_map哪里写入(成意写的) //sku_raw_map哪里写入(成意写的)
packing, _ := redis.String(redisConnSpu.Do("HGET", "sku_raw_map", goodsId)) packing, _ := redis.String(redisConnSpu.Do("HGET", "sku_raw_map", goodsId))
...@@ -94,6 +96,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -94,6 +96,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
brandId := gjson.Get(spu, "brand_id").Int() brandId := gjson.Get(spu, "brand_id").Int()
brandName, _ := redis.String(redisConn.Do("HGET", "brand", brandId)) brandName, _ := redis.String(redisConn.Do("HGET", "brand", brandId))
sku.BrandName = brandName sku.BrandName = brandName
sku.BrandId = brandId
//判断是否要取精简信息 //判断是否要取精简信息
if fast != "1" { if fast != "1" {
...@@ -150,7 +153,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -150,7 +153,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//处理活动 //处理活动
sku.AcType = 0 sku.AcType = 0
sku.AllowCoupon = 1 sku.AllowCoupon = 1
sku.BrandId = brandId
//这里获取活动价格和活动类型 //这里获取活动价格和活动类型
sku = ls.GetActivity(sku) sku = ls.GetActivity(sku)
...@@ -169,16 +171,26 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -169,16 +171,26 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//这里又有一个判断,如果是非猎芯的,目前只有爱智,通过org_id来判断,如果是爱智,不需要走价格体系 //这里又有一个判断,如果是非猎芯的,目前只有爱智,通过org_id来判断,如果是爱智,不需要走价格体系
//1是猎芯,3是爱智 //1是猎芯,3是爱智
switch sku.OrgId { switch sku.OrgId {
//case为0是为了兼容价格体系之前的价格
case 0:
case 1: case 1:
case 3:
//如果是寄售的,也不走价格体系 //如果是寄售的,也不走价格体系
if sku.Source != 12 { if sku.Source != 12 {
//这里还有个特殊判断,要兼容华云改价格体系之前的老数据
//判断组织是3并且阶梯价数量为2的就是老数据
if sku.OrgId == 3 && len(sku.LadderPrice) == 2 {
priceService := PriceService{}
sku.LadderPrice = priceService.GetIEdgePrice(sku.LadderPrice)
}else{
//这里猎芯和华云都是走同一套的价格体系了
//获取系数和价格 //获取系数和价格
sku = ls.GetCoefficientAndPrice(sku) sku = ls.GetCoefficientAndPrice(sku)
} }
}
break break
case 3: default:
priceService := PriceService{}
sku.LadderPrice = priceService.GetIEdgePrice(sku.LadderPrice)
break break
} }
......
...@@ -287,18 +287,23 @@ func (ls *LyService) CombineSup(sku model.LySku, spuStr string) model.LySku { ...@@ -287,18 +287,23 @@ func (ls *LyService) CombineSup(sku model.LySku, spuStr string) model.LySku {
// 获取系数和总体价格,生成和处理价格的方法,很重要 // 获取系数和总体价格,生成和处理价格的方法,很重要
func (ls *LyService) GetCoefficientAndPrice(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
} }
priceService := PriceService{} priceService := PriceService{}
flag := 0 flag := 0
var data []model.LadderPrice var data []model.LadderPrice
var originalPrice []model.OriginPrice var originalPrice []model.OriginPrice
sort.Sort(sorter.OriginPriceSorter(sku.OriginalPrice)) sort.Sort(sorter.OriginPriceSorter(sku.OriginalPrice))
//专卖价格获取 //专卖价格获取
if sku.SupplierId == 17 { if sku.SupplierId == 17 {
ladderPrice := sku.LadderPrice ladderPrice := sku.LadderPrice
//这里是存了一些特殊供应商价格的判断,数据库里不是所有供应商都是存的人民币/美金
sku = priceService.TransformSpecialSupplierPrice(sku) sku = priceService.TransformSpecialSupplierPrice(sku)
//判断redis里面是否有成本价,有的话,那就直接去取价格,不需要生成阶梯价 //判断redis里面是否有成本价,有的话,那就直接去取价格,不需要生成阶梯价
//如果没有成本价字段,就要去生成阶梯价格 //如果没有成本价字段,就要去生成阶梯价格
...@@ -306,9 +311,9 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -306,9 +311,9 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if ladderPrice[0].PriceCostUs == 0 && ladderPrice[0].PriceCostCn == 0 { if ladderPrice[0].PriceCostUs == 0 && ladderPrice[0].PriceCostCn == 0 {
sku = priceService.GenerateLadderPrice(sku) sku = priceService.GenerateLadderPrice(sku)
ladderPrice = sku.LadderPrice ladderPrice = sku.LadderPrice
//fmt.Println(ladderPrice)
} }
} }
//获取折扣系数 //获取折扣系数
sku = priceService.GetDiscountRatio(sku) sku = priceService.GetDiscountRatio(sku)
data = make([]model.LadderPrice, len(ladderPrice)) data = make([]model.LadderPrice, len(ladderPrice))
......
package service package service
import ( import (
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go" "github.com/syyongx/php2go"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
...@@ -17,6 +18,7 @@ type PriceService struct { ...@@ -17,6 +18,7 @@ type PriceService struct {
} }
// 构建专营的阶梯价,现在专营只会存一个简单的成本价,阶梯数量是1,所以我这边要根据专营的阶梯系数去构建具体的阶梯价 // 构建专营的阶梯价,现在专营只会存一个简单的成本价,阶梯数量是1,所以我这边要根据专营的阶梯系数去构建具体的阶梯价
// 还要需要注意的一点是,价格体系改版后华云的sku,也会进入这个判断,毕竟华云的sku也是属于专营的
func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//需要展示的价格系数 //需要展示的价格系数
var showPriceRatioList []model.PriceRatio var showPriceRatioList []model.PriceRatio
...@@ -32,7 +34,13 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -32,7 +34,13 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
defer redisCon.Close() defer redisCon.Close()
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的 //找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
isDefaultPriceRatio := false isDefaultPriceRatio := false
priceRatioCache, _ := redis.String(redisCon.Do("HGET", "magic_cube_price_rule_v2", sku.Canal)) //这里很关键,因为华云也要兼容到猎芯的价格体系,所以缓存里面也有了华云的售价组,但是猎芯存的哈希对应的key是 供应商编码(L002323)
//而华云(或者以后的新组织),存的哈希对应的key是 供应商编码_组织ID (L00232_3)
ruleKey := sku.Canal
if sku.OrgId != 1 {
ruleKey = sku.Canal + "_" + gconv.String(sku.OrgId)
}
priceRatioCache, _ := redis.String(redisCon.Do("HGET", "magic_cube_price_rule_v2", ruleKey))
//判断是否是空 //判断是否是空
checkNullRation := gjson.Get(priceRatioCache, ratioDataKey).String() checkNullRation := gjson.Get(priceRatioCache, ratioDataKey).String()
//如果这个渠道没有对应的折扣系数,那么就去读取全局的 //如果这个渠道没有对应的折扣系数,那么就去读取全局的
...@@ -185,9 +193,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -185,9 +193,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
} }
//fmt.Println("最低利润点阶梯数 : ", ladderPriceMiniProfitLevel) //fmt.Println("最低利润点阶梯数 : ", ladderPriceMiniProfitLevel)
var generatedLadderPrice []model.LadderPrice var generatedLadderPrice []model.LadderPrice
//先直接获取成本价原始值,判断第一个阶梯的阶梯数量是否为0,如果是0,那么代表是要走成本价生成,如果不是0,那么就要走阶梯价生成 //先直接获取成本价原始值,判断第一个阶梯的阶梯数量是否为0,如果是0,那么代表是要走成本价生成,如果不是0,那么就要走阶梯价生成
firstLadderPurchases := sku.LadderPrice[0].Purchases firstLadderPurchases := sku.LadderPrice[0].Purchases
isCostPrice := bool(firstLadderPurchases == 0) isCostPrice := bool(firstLadderPurchases == 0)
//判断是否走成本价判断还是走阶梯价判断,因为上传sku的时候,可以设置每个sku的成本价(人民币&&美金),也可以设置每个sku的阶梯价 //判断是否走成本价判断还是走阶梯价判断,因为上传sku的时候,可以设置每个sku的成本价(人民币&&美金),也可以设置每个sku的阶梯价
//如果有阶梯价,就要跳过设置的成本价(假设有设置的话) //如果有阶梯价,就要跳过设置的成本价(假设有设置的话)
if isCostPrice { if isCostPrice {
...@@ -196,7 +206,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -196,7 +206,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
costPriceUs := sku.LadderPrice[0].PriceUs costPriceUs := sku.LadderPrice[0].PriceUs
//fmt.Println("人民币和美金的成本价分别为 : ", costPriceCn, costPriceUs) //fmt.Println("人民币和美金的成本价分别为 : ", costPriceCn, costPriceUs)
//先去判断起订量,如果起订量小于50,就要走固定配置的阶梯系数 //先去判断起订量,如果起订量小于50,就要走固定配置的阶梯系数
if sku.Moq <= 50 { if sku.Moq <= 50 && sku.OrgId == 1 {
moq := int(sku.Moq) moq := int(sku.Moq)
fixedRatio := make(map[int]float64) fixedRatio := make(map[int]float64)
//当起订量是小于等于50的时候,阶梯数量和阶梯数是固定的,但是具体的利润还是要去取配置的值,因为固定死的阶梯数量是5,所以这边要直接取魔方配置9个的后5个 //当起订量是小于等于50的时候,阶梯数量和阶梯数是固定的,但是具体的利润还是要去取配置的值,因为固定死的阶梯数量是5,所以这边要直接取魔方配置9个的后5个
......
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