Commit 0618a067 by mushishixian

Merge branch 'ysx-专营商品构建阶梯价-20230612' into dev

parents 57b0382c bffa45a8
;redis连接信息 ;redis连接信息
[default_redis_read] [default_redis_read]
host = 192.168.1.234:6379 host = redis.liexindev.me:6379
password = icDb29mLy2s password = icDb29mLy2s
max_idle = 2000 max_idle = 2000
max_active = 5000 max_active = 5000
idle_timeout = 20 idle_timeout = 20
[default_redis_write] [default_redis_write]
host = 192.168.1.234:6379 host = redis.liexindev.me:6379
password = icDb29mLy2s password = icDb29mLy2s
max_idle = 2000 max_idle = 2000
max_active = 5000 max_active = 5000
......
...@@ -180,6 +180,10 @@ func InitSkuData(sku string) (data LySku) { ...@@ -180,6 +180,10 @@ func InitSkuData(sku string) (data LySku) {
data.Multiple = mpq data.Multiple = mpq
} }
} }
//todo 2023.5.6 如果是rochester ,递增量为1
if supplierId == 3 {
data.Multiple = 1
}
stock := gjson.Get(sku, "stock").Int() stock := gjson.Get(sku, "stock").Int()
data.Stock = stock data.Stock = stock
......
...@@ -52,7 +52,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -52,7 +52,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
GoodsRes.Store(goodsId, false) GoodsRes.Store(goodsId, false)
continue continue
} }
//初始化有序map,拼接data 数据 //初始化有序map,拼接data数据,就是从redis取出初始数据
sku := model.InitSkuData(skuStr) sku := model.InitSkuData(skuStr)
sku.GoodsId = goodsId sku.GoodsId = goodsId
spu := spuList[sku.SpuId] spu := spuList[sku.SpuId]
...@@ -65,7 +65,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -65,7 +65,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku = ls.GetGoodsImages(sku, spu) sku = ls.GetGoodsImages(sku, spu)
//pdf //pdf
pdf := gjson.Get(spu, "pdf").String() pdf := gjson.Get(spu, "pdf").String()
// spuLargeImage := gjson.Get(spu, "images_l").String()
if pdf != "" { if pdf != "" {
pdf = strings.Replace(pdf, "http://img.ichunt.com", "https://img.ichunt.com", 1) pdf = strings.Replace(pdf, "http://img.ichunt.com", "https://img.ichunt.com", 1)
//还要针对如果是自己的上传服务的pdf文件,还要补上类型用于预览 //还要针对如果是自己的上传服务的pdf文件,还要补上类型用于预览
...@@ -75,12 +74,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -75,12 +74,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.Pdf = pdf sku.Pdf = pdf
} }
//处理分类
//fast的参数含义,为了节省开销性能的参数,传1就不会去分类这些参数
if fast != "1" {
sku = ls.GetGoodsClass(sku, spu)
}
//获取商品名称 //获取商品名称
if sku.GoodsName == "" { if sku.GoodsName == "" {
sku.GoodsName = gjson.Get(spu, "spu_name").String() sku.GoodsName = gjson.Get(spu, "spu_name").String()
...@@ -90,8 +83,11 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -90,8 +83,11 @@ 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
//获取税务信息
if fast != "1" { //仅提供价格和库存 //判断是否要取精简信息
if fast != "1" {
sku = ls.GetGoodsClass(sku, spu)
//仅提供价格和库存
if sku.GoodsName != "" && brandId != 0 { if sku.GoodsName != "" && brandId != 0 {
sku.ErpTax = ls.GetErpTax(sku.GoodsName, brandName) sku.ErpTax = ls.GetErpTax(sku.GoodsName, brandName)
} }
...@@ -105,6 +101,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -105,6 +101,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
} }
} }
//获取在途库存信息
if showStockInfo == "1" && sku.OldGoodsId != 0 { if showStockInfo == "1" && sku.OldGoodsId != 0 {
sku.StockInfo = ls.getStockInfo(sku.SupplierId, sku.OldGoodsId) sku.StockInfo = ls.getStockInfo(sku.SupplierId, sku.OldGoodsId)
} }
...@@ -136,7 +133,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -136,7 +133,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//这里获取活动价格和活动类型 //这里获取活动价格和活动类型
sku = ls.GetActivity(sku) sku = ls.GetActivity(sku)
//处理阶梯价数据 //最小起订量要大于阶梯价的最小阶梯数量
if len(sku.LadderPrice) > 0 { if len(sku.LadderPrice) > 0 {
//排序 //排序
sort.Sort(sorter.LadderPriceSorter(sku.LadderPrice)) sort.Sort(sorter.LadderPriceSorter(sku.LadderPrice))
...@@ -146,6 +143,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -146,6 +143,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.Moq = purchases sku.Moq = purchases
} }
} }
//获取系数 //获取系数
sku = ls.GetCoefficientAndPrice(sku) sku = ls.GetCoefficientAndPrice(sku)
...@@ -156,12 +154,13 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -156,12 +154,13 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
} }
//还要处理货期 //还要处理货期
delivery := ls.GetDelivery(sku.SupplierId, sku.Canal) delivery := ls.GetDelivery(sku.SupplierId, sku.Canal)
if delivery["cn_delivery"] != "" { if sku.CnDeliveryTime == "" {
sku.CnDeliveryTime = delivery["cn_delivery"] sku.CnDeliveryTime = delivery["cn_delivery"]
} }
if delivery["hk_delivery"] != "" { if sku.HkDeliveryTime == "" {
sku.HkDeliveryTime = delivery["hk_delivery"] sku.HkDeliveryTime = delivery["hk_delivery"]
} }
} }
//处理是否可以购买 //处理是否可以购买
...@@ -175,11 +174,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -175,11 +174,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.LadderPriceResult = []int{} sku.LadderPriceResult = []int{}
} }
//这边有个临时逻辑,如果供应商id是TI的,就库存为0
// if sku.SupplierId == 1679 {
// sku.Stock = 0
// }
//判断是否可以购买 //判断是否可以购买
sku.IsBuy = ls.GetIsBuy(sku) sku.IsBuy = ls.GetIsBuy(sku)
sku.IsBuy = 1 sku.IsBuy = 1
...@@ -188,6 +182,16 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -188,6 +182,16 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
// sku.Stock = 0 // sku.Stock = 0
} }
//特殊判断,如果是罗侧斯特的ADI的商品,价格为0,库存为0
if sku.StandardBrand.StandardBrandId == 8 && sku.SupplierId == 3 {
sku.Stock = 0
sku.LadderPriceResult = []int{}
sku.IsBuy = 0
sku.BatchSn = ""
sku.Attrs = []int{}
}
//获取标签信息
var TagService TagsService var TagService TagsService
sku.GoodsTag = TagService.GetTags(sku.GoodsId, 0) sku.GoodsTag = TagService.GetTags(sku.GoodsId, 0)
......
...@@ -2,6 +2,7 @@ package service ...@@ -2,6 +2,7 @@ package service
import ( import (
"encoding/json" "encoding/json"
"fmt"
"go_sku_server/model" "go_sku_server/model"
c "go_sku_server/pkg/common" c "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis" "go_sku_server/pkg/gredis"
...@@ -187,11 +188,23 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -187,11 +188,23 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
return sku return sku
} }
flag := 0 flag := 0
data := make([]model.LadderPrice, len(sku.LadderPrice)) var data []model.LadderPrice
var originalPrice []model.OriginPrice var originalPrice []model.OriginPrice
//专卖 //专卖价格获取
if sku.SupplierId == 17 { if sku.SupplierId == 17 {
ladderPrice := sku.LadderPrice ladderPrice := sku.LadderPrice
//判断redis里面是否有成本价,有的话,那就直接去取价格,不需要生成阶梯价
//如果没有成本价字段,就要去生成阶梯价格
if len(ladderPrice) > 0 {
if ladderPrice[0].PriceCostUs == 0 && ladderPrice[0].PriceCostCn == 0 {
var priceService PriceService
ladderPrice = priceService.GenerateLadderPrice(sku)
sku.Original = ladderPrice
} else {
fmt.Println("不走成本价生成")
}
}
data = make([]model.LadderPrice, len(ladderPrice))
for key, price := range ladderPrice { for key, price := range ladderPrice {
if price.Purchases == 0 { if price.Purchases == 0 {
continue continue
...@@ -203,15 +216,16 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -203,15 +216,16 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if price.PriceCn != 0 { if price.PriceCn != 0 {
data[key].PriceCn = c.MyRound(price.PriceCn, 4) data[key].PriceCn = c.MyRound(price.PriceCn, 4)
} }
//todo 2023.4.6 专卖成本价
//专卖成本价
data[key].PriceCostUs = price.PriceCostUs data[key].PriceCostUs = price.PriceCostUs
data[key].PriceCostCn = price.PriceCostCn data[key].PriceCostCn = price.PriceCostCn
//联营或者专卖 同时 存在活动价格 //联营或者专卖 同时 存在活动价格
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 {
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].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,就代表没有搞活动 //优惠价后等于0,就代表没有搞活动
if tempAcPrice <= 0 { if tempAcPrice <= 0 {
...@@ -227,6 +241,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -227,6 +241,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
} }
} }
} else { } else {
data = make([]model.LadderPrice, len(sku.LadderPrice))
//去获取各种系数(成本折扣系数,售价组系数,供应商系数) //去获取各种系数(成本折扣系数,售价组系数,供应商系数)
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
......
...@@ -54,6 +54,9 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag ...@@ -54,6 +54,9 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag
if !php2go.InArray(TagZiyingSku, tags) { if !php2go.InArray(TagZiyingSku, tags) {
tags = append(tags, TagZiyingSku) tags = append(tags, TagZiyingSku)
tagNames = append(tagNames, vars.GoodsTags[TagZiyingSku]) tagNames = append(tagNames, vars.GoodsTags[TagZiyingSku])
goodsTags.GoodsLabel = TagZiyingSku
goodsTags.GoodsLabelName = vars.GoodsTags[TagZiyingSku]
} }
} }
goodsTags.GoodsTagNames = tagNames goodsTags.GoodsTagNames = tagNames
......
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