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
dec08ef8
authored
Jan 02, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
获取库存的时候,如果是寄售,那么要扣减锁库库存
parent
0abcfcf0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
service/service_ly.go
service/service_ly_common.go
service/service_ly.go
View file @
dec08ef8
...
...
@@ -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
...
...
service/service_ly_common.go
View file @
dec08ef8
...
...
@@ -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()
...
...
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