Commit c48c9883 by mushishixian

fix

parent 66d3adc7
[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 =
......
......@@ -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
}
}
......
package controller
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/gomodule/redigo/redis"
"github.com/ichunt2019/logger"
......@@ -34,10 +35,12 @@ func QuoteIndex(c *gin.Context) {
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)
}
common.Output(flag, "", res)
return
}
//获取供应商名称
......@@ -62,7 +65,7 @@ func QuoteIndex(c *gin.Context) {
}
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)
......@@ -71,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
......@@ -94,32 +97,47 @@ func mouserOrg(keyword, suppliedId string) (result map[string]interface{}, err e
//获取内部编码对应关系
func GetDataPur(c *gin.Context) {
supplierData, _ := dao.GetAllSupplierCodeAndUid()
intracode, _ := dao.GetAllIntraCode()
userInfo, _ := dao.GetAllUserBaseInfo()
temp := make(map[int]string)
supplierData, err := dao.GetAllSupplierCodeAndUid()
if err != nil {
c.JSON(200, err.Error())
return
}
intracode, err := dao.GetAllIntraCode()
if err != nil {
c.JSON(200, err.Error())
return
}
userInfo, err := dao.GetAllUserBaseInfo()
if err != nil {
c.JSON(200, err.Error())
return
}
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 {
res, err := redis.Bool(redisCon.Do("HSET", "search_supplier_canaltopurchase", supplier.SupplierCode, value))
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, "失败")
return
......@@ -134,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
}
......@@ -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
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"`
}
......@@ -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(),
},
}
}
......@@ -29,7 +29,7 @@ func Setup() error {
}
//日志打印SQL
DatabaseConMap[conName].ShowSQL(false)
DatabaseConMap[conName].ShowSQL(true)
//设置连接池的空闲数大小
DatabaseConMap[conName].SetMaxIdleConns(db.MaxIdleCons)
......@@ -44,4 +44,3 @@ func Setup() error {
func Conn(conName string) *xorm.Engine {
return DatabaseConMap[conName]
}
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
}
......
......@@ -5,9 +5,9 @@ import (
"fmt"
log "github.com/sirupsen/logrus"
"github.com/syyongx/php2go"
"os"
"reflect"
"search_server/boot"
"search_server/controller"
)
func StrRandom(lenNum int) string {
......@@ -39,15 +39,16 @@ func main() {
if err := boot.Boot(path); err != nil {
fmt.Println(err)
}
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")
//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")
}
......
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