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
f3699e46
authored
May 20, 2026
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加仓库列表
parent
99bee35b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
17 deletions
model/ly_sku.go
service/service_sku_batch.go
model/ly_sku.go
View file @
f3699e46
...
@@ -107,6 +107,7 @@ type LySku struct {
...
@@ -107,6 +107,7 @@ type LySku struct {
CostUs
float64
`json:"cost_us"`
CostUs
float64
`json:"cost_us"`
IsZiying
int
`json:"is_ziying"`
IsZiying
int
`json:"is_ziying"`
BatchFormat
interface
{}
`json:"batch_format"`
BatchFormat
interface
{}
`json:"batch_format"`
SpotList
[]
Spot
`json:"spot_list"`
}
}
type
BatchFormatItem
struct
{
type
BatchFormatItem
struct
{
...
@@ -114,6 +115,18 @@ type BatchFormatItem struct {
...
@@ -114,6 +115,18 @@ type BatchFormatItem struct {
Value
interface
{}
`json:"value"`
Value
interface
{}
`json:"value"`
}
}
type
Spot
struct
{
Id
int
`json:"id"`
Name
string
`json:"name"`
// GoodsId string `json:"goods_id"`
// OrgId int `json:"org_id"`
// Currency int `json:"currency"`
// Stock int `json:"stock"`
// BatchSn string `json:"batch_sn"`
// SinglePrice string `json:"single_price"`
// NewCost string `json:"new_cost"`
}
type
DiscountRatio
struct
{
type
DiscountRatio
struct
{
Ratio
float64
`json:"ratio"`
Ratio
float64
`json:"ratio"`
RatioUsd
float64
`json:"ratio_usd"`
RatioUsd
float64
`json:"ratio_usd"`
...
...
service/service_sku_batch.go
View file @
f3699e46
...
@@ -24,6 +24,13 @@ var batchCodeMap = map[int]string{
...
@@ -24,6 +24,13 @@ var batchCodeMap = map[int]string{
6
:
"5年内"
,
6
:
"5年内"
,
}
}
var
warehouseIdText
=
map
[
string
]
string
{
"7"
:
"深圳仓"
,
"9"
:
"深圳仓"
,
"10"
:
"香港仓"
,
"51"
:
"京东寄售仓"
,
}
func
(
ls
*
LyService
)
GetSkuBatchFormat
(
sku
*
model
.
LySku
)
{
func
(
ls
*
LyService
)
GetSkuBatchFormat
(
sku
*
model
.
LySku
)
{
if
sku
.
BatchSn
!=
""
{
if
sku
.
BatchSn
!=
""
{
var
items
[]
model
.
BatchFormatItem
var
items
[]
model
.
BatchFormatItem
...
@@ -43,27 +50,29 @@ func (ls *LyService) GetSkuBatchFormat(sku *model.LySku) {
...
@@ -43,27 +50,29 @@ func (ls *LyService) GetSkuBatchFormat(sku *model.LySku) {
}
}
sku
.
BatchFormat
=
items
sku
.
BatchFormat
=
items
return
}
else
{
}
if
sku
.
SupplierId
==
0
{
sku
.
BatchFormat
=
[]
model
.
BatchFormatItem
{}
if
sku
.
SupplierId
==
0
{
return
sku
.
BatchFormat
=
[]
model
.
BatchFormatItem
{}
}
return
}
supplierBatch
:=
ls
.
getSupplierBatch
(
sku
.
SupplierId
)
supplierBatch
:=
ls
.
getSupplierBatch
(
sku
.
SupplierId
)
if
len
(
supplierBatch
)
==
0
{
if
len
(
supplierBatch
)
==
0
{
sku
.
BatchFormat
=
[]
model
.
BatchFormatItem
{}
sku
.
BatchFormat
=
[]
model
.
BatchFormatItem
{}
return
}
else
{
var
items
[]
model
.
BatchFormatItem
for
_
,
code
:=
range
supplierBatch
{
if
label
,
ok
:=
batchCodeMap
[
code
];
ok
{
items
=
append
(
items
,
model
.
BatchFormatItem
{
Name
:
label
,
Value
:
"可供应"
})
}
}
sku
.
BatchFormat
=
items
}
}
}
var
items
[]
model
.
BatchFormatItem
if
sku
.
IsZiying
==
1
&&
sku
.
GoodsId
!=
""
{
for
_
,
code
:=
range
supplierBatch
{
sku
.
SpotList
=
ls
.
getSpotList
(
sku
.
GoodsId
)
if
label
,
ok
:=
batchCodeMap
[
code
];
ok
{
items
=
append
(
items
,
model
.
BatchFormatItem
{
Name
:
label
,
Value
:
"可供应"
})
}
}
}
sku
.
BatchFormat
=
items
}
}
func
(
ls
*
LyService
)
getSupplierBatch
(
supplierId
int64
)
[]
int
{
func
(
ls
*
LyService
)
getSupplierBatch
(
supplierId
int64
)
[]
int
{
...
@@ -95,3 +104,44 @@ func (ls *LyService) getSupplierBatch(supplierId int64) []int {
...
@@ -95,3 +104,44 @@ func (ls *LyService) getSupplierBatch(supplierId int64) []int {
}
}
return
result
return
result
}
}
func
(
ls
*
LyService
)
getSpotList
(
goodsId
string
)
[]
model
.
Spot
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
skuSpotStr
,
err
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"sku_spot"
,
goodsId
))
if
err
!=
nil
||
skuSpotStr
==
""
{
return
[]
model
.
Spot
{}
}
skuSpotData
:=
gjson
.
Parse
(
skuSpotStr
)
if
!
skuSpotData
.
IsObject
()
{
return
[]
model
.
Spot
{}
}
var
stockList
[]
model
.
Spot
skuSpotData
.
ForEach
(
func
(
key
,
value
gjson
.
Result
)
bool
{
id
:=
key
.
Int
()
idStr
:=
strconv
.
Itoa
(
int
(
id
))
name
,
exists
:=
warehouseIdText
[
idStr
]
if
!
exists
{
name
=
idStr
}
stockItem
:=
model
.
Spot
{
Id
:
int
(
id
),
Name
:
name
,
// GoodsId: value.Get("goods_id").String(),
// OrgId: int(value.Get("org_id").Int()),
// Currency: int(value.Get("currency").Int()),
// Stock: int(value.Get("stock").Int()),
// BatchSn: value.Get("batch_sn").String(),
// SinglePrice: value.Get("single_price").String(),
// NewCost: value.Get("new_cost").String(),
}
stockList
=
append
(
stockList
,
stockItem
)
return
true
})
return
stockList
}
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