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
9f88f381
authored
Mar 02, 2026
by
hcy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
京东库存
parent
db02deb2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
model/ly_sku.go
service/service_ly.go
service/service_ly_common.go
model/ly_sku.go
View file @
9f88f381
...
@@ -22,6 +22,7 @@ type LySku struct {
...
@@ -22,6 +22,7 @@ type LySku struct {
Mpq
int64
`json:"mpq"`
Mpq
int64
`json:"mpq"`
Multiple
int64
`json:"multiple"`
Multiple
int64
`json:"multiple"`
Stock
int64
`json:"stock"`
Stock
int64
`json:"stock"`
StockJd
int64
`json:"stock_jd"`
//京东可售库存
HkDeliveryTime
string
`json:"hk_delivery_time"`
HkDeliveryTime
string
`json:"hk_delivery_time"`
CnDeliveryTime
string
`json:"cn_delivery_time"`
CnDeliveryTime
string
`json:"cn_delivery_time"`
LadderPriceResult
interface
{}
`json:"ladder_price"`
LadderPriceResult
interface
{}
`json:"ladder_price"`
...
...
service/service_ly.go
View file @
9f88f381
...
@@ -313,7 +313,7 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
...
@@ -313,7 +313,7 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
sku
.
LadderPriceResult
=
[]
int
{}
sku
.
LadderPriceResult
=
[]
int
{}
}
}
sku
.
Stock
=
ls
.
GetStock
(
sku
)
sku
.
Stock
,
sku
.
StockJd
=
ls
.
GetStock
(
sku
)
//判断是否可以购买
//判断是否可以购买
sku
.
IsBuy
=
ls
.
GetIsBuy
(
sku
)
sku
.
IsBuy
=
ls
.
GetIsBuy
(
sku
)
...
...
service/service_ly_common.go
View file @
9f88f381
...
@@ -2,6 +2,7 @@ package service
...
@@ -2,6 +2,7 @@ package service
import
(
import
(
"encoding/json"
"encoding/json"
"github.com/gogf/gf/util/gconv"
"go_sku_server/model"
"go_sku_server/model"
c
"go_sku_server/pkg/common"
c
"go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/gredis"
...
@@ -258,26 +259,32 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
...
@@ -258,26 +259,32 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
}
}
// 获取库存
// 获取库存
func
(
ls
*
LyService
)
GetStock
(
sku
model
.
LySku
)
(
stock
int64
)
{
func
(
ls
*
LyService
)
GetStock
(
sku
model
.
LySku
)
(
stock
_all
,
jd_stock
int64
)
{
//过期修改库存为0
//过期修改库存为0
if
sku
.
IsExpire
==
1
&&
sku
.
SupplierId
!=
17
{
if
sku
.
IsExpire
==
1
&&
sku
.
SupplierId
!=
17
{
sku
.
Stock
=
0
sku
.
Stock
=
0
}
}
stock_all_t
:=
sku
.
Stock
jd_stock_t
:=
int64
(
0
)
//这里还有一个逻辑
//这里还有一个逻辑
//如果是寄售的数据(source=12),获取的库存还要减去锁库的库存
//如果是寄售的数据(source=12),获取的库存还要减去锁库的库存
if
sku
.
Source
==
12
||
php2go
.
InArray
(
sku
.
Canal
,
[]
string
{
"L0018319"
,
"L0013521"
,
"L0018562"
,
"L0017764"
,
"L0003270"
,
"L0012413"
,
"L0013521"
})
{
if
sku
.
Source
==
12
||
php2go
.
InArray
(
sku
.
Canal
,
[]
string
{
"L0018319"
,
"L0013521"
,
"L0018562"
,
"L0017764"
,
"L0003270"
,
"L0012413"
,
"L0013521"
})
{
//获取锁库库存
//获取
总
锁库库存
redisCon
:=
gredis
.
Conn
(
"spu"
)
redisCon
:=
gredis
.
Conn
(
"spu"
)
defer
redisCon
.
Close
()
defer
redisCon
.
Close
()
stockStr
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"sku_lock_stock"
,
sku
.
GoodsId
))
stockStr
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"sku_lock_stock"
,
sku
.
GoodsId
))
lockStock
,
_
:=
strconv
.
ParseInt
(
stockStr
,
10
,
64
)
lockStock
,
_
:=
strconv
.
ParseInt
(
stockStr
,
10
,
64
)
if
sku
.
Stock
<
lockStock
{
if
sku
.
Stock
<
lockStock
{
return
0
stock_all_t
=
0
}
else
{
}
else
{
return
sku
.
Stock
-
lockStock
stock_all_t
=
sku
.
Stock
-
lockStock
}
}
//获取京东库存
jdStockShiwuStr
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"sku_jd_stock"
,
sku
.
GoodsId
))
// 京东单个sku实物总数量
jdStockLockStr
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"sku_lock_stock_jd"
,
sku
.
GoodsId
))
//京东锁库数量
jd_stock_t
=
gconv
.
Int64
(
jdStockShiwuStr
)
-
gconv
.
Int64
(
jdStockLockStr
)
}
}
return
s
ku
.
Stock
return
s
tock_all_t
,
jd_stock_t
}
}
// 合并spu的信息
// 合并spu的信息
...
...
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