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
9279af23
authored
Mar 25, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加sku_detail返回
parent
4853474c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
model/ly_sku.go
service/service_ly.go
model/ly_sku.go
View file @
9279af23
...
...
@@ -76,6 +76,7 @@ type LySku struct {
StandardBrand
StandardBrand
`json:"standard_brand"`
GoodsTag
GoodsTag
`json:"goods_tag"`
StockInfo
interface
{}
`json:"stock_info"`
SkuDetail
string
`json:"sku_detail"`
Eccn
string
`json:"eccn"`
DiscountRatio
DiscountRatio
`json:"discount_ratio"`
PriceRatioSort
int
`json:"price_ratio_sort"`
...
...
service/service_ly.go
View file @
9279af23
...
...
@@ -3,7 +3,11 @@ package service
import
(
"go_sku_server/model"
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/logger"
"go_sku_server/pkg/mongo"
"go_sku_server/service/sorter"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"sort"
"sync"
...
...
@@ -42,6 +46,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
showAttr
:=
ctx
.
Request
.
FormValue
(
"show_attr"
)
//是否展示在途库存
showStockInfo
:=
ctx
.
Request
.
FormValue
(
"show_stock_info"
)
//是否展示sku详情
showSkuDetail
:=
ctx
.
Request
.
FormValue
(
"show_sku_detail"
)
//批量获取商品详情
skuArr
:=
gredis
.
Hmget
(
"default_r"
,
"sku"
,
goodsIds
)
...
...
@@ -108,6 +114,12 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
if
showStockInfo
==
"1"
&&
sku
.
OldGoodsId
!=
0
{
sku
.
StockInfo
=
ls
.
getStockInfo
(
sku
.
SupplierId
,
sku
.
OldGoodsId
)
}
//判断是否需要返回sku详情
if
showSkuDetail
==
"1"
{
sku
.
SkuDetail
=
ls
.
GetSkuDetail
(
sku
.
GoodsId
)
}
//格式化为对象返回
if
sku
.
StockInfo
==
nil
{
type
StockInfoResult
struct
{
...
...
@@ -240,3 +252,22 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
}
return
sku
}
// 获取sku_detail
func
(
ls
*
LyService
)
GetSkuDetail
(
skuId
string
)
string
{
mongodb
:=
mongo
.
Conn
(
"default"
)
defer
func
()
{
mongodb
.
Close
()
}()
var
skuDetail
struct
{
SkuId
string
`bson:"sku_id"`
Detail
string
`bson:"detail"`
}
err
:=
mongodb
.
DB
(
"ichunt"
)
.
C
(
"sku_detail"
)
.
Find
(
bson
.
M
{
"sku_id"
:
skuId
})
.
One
(
&
skuDetail
)
if
err
!=
nil
&&
err
!=
mgo
.
ErrNotFound
{
logger
.
Select
(
"sku_query"
)
.
Error
(
err
.
Error
())
}
return
skuDetail
.
Detail
}
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