Commit a03eba7e by mushishixian

专营商品成本价构建逻辑

parent 9500c3c1
......@@ -52,7 +52,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
GoodsRes.Store(goodsId, false)
continue
}
//初始化有序map,拼接data 数据
//初始化有序map,拼接data数据,就是从redis取出初始数据
sku := model.InitSkuData(skuStr)
sku.GoodsId = goodsId
spu := spuList[sku.SpuId]
......@@ -65,7 +65,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku = ls.GetGoodsImages(sku, spu)
//pdf
pdf := gjson.Get(spu, "pdf").String()
// spuLargeImage := gjson.Get(spu, "images_l").String()
if pdf != "" {
pdf = strings.Replace(pdf, "http://img.ichunt.com", "https://img.ichunt.com", 1)
//还要针对如果是自己的上传服务的pdf文件,还要补上类型用于预览
......@@ -75,12 +74,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.Pdf = pdf
}
//处理分类
//fast的参数含义,为了节省开销性能的参数,传1就不会去分类这些参数
if fast != "1" {
sku = ls.GetGoodsClass(sku, spu)
}
//获取商品名称
if sku.GoodsName == "" {
sku.GoodsName = gjson.Get(spu, "spu_name").String()
......@@ -90,8 +83,11 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
brandId := gjson.Get(spu, "brand_id").Int()
brandName, _ := redis.String(redisConn.Do("HGET", "brand", brandId))
sku.BrandName = brandName
//获取税务信息
if fast != "1" { //仅提供价格和库存
//判断是否要取精简信息
if fast != "1" {
sku = ls.GetGoodsClass(sku, spu)
//仅提供价格和库存
if sku.GoodsName != "" && brandId != 0 {
sku.ErpTax = ls.GetErpTax(sku.GoodsName, brandName)
}
......@@ -105,6 +101,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
}
}
//获取在途库存信息
if showStockInfo == "1" && sku.OldGoodsId != 0 {
sku.StockInfo = ls.getStockInfo(sku.SupplierId, sku.OldGoodsId)
}
......@@ -136,7 +133,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//这里获取活动价格和活动类型
sku = ls.GetActivity(sku)
//处理阶梯价数据
//最小起订量要大于阶梯价的最小阶梯数量
if len(sku.LadderPrice) > 0 {
//排序
sort.Sort(sorter.LadderPriceSorter(sku.LadderPrice))
......@@ -146,6 +143,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.Moq = purchases
}
}
//获取系数
sku = ls.GetCoefficientAndPrice(sku)
......@@ -176,11 +174,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.LadderPriceResult = []int{}
}
//这边有个临时逻辑,如果供应商id是TI的,就库存为0
// if sku.SupplierId == 1679 {
// sku.Stock = 0
// }
//判断是否可以购买
sku.IsBuy = ls.GetIsBuy(sku)
......@@ -198,6 +191,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.Attrs = []int{}
}
//获取标签信息
var TagService TagsService
sku.GoodsTag = TagService.GetTags(sku.GoodsId, 0)
......
......@@ -2,6 +2,7 @@ package service
import (
"encoding/json"
"fmt"
"go_sku_server/model"
c "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
......@@ -187,11 +188,22 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
return sku
}
flag := 0
data := make([]model.LadderPrice, len(sku.LadderPrice))
var data []model.LadderPrice
var originalPrice []model.OriginPrice
//专卖
//专卖价格获取
if sku.SupplierId == 17 {
ladderPrice := sku.LadderPrice
//判断redis里面是否有成本价,有的话,那就直接去取价格,不需要生成阶梯价
//如果没有成本价字段,就要去生成阶梯价格
if len(ladderPrice) > 0 {
if ladderPrice[0].PriceCostUs == 0 && ladderPrice[0].PriceCostCn == 0 {
var priceService PriceService
ladderPrice = priceService.GenerateLadderPrice(sku)
} else {
fmt.Println("不走成本价生成")
}
}
data = make([]model.LadderPrice, len(ladderPrice))
for key, price := range ladderPrice {
if price.Purchases == 0 {
continue
......@@ -203,15 +215,16 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if price.PriceCn != 0 {
data[key].PriceCn = c.MyRound(price.PriceCn, 4)
}
//todo 2023.4.6 专卖成本价
//专卖成本价
data[key].PriceCostUs = price.PriceCostUs
data[key].PriceCostCn = price.PriceCostCn
//联营或者专卖 同时 存在活动价格
if (sku.GoodsType == 1 || sku.GoodsType == 2) && sku.AcType > 1 && sku.Ratio > 0 {
tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, (sku.Ratio/100)), 4)
tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, sku.Ratio/100), 4)
data[key].PriceAc = tempAcPrice
data[key].PriceAcUs = c.MyRound(c.MulFloat(price.PriceUs, (sku.RatioUs/100)), 4)
data[key].PriceAcUs = c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 4)
//优惠价后等于0,就代表没有搞活动
if tempAcPrice <= 0 {
......@@ -227,6 +240,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
} else {
data = make([]model.LadderPrice, len(sku.LadderPrice))
//去获取各种系数(成本折扣系数,售价组系数,供应商系数)
redisCon := gredis.Conn("default_r")
defer redisCon.Close()
......
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