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
620d3937
authored
Nov 11, 2025
by
hcy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
并发问题
parent
0e1a7e0a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
12 deletions
conf/dev/redis.ini
pkg/gredis/redis.go
service/service_activity.go
service/service_ly.go
service/service_spu.go
conf/dev/redis.ini
View file @
620d3937
...
...
@@ -2,23 +2,23 @@
[default_redis_read]
host
=
redis.liexindev.me:6379
password
=
icDb29mLy2s
max_idle
=
50
00
max_active
=
5
000
max_idle
=
3
00
max_active
=
1
000
idle_timeout
=
20
[default_redis_write]
host
=
redis.liexindev.me:6379
password
=
icDb29mLy2s
max_idle
=
50
00
max_active
=
5
000
max_idle
=
3
00
max_active
=
1
000
idle_timeout
=
20
;新spu redis
[default_redis_spu]
host
=
192.168.1.234:6379
password
=
icDb29mLy1s
max_idle
=
20
00
max_active
=
5
000
max_idle
=
3
00
max_active
=
1
000
idle_timeout
=
20
...
...
pkg/gredis/redis.go
View file @
620d3937
...
...
@@ -2,10 +2,9 @@ package gredis
import
(
"fmt"
"github.com/gomodule/redigo/redis"
"go_sku_server/pkg/config"
"time"
"github.com/gomodule/redigo/redis"
)
type
ichuntRedis
struct
{
...
...
@@ -88,6 +87,8 @@ func Hmget(redisCon string, hkey string, targetIds []string) map[string]string {
redisConn
:=
Conn
(
redisCon
)
defer
redisConn
.
Close
()
GetPoolStats
(
"default_r"
)
skuArr
:=
make
(
map
[
string
]
string
,
0
)
if
len
(
targetIds
)
==
1
{
goods_id
:=
targetIds
[
0
]
...
...
service/service_activity.go
View file @
620d3937
...
...
@@ -33,7 +33,7 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p
}
//处理单品促销活动(打折活动)
activityStr
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"hget"
,
"lie_price_activity"
,
redisKey
))
activityStr
:=
AllPriceActivity
[
redisKey
]
if
activityStr
!=
""
{
var
activities
[]
model
.
Activity
err
:=
json
.
Unmarshal
([]
byte
(
activityStr
),
&
activities
)
...
...
service/service_ly.go
View file @
620d3937
...
...
@@ -84,7 +84,8 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, sk
//获取品牌名称
brandId
:=
gjson
.
Get
(
spu
,
"brand_id"
)
.
Int
()
brandName
,
_
:=
AllLyBrand
[
gconv
.
String
(
brandId
)]
brandIdStr
:=
gconv
.
String
(
brandId
)
brandName
,
_
:=
AllLyBrand
[
brandIdStr
]
sku
.
BrandName
=
brandName
sku
.
BrandId
=
brandId
...
...
@@ -136,10 +137,10 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, sk
//获取供应链标准品牌
//什么是供应链的标准品牌 供应链那边报关的时候要求他们的标准品牌,所以要吧自己的品牌映射上去
//继来那边对接的标准品牌(下单的时候)
sku
.
ScmBrand
=
ls
.
GetScmBrand
(
brandId
)
sku
.
ScmBrand
=
AllScmBrands
[
brandIdStr
]
//获取新版的标准品牌
sku
.
StandardBrand
=
AllStandardBrands
[
gconv
.
String
(
brandId
)
]
sku
.
StandardBrand
=
AllStandardBrands
[
brandIdStr
]
//处理过期, 2022.7.13 专卖没有过期
if
sku
.
SupplierId
!=
17
&&
gjson
.
Get
(
skuStr
,
"is_expire"
)
.
Int
()
!=
0
{
...
...
service/service_spu.go
View file @
620d3937
...
...
@@ -28,6 +28,7 @@ var (
AllErpTax
map
[
string
]
interface
{}
//获取税务信息,对接税务系统
AllSupplierName
map
[
string
]
string
//供应商名称
AllScmBrands
map
[
string
]
map
[
string
]
interface
{}
//所有scm品牌,普通品牌=>scm品牌
AllPriceActivity
map
[
string
]
string
//所有的活动促销信息
)
// 币种中文
...
...
@@ -101,6 +102,7 @@ func (ss *SpuService) SetInit(redisLySkuArr, redisLySpuArr map[string]string, zy
brandIds
:=
make
([]
string
,
0
)
//所有品牌id
ClassIds
:=
make
([]
string
,
0
)
//所有分类id
erpMd5Key
:=
make
([]
string
,
0
)
//查询税率
priceActivityKey
:=
make
([]
string
,
0
)
//查询活动key
//预查询
for
_
,
info
:=
range
redisLySkuArr
{
spuId
:=
gjson
.
Get
(
info
,
"spu_id"
)
.
String
()
...
...
@@ -116,9 +118,21 @@ func (ss *SpuService) SetInit(redisLySkuArr, redisLySpuArr map[string]string, zy
source
:=
gjson
.
Get
(
info
,
"source"
)
.
Int
()
canal
:=
gjson
.
Get
(
info
,
"canal"
)
.
String
()
spuId
:=
gjson
.
Get
(
info
,
"spu_id"
)
.
String
()
orgId
:=
gjson
.
Get
(
info
,
"org_id"
)
.
String
()
spuInfo
:=
redisLySpuArr
[
spuId
]
brandId
:=
gjson
.
Get
(
spuInfo
,
"brand_id"
)
.
String
()
//活动key
var
priceRedisKey
string
//区分猎芯和华云
if
orgId
==
"1"
{
priceRedisKey
=
supplierIdStr
}
else
{
priceRedisKey
=
supplierIdStr
+
"_"
+
orgId
}
priceActivityKey
=
append
(
priceActivityKey
,
priceRedisKey
)
//分类id
spuClassId1
:=
gjson
.
Get
(
spuInfo
,
"class_id1"
)
.
String
()
spuClassId2
:=
gjson
.
Get
(
spuInfo
,
"class_id2"
)
.
String
()
...
...
@@ -171,6 +185,12 @@ func (ss *SpuService) SetInit(redisLySkuArr, redisLySpuArr map[string]string, zy
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
BatchGetPriceActivity
(
priceActivityKey
)
//获取活动信息,目前是包括促销活动(系数打折)以及满赠活动
}()
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
BatchScmBrand
(
brandIds
)
//批量H获取供应链标准品牌
}()
...
...
@@ -232,6 +252,11 @@ func (ss *SpuService) SetInit(redisLySkuArr, redisLySpuArr map[string]string, zy
}
// 获取活动信息,目前是包括促销活动(系数打折)以及满赠活动
func
BatchGetPriceActivity
(
redisKey
[]
string
)
{
AllPriceActivity
=
gredis
.
Hmget
(
"default_r"
,
"lie_price_activity"
,
removeDuplicateString
(
redisKey
))
//批量查询品牌
}
// 批量H获取供应链标准品牌
func
BatchScmBrand
(
brandIds
[]
string
)
{
brandIds
=
removeDuplicateString
(
brandIds
)
...
...
@@ -309,6 +334,7 @@ func BatchLyBrand(brandIds []string) {
standardBrandStr
:=
standardBrandArr
[
standardBrandId
]
var
standardBrand
model
.
StandardBrand
if
standardBrandStr
!=
""
{
println
(
"standardBrandId:"
+
standardBrandStr
)
standardBrand
.
BrandName
=
gjson
.
Get
(
standardBrandStr
,
"brand_name"
)
.
String
()
standardBrand
.
StandardBrandId
=
int
(
gjson
.
Get
(
standardBrandStr
,
"standard_brand_id"
)
.
Int
())
standardBrand
.
BrandLogo
=
gjson
.
Get
(
standardBrandStr
,
"brandLogo"
)
.
String
()
...
...
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