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
ddf23d82
authored
Nov 01, 2025
by
hcy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
可买库存扣锁库数量
parent
32b298ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
service/service_zy.go
service/service_zy.go
View file @
ddf23d82
...
@@ -2,10 +2,12 @@ package service
...
@@ -2,10 +2,12 @@ package service
import
(
import
(
"context"
"context"
"github.com/gomodule/redigo/redis"
"go_sku_server/model"
"go_sku_server/model"
"go_sku_server/pkg/common"
"go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/logger"
"go_sku_server/pkg/logger"
"strconv"
"strings"
"strings"
"sync"
"sync"
...
@@ -179,11 +181,13 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx context.Context, params RequestParams
...
@@ -179,11 +181,13 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx context.Context, params RequestParams
A
.
Set
(
"stock"
,
0
)
//默认库存为0
A
.
Set
(
"stock"
,
0
)
//默认库存为0
dbStock
:=
gjson
.
Get
(
info
,
"stock"
)
.
Int
()
//当前db库存
dbStock
:=
gjson
.
Get
(
info
,
"stock"
)
.
Int
()
//当前db库存
if
dbStock
>
0
{
if
dbStock
>
0
{
lockStock
:=
qs
.
skuLockNum
(
&
redisConn
,
goodsId
)
//当前锁库库存
redisCon
:=
gredis
.
Conn
(
"search_r"
)
stockG
:=
dbStock
-
lockStock
//当前可购买库存
stockStr
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"sku_lock_stock"
,
goodsId
))
lockStock
,
_
:=
strconv
.
ParseInt
(
stockStr
,
10
,
64
)
//当前锁库库存
stockG
:=
dbStock
-
lockStock
//当前可购买库存
if
stockG
>
0
{
if
stockG
>
0
{
A
.
Set
(
"actual_stock"
,
dbStock
)
//
锁定
库存
A
.
Set
(
"actual_stock"
,
dbStock
)
//
数据库
库存
A
.
Set
(
"stock"
,
stockG
)
A
.
Set
(
"stock"
,
stockG
)
//总库存
}
}
A
.
Set
(
"saler_atio"
,
""
)
//
A
.
Set
(
"saler_atio"
,
""
)
//
}
}
...
...
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