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
ac1a02db
authored
Jul 20, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-quote-20200628' into dev
parents
76f0856b
4714c1e0
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
177 additions
and
24 deletions
conf/search.ini
controller/ziyin_controller.go
middleware/cors.go
model/goods.go
pkg/common/function.go
pkg/common/sort.go
service/bom_service.go
service/get_data_service.go
service/goods_service.go
test/test.go
conf/search.ini
View file @
ac1a02db
...
...
@@ -150,3 +150,5 @@ Index = liexin_ziying
1678
=
https://estore.heilindasia.com/search.asp?p=liexin
1680
=
http://shop.wpgam.com/WPGAStore/index.php?route=product/search&filter_description=true&filter_name=liexin
SUPER_AUTH_KEY
=
fh6y5t4rr351d2c3bryi
SEARCH_TOKEN_EXPIRE_TIME
=
30
\ No newline at end of file
controller/ziyin_controller.go
View file @
ac1a02db
...
...
@@ -18,6 +18,7 @@ func Zyh(ctx *gin.Context){
zyhRequest
[
requestName
]
=
strings
.
TrimSpace
(
requstValue
[
0
])
}
}
fmt
.
Println
(
zyhRequest
)
zyServiceImpl
:=
service
.
NewZyServiceImpl
()
...
...
middleware/cors.go
View file @
ac1a02db
...
...
@@ -9,6 +9,7 @@ import (
func
Cors
()
gin
.
HandlerFunc
{
corsDomain
:=
config
.
Get
(
"web.cors_domain"
)
.
Strings
(
","
)
corsDomain
=
append
(
corsDomain
,
"https://bom.ichunt.com"
)
return
cors
.
New
(
cors
.
Config
{
AllowOrigins
:
corsDomain
,
AllowMethods
:
[]
string
{
"POST"
,
"GET"
,
"PUT"
,
"DELETE"
},
...
...
model/goods.go
View file @
ac1a02db
...
...
@@ -13,7 +13,7 @@ type ApiGoods struct {
Mpq
int
`json:"-"`
MpqStr
interface
{}
`json:"mpq"`
Mpl
int
`json:"-"`
MplStr
interface
{}
`json:"mpl"`
MplStr
interface
{}
`json:"mpl
,omitempty
"`
Stock
int
`json:"-"`
StockStr
interface
{}
`json:"stock"`
HkDeliveryTime
string
`json:"hk_delivery_time"`
...
...
@@ -24,10 +24,12 @@ type ApiGoods struct {
BrandId
int
`json:"brand_id"`
ClassId1
int
`json:"class_id1"`
ClassId2
int
`json:"class_id2"`
ClassName
string
`json:"class_name"`
Encoded
string
`json:"encoded"`
Packing
string
`json:"packing,omitempty"`
GoodsUnit
string
`json:"goods_unit,goods_unit"`
GoodsImages
string
`json:"goods_images"`
GoodsDetails
string
`json:"goods_details"`
GoodsBrief
string
`json:"goods_brief,omitempty"`
IsBuy
int
`json:"is_buy"`
Status
int
`json:"status"`
...
...
@@ -50,8 +52,8 @@ type ApiGoods struct {
ClassId1Name
string
`json:"class_id1_name"`
CLassId2Name
string
`json:"c_lass_id2_name"`
SpuId
string
`json:"spu_id,omitempty"`
BatchSn
string
`json:"batch_sn
,omitempty
"`
Canal
string
`json:"canal
,omitempty
"`
BatchSn
string
`json:"batch_sn"`
Canal
string
`json:"canal"`
CpTime
int
`json:"cp_time"`
Coefficient
Coefficient
`json:"coefficient,omitempty"`
OriginalPrice
[]
OriginalPrice
`json:"original_price,omitempty"`
...
...
pkg/common/function.go
View file @
ac1a02db
...
...
@@ -8,6 +8,8 @@ import (
"math/big"
"math/rand"
"regexp"
"search_server/middleware"
"search_server/pkg/config"
"search_server/pkg/vars"
"strconv"
"strings"
...
...
@@ -149,10 +151,117 @@ func Rand(min, max int) int {
return
int
(
n
.
Int64
())
+
min
}
func
CopyMapString
(
distmap
map
[
string
]
string
)
map
[
string
]
string
{
tmpmap
:=
make
(
map
[
string
]
string
,
0
)
func
CopyMapString
(
distmap
map
[
string
]
string
)
map
[
string
]
string
{
tmpmap
:=
make
(
map
[
string
]
string
,
0
)
for
k
,
v
:=
range
distmap
{
tmpmap
[
k
]
=
v
}
return
tmpmap
}
\ No newline at end of file
}
//反爬虫加密验证
func
CheckSignApi
(
params
map
[
string
]
string
)
(
resNo
int
)
{
ctx
:=
middleware
.
Context
if
ctx
==
nil
{
return
}
referer
:=
ctx
.
Request
.
Referer
()
request
:=
make
(
map
[
string
]
string
)
ctx
.
MultipartForm
()
for
name
,
value
:=
range
ctx
.
Request
.
Form
{
if
value
[
0
]
!=
""
{
request
[
name
]
=
strings
.
TrimSpace
(
value
[
0
])
}
}
if
request
[
"hcy_test"
]
==
"1122"
{
return
0
}
if
request
[
"no_rule"
]
==
"1122"
{
return
0
}
if
request
[
"check_button"
]
==
"2"
||
strings
.
Contains
(
ctx
.
Request
.
Referer
(),
"liexin.com"
)
{
return
0
}
//如果是内部验证通过,则内部通过
if
auth
()
{
return
0
}
//验证必填参数
if
referer
==
""
{
return
4
}
if
ctx
.
Query
(
"asdfghjkl"
)
!=
""
{
params
=
request
}
if
ctx
.
PostForm
(
"asdfghjkl"
)
!=
""
{
params
=
request
}
params
[
"Yo4teW_gid"
],
_
=
ctx
.
Cookie
(
"Yo4teW_gid"
)
if
params
[
"asdfghjkl"
]
==
""
||
params
[
"Yo4teW_gid"
]
==
""
||
params
[
"qwertyuiop"
]
==
""
{
return
1
}
var
temp1
[]
string
//根据参数,按照规则进行签名生成
for
k
,
v
:=
range
params
{
if
k
==
"asdfghjkl"
||
k
==
"_"
||
k
==
"callback"
{
continue
}
if
v
==
""
||
v
==
"undefined"
||
v
==
"null"
||
v
==
"NULL"
{
continue
}
if
len
(
v
)
<=
0
{
continue
}
temp1
=
append
(
temp1
,
k
+
"="
+
v
)
}
SortSlice
(
temp1
)
temp2
:=
strings
.
Join
(
temp1
,
""
)
r
:=
regexp
.
MustCompile
(
`[^0-9a-zA-Z]`
)
temp2
=
r
.
ReplaceAllString
(
temp2
,
""
)
temp2
=
strings
.
ToUpper
(
temp2
)
r
=
regexp
.
MustCompile
(
`[ABC]`
)
temp2
=
r
.
ReplaceAllString
(
temp2
,
""
)
temp3
:=
php2go
.
Sha1
(
temp2
)
//'YO4TEW_GID%3DEFDDE3E06D15F887866E9D96DOM_RNK%3D1GOODS_NME%2FONDITION%3DLM358P%3D1PF%3D1TIME_LIEXIN%3D1545009990450';
//验证签名
if
temp3
==
params
[
"asdfghjkl"
]
{
return
0
}
return
3
}
//内部免验证通过
func
auth
()
bool
{
ctx
:=
middleware
.
Context
if
ctx
==
nil
{
return
false
}
request
:=
make
(
map
[
string
]
string
)
ctx
.
MultipartForm
()
for
name
,
value
:=
range
ctx
.
Request
.
Form
{
if
value
[
0
]
!=
""
{
request
[
name
]
=
strings
.
TrimSpace
(
value
[
0
])
}
}
k1
:=
request
[
"k1"
]
k1Num
,
_
:=
strconv
.
Atoi
(
k1
)
k2
:=
request
[
"k2"
]
key
:=
config
.
Get
(
"SUPER_AUTH_KEY"
)
.
String
()
if
k1
!=
""
&&
int64
(
k1Num
)
<
(
time
.
Now
()
.
Unix
()
-
600
)
{
return
false
}
//md5(md5($pwd).$salt);
pwd
:=
Md5
(
Md5
(
k1
)
+
key
)
if
k2
==
pwd
{
return
true
}
return
false
}
pkg/common/sort.go
0 → 100644
View file @
ac1a02db
package
common
import
(
"reflect"
"sort"
)
func
getCommon
(
array
interface
{})
(
reflect
.
Type
,
reflect
.
Value
,
int
)
{
t
:=
reflect
.
TypeOf
(
array
)
v
:=
reflect
.
ValueOf
(
array
)
l
:=
v
.
Len
()
return
t
,
v
,
l
}
func
SortSlice
(
array
interface
{})
{
t
,
v
,
_
:=
getCommon
(
array
)
// res := make([]interface{}, l)
if
t
.
Kind
()
==
reflect
.
Slice
{
switch
v
.
Index
(
0
)
.
Kind
()
{
case
reflect
.
Int
:
array
:=
array
.
([]
int
)
sort
.
Ints
(
array
)
case
reflect
.
String
:
array
:=
array
.
([]
string
)
sort
.
Strings
(
array
)
case
reflect
.
Float64
:
array
:=
array
.
([]
float64
)
sort
.
Float64s
(
array
)
default
:
panic
(
"the param can only be int/string/float64 array"
)
}
}
else
{
panic
(
"expects parameter 1 to be array"
)
}
}
service/bom_service.go
View file @
ac1a02db
...
...
@@ -170,7 +170,7 @@ func getBomTermQuery(goodsName, brandName string, number int, isRawSearch bool)
if
isRawSearch
{
source
.
Size
(
100
)
}
else
{
source
.
Size
(
1
)
source
.
Size
(
50
)
}
source
.
Sort
(
"_score"
,
false
)
.
Sort
(
"sort"
,
false
)
.
Sort
(
"single_price"
,
true
)
queryRequest
:=
elastic
.
NewSearchRequest
()
.
Source
(
source
)
...
...
service/get_data_service.go
View file @
ac1a02db
...
...
@@ -85,6 +85,7 @@ func (gs *GetDataService) GetQuery(originKeyword, supplierName, brandId, goodsNa
source
.
Sort
(
"update_time"
,
false
)
source
.
Sort
(
"stock"
,
false
)
source
.
Sort
(
"single_price"
,
true
)
source
.
FetchSourceContext
(
elastic
.
NewFetchSourceContext
(
true
)
.
Include
(
"goods_id"
,
"old_goods_id"
,
"status"
))
source
.
From
(
0
)
source
.
Size
(
2
)
...
...
service/goods_service.go
View file @
ac1a02db
package
service
import
(
"fmt"
"github.com/gomodule/redigo/redis"
"github.com/imroc/req"
"github.com/tidwall/gjson"
...
...
@@ -66,13 +65,16 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
goods
.
GoodsType
=
int
(
data
.
Get
(
"goods_type"
)
.
Int
())
goods
.
SupplierId
=
int
(
data
.
Get
(
"supplier_id"
)
.
Int
())
goods
.
Mpq
=
int
(
data
.
Get
(
"mpq"
)
.
Int
())
goods
.
MpqStr
=
int
(
data
.
Get
(
"mpq"
)
.
Int
())
goods
.
Moq
=
int
(
data
.
Get
(
"moq"
)
.
Int
())
goods
.
MoqStr
=
int
(
data
.
Get
(
"moq"
)
.
Int
())
goods
.
Stock
=
int
(
data
.
Get
(
"stock"
)
.
Int
())
goods
.
StockStr
=
int
(
data
.
Get
(
"stock"
)
.
Int
())
goods
.
HkDeliveryTime
=
data
.
Get
(
"hk_delivery_time"
)
.
String
()
goods
.
CnDeliveryTime
=
data
.
Get
(
"cn_delivery_time"
)
.
String
()
goods
.
BrandName
=
data
.
Get
(
"brand_name"
)
.
String
()
goods
.
SupplierName
=
data
.
Get
(
"supplier_name"
)
.
String
()
goods
.
BrandId
=
int
(
data
.
Get
(
"
goods
_id"
)
.
Int
())
goods
.
BrandId
=
int
(
data
.
Get
(
"
brand
_id"
)
.
Int
())
goods
.
ClassId1
=
int
(
data
.
Get
(
"class_id1"
)
.
Int
())
goods
.
ClassId2
=
int
(
data
.
Get
(
"class_id2"
)
.
Int
())
goods
.
Encoded
=
data
.
Get
(
"encoded"
)
.
String
()
...
...
@@ -81,6 +83,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
goods
.
GoodsImages
=
data
.
Get
(
"goods_images"
)
.
String
()
goods
.
GoodsBrief
=
data
.
Get
(
"goods_brief"
)
.
String
()
goods
.
Mpl
=
int
(
data
.
Get
(
"mpl"
)
.
Int
())
goods
.
MplStr
=
int
(
data
.
Get
(
"mpl"
)
.
Int
())
goods
.
Status
=
int
(
data
.
Get
(
"status"
)
.
Int
())
goods
.
IsBuy
=
int
(
data
.
Get
(
"is_buy"
)
.
Int
())
goods
.
Pdf
=
data
.
Get
(
"pdf"
)
.
String
()
...
...
@@ -96,6 +99,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
goods
.
MpgUnitName
=
data
.
Get
(
"mpg_unit_name"
)
.
String
()
goods
.
ScmBrandName
=
data
.
Get
(
"scm_brand_name"
)
.
String
()
goods
.
AllowCoupon
=
int
(
data
.
Get
(
"allow_coupon"
)
.
Int
())
goods
.
UpdateTime
=
int
(
data
.
Get
(
"update_time"
)
.
Int
())
goods
.
ClassId1Name
=
data
.
Get
(
"class_id1_name"
)
.
String
()
goods
.
CLassId2Name
=
data
.
Get
(
"c_lass_id2_name"
)
.
String
()
goods
.
SpuId
=
data
.
Get
(
"spu_id"
)
.
String
()
...
...
@@ -108,6 +112,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
goods
.
SpuBrief
=
data
.
Get
(
"spu_brief"
)
.
String
()
goods
.
SpuDetail
=
data
.
Get
(
"spu_detail"
)
.
String
()
goods
.
ClassName3
=
data
.
Get
(
"class_name3"
)
.
String
()
goods
.
ClassName
=
data
.
Get
(
"class_name"
)
.
String
()
goods
.
ErpTax
=
data
.
Get
(
"erp_tax"
)
.
Bool
()
goods
.
SupplierId
=
int
(
data
.
Get
(
"supplier_id"
)
.
Int
())
goods
.
GoodsType
=
int
(
data
.
Get
(
"goods_type"
)
.
Int
())
...
...
@@ -116,10 +121,11 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
ladderPrice
:=
make
([]
model
.
LadderPrice
,
0
)
for
_
,
price
:=
range
data
.
Get
(
"ladder_price"
)
.
Array
()
{
ladder
:=
model
.
LadderPrice
{
Purchases
:
int
(
price
.
Get
(
"purchases"
)
.
Int
()),
PriceUs
:
price
.
Get
(
"price_us"
)
.
Float
(),
PriceCn
:
price
.
Get
(
"price_cn"
)
.
Float
(),
PriceAc
:
price
.
Get
(
"price_ac"
)
.
Float
(),
Purchases
:
int
(
price
.
Get
(
"purchases"
)
.
Int
()),
PurchasesStr
:
int
(
price
.
Get
(
"purchases"
)
.
Int
()),
PriceUs
:
price
.
Get
(
"price_us"
)
.
Float
(),
PriceCn
:
price
.
Get
(
"price_cn"
)
.
Float
(),
PriceAc
:
price
.
Get
(
"price_ac"
)
.
Float
(),
}
ladderPrice
=
append
(
ladderPrice
,
ladder
)
}
...
...
@@ -161,8 +167,8 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
//supp_extend_fee
goods
.
SuppExtendFee
.
Cn
.
Max
=
int
(
data
.
Get
(
"supp_extend_fee.cn.max"
)
.
Int
())
goods
.
SuppExtendFee
.
Cn
.
Price
=
data
.
Get
(
"supp_extend_fee.cn.price"
)
.
Float
()
goods
.
SuppExtendFee
.
Hk
.
Max
=
int
(
data
.
Get
(
"supp_extend_fee.
cn
.max"
)
.
Int
())
goods
.
SuppExtendFee
.
Hk
.
Price
=
data
.
Get
(
"supp_extend_fee.
cn
.price"
)
.
Float
()
goods
.
SuppExtendFee
.
Hk
.
Max
=
int
(
data
.
Get
(
"supp_extend_fee.
hk
.max"
)
.
Int
())
goods
.
SuppExtendFee
.
Hk
.
Price
=
data
.
Get
(
"supp_extend_fee.
hk
.price"
)
.
Float
()
//scm_brand
goods
.
ScmBrand
.
ErpBrandName
=
data
.
Get
(
"scm_brand.erp_brand_name"
)
.
String
()
...
...
@@ -231,7 +237,6 @@ func GetGoodsIdsByEs(res string) (goodsIds []string) {
for
_
,
item
:=
range
gjArray
{
goodsIds
=
append
(
goodsIds
,
item
.
String
())
}
fmt
.
Println
(
goodsIds
)
return
}
...
...
@@ -241,8 +246,5 @@ func GetGoodsIdsByEsMsearch(res string) (goodsIds []string) {
for
_
,
item
:=
range
gjArray
{
goodsIds
=
append
(
goodsIds
,
item
.
String
())
}
fmt
.
Println
(
goodsIds
)
return
}
test/test.go
View file @
ac1a02db
...
...
@@ -6,6 +6,7 @@ import (
"github.com/syyongx/php2go"
"reflect"
"search_server/boot"
"search_server/pkg/common"
)
func
StrRandom
(
lenNum
int
)
string
{
...
...
@@ -29,12 +30,11 @@ func main() {
if
err
:=
boot
.
Boot
(
path
);
err
!=
nil
{
fmt
.
Println
(
err
)
}
a
:=
[]
int
{
1
,
2
,
3
}
fmt
.
Println
(
InterfaceSlice
(
a
))
b
:=
[]
string
{
"b"
,
"z"
,
"a"
}
common
.
SortSlice
(
b
)
fmt
.
Println
(
b
)
}
func
InterfaceSlice
(
slice
interface
{})
[]
interface
{}
{
s
:=
reflect
.
ValueOf
(
slice
)
if
s
.
Kind
()
!=
reflect
.
Slice
{
...
...
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