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
64931402
authored
Sep 28, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
5ce78307
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
2 additions
and
155 deletions
cmd/cron_server.go
cmd/rpc_server.go
cmd/test1.go
pkg/gredis/redis.go
service/service_zy.go
cmd/cron_server.go
deleted
100644 → 0
View file @
5ce78307
package
main
import
(
"flag"
"goods_machining/boot"
)
func
main
()
{
var
path
string
flag
.
StringVar
(
&
path
,
"config"
,
"conf"
,
"配置文件"
)
var
mod
string
;
flag
.
StringVar
(
&
mod
,
"m"
,
"all"
,
"请输入模块id"
)
// 单独计算某个模块,默认计算全部,0计算全部
flag
.
Parse
()
if
err
:=
boot
.
Boot
(
path
);
err
!=
nil
{
panic
(
err
)
}
}
cmd/rpc_server.go
deleted
100644 → 0
View file @
5ce78307
package
main
import
(
"github.com/micro/go-micro/v2"
)
func
main
()
{
cService
:=
micro
.
NewService
(
micro
.
Name
(
"go.micro.grpc.search"
))
cService
.
Init
()
}
\ No newline at end of file
cmd/test1.go
deleted
100644 → 0
View file @
5ce78307
package
main
import
(
"encoding/json"
"flag"
"fmt"
"github.com/tidwall/gjson"
"os"
"goods_machining/boot"
"goods_machining/service/query"
)
func
main
()
{
//MouserService := service.NewMouserServiceImpl()
//MouserGetData(MouserService)
var
path
string
flag
.
StringVar
(
&
path
,
"config"
,
"conf"
,
"配置文件"
)
flag
.
Parse
()
if
err
:=
boot
.
Boot
(
path
);
err
!=
nil
{
panic
(
err
)
}
//lock_key := "searchapi_668777";
////flag := gredis.Set(lock_key,php2go.Time()+2)
//flag,_ := gredis.Setnx(lock_key,2222)
//
//fmt.Println(flag)
//os.Exit(1)
//redisConn := gredis.Conn("search_r")
//defer redisConn.Close()
//attrName, err := gredis.String(redisConn.Do("GET", "hcy1"))
//
//fmt.Println(err)
//fmt.Println(attrName)
//os.Exit(1)
//ss := "LM358"
//mouserRes := service.OutLink(&ss,"-1")
//for k, mouseItem := range mouserRes {
// fmt.Println(k)
// fmt.Println(mouseItem.PriceTemp)
// os.Exit(1)
//}
//fmt.Errorf()
println
(
query
.
GetExactGoodsQuery
(
"nninin"
))
jsonstr
:=
`{"goods_id":1156147221172418504,"goods_sn":"","spu_id":"2156147221162468806","update_time":1561472211,"goods_status":3,"goods_name":"RC0603FR-07100KL","goods_type":2,"supplier_id":17,"encoded":"10059","batch_sn":"1148","moq":27961,"mpq":1,"stock":1765,"hk_delivery_time":"","cn_delivery_time":"4\u4e2a\u5de5\u4f5c\u65e5","goods_details":"","ladder_price":[{"purchases":2765,"price_cn":0.01072951425,"price_us":0},{"purchases":45654,"price_cn":0.343434,"price_us":6666}],"goods_images":"","canal":"L0000110","cp_time":0}`
m
,
ok
:=
gjson
.
Parse
(
jsonstr
)
.
Value
()
.
(
map
[
string
]
interface
{})
if
!
ok
{
fmt
.
Println
(
ok
)
os
.
Exit
(
1
)
}
goods_id
:=
gjson
.
Get
(
jsonstr
,
"goods_id"
)
.
String
()
ladder
:=
gjson
.
Get
(
jsonstr
,
"ladder_price"
)
.
Array
()
temp1
:=
[]
map
[
string
]
float64
{};
for
_
,
value
:=
range
ladder
{
b
:=
value
.
Map
()
temp1
=
append
(
temp1
,
map
[
string
]
float64
{
"purchases"
:
b
[
"purchases"
]
.
Float
(),
"price_cn"
:
b
[
"price_cn"
]
.
Float
(),
"price_us"
:
b
[
"price_us"
]
.
Float
(),
})
}
//fmt.Println(ladder)
//
m
[
"goods_id"
]
=
goods_id
m
[
"ladder_price"
]
=
temp1
dd
,
_
:=
json
.
Marshal
(
m
)
fmt
.
Println
(
string
(
dd
))
//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
//
//param := map[string]interface{}{
// "goods_status":1,
// "status":1,
// "encoded": "{'ddd'}",
//}
//
//paramjson,_ := json.Marshal(param)
//
//skuEsUpdataList = append(skuEsUpdataList,string(paramjson))
//skuEsUpdataList = append(skuEsUpdataList,string(paramjson))
//
//
//println(strings.Join(skuEsUpdataList,"\n"))
os
.
Exit
(
1
)
}
//xml := strings.NewReader(resp)
//json, err := xj.Convert(xml)
//if err != nil {
// panic("That's embarrassing...")
//}
//
//json_str := json.String();
////ss := gjson.Get(json_str,"hello").String()
//
//fmt.Println(json_str)
pkg/gredis/redis.go
View file @
64931402
...
...
@@ -122,8 +122,7 @@ func HgetPi2(redisCon string,hkey string,targetIds []string) map[string]string
skuArr
:=
make
(
map
[
string
]
string
,
0
)
for
_
,
goods_id
:=
range
targetIds
{
info
,
err
:=
String
(
redisConn
.
Do
(
"HGET"
,
hkey
,
goods_id
))
fmt
.
Print
(
err
)
info
,
_
:=
String
(
redisConn
.
Do
(
"HGET"
,
hkey
,
goods_id
))
if
info
==
""
{
skuArr
[
goods_id
]
=
""
}
else
{
...
...
service/service_zy.go
View file @
64931402
...
...
@@ -39,8 +39,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsR
redisConn
.
Close
();
}()
skuArr
:=
gredis
.
HgetPi2
(
"search_r"
,
"Self_SelfGoods"
,
goodsIds
)
//批量获取商品详情
fmt
.
Print
(
"查询redis"
,
len
(
skuArr
))
skuArr
:=
gredis
.
HgetPi
(
"search_r"
,
"Self_SelfGoods"
,
goodsIds
)
//批量获取商品详情
fast
:=
ctx
.
Request
.
FormValue
(
"power[fast]"
)
for
goods_id
,
info
:=
range
skuArr
{
...
...
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