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
37fbe663
authored
Nov 10, 2025
by
hcy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
并发问题
parent
7510df85
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
28 deletions
service/service_spu.go
service/service_spu.go
View file @
37fbe663
...
...
@@ -9,6 +9,7 @@ import (
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/vars"
"strings"
"sync"
)
var
UsdRate
float64
//美金匯率
...
...
@@ -94,6 +95,7 @@ func (ss *SpuService) GetSpuList(skuArr map[string]string) map[string]string {
// 设置查询公共变量
func
(
ss
*
SpuService
)
SetInit
(
redisLySkuArr
map
[
string
]
string
,
zyGoodsId
,
lyGoodsId
[]
string
)
{
AllDelivery
=
make
(
map
[
string
]
map
[
string
]
string
,
0
)
//获取供应商货期
needRawGoodsIds
:=
make
([]
string
,
0
)
//批量获取 原始编码
needExtendFeeId
:=
make
([]
string
,
0
)
//批量获取 附加费
canals
:=
make
([]
string
,
0
)
//所有渠道,目前只有专卖有
...
...
@@ -134,26 +136,86 @@ func (ss *SpuService) SetInit(redisLySkuArr map[string]string, zyGoodsId, lyGood
needExtendFeeId
=
append
(
needExtendFeeId
,
feekey
)
}
}
//批量获取汇率
AllCurrencyRate
=
gredis
.
Hmget
(
"default_r"
,
"erp_rate"
,
[]
string
{
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"10"
,
"11"
,
"12"
,
"13"
})
UsdRate
=
gconv
.
Float64
(
AllCurrencyRate
[
"2"
])
//批量获取标签a
GoodsSourceTags
=
gredis
.
Hmget
(
"default_r"
,
"goods_source_tags"
,
[]
string
{
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"10"
,
"11"
,
"12"
})
//批量获取标签b
GoodsLabelTags
=
gredis
.
Hmget
(
"default_r"
,
"goods_source_tags"
,
[]
string
{
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
})
GoodsLabelTags
=
gredis
.
Hmget
(
"default_r"
,
"goods_label_tags"
,
[]
string
{
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
})
var
wg
sync
.
WaitGroup
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
go
BatchCurrency
()
//批量获取汇率
}()
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
go
BatchLyRawGoods
(
needRawGoodsIds
)
//批量获取原始编码
}()
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
go
BatchZyLockStock
(
zyGoodsId
)
//批量获取锁库信息
}()
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
go
BatchLyFee
(
needExtendFeeId
)
//查询附加费
}()
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
go
BatchZhuanmaiDelivery
(
canals
)
//专营货期
}()
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
go
BatchSeaDelivery
(
supplierIds
)
//代购货期
}()
//批量获取原始编码
if
len
(
needRawGoodsIds
)
>
0
{
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
go
BatchLyTags
(
redisLySkuArr
,
lyGoodsId
)
// 批量获取联营tags
}()
wg
.
Wait
()
}
// 批量获取汇率
func
BatchCurrency
()
{
AllCurrencyRate
=
gredis
.
Hmget
(
"default_r"
,
"erp_rate"
,
[]
string
{
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"10"
,
"11"
,
"12"
,
"13"
})
UsdRate
=
gconv
.
Float64
(
AllCurrencyRate
[
"2"
])
}
// 批量获取原始编码
func
BatchLyRawGoods
(
needRawGoodsIds
[]
string
)
{
if
len
(
needRawGoodsIds
)
==
0
{
return
}
AllSkuRawMap
=
gredis
.
Hmget
(
"default_r"
,
"sku_raw_map"
,
needRawGoodsIds
)
}
// 查询自营锁库信息
func
BatchZyLockStock
(
zyGoodsId
[]
string
)
{
if
len
(
zyGoodsId
)
==
0
{
return
}
//批量获取锁库信息
if
len
(
zyGoodsId
)
>
0
{
AllSkuLockMap
=
gredis
.
Hmget
(
"default_r"
,
"sku_lock_stock"
,
zyGoodsId
)
//所有锁库信息
}
// 查询附加费
func
BatchLyFee
(
needExtendFeeId
[]
string
)
{
if
len
(
needExtendFeeId
)
==
0
{
return
}
//查询附加费
if
len
(
needExtendFeeId
)
>
0
{
AllExtendFee
=
make
(
map
[
string
]
interface
{})
redisFeeArr
:=
gredis
.
Hmget
(
"default_r"
,
"supp_extend_fee"
,
needExtendFeeId
)
for
keyOne
,
feeone
:=
range
redisFeeArr
{
...
...
@@ -177,33 +239,44 @@ func (ss *SpuService) SetInit(redisLySkuArr map[string]string, zyGoodsId, lyGood
AllExtendFee
[
keyOne
]
=
extendFee
}
}
}
// 专营货期
func
BatchZhuanmaiDelivery
(
canals
[]
string
)
{
if
len
(
canals
)
==
0
{
//专营货期
return
}
//获取供应商货期
AllDelivery
=
make
(
map
[
string
]
map
[
string
]
string
,
0
)
if
len
(
canals
)
>
0
{
//专营货期
supplierRatios
:=
gredis
.
Hmget
(
"default_r"
,
"supp_ratio"
,
canals
)
for
dkey
,
supplierRatio
:=
range
supplierRatios
{
if
supplierRatio
==
""
{
AllDelivery
[
dkey
][
"cn_delivery"
]
=
""
AllDelivery
[
dkey
][
"hk_delivery"
]
=
""
continue
}
cn_delivery
:=
""
hk_delivery
:=
""
if
supplierRatio
!=
""
{
cnDeliveryTime
:=
gjson
.
Get
(
supplierRatio
,
"cn_delivery_time"
)
.
String
()
usDeliveryTime
:=
gjson
.
Get
(
supplierRatio
,
"us_delivery_time"
)
.
String
()
//为了兼容供应商修改的问题
if
cnDeliveryTime
!=
"周"
&&
cnDeliveryTime
!=
"天"
{
AllDelivery
[
dkey
][
"cn_delivery"
]
=
gjson
.
Get
(
supplierRatio
,
"cn_delivery_time"
)
.
String
()
cn_delivery
=
gjson
.
Get
(
supplierRatio
,
"cn_delivery_time"
)
.
String
()
}
else
{
AllDelivery
[
dkey
][
"cn_delivery"
]
=
""
cn_delivery
=
""
}
if
usDeliveryTime
!=
"周"
&&
usDeliveryTime
!=
"天"
{
AllDelivery
[
dkey
][
"hk_delivery"
]
=
gjson
.
Get
(
supplierRatio
,
"us_delivery_time"
)
.
String
()
hk_delivery
=
gjson
.
Get
(
supplierRatio
,
"us_delivery_time"
)
.
String
()
}
else
{
AllDelivery
[
dkey
][
"hk_delivery"
]
=
""
hk_delivery
=
""
}
}
AllDelivery
[
dkey
]
=
map
[
string
]
string
{
"cn_delivery"
:
cn_delivery
,
"hk_delivery"
:
hk_delivery
,
}
}
}
// 代购货期
func
BatchSeaDelivery
(
supplierIds
[]
string
)
{
if
len
(
supplierIds
)
==
0
{
return
}
if
len
(
supplierIds
)
>
0
{
//代购货期
supplierRatios
:=
gredis
.
Hmget
(
"default_r"
,
"SUPPLIER_REDIS_INFO_"
,
supplierIds
)
for
dkey
,
sinfo
:=
range
supplierRatios
{
cnDelivery
:=
gjson
.
Get
(
sinfo
,
"cn_delivery"
)
.
String
()
...
...
@@ -220,10 +293,14 @@ func (ss *SpuService) SetInit(redisLySkuArr map[string]string, zyGoodsId, lyGood
}
}
}
}
// 批量获取联营tags
func
BatchLyTags
(
redisLySkuArr
map
[
string
]
string
,
lyGoodsId
[]
string
)
{
if
len
(
lyGoodsId
)
==
0
{
return
}
//批量获取联营tags-标签
if
len
(
lyGoodsId
)
>
0
{
AllLyGoodsTag
=
make
(
map
[
string
]
model
.
GoodsTag
,
0
)
goodsTagArr
:=
gredis
.
Hmget
(
"default_r"
,
"goods_tag"
,
lyGoodsId
)
var
tags
[]
int
...
...
@@ -286,8 +363,6 @@ func (ss *SpuService) SetInit(redisLySkuArr map[string]string, zyGoodsId, lyGood
goodsTags
.
GoodsTag
=
tags
AllLyGoodsTag
[
goods_id
]
=
goodsTags
}
}
}
// 获取指定的币种汇率
...
...
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