Commit 3f5b1808 by mushishixian

整理数据

parent 38af2c53
......@@ -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
......@@ -18,6 +18,7 @@ func Zyh(ctx *gin.Context){
zyhRequest[requestName] = strings.TrimSpace(requstValue[0])
}
}
fmt.Println(zyhRequest)
zyServiceImpl := service.NewZyServiceImpl()
......
......@@ -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"`
......
......@@ -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
}
//反爬虫加密验证
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
}
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")
}
}
......@@ -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)
......
......@@ -66,13 +66,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 +84,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 +100,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 +113,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())
......@@ -117,6 +123,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
for _, price := range data.Get("ladder_price").Array() {
ladder := model.LadderPrice{
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(),
......@@ -161,8 +168,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()
......@@ -244,5 +251,3 @@ func GetGoodsIdsByEsMsearch(res string) (goodsIds []string) {
fmt.Println(goodsIds)
return
}
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment