Commit ed6c30a1 by 杨树贤

Merge branch 'ysx-寄售需求-20250102' into dev

parents ef5098e5 dec08ef8
...@@ -208,10 +208,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -208,10 +208,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//判断是否可以购买 //判断是否可以购买
sku.IsBuy = ls.GetIsBuy(sku) sku.IsBuy = ls.GetIsBuy(sku)
//过期修改库存为0
if sku.IsExpire == 1 && sku.SupplierId != 17 { sku.Stock = ls.GetStock(sku)
sku.Stock = 0
}
//获取标签信息 //获取标签信息
var TagService TagsService var TagService TagsService
......
...@@ -14,6 +14,7 @@ import ( ...@@ -14,6 +14,7 @@ import (
"go_sku_server/service/sorter" "go_sku_server/service/sorter"
_ "gopkg.in/mgo.v2/bson" _ "gopkg.in/mgo.v2/bson"
"sort" "sort"
"strconv"
"strings" "strings"
) )
...@@ -252,6 +253,23 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) { ...@@ -252,6 +253,23 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
return 1 return 1
} }
// 获取库存
func (ls *LyService) GetStock(sku model.LySku) (stock int64) {
//过期修改库存为0
if sku.IsExpire == 1 && sku.SupplierId != 17 {
sku.Stock = 0
}
//这里还有一个逻辑
//如果是寄售的数据(source=12),获取的库存还要减去锁库的库存
if sku.Source == 12 {
//获取锁库库存
redisCon := gredis.Conn("search_r")
stockStr, _ := redis.String(redisCon.Do("HGET", "sku_lock_stock", sku.GoodsId))
stock, _ = strconv.ParseInt(stockStr, 10, 64)
}
return
}
// 合并spu的信息 // 合并spu的信息
func (ls *LyService) CombineSup(sku model.LySku, spuStr string) model.LySku { func (ls *LyService) CombineSup(sku model.LySku, spuStr string) model.LySku {
//sku.UpdateTime = gjson.Get(spuStr, "update_time").Int() //sku.UpdateTime = gjson.Get(spuStr, "update_time").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