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
76f0856b
authored
Jul 17, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
a362780b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
26 deletions
cmd/test1.go
conf/rabmq_key.ini
service/common_ly_service.go
service/mouser_service.go
cmd/test1.go
View file @
76f0856b
...
...
@@ -2,10 +2,10 @@ package main
import
(
"flag"
"fmt"
"os"
"search_server/boot"
"search_server/pkg/es"
"strings"
"search_server/service"
)
func
main
()
{
...
...
@@ -32,18 +32,27 @@ func main() {
//fmt.Println(err)
//fmt.Println(attrName)
//os.Exit(1)
//dd := service.OutLink("LM358","-1")
lines
:=
[]
string
{
`{"index":{"_index":"hcy1","_type":"goods","_id":"s1"} }`
,
`{"name":"john doe","age":25 }`
,
`{"index":{"_index":"hcy1","_type":"goods","_id":"s2"} }`
,
`{"name":"mary smith","age":32 }`
,
ss
:=
"LM358"
mouserRes
:=
service
.
OutLink
(
&
ss
,
"-1"
)
for
k
,
mouseItem
:=
range
mouserRes
{
fmt
.
Println
(
k
)
fmt
.
Println
(
mouseItem
.
PriceTemp
)
os
.
Exit
(
1
)
}
param
:=
strings
.
Join
(
lines
,
"
\n
"
)
+
"
\n
"
//fmt.Errorf()
result
,
err
:=
es
.
BulkES
(
param
)
println
(
result
,
err
)
//lines := []string{
// `{"index":{"_index":"hcy1","_type":"goods","_id":"s1"} }`,
// `{"name":"john doe","age":25 }`,
// `{"index":{"_index":"hcy1","_type":"goods","_id":"s2"} }`,
// `{"name":"mary smith","age":32 }`,
//}
//param := strings.Join(lines, "\n")+"\n"
//
//result,err := es.BulkES(param)
//println(result,err)
//var skuEsUpdataList []string
//
...
...
conf/rabmq_key.ini
View file @
76f0856b
[rabmq]
url
=
amqp:
//
guest:guest@192.168.2.232:5672/
url
=
amqp:
;
guest:guest@192.168.2.232:5672/
;存放本系统所有的队列名称
[rabmq_all]
; bom任务id
MQ_BOM_ITEMS_LIST
=
bom_items_list
; bom更新数据队列
MQ_BOM_SKU_LIST
=
bom_sku_list
;联营数据推送入队列-》go后台任务消费(斌哥脚本)
search_sku_list
=
search_sku_list
SEARCH_SKU_UPDATE_LIST
=
search_sku_update_list
; bom任务id
ZIYING_MQ_BOM_ITEMS_LIST
=
ziying_bom_items_list
; bom更新数据队列
ZIYING_MQ_BOM_SKU_LIST
=
ziying_bom_sku_list
\ No newline at end of file
service/common_ly_service.go
View file @
76f0856b
...
...
@@ -13,6 +13,7 @@ import (
"search_server/pkg/config"
"search_server/pkg/es"
"search_server/pkg/gredis"
"search_server/pkg/mq"
"search_server/pkg/mysql"
"strconv"
"strings"
...
...
@@ -287,8 +288,14 @@ func (t * CommonLyService) updateSkuDB(skuInfo *model.LyClearGoodsList) {
"goods_name"
:
skuInfo
.
GoodsName
,
"goods_sn"
:
skuInfo
.
GoodsSn
,
}
paramjson
,
_
:=
json
.
Marshal
(
param
)
if
t
.
flag
==
"101"
{
t
.
flagStr
=
"<br/><br/>"
;
t
.
flagStr
=
"推送到go更新db:"
;
t
.
flagStr
=
string
(
paramjson
);
t
.
flagStr
=
"<br/><br/>"
;
}
mq
.
PushMsg
(
config
.
Get
(
"rabmq_all.SEARCH_SKU_UPDATE_LIST"
)
.
String
(),
string
(
paramjson
))
}
/*
...
...
service/mouser_service.go
View file @
76f0856b
...
...
@@ -4,6 +4,8 @@ import (
"github.com/imroc/req"
"github.com/tidwall/gjson"
"search_server/model"
"strconv"
"strings"
"time"
)
//mouser外链网址
...
...
@@ -25,8 +27,7 @@ func OutLink(goodsName *string,flag string) map[string]*model.LyClearGoodsList {
result
=
resp
.
String
();
//请求外链拿到结果
}
var
productList
map
[
string
]
*
model
.
LyClearGoodsList
//格式化数据后返回的所有数据
productList
=
make
(
map
[
string
]
*
model
.
LyClearGoodsList
,
0
)
productList
:=
make
(
map
[
string
]
*
model
.
LyClearGoodsList
,
0
)
apiGoodsList
:=
gjson
.
Get
(
result
,
"SearchResults.Parts"
)
.
Array
()
for
_
,
goods
:=
range
apiGoodsList
{
...
...
@@ -40,22 +41,30 @@ func OutLink(goodsName *string,flag string) map[string]*model.LyClearGoodsList {
var
apiLowerPrice
float64
=
0
;
//计算最低价格
for
_
,
priceItem
:=
range
apiPriceTi
{
priceItemStr
:=
priceItem
.
String
();
onePrice
:=
gjson
.
Get
(
priceItemStr
,
"Price"
)
.
Float
()
//价格转换
onePrice
:=
gjson
.
Get
(
priceItemStr
,
"Price"
)
.
String
()
onePrice
=
strings
.
ReplaceAll
(
strings
.
Trim
(
onePrice
,
"$"
),
","
,
""
)
skuPrice
,
_
:=
strconv
.
ParseFloat
(
onePrice
,
64
)
//转成float64
//数量转换
quantity
:=
gjson
.
Get
(
priceItemStr
,
"Quantity"
)
.
Uint
()
if
apiLowerPrice
==
0
{
apiLowerPrice
=
one
Price
}
else
if
apiLowerPrice
>
one
Price
{
apiLowerPrice
=
one
Price
apiLowerPrice
=
sku
Price
}
else
if
apiLowerPrice
>
sku
Price
{
apiLowerPrice
=
sku
Price
}
ladder
:=
model
.
TierItem
{
Purchases
:
gjson
.
Get
(
priceItemStr
,
"Quantity"
)
.
Uint
()
,
PriceUs
:
one
Price
,
Purchases
:
quantity
,
PriceUs
:
sku
Price
,
PriceCn
:
0
,
}
ladderPrice
=
append
(
ladderPrice
,
&
ladder
)
//梯度缓存数据
priceTemp
=
append
(
priceTemp
,
gjson
.
Get
(
priceItemStr
,
"Quantity"
)
.
Uint
())
priceTemp
=
append
(
priceTemp
,
gjson
.
Get
(
priceItemStr
,
"Price"
)
.
Float
())
priceTemp
=
append
(
priceTemp
,[]
interface
{}{
quantity
,
skuPrice
,
})
}
//拼接联营数据
...
...
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