Commit dec08ef8 by 杨树贤

获取库存的时候,如果是寄售,那么要扣减锁库库存

parent 0abcfcf0
......@@ -208,10 +208,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//判断是否可以购买
sku.IsBuy = ls.GetIsBuy(sku)
//过期修改库存为0
if sku.IsExpire == 1 && sku.SupplierId != 17 {
sku.Stock = 0
}
sku.Stock = ls.GetStock(sku)
//获取标签信息
var TagService TagsService
......
......@@ -14,6 +14,7 @@ import (
"go_sku_server/service/sorter"
_ "gopkg.in/mgo.v2/bson"
"sort"
"strconv"
"strings"
)
......@@ -252,6 +253,23 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
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的信息
func (ls *LyService) CombineSup(sku model.LySku, spuStr string) model.LySku {
//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