Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_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
e1f59200
authored
Jul 17, 2023
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
spu分离
parent
d66e63ff
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
12 deletions
conf/dev/config.ini
conf/dev/redis.ini
controller/quote_controller.go
pkg/config/redis.go
service/ly/common.go
conf/dev/config.ini
View file @
e1f59200
[web]
port
=
9008
mode
=
debug
cors_domain
=
http://bom.liexin.com,http://liexin.com,http://www.liexin.com
cors_domain
=
http://bom.liexin.com,http://liexin.com,http://www.liexin.com
,http://localhost:8080,http://localhost
[message]
api_domain
=
http://api.ichunt.com/msg/sendMessageByAuto
...
...
conf/dev/redis.ini
View file @
e1f59200
...
...
@@ -13,6 +13,14 @@ max_idle = 500
max_active
=
500
idle_timeout
=
20
;新spu redis
[default_redis_spu]
host
=
192.168.1.234:6379
password
=
icDb29mLy2s
max_idle
=
2000
max_active
=
5000
idle_timeout
=
20
[api_redis]
host
=
192.168.1.235:6379
password
=
icDb29mLy2s
...
...
controller/quote_controller.go
View file @
e1f59200
...
...
@@ -67,7 +67,11 @@ func QuoteIndex(ctx *gin.Context) {
func
mouserOrg
(
ctx
*
gin
.
Context
,
keyword
,
suppliedId
string
)
(
result
map
[
string
]
interface
{},
err
error
)
{
mouserRes
:=
ly
.
OutLinkMouser
(
ctx
,
&
keyword
)
redisCon
:=
gredis
.
Conn
(
"search_r"
)
defer
redisCon
.
Close
()
redisConSpu
:=
gredis
.
Conn
(
"spu"
)
defer
func
()
{
redisCon
.
Close
()
redisConSpu
.
Close
()
}()
skuMouser
:=
make
(
map
[
string
]
string
)
var
goodsIds
[]
string
for
k
,
mouseItem
:=
range
mouserRes
{
...
...
@@ -75,7 +79,7 @@ func mouserOrg(ctx *gin.Context,keyword, suppliedId string) (result map[string]i
continue
}
snSku
:=
php2go
.
Md5
(
strings
.
ToLower
(
k
+
"_"
+
suppliedId
))
skuId
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
config
.
Get
(
"SKU_UNIQUE_JUDGE"
)
.
String
(),
snSku
))
skuId
,
_
:=
redis
.
String
(
redisCon
Spu
.
Do
(
"HGET"
,
config
.
Get
(
"SKU_UNIQUE_JUDGE"
)
.
String
(),
snSku
))
if
skuId
!=
""
{
skuMouser
[
skuId
]
=
mouseItem
.
RestrictionMessage
goodsIds
=
append
(
goodsIds
,
skuId
)
...
...
pkg/config/redis.go
View file @
e1f59200
...
...
@@ -16,6 +16,8 @@ func BuildRedisConfgs() (RedisDatabaseMap map[string]RedisDatabase) {
redis_read_max_active
,
_
:=
Get
(
"default_redis_read.max_active"
)
.
Int
()
redis_write_max_idle
,
_
:=
Get
(
"default_redis_write.max_idle"
)
.
Int
()
redis_write_max_active
,
_
:=
Get
(
"default_redis_write.max_active"
)
.
Int
()
redisSpuMaxIdle
,
_
:=
Get
(
"default_redis_spu.max_idle"
)
.
Int
()
redisSpuMaxActive
,
_
:=
Get
(
"default_redis_spu.max_active"
)
.
Int
()
return
map
[
string
]
RedisDatabase
{
"search_r"
:
{
Host
:
Get
(
"default_redis_read.host"
)
.
String
(),
...
...
@@ -35,5 +37,11 @@ func BuildRedisConfgs() (RedisDatabaseMap map[string]RedisDatabase) {
MaxIdle
:
redis_write_max_idle
,
MaxActive
:
redis_write_max_active
,
},
"spu"
:
{
Host
:
Get
(
"default_redis_spu.host"
)
.
String
(),
Password
:
Get
(
"default_redis_spu.password"
)
.
String
(),
MaxIdle
:
redisSpuMaxIdle
,
MaxActive
:
redisSpuMaxActive
,
},
}
}
service/ly/common.go
View file @
e1f59200
...
...
@@ -57,7 +57,11 @@ func (t *CommonLyService) GetSkuByGoodsSn(ctx *gin.Context,goodsList map[string]
}
redisWrite
:=
gredis
.
Conn
(
"search_w"
)
defer
redisWrite
.
Close
()
redisSpu
:=
gredis
.
Conn
(
"spu"
)
defer
func
()
{
redisWrite
.
Close
()
redisSpu
.
Close
()
}()
t
.
supplierId
=
supplierInfo
.
SupplierId
supplierIdStr
:=
common
.
MyInt64ToStr
(
supplierInfo
.
SupplierId
);
...
...
@@ -74,7 +78,7 @@ func (t *CommonLyService) GetSkuByGoodsSn(ctx *gin.Context,goodsList map[string]
}
snSku
:=
php2go
.
Md5
(
strings
.
ToLower
(
goodsSn
+
"_"
+
supplierIdStr
))
skuId
,
_
:=
gredis
.
String
(
redis
Write
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.SKU_UNIQUE_JUDGE"
)
.
String
(),
snSku
))
//查询唯一值,反查sku_id
skuId
,
_
:=
gredis
.
String
(
redis
Spu
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.SKU_UNIQUE_JUDGE"
)
.
String
(),
snSku
))
//查询唯一值,反查sku_id
common
.
PrintDebugHtml
(
ctx
,
"算法goodsSn:"
+
goodsSn
+
"_"
+
supplierIdStr
+
" :md5("
+
strings
.
ToLower
(
goodsSn
+
"_"
+
supplierIdStr
)
+
") = snSku:"
+
snSku
+
" 查询 sku_unique_judge 得出skuid: "
+
skuId
)
...
...
@@ -118,7 +122,7 @@ func (t *CommonLyService) GetSkuByGoodsSn(ctx *gin.Context,goodsList map[string]
//获取spu详情
spuId
:=
gjson
.
Get
(
redisData
,
"spu_id"
)
.
String
();
spuStr
,
_
:=
redis
.
String
(
redis
Write
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.SPU"
)
.
String
(),
spuId
))
spuStr
,
_
:=
redis
.
String
(
redis
Spu
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.SPU"
)
.
String
(),
spuId
))
info
.
SpuId
=
spuId
//平台spuid
info
.
BrandId
=
gjson
.
Get
(
spuStr
,
"brand_id"
)
.
String
();
//平台品牌id
...
...
@@ -182,10 +186,14 @@ func (t *CommonLyService) GetSkuByGoodsSn(ctx *gin.Context,goodsList map[string]
*/
func
(
t
*
CommonLyService
)
writeSkuInfo
(
ctx
*
gin
.
Context
,
skuInfo
*
model
.
LyClearGoodsList
,
skuId
string
)
string
{
redisWrite
:=
gredis
.
Conn
(
"search_w"
)
defer
redisWrite
.
Close
()
redisSpu
:=
gredis
.
Conn
(
"spu"
)
defer
func
()
{
redisWrite
.
Close
()
redisSpu
.
Close
()
}()
spuKey
:=
common
.
GetKey
(
skuInfo
.
GoodsName
+
"_"
+
skuInfo
.
BrandName
)
spuId
,
_
:=
gredis
.
String
(
redis
Write
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.SPU_UNIQUE_JUDGE"
)
.
String
(),
spuKey
))
spuId
,
_
:=
gredis
.
String
(
redis
Spu
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.SPU_UNIQUE_JUDGE"
)
.
String
(),
spuKey
))
common
.
PrintDebugHtml
(
ctx
,
"spu唯一值---spu_unique_judge:"
+
spuKey
+
" spu_id:"
+
spuId
)
...
...
@@ -224,7 +232,7 @@ func (t *CommonLyService) writeSkuInfo(ctx *gin.Context,skuInfo *model.LyClearGo
common
.
PrintDebugHtml
(
ctx
,
inSkuInfo
)
skuKey
:=
common
.
GetKey
(
skuInfo
.
GoodsSn
+
"_"
+
strconv
.
FormatInt
(
t
.
supplierId
,
10
))
redis
Write
.
Do
(
"HSET"
,
config
.
Get
(
"redis_all.SKU_UNIQUE_JUDGE"
)
.
String
(),
skuKey
,
skuId
)
redis
Spu
.
Do
(
"HSET"
,
config
.
Get
(
"redis_all.SKU_UNIQUE_JUDGE"
)
.
String
(),
skuKey
,
skuId
)
//todo 如果是digikey新增,需要插入原始映射表
if
t
.
supplierId
==
7
{
...
...
@@ -240,7 +248,11 @@ func (t *CommonLyService) writeSkuInfo(ctx *gin.Context,skuInfo *model.LyClearGo
*/
func
(
t
*
CommonLyService
)
writeSpuInfo
(
ctx
*
gin
.
Context
,
skuInfo
*
model
.
LyClearGoodsList
)
string
{
redisWrite
:=
gredis
.
Conn
(
"search_w"
)
defer
redisWrite
.
Close
()
redisSpu
:=
gredis
.
Conn
(
"spu"
)
defer
func
()
{
redisWrite
.
Close
()
redisSpu
.
Close
()
}()
brand_key
:=
common
.
GetKey
(
strings
.
ToLower
(
skuInfo
.
BrandName
))
brandId
,
_
:=
redis
.
Int64
(
redisWrite
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.BRAND_NAME_ALL"
)
.
String
(),
brand_key
))
...
...
@@ -271,12 +283,12 @@ func (t *CommonLyService) writeSpuInfo(ctx *gin.Context,skuInfo *model.LyClearGo
}
jsonStr
,
_
:=
json
.
Marshal
(
Spuinfo
)
redis
Write
.
Do
(
"HSET"
,
"spu"
,
spuId
,
jsonStr
)
redis
Spu
.
Do
(
"HSET"
,
"spu"
,
spuId
,
jsonStr
)
common
.
PrintDebugHtml
(
ctx
,
"新增spu:"
+
string
(
jsonStr
))
spuKey
:=
common
.
GetKey
(
skuInfo
.
GoodsName
+
"_"
+
skuInfo
.
BrandName
)
redis
Write
.
Do
(
"HSET"
,
config
.
Get
(
"redis_all.SPU_UNIQUE_JUDGE"
)
.
String
(),
spuKey
,
spuId
)
redis
Spu
.
Do
(
"HSET"
,
config
.
Get
(
"redis_all.SPU_UNIQUE_JUDGE"
)
.
String
(),
spuKey
,
spuId
)
return
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