Commit e754337f by 杨树贤

在途库存的展示和标签的展示

parent 06c00213
......@@ -93,6 +93,7 @@ type LySku struct {
TariffFormat string `json:"tariff_format"`
AbilityLevel int `json:"ability_level"`
BrandPack string `json:"brand_pack"`
OnwayStock int `json:"onway_stock"`
}
type DiscountRatio struct {
......
......@@ -170,6 +170,10 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
if showStockInfo == "1" && sku.OldGoodsId != 0 {
sku.StockInfo = ls.getStockInfo(sku.SupplierId, sku.OldGoodsId)
}
//获取新的在途库存信息
sku.OnwayStock = ls.getOnwayStock(sku.GoodsId)
//格式化为对象返回
if sku.StockInfo == nil {
type StockInfoResult struct {
......
......@@ -2,20 +2,24 @@ package service
import (
"go_sku_server/model"
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/logger"
"go_sku_server/pkg/mongo"
"go_sku_server/pkg/vars"
"time"
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
//在途库存服务
// 在途库存服务
type StockInfoService struct {
}
// 这个是老的在途库存,基本上就是Digikey用的
func (ss *LyService) getStockInfo(supplierId, oldGoodsId int64) interface{} {
if !php2go.InArray(supplierId, vars.StockInfoSupplierIds) {
return nil
......@@ -49,3 +53,18 @@ func (ss *LyService) getStockInfo(supplierId, oldGoodsId int64) interface{} {
return nil
}
// 获取新的在途库存
func (ss *LyService) getOnwayStock(goodsId string) int {
redisConn := gredis.Conn("search_r")
defer func() {
redisConn.Close()
}()
onWayStockStr, _ := redis.String(redisConn.Do("HGET", "sku_onway_stock", goodsId))
if onWayStockStr == "" {
return 0
}
return gconv.Int(onWayStockStr)
}
......@@ -115,6 +115,23 @@ func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) {
tagNames = append(tagNames, tag.String())
}
}
//还要根据在途库存进行标签
// 针对渠道L0018562,L0018319
// 1.SKU存在在途数量,则SKU增加标签:在途预售
// 2.SKU没有在途数量,但是有库存数量,则SKU增加标签:在库即发
// 3.SKU没有在途数量,也没有库存数量,则两个标签都不需要
// 4.同时存在在途数量和库存数量,则标签为:在途预售
if sku.Canal == "L0018562" || sku.Canal == "L0018319" {
if sku.OnwayStock > 0 {
tagNames = append(tagNames, "在途预售")
} else if sku.OnwayStock == 0 && sku.Stock > 0 {
tagNames = append(tagNames, "在库即发")
} else if sku.Stock > 0 && sku.OnwayStock > 0 {
tagNames = append(tagNames, "在途预售")
}
}
//去重tagNames
tagNames = removeDuplicateString(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