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
52bd65bb
authored
Jul 02, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'dev' into ysx-quote-20200628
parents
8fbc8f1d
9623f3c8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
187 additions
and
34 deletions
cmd/test1.go
go.mod
model/ly.go
pkg/common/function.go
service/common_ly_service.go
service/mouser_service.go
cmd/test1.go
View file @
52bd65bb
...
...
@@ -8,11 +8,20 @@ import (
func
main
()
{
//MouserService := service.NewMouserServiceImpl()
//MouserGetData(MouserService)
dd
:=
service
.
OutLink
(
"LM358"
,
"-1"
)
print
(
"niin"
)
print
(
dd
)
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)
\ No newline at end of file
go.mod
View file @
52bd65bb
...
...
@@ -27,6 +27,7 @@ require (
github.com/prometheus/client_golang v1.5.1 // indirect
github.com/prometheus/common v0.10.0
github.com/prometheus/procfs v0.0.11 // indirect
github.com/silenceper/gowatch v0.0.0-20200624073703-8e473a9db258 // indirect
github.com/sirupsen/logrus v1.5.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.5.1 // indirect
...
...
@@ -35,6 +36,7 @@ require (
go.uber.org/zap v1.14.1 // indirect
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361
google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece // indirect
google.golang.org/grpc v1.29.1 // indirect
google.golang.org/protobuf v1.24.0
...
...
model/ly.go
View file @
52bd65bb
...
...
@@ -11,13 +11,148 @@ type LyClearGoodsList struct {
GoodsImg
string
`json:"goods_img"`
//sku图片
Cat
string
`json:"cat"`
//分类
RestrictionMessage
string
`json:"RestrictionMessage"`
//额外购买限制内容,如 ‘当前商品不在本地区销售’
increment
int
`json:"increment"`
//最小包装量、倍数
Increment
uint64
`json:"increment"`
//最小包装量、倍数
SinglePrice
float64
`json:"single_price"`
//最小单价
Tiered
[]
*
TierItem
//价格梯度数量
}
type
TierItem
struct
{
Purchases
int
//购买数量
Purchases
uint64
//购买数量
PriceUs
float64
//数量对应的英文价格
PriceCn
float64
//数量对应的中文价格
}
/*
供应商详情
Array
(
[supplier_id] => 4
[supplier_nickname] => tme
[ad_text] => 电子元器件、电工产品和工业自动化元件的全球分销商
[cn_delivery] => 5-9工作日
[hk_delivery] => 4-7工作日
[ad_url] => https://www.ichunt.com/
[sort] => 0
[supplier_logo] => http://img.ichunt.com/images/cms/201912/11/b2c4e3aae9a2312dfe6b9c318b430354.jpg
[status] => 1
[describe] => 电子元器件、电工产品和工业自动化元件的全球分销商
[price_json] => Array
(
[0] => Array
(
[hk] => 1.197
[cn] => 9.2534796
[rate] => 6.9
)
)
)
*/
type
SUPPLIER_REDIS_INFO_
struct
{
SupplierId
string
`json:"supplier_id"`
//供应商id
SupplierNickname
string
`json:"supplier_nickname"`
//供应商名称
AdText
string
`json:"ad_text"`
//供应商描述
CnDelivery
string
`json:"cn_delivery"`
//国内交货时间
HkDelivery
string
`json:"hk_delivery"`
//香港交货时间
AdUrl
string
`json:"ad_url"`
//供应商官网
Sort
string
`json:"sort"`
//排序
SupplierLogo
string
`json:"supplier_logo"`
//供应商logo
Status
string
`json:"status"`
//状态,1开启
Describe
string
`json:"describe"`
//描述
PriceJson
[]
*
PriceJsonItem
//价格
}
type
PriceJsonItem
struct
{
hk
float64
//购买数量
cn
float64
//数量对应的英文价格
rate
float64
//数量对应的中文价格
}
/*
联营sku详情
Array
(
[spu_id] => 2.1540893752409E+18
[encoded] =>
[moq] => 624
[mpq] => 1
[old_goods_id] => 0
[goods_type] => 1
[goods_status] => 1
[batch_sn] =>
[stock] => 0
[hk_delivery_time] =>
[cn_delivery_time] =>
[update_time] => 1540967156
[goods_images] =>
[canal] =>
[supplier_id] => 10
[is_expire] => 1
[ladder_price] => Array
(
[0] => Array
(
[purchases] => 624
[price_cn] => 0
[price_us] => 13.42
)
[1] => Array
(
[purchases] => 6240
[price_cn] => 0
[price_us] => 12.12
)
[2] => Array
(
[purchases] => 624000
[price_cn] => 0
[price_us] => 2.383
)
)
)
*/
type
LySkuInfo
struct
{
SpuId
string
`json:"spu_id"`
//spu_id
Encoded
string
`json:"encoded"`
Moq
int
`json:"moq"`
Mpq
int
`json:"mpq"`
OldGoodsId
int
`json:"old_goods_id"`
GoodsType
int
`json:"goods_type"`
GoodsStatus
int
`json:"goods_status"`
BatchSn
string
`json:"batch_sn"`
Stock
string
`json:"stock"`
UpdateTime
string
`json:"update_time"`
GoodsImages
string
`json:"goods_images"`
Canal
string
`json:"canal"`
SupplierId
string
`json:"supplier_id"`
IsExpire
string
`json:"is_expire"`
HkDeliveryTime
string
`json:"hk_delivery_time"`
CnDeliveryTime
string
`json:"cn_delivery_time"`
LadderPrice
[]
*
LadderPrice2
`json:"ladder_price"`
}
type
LadderPrice2
struct
{
Purchases
int
`json:"purchases"`
//数量
PriceUs
float64
`json:"price_us"`
//英文价格
PriceCn
float64
`json:"price_cn"`
//中文价格
PriceAc
float64
`json:"price_ac"`
}
/*
spu详情
Array
(
[class_id1] => 0
[class_id2] => 0
[class_id3] => 0
[brand_id] => 7087
[spu_name] => SI4704-D50-GM
[status] => 1
[images_l] =>
[encap] =>
[pdf] =>
[spu_brief] =>
[update_time] => 1540893752
)
*/
\ No newline at end of file
pkg/common/function.go
View file @
52bd65bb
...
...
@@ -57,3 +57,10 @@ func ToString(a interface{}) string {
}
return
"change to String error"
}
/**
* 获取联营活动价
*/
func
lyActivityPrice
()
{
}
\ No newline at end of file
service/common_ly_service.go
0 → 100644
View file @
52bd65bb
This diff is collapsed.
Click to expand it.
service/mouser_service.go
View file @
52bd65bb
package
service
import
(
"github.com/imroc/req"
"os"
"fmt"
"
search_server/model
"
"
github.com/imroc/req
"
"github.com/tidwall/gjson"
"search_server/model"
"time"
)
//mouser外链网址
...
...
@@ -17,7 +16,6 @@ func NewMouserServiceImpl() *MouserServiceImpl {
return
&
MouserServiceImpl
{}
}
//mouser请求外链
func
OutLink
(
goodsName
string
,
flag
string
)
map
[
string
]
*
model
.
LyClearGoodsList
{
var
result
string
;
...
...
@@ -39,49 +37,49 @@ func OutLink(goodsName string,flag string) map[string]*model.LyClearGoodsList {
apiGoodsList
:=
gjson
.
Get
(
result
,
"SearchResults.Parts"
)
.
Array
()
for
_
,
goods
:=
range
apiGoodsList
{
fmt
.
Println
(
goods
)
os
.
Exit
(
1
)
//拼接价格梯度
//PriceBreaks := goods["PriceBreaks"]
goodsStr
:=
goods
.
String
(
)
goodsSn
:=
gjson
.
Get
(
goodsStr
,
"MouserPartNumber"
)
.
String
()
//供应商唯一编码
ladderPrice
:=
make
([]
*
model
.
TierItem
,
0
)
//拼接价格梯度
apiPriceTi
:=
gjson
.
Get
(
goodsStr
,
"PriceBreaks"
)
.
Array
()
var
apiLowerPrice
float64
=
0
;
//计算最低价格
for
_
,
priceItem
:=
range
apiPriceTi
{
priceItemStr
:=
priceItem
.
String
();
onePrice
:=
gjson
.
Get
(
priceItemStr
,
"Price"
)
.
Float
()
if
apiLowerPrice
==
0
{
apiLowerPrice
=
onePrice
}
else
if
apiLowerPrice
>
onePrice
{
apiLowerPrice
=
onePrice
}
ladder
:=
model
.
TierItem
{
Purchases
:
1
,
PriceUs
:
0.44
,
PriceCn
:
1.55
,
Purchases
:
gjson
.
Get
(
priceItemStr
,
"Quantity"
)
.
Uint
()
,
PriceUs
:
onePrice
,
PriceCn
:
0
,
}
ladderPrice
=
append
(
ladderPrice
,
&
ladder
)
}
goodsStr
:=
goods
.
String
()
//拼接联营数据
LyClearGoodsList
:=
model
.
LyClearGoodsList
{
GoodsName
:
gjson
.
Get
(
goodsStr
,
"ManufacturerPartNumber"
)
.
String
(),
BrandName
:
gjson
.
Get
(
goodsStr
,
"Manufacturer"
)
.
String
(),
Desc
:
gjson
.
Get
(
goodsStr
,
"Description"
)
.
String
(),
GoodsSn
:
g
json
.
Get
(
goodsStr
,
"MouserPartNumber"
)
.
String
()
,
GoodsSn
:
g
oodsSn
,
Docurl
:
gjson
.
Get
(
goodsStr
,
"DataSheetUrl"
)
.
String
(),
Url
:
gjson
.
Get
(
goodsStr
,
"ProductDetailUrl"
)
.
String
(),
GoodsImg
:
gjson
.
Get
(
goodsStr
,
"ImagePath"
)
.
String
(),
Cat
:
gjson
.
Get
(
goodsStr
,
"Category"
)
.
String
(),
Increment
:
gjson
.
Get
(
goodsStr
,
"Mult"
)
.
Uint
(),
RestrictionMessage
:
gjson
.
Get
(
goodsStr
,
"RestrictionMessage"
)
.
String
(),
SinglePrice
:
apiLowerPrice
,
Tiered
:
ladderPrice
,
}
productList
[
"595-LM358BIDR"
]
=
&
LyClearGoodsList
productList
[
goodsSn
]
=
&
LyClearGoodsList
}
fmt
.
Println
(
productList
)
return
productList
//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)
}
\ No newline at end of file
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