Commit e85062c1 by mushishixian

添加部分方法

parent 6d1f8af8
...@@ -41,6 +41,6 @@ database = liexin_config ...@@ -41,6 +41,6 @@ database = liexin_config
[brand] [brand]
#是否开启排除品牌 #是否开启排除品牌
is_not_ti = 1 IS_NOT_TI = 1
ti_ly_brand_ids = 23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752 TI_LY_BRAND_IDS = 23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752
ti_zy_brand_id = 23 ti_zy_brand_id = 23
\ No newline at end of file
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
'MOUSER_API'='http://footstone.liexin.net/webapi/handle_mouser' 'MOUSER_API'='http://footstone.liexin.net/webapi/handle_mouser'
[brand] [brand]
is_not_ti = 0 IS_NOT_TI = 0
ti_ly_brand_ids=23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752 TI_LY_BRAND_IDS=23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752
ti_zy_brand_ids=23 TI_ZY_BRAND_IDS=23
\ No newline at end of file
[supplier]
# 供应商redis的首key
SUPPLIER_REDIS_PRE = SUPPLIER_REDIS_INFO_
...@@ -7,20 +7,20 @@ import ( ...@@ -7,20 +7,20 @@ import (
//获取需要排除的品牌id //获取需要排除的品牌id
//branType = 1 : 联营 2 : 自营 //branType = 1 : 联营 2 : 自营
func GetExcludeBrandIds(brandType int) (excludeBrandIds []int) { func GetExcludeBrandIds(brandType int) (excludeBrandIds []int) {
isNoTi := config.Get("brand.is_not_ti").String() isNoTi := config.Get("brand.IS_NOT_TI").String()
//如果关闭,直接返回空数据 //如果关闭,直接返回空数据
if isNoTi == "1" { if isNoTi == "1" {
return return
} }
//返回联营的brand_id切片 //返回联营的brand_id切片
if brandType == 1 { if brandType == 1 {
tiLyBrandIds := config.Get("brand.ti_ly_brand_ids").Ints(",") tiLyBrandIds := config.Get("brand.TI_LY_BRAND_IDS").Ints(",")
excludeBrandIds = tiLyBrandIds excludeBrandIds = tiLyBrandIds
//获取的是字符串 //获取的是字符串
return return
} }
//返回自营的ti的brand_id切片 //返回自营的ti的brand_id切片
tiZyBrandId := config.Get("brand.ti_zy_brand_ids").Ints(",") tiZyBrandId := config.Get("brand.TI_ZY_BRAND_IDS").Ints(",")
excludeBrandIds = tiZyBrandId excludeBrandIds = tiZyBrandId
return return
......
...@@ -55,11 +55,16 @@ type ApiGoods struct { ...@@ -55,11 +55,16 @@ type ApiGoods struct {
ClassId3 int `json:"class_id3,omitempty"` ClassId3 int `json:"class_id3,omitempty"`
SpuName string `json:"spu_name,omitempty"` SpuName string `json:"spu_name,omitempty"`
ImagesL string `json:"images_l,omitempty"` ImagesL string `json:"images_l,omitempty"`
SpuBrief string `json:"spu_brief,omitempty"` SpuBrief string `json:"spu_brief"`
SpuDetail string `json:"spu_detail,omitempty"` SpuDetail string `json:"spu_detail,omitempty"`
ClassName3 string `json:"class_name3,omitempty"` ClassName3 string `json:"class_name3,omitempty"`
ErpTax bool `json:"erp_tax"` ErpTax bool `json:"erp_tax"`
ScmBrand ScmBrand `json:"scm_brand,omitempty"` ScmBrand ScmBrand `json:"scm_brand,omitempty"`
//额外增加的字段
GoodsNameTemp string `json:"goods_name_temp,omitempty"`
Multiple int `json:"multiple,omitempty"`
SearchSampleApplication string `json:"search_sample_application"`
SearchContactExperts string `json:"search_contact_experts"`
} }
type Attr struct { type Attr struct {
......
package model
import (
"github.com/gomodule/redigo/redis"
"search_server/pkg/config"
"search_server/pkg/gredis"
)
type QuoteSupplier struct {
HkDelivery string `json:"hk_delivery"`
CnDelivery string `json:"cn_delivery"`
PriceJson string `json:"price_json"`
AdText string `json:"ad_text"`
SupplierLogo string `json:"supplier_logo"`
AdUrl string `json:"ad_url"`
Sort int `json:"sort"`
}
func getSupplier(supplierId string) {
redisCon := gredis.Conn("default_r")
defer redisCon.Close()
supplierInfoStr, _ := redis.String(redisCon.Do("HGET", config.Get("supplier.SUPPLIER_REDIS_PRE")))
if supplierInfoStr != "" {
//序列化出来使用
} else {
//如果redis找不到,就要去数据库里面取了
}
}
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"crypto/md5" "crypto/md5"
"encoding/hex" "encoding/hex"
"github.com/syyongx/php2go" "github.com/syyongx/php2go"
"regexp"
"strconv" "strconv"
) )
...@@ -58,6 +59,12 @@ func ToString(a interface{}) string { ...@@ -58,6 +59,12 @@ func ToString(a interface{}) string {
return "change to String error" return "change to String error"
} }
//替换字符串,不区分大小写
func CaseInsensitiveReplace(subject string, search string, replace string) string {
searchRegex := regexp.MustCompile("(?i)" + search)
return searchRegex.ReplaceAllString(subject, replace)
}
/** /**
* 获取联营活动价 * 获取联营活动价
*/ */
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"gopkg.in/olivere/elastic.v5" "gopkg.in/olivere/elastic.v5"
"regexp" "regexp"
"search_server/model" "search_server/model"
"search_server/pkg/common"
"search_server/pkg/config" "search_server/pkg/config"
"search_server/pkg/es" "search_server/pkg/es"
"search_server/pkg/gredis" "search_server/pkg/gredis"
...@@ -40,6 +41,48 @@ func GetGoodsInfoByApi(goodsIdsStr string) (goodsList []*model.ApiGoods, err err ...@@ -40,6 +41,48 @@ func GetGoodsInfoByApi(goodsIdsStr string) (goodsList []*model.ApiGoods, err err
} }
//处理商品信息数据
func DullGoodsInfo(keyword string, goodsListMap map[string]*model.ApiGoods) map[string]*model.ApiGoods {
//获取redis链接
redisCon := gredis.Conn("default_r")
defer redisCon.Close()
for key, goods := range goodsListMap {
fmt.Println(key)
fmt.Println(goods)
if goods.Mpq == 0 {
goods.Mpq = 1
}
if goods.GoodsName == "" {
goods.GoodsName = goods.SpuName
}
//goods_name_temp
if keyword != "" {
replaceString := "<b class='f-red'>" + strings.ToUpper(keyword) + "</b>"
goods.GoodsNameTemp = common.CaseInsensitiveReplace(goods.GoodsName, keyword, replaceString)
} else {
goods.GoodsNameTemp = goods.GoodsName
}
if goods.Mpq > goods.Moq {
goods.Multiple = goods.Moq
} else {
goods.Multiple = goods.Mpq
}
//te广告按钮
teSwitch, _ := redis.Int(redisCon.Do("GET", "TeSwitch"))
if goods.BrandId == 161 && goods.GoodsId != "1152755238555810539" && teSwitch == 2 {
goods.SearchSampleApplication = "https://www.te.com.cn/chn-zh/solutions/sg-sample-request-form.html?te_bu=Cor&te_type=other&te_campaign=ich_chn_cor-ich-chn-part-selectmktg-fy19-srp-sample_sma-431_10&elqCampaignId=32896"
goods.SearchContactExperts = "https://www.te.com.cn/chn-zh/solutions/connectivity.html?te_bu=Cor&te_type=other&te_campaign=ich_chn_cor-ich-chn-part-selectmktg-fy19-srp-contact_sma-431_11&elqCampaignId=32897"
}
//供应商信息,读取redis,来源于基石配置
}
return nil
}
//isMap:是否以字典形式返回值,默认是数组 //isMap:是否以字典形式返回值,默认是数组
func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []*model.ApiGoods, goodsListMap map[string]*model.ApiGoods, err error) { func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []*model.ApiGoods, goodsListMap map[string]*model.ApiGoods, err error) {
//req.Debug = true //req.Debug = true
......
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