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
043fef3a
authored
Aug 19, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化补充数据
parent
445c7644
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
service/service_ly.go
service/service_ly.go
View file @
043fef3a
...
...
@@ -39,7 +39,10 @@ type Power struct {
func
(
ls
*
LyService
)
LyGoodsDetail
(
ctx
*
gin
.
Context
,
goodsIds
[]
string
,
ch
chan
sync
.
Map
)
{
redisConn
:=
gredis
.
Conn
(
"search_r"
)
redisConnSpu
:=
gredis
.
Conn
(
"spu"
)
// 连接prev_sku MongoDB
prevSkuMongo
:=
mongo
.
Conn
(
"pre_sku"
)
defer
func
()
{
prevSkuMongo
.
Close
()
redisConn
.
Close
()
redisConnSpu
.
Close
()
}()
...
...
@@ -63,8 +66,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
spuList
:=
spuService
.
getSpuList
(
skuArr
)
GoodsRes
:=
sync
.
Map
{}
// 连接prev_sku MongoDB
prevSkuMongo
:=
mongo
.
Conn
(
"pre_sku"
)
for
goodsId
,
skuStr
:=
range
skuArr
{
//初始化有序map,拼接data数据,就是从redis取出初始数据
sku
:=
model
.
InitSkuData
(
skuStr
)
...
...
@@ -78,8 +79,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
}
var
prevSku
model
.
PrevSku
err
=
prevSkuMongo
.
DB
(
"ichunt"
)
.
C
(
"prev_sku"
)
.
Find
(
bson
.
M
{
"sku_id"
:
skuId
})
.
One
(
&
prevSku
)
prevSkuMongo
.
Close
()
if
err
!=
nil
{
// 如果在prev_sku中也找不到,则保持默认值
GoodsRes
.
Store
(
goodsId
,
false
)
...
...
@@ -94,6 +93,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
GoodsRes
.
Store
(
goodsId
,
false
)
continue
}
sku
.
SpuId
=
spuIdStr
spu
=
spuStr
}
else
{
spu
=
spuList
[
sku
.
SpuId
]
...
...
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