Commit 1d3cd9aa by mushishixian

getData

parent 91fb86ec
......@@ -36,11 +36,12 @@ func GetDataIndex(c *gin.Context) {
if r.SupplierId != "" && r.IsSort == 2 {
//所有供应商列表
//如果供应商不在合并供应商列表,则实时更新数据
if supplierName != "" && !php2go.InArray(r.SupplierName, supplierList) {
if supplierName != "" && !php2go.InArray(supplierName, supplierList) {
redisCon := gredis.Conn("search_w")
defer redisCon.Close()
//获取stockFlag
res, err := redis.Bool(redisCon.Do("SADD", "search_keyword_member", r.Keyword+"_"+r.SupplierName))
fmt.Println(r.Keyword+"_"+r.SupplierName)
if err != nil {
fmt.Println(err)
}
......
......@@ -73,7 +73,7 @@ func BulkES(param string) (result string, err error) {
func CurlESMSearch(queryJson string) (result string, err error) {
endpoints := config.Get("es.urls").Strings(",")
//随机获取一个节点进行请求
req.Debug = true
req.Debug = false
esUrl := endpoints[rand.Intn(len(endpoints))]
params := req.BodyJSON(queryJson)
resp, err := req.Post(esUrl+"/_msearch", params)
......
......@@ -29,8 +29,8 @@ func InitRouter() *gin.Engine {
r.POST("/search/quote/getDataPur", controller.GetDataPur)
//GetData控制器相关
r.GET("/search/get_data/index", controller.GetDataIndex)
r.POST("/search/get_data/index", controller.GetDataIndex)
r.GET("/search/get_data", controller.GetDataIndex)
r.POST("/search/get_data", controller.GetDataIndex)
r.GET("/test", func(c *gin.Context) {
fmt.Println(c.Query("test"))
......
......@@ -50,6 +50,9 @@ func (qs *QuoteService) GetGoodsBySupplierName(r requests.GetGoodsBySupplierRequ
goodsIds := GetGoodsIdsByEs(esResult)
goodsList, err := GetGoodsInfo(goodsIds)
dullData, err := transformer.DullDataInfo(r.Keyword, goodsList)
quoteTransformer := transformer.QuoteTransformer{}
//还要去转一下阶梯价比例
dullData = quoteTransformer.TransformLadderPrice(dullData)
result = GetReturnSupplierData(dullData)
result["total"] = gjson.Get(esResult, "hits.total").Int()
result["took"] = gjson.Get(esResult, "took").Int()
......
......@@ -48,3 +48,21 @@ func (qt *QuoteTransformer) TransformCollectData(keyword, supplierName string, c
}
return
}
//提供给客服报价系统专用
func (qt *QuoteTransformer) TransformLadderPrice(dullData []model.DullGoodsData) (result []model.DullGoodsData) {
for key, data := range dullData {
if len(data.LadderPrice) > 0 {
for k, price := range data.LadderPrice {
if price.PriceUs != 0 {
if data.SupplierId == 6 {
dullData[key].LadderPrice[k].PriceUs = data.OriginalPrice[k].PriceUs * data.PriceHkxs
} else {
dullData[key].LadderPrice[k].PriceUs = data.OriginalPrice[k].PriceUs * data.ApiGoods.Coefficient.ExtraRatio
}
}
}
}
}
return dullData
}
......@@ -4,7 +4,7 @@ import (
"flag"
"fmt"
"github.com/syyongx/php2go"
"regexp"
"reflect"
"search_server/boot"
)
......@@ -29,10 +29,23 @@ func main() {
if err := boot.Boot(path); err != nil {
fmt.Println(err)
}
temp:=1
result:=float64(temp)
fmt.Println(result)
r := regexp.MustCompile(`<b .+?>(.+?)<\/b>`)
name := r.ReplaceAllString(`<b>219038021wdksa;ldas</b>`, `${1}`)
fmt.Println(name)
a := []int{1,2,3}
fmt.Println(InterfaceSlice(a))
}
func InterfaceSlice(slice interface{}) []interface{} {
s := reflect.ValueOf(slice)
if s.Kind() != reflect.Slice {
panic("InterfaceSlice() given a non-slice type")
}
ret := make([]interface{}, s.Len())
for i := 0; i < s.Len(); i++ {
ret[i] = s.Index(i).Interface()
}
return ret
}
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