Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
75c4d7f6
authored
Nov 18, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-可售库存-20251118' into dev
parents
eec49b35
23be8dbd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
3 deletions
model/ly_sku.go
service/service_ly.go
service/service_stock_info.go
service/service_tags.go
model/ly_sku.go
View file @
75c4d7f6
...
@@ -93,6 +93,7 @@ type LySku struct {
...
@@ -93,6 +93,7 @@ type LySku struct {
TariffFormat
string
`json:"tariff_format"`
TariffFormat
string
`json:"tariff_format"`
AbilityLevel
int
`json:"ability_level"`
AbilityLevel
int
`json:"ability_level"`
BrandPack
string
`json:"brand_pack"`
BrandPack
string
`json:"brand_pack"`
OnwayStock
int
`json:"onway_stock"`
}
}
type
DiscountRatio
struct
{
type
DiscountRatio
struct
{
...
...
service/service_ly.go
View file @
75c4d7f6
...
@@ -171,6 +171,16 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
...
@@ -171,6 +171,16 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
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
)
}
}
//获取新的在途库存信息
sku
.
OnwayStock
=
ls
.
getOnwayStock
(
sku
.
GoodsId
)
//获取新的限制库存信息
limitStock
:=
ls
.
getLimitStock
(
sku
.
GoodsId
)
if
limitStock
>
0
{
sku
.
Stock
=
int64
(
limitStock
)
}
//格式化为对象返回
//格式化为对象返回
if
sku
.
StockInfo
==
nil
{
if
sku
.
StockInfo
==
nil
{
type
StockInfoResult
struct
{
type
StockInfoResult
struct
{
...
@@ -304,14 +314,14 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
...
@@ -304,14 +314,14 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
sku
.
LadderPriceResult
=
[]
int
{}
sku
.
LadderPriceResult
=
[]
int
{}
}
}
sku
.
Stock
=
ls
.
GetStock
(
sku
)
//判断是否可以购买
//判断是否可以购买
sku
.
IsBuy
=
ls
.
GetIsBuy
(
sku
)
sku
.
IsBuy
=
ls
.
GetIsBuy
(
sku
)
if
sku
.
IsBuy
==
0
&&
sku
.
OrgId
!=
1
{
if
sku
.
IsBuy
==
0
&&
sku
.
OrgId
!=
1
{
sku
.
AcType
=
0
sku
.
AcType
=
0
}
}
sku
.
Stock
=
ls
.
GetStock
(
sku
)
//获取标签信息
//获取标签信息
var
TagService
TagsService
var
TagService
TagsService
sku
.
GoodsTag
=
TagService
.
GetLyTags
(
sku
)
sku
.
GoodsTag
=
TagService
.
GetLyTags
(
sku
)
...
...
service/service_stock_info.go
View file @
75c4d7f6
...
@@ -2,20 +2,24 @@ package service
...
@@ -2,20 +2,24 @@ package service
import
(
import
(
"go_sku_server/model"
"go_sku_server/model"
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/logger"
"go_sku_server/pkg/logger"
"go_sku_server/pkg/mongo"
"go_sku_server/pkg/mongo"
"go_sku_server/pkg/vars"
"go_sku_server/pkg/vars"
"time"
"time"
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go"
"github.com/syyongx/php2go"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"gopkg.in/mgo.v2/bson"
)
)
//在途库存服务
//
在途库存服务
type
StockInfoService
struct
{
type
StockInfoService
struct
{
}
}
// 这个是老的在途库存,基本上就是Digikey用的
func
(
ss
*
LyService
)
getStockInfo
(
supplierId
,
oldGoodsId
int64
)
interface
{}
{
func
(
ss
*
LyService
)
getStockInfo
(
supplierId
,
oldGoodsId
int64
)
interface
{}
{
if
!
php2go
.
InArray
(
supplierId
,
vars
.
StockInfoSupplierIds
)
{
if
!
php2go
.
InArray
(
supplierId
,
vars
.
StockInfoSupplierIds
)
{
return
nil
return
nil
...
@@ -49,3 +53,33 @@ func (ss *LyService) getStockInfo(supplierId, oldGoodsId int64) interface{} {
...
@@ -49,3 +53,33 @@ func (ss *LyService) getStockInfo(supplierId, oldGoodsId int64) interface{} {
return
nil
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
)
}
// 获取新的在途库存
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
)
}
service/service_tags.go
View file @
75c4d7f6
...
@@ -115,6 +115,23 @@ func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) {
...
@@ -115,6 +115,23 @@ func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) {
tagNames
=
append
(
tagNames
,
tag
.
String
())
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
tagNames
=
removeDuplicateString
(
tagNames
)
tagNames
=
removeDuplicateString
(
tagNames
)
goodsTags
.
GoodsTagNames
=
tagNames
goodsTags
.
GoodsTagNames
=
tagNames
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment