Commit 45f76ff4 by mushishixian

Merge branch 'ysx-quote-20200628' into dev

parents e11a3be3 c48c9883
[gorm]
mode = debug
[mysql]
user_name = root
password = root
host = 192.168.2.250
database = test1
table_prefix =
type = mysql
[bom]
user_name = root
password = root
host = 192.168.2.250
database = test
table_prefix =
type = mysql
[spu]
user_name = spu
password = spu
......@@ -29,7 +13,7 @@ type = mysql
#SupDbUser:Supssy2@@!!@$#yxy@172.18.137.21:3306/liexin_supp
[supp]
user_name = liexin_ass
password = liexin_ass#zsyM
password = `liexin_ass#zsyM`
host = 192.168.2.232
database = liexin_ass
table_prefix =lie_
......@@ -37,7 +21,7 @@ type = mysql
[cms]
user_name = ichuntcms
password = ichuntcms#zsyM
password = `ichuntcms#zsyM`
host = 192.168.2.232
database = ichuntcms
table_prefix =
......
......@@ -150,5 +150,19 @@ 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
[AUTH]
SUPER_AUTH_KEY = fh6y5t4rr351d2c3bryi
SEARCH_TOKEN_EXPIRE_TIME = 30
\ No newline at end of file
SEARCH_TOKEN_EXPIRE_TIME = 30
[UNIT_SUPPLIER_LOG_CODE]
333333 = arrow
444444 = master
555555 = mouser
666666 = verical
777777 = tme
888888 = buerklin
999999 = zhuanmai
[SEARCH_API_LOG]
SEARCH_API_ERROR_PRE = search_api_overtime_
\ No newline at end of file
......@@ -41,7 +41,7 @@ func GetDataIndex(c *gin.Context) {
defer redisCon.Close()
//获取stockFlag
res, err := redis.Bool(redisCon.Do("SADD", "search_keyword_member", r.Keyword+"_"+r.SupplierName))
fmt.Println(r.Keyword+"_"+r.SupplierName)
fmt.Println(r.Keyword + "_" + r.SupplierName)
if err != nil {
fmt.Println(err)
}
......@@ -54,7 +54,7 @@ func GetDataIndex(c *gin.Context) {
r.FirstSearchPage = 2
quoteService := service.QuoteService{}
result, _ := quoteService.GetGoodsBySupplier(r.GetGoodsBySupplierRequest)
c.JSON(200, common.SuccessResponse(1, "", result))
common.Output(1, "", result)
return
}
}
......
......@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/gomodule/redigo/redis"
"github.com/ichunt2019/logger"
"github.com/syyongx/php2go"
"search_server/dao"
"search_server/pkg/common"
......@@ -21,47 +22,50 @@ func QuoteIndex(c *gin.Context) {
var r requests.QuoteIndexRequest
//绑定参数到结构体
if err := c.ShouldBind(&r); err != nil {
fmt.Println(err)
logger.Error("%s", err)
}
quoteService := service.QuoteService{}
//检查参数,有错误就返回错误
errCode, errMsg := requests.CheckQuoteRequest(r)
if errCode != 0 {
c.JSON(200, common.ErrorResponse(errCode, errMsg))
common.Output(errCode, errMsg, nil)
return
}
flag := 1
var res map[string]interface{}
if r.FollowHit != 0 && r.FollowHit != 1 {
res, _ = quoteService.GetGoodsBySupplier(r.GetGoodsBySupplierRequest)
if len(res) > 0 {
if res != nil {
flag = 0
common.Output(flag, "", res)
} else {
common.Output(flag, "", nil)
}
c.JSON(200, common.SuccessResponse(flag, "", res))
return
}
//获取供应商名称
supplierNameMap := config.Cfg.Section("SUPPLIER_ALL").KeysHash()
supplierName, exist := supplierNameMap[r.SupplierId]
if !exist {
c.JSON(200, common.ErrorResponse(1, "供应商有误"))
common.Output(1, "供应商有误", nil)
return
}
if supplierName == "mouser" {
//mouser同步请求搜索
res, _ = mouserOrg(r.Keyword, r.SupplierId)
} else {
r.GetGoodsBySupplierRequest.SupplierName = supplierName
res, _ = quoteService.GetGoodsBySupplierName(r.GetGoodsBySupplierRequest)
}
if len(res) > 0 {
flag = 0
}
c.JSON(200, common.SuccessResponse(flag, "", res))
common.Output(flag, "", res)
return
}
func mouserOrg(keyword, suppliedId string) (result map[string]interface{}, err error) {
mouserRes := service.OutLink(&keyword, "-1")
mouserRes := service.OutLink(&keyword, "1")
redisCon := gredis.Conn("search_r")
defer redisCon.Close()
skuMouser := make(map[string]string)
......@@ -70,7 +74,7 @@ func mouserOrg(keyword, suppliedId string) (result map[string]interface{}, err e
if k == "N/A" {
continue
}
snSku := php2go.Md5(strings.ToUpper(k + "_" + suppliedId))
snSku := php2go.Md5(strings.ToLower(k + "_" + suppliedId))
skuId, _ := redis.String(redisCon.Do("HGET", config.Get("SKU_UNIQUE_JUDGE").String(), snSku))
if skuId != "" {
skuMouser[skuId] = mouseItem.RestrictionMessage
......@@ -91,44 +95,48 @@ func mouserOrg(keyword, suppliedId string) (result map[string]interface{}, err e
return
}
//获取内部编码对应关系
func GetDataPur(c *gin.Context) {
supplierData, err := dao.GetAllSupplierCodeAndUid()
if err != nil {
c.String(200, err.Error())
c.JSON(200, err.Error())
return
}
intracode, err := dao.GetAllIntraCode()
if err != nil {
c.String(200, err.Error())
c.JSON(200, err.Error())
return
}
userInfo, err := dao.GetAllUserBaseInfo()
if err != nil {
c.String(200, err.Error())
c.JSON(200, err.Error())
return
}
temp := make(map[int]string)
userInfoData := make(map[int]string)
for _, user := range userInfo {
if user.Name == "" && user.Email != "" {
temp[user.UserId] = user.Email
userInfoData[user.UserId] = user.Email
} else {
temp[user.UserId] = user.Name
fmt.Println(user.UserId)
userInfoData[user.UserId] = user.Name
}
}
temp2 := make(map[int]string)
for _, code := range intracode {
if _, exist := temp[code.AdminId]; exist {
temp2[code.CodeId] = temp[code.AdminId]
//fmt.Println(userInfoData[code.AdminId])
if _, exist := userInfoData[code.AdminId]; exist {
temp2[code.CodeId] = userInfoData[code.AdminId]
} else {
temp2[code.CodeId] = ""
}
}
redisCon := gredis.Conn("search_r")
redisCon := gredis.Conn("search_w")
defer redisCon.Close()
for _, supplier := range supplierData {
if value, exist := temp2[supplier.ChannelUid]; exist {
fmt.Println(value)
fmt.Println(temp2[supplier.ChannelUid])
res, err := redis.Bool(redisCon.Do("HSET", "search_supplier_canaltopurchase_test", supplier.SupplierCode, value))
if err != nil || !res {
c.String(200, "失败")
......@@ -144,5 +152,6 @@ func GetDataPur(c *gin.Context) {
func GetData(keyword, supplierName string) (res interface{}) {
quoteService := service.QuoteService{}
res, _ = quoteService.GetData(keyword, supplierName)
fmt.Println(res)
return
}
......@@ -7,13 +7,12 @@ import (
//获取所有内部编码
func GetAllIntraCode() (intracode []model.Intracode, err error) {
_, err = mysql.Conn("cms").Table("lie_intracode").Select("supplier_code,channel_uid").
Where("status = ?", 2).Get(&intracode)
err = mysql.Conn("cms").Table("lie_intracode").Select("code_id,admin_id").Find(&intracode)
return
}
//获取所有的用户基础信息
func GetAllUserBaseInfo() (userBaseInfo []model.CmsUserInfo, err error) {
_, err = mysql.Conn("cms").Table("user_info").Select("name,email,userId").Get(&userBaseInfo)
err = mysql.Conn("cms").Table("user_info").Select("name,email,userId").Find(&userBaseInfo)
return
}
......@@ -7,8 +7,7 @@ import (
//获取供应商编码和渠道开发员id
func GetAllSupplierCodeAndUid() (supplierChannels []model.SupplierChannel, err error) {
_, err = mysql.Conn("supp").Table("lie_supplier_extra").Select("supplier_code,channel_uid").
Where("status = ?", 2).Get(&supplierChannels)
err = mysql.Conn("supp").Table("lie_supplier_channel").Select("supplier_code,channel_uid").
Where("status = ?", 2).Find(&supplierChannels)
return
}
......@@ -25,7 +25,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/sirupsen/logrus v1.5.0 // indirect
github.com/sirupsen/logrus v1.5.0
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.5.1 // indirect
github.com/syyongx/php2go v0.9.4
......
......@@ -10,6 +10,7 @@ import (
func Cors() gin.HandlerFunc {
corsDomain := config.Get("web.cors_domain").Strings(",")
corsDomain = append(corsDomain, "https://bom.ichunt.com")
corsDomain = append(corsDomain, "https://bom.ichunt.com")
return cors.New(cors.Config{
AllowOrigins: corsDomain,
AllowMethods: []string{"POST", "GET", "PUT", "DELETE"},
......
......@@ -2,18 +2,18 @@ package model
//内部编码表
type Intracode struct {
CodeId int `json:"code_id"`
AdminId int `json:"admin_id"`
UserId int `json:"user_id"`
CreateTime int `json:"create_time"`
UpdateTime int `json:"update_time"`
CodeId int `xorm:"code_id"`
AdminId int `xorm:"admin_id"`
UserId int `xorm:"user_id"`
CreateTime int `xorm:"create_time"`
UpdateTime int `xorm:"update_time"`
}
type CmsUserInfo struct {
UserId int `json:"userId"`
Name string `json:"name"`
EngName string `json:"engName"`
Email string `json:"email"`
Mobile string `json:"mobile"`
UserId int `json:"userId" xorm:"userId"`
Name string `xorm:"name"`
EngName string `xorm:"engName"`
Email string `xorm:"email"`
Mobile string `xorm:"mobile"`
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ type ApiGoods struct {
GoodsName string `json:"goods_name"`
GoodsSn string `json:"goods_sn"`
GoodsType int `json:"goods_type"`
GoodsStatus int `json:"goods_status"`
SupplierId int `json:"supplier_id"`
Moq int `json:"-"`
MoqStr interface{} `json:"moq"`
......@@ -58,14 +59,15 @@ type ApiGoods struct {
Coefficient Coefficient `json:"coefficient,omitempty"`
OriginalPrice []OriginalPrice `json:"original_price,omitempty"`
SuppExtendFee SuppExtendFee `json:"supp_extend_fee,omitempty"`
ClassId3 int `json:"class_id3,omitempty"`
ClassId3 int `json:"class_id3"`
SpuName string `json:"spu_name,omitempty"`
ImagesL string `json:"images_l,omitempty"`
SpuBrief string `json:"spu_brief"`
SpuDetail string `json:"spu_detail,omitempty"`
ClassName3 string `json:"class_name3,omitempty"`
SpuDetail string `json:"spu_detail"`
ClassName3 string `json:"class_name3"`
ErpTax bool `json:"erp_tax"`
ScmBrand ScmBrand `json:"scm_brand,omitempty"`
ActivityEndTime int64 `json:"activity_end_time,omitempty"`
}
//经过处理后的商品数据
......
package model
type SupplierChannel struct {
SupplierCode string `json:"supplier_code"`
ChannelUid int `json:"channel_uid"`
SupplierCode string `xorm:"supplier_code"`
ChannelUid int `xorm:"channel_uid"`
}
......@@ -255,7 +255,7 @@ func auth() bool {
k1 := request["k1"]
k1Num, _ := strconv.Atoi(k1)
k2 := request["k2"]
key := config.Get("SUPER_AUTH_KEY").String()
key := config.Get("AUTH.SUPER_AUTH_KEY").String()
if k1 != "" && int64(k1Num) < (time.Now().Unix()-600) {
return false
}
......
package common
import (
"regexp"
"runtime"
"search_server/middleware"
"search_server/pkg/log_report"
"strconv"
)
type Response struct {
ErrCode int `json:"error_code"`
ErrMsg string `json:"err_msg"`
......@@ -28,4 +36,44 @@ func ErrorResponse(errCode int, errMsg string) Response {
ErrMsg: errMsg,
Data: []string{},
}
}
\ No newline at end of file
}
//统一输出,里面还要去处理jsonp
func Output(errCode int, errMsg string, data interface{}) {
if data == nil {
data = []string{}
}
response := Response{
ErrCode: errCode,
ErrMsg: errMsg,
Data: data,
}
ctx := middleware.Context
if ctx.DefaultQuery("callback", "") != "" {
ctx.JSONP(200, response)
} else {
referer := ctx.Request.Referer()
r, _ := regexp.Compile(`/^(\w+:\/\/)?([^\/]+)/i`)
var match string
matches := r.FindStringSubmatch(referer)
if len(matches) > 0 {
match = matches[0]
}
ctx.Header("Access-Control-Allow-Origin", match)
ctx.Header("Access-Control-Allow-Credentials", "true")
//允许跨站访问的站点域名
//跨域请求头设置
ctx.JSONP(200, response)
}
}
//错误的搜索日志记录
func SearchApiLog(code int, msg string) {
pc, file, line, _ := runtime.Caller(0)
f := runtime.FuncForPC(pc)
ctx := middleware.Context
errMsg := "提示信息:" + msg + ",请求url:" + ctx.Request.URL.String()
lineNo := strconv.Itoa(line)
log_report.AnalyzeSearchError(code, ctx.ClientIP(), errMsg, file, lineNo, f.Name())
}
......@@ -13,20 +13,6 @@ type BaseDatabase struct {
//多数据库配置
func BuildDatabaseList() (DatabaseList map[string]BaseDatabase) {
return map[string]BaseDatabase{
"mysql": {
UserName: Get("mysql.user_name").String(),
Password: Get("mysql.password").String(),
Host: Get("mysql.host").String(),
Database: Get("mysql.database").String(),
Prefix: Get("mysql.prefix").String(),
},
"bom": {
UserName: Get("bom.user_name").String(),
Password: Get("bom.password").String(),
Host: Get("bom.host").String(),
Database: Get("bom.database").String(),
Prefix: Get("mysql.prefix").String(),
},
"spu": {
UserName: Get("spu.user_name").String(),
Password: Get("spu.password").String(),
......@@ -35,11 +21,18 @@ func BuildDatabaseList() (DatabaseList map[string]BaseDatabase) {
Prefix: Get("spu.table_prefix").String(),
},
"supp": {
UserName: Get("spu.user_name").String(),
Password: Get("spu.password").String(),
Host: Get("spu.host").String(),
Database: Get("spu.database").String(),
Prefix: Get("spu.table_prefix").String(),
UserName: Get("supp.user_name").String(),
Password: Get("supp.password").String(),
Host: Get("supp.host").String(),
Database: Get("supp.database").String(),
Prefix: Get("supp.table_prefix").String(),
},
"cms": {
UserName: Get("cms.user_name").String(),
Password: Get("cms.password").String(),
Host: Get("cms.host").String(),
Database: Get("cms.database").String(),
Prefix: Get("cms.table_prefix").String(),
},
}
}
package log_report
import (
"encoding/json"
log "github.com/sirupsen/logrus"
"os"
)
type SearchApiLog struct {
Msg string
MsgCode int
Ts int64
DateStr string
App string
ServerIp string
FileName string
LineNo string
Method string
}
func AnalyzeSearchError(code int, ip, errMsg, file, line, method string) (log SearchApiLog) {
//log.Msg = "" + errMsg
//log.MsgCode = 1
//log.Ts = time.Now().Unix()
//log.DateStr = time.Now().Format("2006-01-02 15:04:05")
//log.App = "search_api"
//log.ServerIp = ip
//log.FileName = file
//log.LineNo = line
//log.Method = method
//
////还要判断是否要推送消息
//unitSupplierLogCode := config.Cfg.Section("UNIT_SUPPLIER_LOG_CODE").KeysHash()
//codeStr := strconv.Itoa(code)
//if unitSupplierLogCode[codeStr] == "" {
// if !strings.Contains(strings.ToUpper(errMsg), "SOAP-ERROR") {
// //推送到钉钉
// result, err := message.DingDingPush(errMsg)
// if err != nil || result.Errcode != 0 {
// //logger.Errorf("%s", err, result)
// }
// }
//} else {
// redisCon := gredis.Conn("search_w")
// defer redisCon.Close()
// key := config.Get("SEARCH_API_LOG.SEARCH_API_ERROR_PRE").String() + unitSupplierLogCode[codeStr]
// redisCon.Do("INCR", key)
//}
return
}
type LogFormatter struct{}
//格式详情
func (s *LogFormatter) Format(entry *log.Entry) ([]byte, error) {
msg := entry.Message
return []byte(msg), nil
}
//写入到特定的文件夹给ELK使用的日志
func WriteSearchErrorLog(searchLog SearchApiLog) {
logJson, _ := json.Marshal(searchLog)
// 设置日志格式为json格式
log.SetFormatter(new(LogFormatter))
//设置output,默认为stderr,可以为任何io.Writer,比如文件*os.File
file, _ := os.OpenFile("1.log", os.O_CREATE|os.O_WRONLY, 0666)
log.SetOutput(file)
log.Error(logJson)
}
func WriteSearchErrorLogTest(searchLog string) {
// 设置日志格式为json格式
log.SetFormatter(new(LogFormatter))
//设置output,默认为stderr,可以为任何io.Writer,比如文件*os.File
file, _ := os.OpenFile("1.log", os.O_CREATE|os.O_WRONLY, 0666)
log.SetOutput(file)
log.Error(searchLog)
}
......@@ -2,7 +2,6 @@ package message
import (
"encoding/json"
"fmt"
"github.com/imroc/req"
"github.com/tidwall/gjson"
"search_server/pkg/config"
......@@ -32,7 +31,6 @@ func DingDingPush(content string) (result DingDingResponse, err error) {
req.Debug = false
dataStrByte, _ := json.Marshal(data)
dataStr := string(dataStrByte)
fmt.Println(dataStr)
dataStr = strings.Replace(dataStr, "\\", "\\\\", -1)
params := req.BodyJSON(dataStr)
resp, err := req.Post(webhook, params, req.Header{
......
......@@ -44,4 +44,3 @@ func Setup() error {
func Conn(conName string) *xorm.Engine {
return DatabaseConMap[conName]
}
......@@ -13,7 +13,7 @@ import (
)
//获取商品信息,需要传入userId用于判断是否登陆
func GetGoodsInfo(goodsIds []string) (goodsListMap map[string]model.ApiGoods, err error) {
func GetGoodsInfo(goodsIds []string) (goodsList []model.ApiGoods, err error) {
var userIdStr string
userIdStr, _ = middleware.Context.Cookie("Yo4teW_uid")
userId, _ := strconv.Atoi(userIdStr)
......@@ -24,7 +24,7 @@ func GetGoodsInfo(goodsIds []string) (goodsListMap map[string]model.ApiGoods, er
"power[newCustomer]": isNewCustomer,
"power[member]": isMember,
}
_, goodsListMap, err = CurlGoodsInfo(goodsIdsStr, params)
goodsList, _, err = CurlGoodsInfo(goodsIdsStr, params)
return
}
......@@ -63,6 +63,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
goods.GoodsName = data.Get("goods_name").String()
goods.GoodsSn = data.Get("goods_sn").String()
goods.GoodsType = int(data.Get("goods_type").Int())
goods.GoodsStatus = int(data.Get("goods_status").Int())
goods.SupplierId = int(data.Get("supplier_id").Int())
goods.Mpq = int(data.Get("mpq").Int())
goods.MpqStr = int(data.Get("mpq").Int())
......@@ -154,7 +155,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
//original_price
originalPrice := make([]model.OriginalPrice, 0)
for _, price := range data.Get("ladder_price").Array() {
for _, price := range data.Get("original_price").Array() {
price := model.OriginalPrice{
Purchases: int(price.Get("purchases").Int()),
PriceUs: price.Get("price_us").Float(),
......@@ -174,6 +175,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
goods.ScmBrand.ErpBrandName = data.Get("scm_brand.erp_brand_name").String()
goods.ScmBrand.ErpBrandId = data.Get("scm_brand.erp_brand_id").String()
goods.ScmBrand.ScmBrandId = data.Get("scm_brand.scm_brand_id").String()
goods.ActivityEndTime = data.Get("activity_end_time").Int()
goodsList = append(goodsList, goods)
goodsListMap[goodsId] = goods
......
package query
import (
"fmt"
"github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go"
"github.com/uniplaces/carbon"
......@@ -77,7 +76,6 @@ func GetGoodsBySupplierNameQuery(r requests.GetGoodsBySupplierRequest) (string,
query.MustNot(elastic.NewTermQuery("status", 10))
if r.BrandId != "" {
brandIdSlice := strings.Split(r.BrandId, ",")
//todo : 取整
query.MustNot(elastic.NewTermQuery("brand_id", brandIdSlice))
}
......@@ -332,6 +330,5 @@ func GetGoodsBySupplierIdQuery(r requests.GetGoodsBySupplierRequest) (string, er
}
source.Query(query)
searchRequest := elastic.NewSearchRequest().Source(source).Preference("_primary_first")
fmt.Println(searchRequest.Body())
return searchRequest.Body()
}
......@@ -26,7 +26,6 @@ func (qs *QuoteService) GetGoodsBySupplier(r requests.GetGoodsBySupplierRequest)
if err != nil {
return
}
queryString = ""
esResult, err := es.CurlES(supplierIndex, queryString)
if err != nil {
return
......@@ -34,8 +33,12 @@ func (qs *QuoteService) GetGoodsBySupplier(r requests.GetGoodsBySupplierRequest)
goodsIds := GetGoodsIdsByEs(esResult)
goodsList, err := GetGoodsInfo(goodsIds)
dullData, err := transformer.DullDataInfo(r.Keyword, goodsList)
//整合供应商数据
result = GetReturnSupplierData(dullData)
result["total"] = gjson.Get(esResult, "hits.total").Int()
if gjson.Get(esResult, "hits.total").Int() == 0 {
return nil, err
}
result["took"] = gjson.Get(esResult, "took").Int()
return
}
......@@ -67,6 +70,7 @@ func (qs *QuoteService) GetData(keyword, supplier string) (res interface{}, err
}
quoteTransformer := transformer.QuoteTransformer{}
res = quoteTransformer.TransformCollectData(keyword, supplier, collectData)
return
}
......
......@@ -2,7 +2,6 @@ package transformer
import (
"encoding/json"
"fmt"
"github.com/gomodule/redigo/redis"
"github.com/tidwall/gjson"
"regexp"
......@@ -12,16 +11,17 @@ import (
"search_server/pkg/common"
"search_server/pkg/config"
"search_server/pkg/gredis"
"search_server/pkg/mq"
"strings"
"time"
)
//处理商品信息数据
func DullDataInfo(keyword string, goodsListMap map[string]model.ApiGoods) (result []model.DullGoodsData, err error) {
func DullDataInfo(keyword string, goodsList []model.ApiGoods) (result []model.DullGoodsData, err error) {
//获取redis链接
redisCon := gredis.Conn("search_r")
defer redisCon.Close()
for _, item := range goodsListMap {
for _, item := range goodsList {
var goods model.DullGoodsData
goods.ApiGoods = item
if goods.GoodsName == "" {
......@@ -40,7 +40,18 @@ func DullDataInfo(keyword string, goodsListMap map[string]model.ApiGoods) (resul
goods = spliceUrlByEnvironment(goods)
//获取汇率相关
goods = getRatio(goods)
//todo:提供给客服报价系统专用(因为只是给快手用的,所以抽离出这个方法)
//提供给客服报价系统专用
if strings.Contains(middleware.Context.Request.URL.String(), "quote") {
for key, price := range goods.LadderPrice {
if price.PriceUs != 0 {
if goods.SupplierId == 6 {
goods.LadderPrice[key].PriceUs = goods.OriginalPrice[key].PriceUs * goods.PriceHkxs
} else {
goods.LadderPrice[key].PriceUs = goods.OriginalPrice[key].PriceUs * goods.Coefficient.ExtraRatio
}
}
}
}
//整理数据
goods = arrangeData(goods)
......@@ -50,7 +61,7 @@ func DullDataInfo(keyword string, goodsListMap map[string]model.ApiGoods) (resul
goods.LastSearchTime = common.GetLastSearchTime(goods.GoodsId)
//关税信息
goods.CustomsTax = common.GetCustomsTax(goods.GoodsName, goods.BrandName)
ShowSku(goods)
go ShowSku(goods)
//价格等信息混淆
if keyword != "---" {
goods, err = MetGoodsInfo(goods)
......@@ -71,7 +82,7 @@ func spliceUrlByEnvironment(goods model.DullGoodsData) model.DullGoodsData {
refererTemp := strings.Split(referer, ".com")
if len(refererTemp) > 0 {
goods.BrandUrl = refererTemp[0] + ".com/v3/brand/list/" + common.ToString(goods.BrandId) + ".html"
goods.GoodsUrl = refererTemp[0] + ".com/goods_" + common.ToString(goods.GoodsId) + ".html"
goods.GoodsUrl = refererTemp[0] + ".com/goods_" + goods.GoodsId + ".html"
}
return goods
}
......@@ -358,7 +369,6 @@ func ShowSku(goods model.DullGoodsData) {
}
}
res, _ := json.Marshal(result)
fmt.Println(string(res))
//mq.PushMsg("search_show_sku_list", string(res))
mq.PushMsg("search_show_sku_list", string(res))
}
}
......@@ -3,10 +3,11 @@ package main
import (
"flag"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/syyongx/php2go"
"reflect"
"search_server/boot"
"search_server/pkg/common"
"search_server/controller"
)
func StrRandom(lenNum int) string {
......@@ -23,6 +24,14 @@ func StrRandom(lenNum int) string {
return result
}
type LogFormatter struct{}
//格式详情
func (s *LogFormatter) Format(entry *log.Entry) ([]byte, error) {
msg := entry.Message + "\n"
return []byte(msg), nil
}
func main() {
var path string
flag.StringVar(&path, "configPath", "conf", "配置文件")
......@@ -30,9 +39,17 @@ func main() {
if err := boot.Boot(path); err != nil {
fmt.Println(err)
}
b := []string{"b", "z", "a"}
common.SortSlice(b)
fmt.Println(b)
//log.SetFormatter(new(LogFormatter))
////设置output,默认为stderr,可以为任何io.Writer,比如文件*os.File
//str, _ := os.Getwd()
//file, _ := os.OpenFile(str+"/logs/search/1.log", os.O_CREATE|os.O_WRONLY, 0666)
//log.SetOutput(file)
//fmt.Println(str)
//log.Error("sadsadsadsa")
//log.Error("sadsadsadsa")
//log.Error("sadsadsadsa")
controller.GetData("LM358","arrow")
}
func InterfaceSlice(slice interface{}) []interface{} {
......
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