Commit 23be8dbd by 杨树贤

限制库存

parent e754337f
......@@ -174,6 +174,12 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
//获取新的在途库存信息
sku.OnwayStock = ls.getOnwayStock(sku.GoodsId)
//获取新的限制库存信息
limitStock := ls.getLimitStock(sku.GoodsId)
if limitStock > 0 {
sku.Stock = int64(limitStock)
}
//格式化为对象返回
if sku.StockInfo == nil {
type StockInfoResult struct {
......
......@@ -68,3 +68,18 @@ func (ss *LyService) getOnwayStock(goodsId string) int {
return gconv.Int(onWayStockStr)
}
// 获取新的在途库存
func (ss *LyService) getLimitStock(goodsId string) int {
redisConn := gredis.Conn("search_r")
defer func() {
redisConn.Close()
}()
limitStockStr, _ := redis.String(redisConn.Do("HGET", "limit_stock", goodsId))
if limitStockStr == "" {
return 0
}
return gconv.Int(limitStockStr)
}
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