Commit d5fe2068 by mushishixian

优化优化优化

parent fa6e2fd3
The file could not be displayed because it is too large.
...@@ -22,7 +22,7 @@ func init() { ...@@ -22,7 +22,7 @@ func init() {
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/", "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
} }
str := `{"bom_id":98,"delivery_type":1,"sort":1}` str := `{"bom_id":168,"delivery_type":1,"sort":1}`
rabbitmq.Send(queueExchange, str) rabbitmq.Send(queueExchange, str)
} }
......
...@@ -7,15 +7,14 @@ require ( ...@@ -7,15 +7,14 @@ require (
github.com/gin-gonic/gin v1.6.3 github.com/gin-gonic/gin v1.6.3
github.com/go-ini/ini v1.56.0 github.com/go-ini/ini v1.56.0
github.com/go-kratos/kratos v0.5.0 github.com/go-kratos/kratos v0.5.0
github.com/hprose/hprose-golang v2.0.5+incompatible
github.com/ichunt2019/go-rabbitmq v1.0.1 github.com/ichunt2019/go-rabbitmq v1.0.1
github.com/imroc/req v0.3.0 github.com/imroc/req v0.3.0
github.com/jinzhu/gorm v1.9.12 github.com/jinzhu/gorm v1.9.12
github.com/jmoiron/sqlx v1.2.0 github.com/jmoiron/sqlx v1.2.0
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/shopspring/decimal v1.2.0
github.com/smartystreets/goconvey v1.6.4 // indirect github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/syyongx/php2go v0.9.4 github.com/syyongx/php2go v0.9.4
gopkg.in/gin-gonic/gin.v1 v1.3.0
gopkg.in/ini.v1 v1.56.0 // indirect gopkg.in/ini.v1 v1.56.0 // indirect
gopkg.in/olivere/elastic.v5 v5.0.85 gopkg.in/olivere/elastic.v5 v5.0.85
) )
...@@ -152,8 +152,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.14.3/go.mod h1:6CwZWGDSPRJidgKAtJVvND6 ...@@ -152,8 +152,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.14.3/go.mod h1:6CwZWGDSPRJidgKAtJVvND6
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hprose/hprose-golang v2.0.5+incompatible h1:Sj+NdtJf+6fHjxZ/ZoS4mBBCYIOIqE6szs1DHFTsTC0=
github.com/hprose/hprose-golang v2.0.5+incompatible/go.mod h1:FfwwCUQFF3f5t03SrzdSghXVZkC01uEJS6Xwzcz0NOo=
github.com/ichunt2019/go-rabbitmq v1.0.1 h1:qHhpGm9v7jnhSBo3f3viX+BSky9yugp9lCSV03eYsF4= github.com/ichunt2019/go-rabbitmq v1.0.1 h1:qHhpGm9v7jnhSBo3f3viX+BSky9yugp9lCSV03eYsF4=
github.com/ichunt2019/go-rabbitmq v1.0.1/go.mod h1:TQsZ1XWULyvm4UwpYHwNPtOXYbuVvLLI0GM7g/BRy68= github.com/ichunt2019/go-rabbitmq v1.0.1/go.mod h1:TQsZ1XWULyvm4UwpYHwNPtOXYbuVvLLI0GM7g/BRy68=
github.com/imroc/req v0.3.0 h1:3EioagmlSG+z+KySToa+Ylo3pTFZs+jh3Brl7ngU12U= github.com/imroc/req v0.3.0 h1:3EioagmlSG+z+KySToa+Ylo3pTFZs+jh3Brl7ngU12U=
...@@ -293,6 +291,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD ...@@ -293,6 +291,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shirou/gopsutil v2.19.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v2.19.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
...@@ -478,8 +478,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 ...@@ -478,8 +478,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gin-gonic/gin.v1 v1.3.0 h1:DjAu49rN1YttQsOkVCPlAO3INcZNFT0IKsNVMk5MRT4=
gopkg.in/gin-gonic/gin.v1 v1.3.0/go.mod h1:Eljh74A/zAvUOQ835v6ySeZ+5gQG6tKjbZTaZ9iWU3A=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v9 v9.29.1 h1:SvGtYmN60a5CVKTOzMSyfzWDeZRxRuGvRQyEAKbw1xc= gopkg.in/go-playground/validator.v9 v9.29.1 h1:SvGtYmN60a5CVKTOzMSyfzWDeZRxRuGvRQyEAKbw1xc=
......
...@@ -4,6 +4,8 @@ import ( ...@@ -4,6 +4,8 @@ import (
"crypto/md5" "crypto/md5"
"encoding/hex" "encoding/hex"
"github.com/syyongx/php2go" "github.com/syyongx/php2go"
"reflect"
"strconv"
) )
// Md5 md5() // Md5 md5()
...@@ -33,3 +35,97 @@ func SubKeyWordStr(str string) string { ...@@ -33,3 +35,97 @@ func SubKeyWordStr(str string) string {
} }
return str return str
} }
func Assert(input interface{}, needType string) (result interface{}) {
value := reflect.ValueOf(input).Type().String()
switch needType {
case "string":
if value == "string" {
result = input.(string)
return
}
if value == "float64" {
result = strconv.FormatFloat(input.(float64), 'E', -1, 64)
return
}
if value == "int" {
result = strconv.Itoa(input.(int))
return
}
if value == "bool" {
result = strconv.FormatBool(input.(bool))
return
}
break
case "int":
if value == "string" {
result, _ = strconv.Atoi(input.(string))
return
}
if value == "int" {
result = input.(int)
return
}
if value == "float64" {
result = int(input.(float64))
return
}
if value == "bool" {
if input.(bool) {
result = 1
} else {
result = 0
}
return
}
break
case "float":
if value == "string" {
result, _ = strconv.ParseFloat(input.(string), 10)
return
}
if value == "int" {
result = strconv.Itoa(input.(int))
return
}
if value == "bool" {
result = strconv.FormatBool(input.(bool))
return
}
if value == "float64" {
result = input.(float64)
return
}
break
case "bool":
if value == "string" {
if input.(string) == "" {
result = false
} else {
result = true
}
return
}
if value == "int" {
if input.(int) > 0 {
result = true
} else {
result = false
}
return
}
if value == "bool" {
result = input.(bool)
return
}
if value == "float" {
if input.(float64) > 0 {
result = true
} else {
result = false
}
return
}
}
return
}
...@@ -82,8 +82,11 @@ func UpdateBomItem(bomId, bomItemId int) (err error) { ...@@ -82,8 +82,11 @@ func UpdateBomItem(bomId, bomItemId int) (err error) {
return return
} }
err = UpdateGoodsData(goodsMapList) err = UpdateGoodsData(goodsMapList)
if err != nil { if len(goodsMapList) == 0 {
return err = UpdateNoMatchBomItem(bomItems)
if err != nil {
return
}
} }
return return
} }
...@@ -2,11 +2,12 @@ package logic ...@@ -2,11 +2,12 @@ package logic
import ( import (
"bom_server/configs" "bom_server/configs"
"bom_server/internal/common"
"bom_server/internal/model" "bom_server/internal/model"
"encoding/json" "encoding/json"
"errors"
"github.com/imroc/req" "github.com/imroc/req"
"reflect" "reflect"
"strconv"
"strings" "strings"
"time" "time"
) )
...@@ -66,9 +67,30 @@ func GetGoodsInfo(goodsIdsStr string) (responseData model.ApiGoodsResponse, err ...@@ -66,9 +67,30 @@ func GetGoodsInfo(goodsIdsStr string) (responseData model.ApiGoodsResponse, err
if err != nil { if err != nil {
return return
} }
if err = resp.ToJSON(&responseData); err != nil { var responseDataTemp model.ApiGoodsResponseTemp
if err = resp.ToJSON(&responseDataTemp); err != nil {
err = errors.New(err.Error())
return return
} }
responseData.Data = make(map[string]model.ApiGoods, 200)
for goodsId, goods := range responseDataTemp.Data {
//不是bool值的,才去给数据,商品服务的商品信息有可能是bool值,蛋疼
if reflect.ValueOf(goods).Type().String() != "bool" {
var goodsStr []byte
goodsStr, err = json.Marshal(goods)
if err != nil {
return
}
var apiGoods model.ApiGoods
err = json.Unmarshal(goodsStr, &apiGoods)
if err != nil {
return
}
responseData.Data[goodsId] = apiGoods
}
}
responseData.Errmsg = responseDataTemp.Errmsg
responseData.Errcode = responseDataTemp.Errcode
return return
} }
...@@ -81,16 +103,18 @@ func MatchGoodsInfo(goods model.ApiGoods, goodsMap GoodsMap) (bomMatching model. ...@@ -81,16 +103,18 @@ func MatchGoodsInfo(goods model.ApiGoods, goodsMap GoodsMap) (bomMatching model.
} else { } else {
delivery = goods.HkDeliveryTime delivery = goods.HkDeliveryTime
} }
goodsIdStr := common.Assert(goods.GoodsID, "string")
pdf := common.Assert(goods.Pdf, "string")
bomMatching = model.BomItemMatching{ bomMatching = model.BomItemMatching{
BomID: goodsMap.BomId, BomID: goodsMap.BomId,
BomItemID: goodsMap.BomItemId, BomItemID: goodsMap.BomItemId,
BrandId: goods.BrandID, BrandId: goods.BrandID,
GoodsID: goods.GoodsID, GoodsID: goodsIdStr.(string),
GoodsName: goods.GoodsName, GoodsName: goods.GoodsName,
BrandName: goods.BrandName, BrandName: goods.BrandName,
GoodsType: goods.GoodsType, GoodsType: goods.GoodsType,
SupplierID: goods.SupplierID, SupplierID: goods.SupplierID,
Pdf: goods.Pdf, Pdf: pdf.(string),
SupplierName: goods.SupplierName, SupplierName: goods.SupplierName,
Delivery: delivery, Delivery: delivery,
DeliveryType: goodsMap.DeliveryType, DeliveryType: goodsMap.DeliveryType,
...@@ -127,22 +151,17 @@ func MatchGoodsInfo(goods model.ApiGoods, goodsMap GoodsMap) (bomMatching model. ...@@ -127,22 +151,17 @@ func MatchGoodsInfo(goods model.ApiGoods, goodsMap GoodsMap) (bomMatching model.
if len(goods.LadderPrice) > 0 { if len(goods.LadderPrice) > 0 {
for _, price := range goods.LadderPrice { for _, price := range goods.LadderPrice {
//要先去断言,因为商品服务返回的json的值类型不确定... //要先去断言,因为商品服务返回的json的值类型不确定...
value := reflect.ValueOf(price.Purchases).Type().String() purchases := common.Assert(price.Purchases, "int")
var purchases int if goodsMap.Number <= purchases.(int) {
if value == "string" {
tempNumber, _ := strconv.ParseInt(price.Purchases.(string), 10, 10)
purchases = int(tempNumber)
} else if value == "float64" {
purchases = int(price.Purchases.(float64))
} else {
purchases = price.Purchases.(int)
}
if goodsMap.Number <= purchases {
//判断是否有优惠价,有的话取优惠价 //判断是否有优惠价,有的话取优惠价
if price.PriceAc != 0 { if price.PriceAc != nil {
bomMatching.Price = price.PriceAc pac := common.Assert(price.PriceAc, "float")
bomMatching.Price = pac.(float64)
} else { } else {
bomMatching.Price = price.PriceCn if price.PriceCn != nil {
p := common.Assert(price.PriceCn, "float")
bomMatching.Price = p.(float64)
}
} }
break break
} }
......
...@@ -11,7 +11,6 @@ import ( ...@@ -11,7 +11,6 @@ import (
es "gopkg.in/olivere/elastic.v5" es "gopkg.in/olivere/elastic.v5"
"math" "math"
"regexp" "regexp"
"strconv"
"strings" "strings"
"sync" "sync"
) )
...@@ -199,7 +198,7 @@ func getUpdateGoodsData(bomId int, bomItems []model.BomItem, deliveryType, sort ...@@ -199,7 +198,7 @@ func getUpdateGoodsData(bomId int, bomItems []model.BomItem, deliveryType, sort
return nil, err return nil, err
} }
var goodsMap GoodsMap var goodsMap GoodsMap
goodsMap.GoodsId = strconv.FormatInt(int64(goods.GoodsID), 10) goodsMap.GoodsId = hit.Id
goodsMap.Number = bomItems[key].Number goodsMap.Number = bomItems[key].Number
goodsMap.GoodsName = bomItems[key].GoodsName goodsMap.GoodsName = bomItems[key].GoodsName
goodsMap.BomItemId = bomItems[key].BomItemID goodsMap.BomItemId = bomItems[key].BomItemID
...@@ -253,7 +252,7 @@ func getTermQuery(goodsName, brandName string, number int, flag bool) (query *es ...@@ -253,7 +252,7 @@ func getTermQuery(goodsName, brandName string, number int, flag bool) (query *es
field = "auto_goods_name" field = "auto_goods_name"
query = query.Must(es.NewTermQuery(field, goodsName)) query = query.Must(es.NewTermQuery(field, goodsName))
} }
query = query.Filter(es.NewTermQuery("status", 0)) //query = query.Filter(es.NewTermQuery("status", 1))
//src, err := query.Source() //src, err := query.Source()
//if err != nil { //if err != nil {
// panic(err) // panic(err)
......
package model package model
type Goods struct { type Goods struct {
GoodsID int `json:"goods_id"` GoodsID float64 `json:"goods_id"`
OldGoodsID int `json:"old_goods_id"` OldGoodsID int `json:"old_goods_id"`
GoodsName string `json:"goods_name"` GoodsName string `json:"goods_name"`
AutoGoodsName string `json:"auto_goods_name"` AutoGoodsName string `json:"auto_goods_name"`
BrandID interface{} `json:"brand_id"` BrandID interface{} `json:"brand_id"`
BrandName string `json:"brand_name"` BrandName string `json:"brand_name"`
SupplierName string `json:"supplier_name"` SupplierName string `json:"supplier_name"`
ClassID1 int `json:"class_id1"` ClassID1 int `json:"class_id1"`
ClassID2 int `json:"class_id2"` ClassID2 int `json:"class_id2"`
ClassID3 int `json:"class_id3"` ClassID3 int `json:"class_id3"`
//SpuID string `json:"spu_id"` //SpuID string `json:"spu_id"`
SaleTime int `json:"sale_time"` SaleTime int `json:"sale_time"`
GoodsDetails string `json:"goods_details"` GoodsDetails string `json:"goods_details"`
CreateTime int `json:"create_time"` CreateTime int `json:"create_time"`
UpdateTime int `json:"update_time"` UpdateTime int `json:"update_time"`
SinglePrice float64 `json:"single_price"` SinglePrice float64 `json:"single_price"`
Stock int `json:"stock"` Stock int `json:"stock"`
GoodsStatus int `json:"goods_status"` GoodsStatus int `json:"goods_status"`
Status int `json:"status"` Status int `json:"status"`
Sort int `json:"sort"` Sort int `json:"sort"`
Encoded string `json:"encoded"` Encoded string `json:"encoded"`
Encap string `json:"encap"` Encap string `json:"encap"`
CanalNew string `json:"canal_new"` CanalNew string `json:"canal_new"`
StockSort int `json:"stock_sort"` StockSort int `json:"stock_sort"`
SinglePriceSort int `json:"single_price_sort"` SinglePriceSort int `json:"single_price_sort"`
}
type ApiGoodsResponseTemp struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
Data DataTemp `json:"data"`
} }
type ApiGoodsResponse struct { type ApiGoodsResponse struct {
...@@ -36,9 +42,11 @@ type ApiGoodsResponse struct { ...@@ -36,9 +42,11 @@ type ApiGoodsResponse struct {
type Data map[string]ApiGoods type Data map[string]ApiGoods
type DataTemp map[string]interface{}
type ApiGoods struct { type ApiGoods struct {
GoodsID string `json:"goods_id"` GoodsID interface{} `json:"goods_id"`
GoodsSn string `json:"goods_sn"` GoodsSn string `json:"goods_sn"`
//SpuID string `json:"spu_id"` //SpuID string `json:"spu_id"`
UpdateTime int `json:"update_time"` UpdateTime int `json:"update_time"`
GoodsStatus int `json:"goods_status"` GoodsStatus int `json:"goods_status"`
...@@ -55,11 +63,10 @@ type ApiGoods struct { ...@@ -55,11 +63,10 @@ type ApiGoods struct {
GoodsDetails string `json:"goods_details"` GoodsDetails string `json:"goods_details"`
LadderPrice []struct { LadderPrice []struct {
Purchases interface{} `json:"purchases"` Purchases interface{} `json:"purchases"`
PriceUs float64 `json:"price_us"` PriceUs interface{} `json:"price_us"`
PriceCn float64 `json:"price_cn"` PriceCn interface{} `json:"price_cn"`
PriceAc float64 `json:"price_ac"` PriceAc interface{} `json:"price_ac"`
} `json:"ladder_price"` } `json:"ladder_price"`
GoodsImages string `json:"goods_images"`
Canal string `json:"canal"` Canal string `json:"canal"`
CpTime int `json:"cp_time"` CpTime int `json:"cp_time"`
BrandName string `json:"brand_name"` BrandName string `json:"brand_name"`
...@@ -75,21 +82,6 @@ type ApiGoods struct { ...@@ -75,21 +82,6 @@ type ApiGoods struct {
Ratio string `json:"ratio"` Ratio string `json:"ratio"`
Tax float64 `json:"tax"` Tax float64 `json:"tax"`
} `json:"coefficient"` } `json:"coefficient"`
//OriginalPrice []struct {
// Purchases int `json:"purchases"`
// PriceCn int `json:"price_cn"`
// PriceUs float64 `json:"price_us"`
//} `json:"original_price"`
//SuppExtendFee struct {
// Cn struct {
// Max string `json:"max"`
// Price string `json:"price"`
// } `json:"cn"`
// Hk struct {
// Max int `json:"max"`
// Price int `json:"price"`
// } `json:"hk"`
//} `json:"supp_extend_fee"`
IsBuy int `json:"is_buy"` IsBuy int `json:"is_buy"`
ClassID1 int `json:"class_id1"` ClassID1 int `json:"class_id1"`
ClassID2 int `json:"class_id2"` ClassID2 int `json:"class_id2"`
...@@ -98,7 +90,7 @@ type ApiGoods struct { ...@@ -98,7 +90,7 @@ type ApiGoods struct {
Status int `json:"status"` Status int `json:"status"`
ImagesL string `json:"images_l"` ImagesL string `json:"images_l"`
Encap string `json:"encap"` Encap string `json:"encap"`
Pdf string `json:"pdf"` Pdf interface{} `json:"pdf"`
SpuBrief string `json:"spu_brief"` SpuBrief string `json:"spu_brief"`
SpuDetail string `json:"spu_detail"` SpuDetail string `json:"spu_detail"`
ClassName string `json:"class_name"` ClassName string `json:"class_name"`
......
...@@ -16,7 +16,7 @@ func Export(bomId int) (ossPath string, err error) { ...@@ -16,7 +16,7 @@ func Export(bomId int) (ossPath string, err error) {
return return
} }
bomIdStr := strconv.Itoa(bomId) bomIdStr := strconv.Itoa(bomId)
filePath := "Bom_" + bomIdStr + ".xlsx" filePath := "Bom_" + bomIdStr + ".xls"
f := excelize.NewFile() f := excelize.NewFile()
index := f.NewSheet("Sheet1") index := f.NewSheet("Sheet1")
f.SetActiveSheet(index) f.SetActiveSheet(index)
...@@ -64,7 +64,7 @@ func Export(bomId int) (ossPath string, err error) { ...@@ -64,7 +64,7 @@ func Export(bomId int) (ossPath string, err error) {
} }
//删除文件 //删除文件
} }
ossPath, err = UploadToOss(filePath, "xlsx") ossPath, err = UploadToOss(filePath, "xls")
if err != nil { if err != nil {
return return
} }
......
...@@ -49,4 +49,4 @@ func UpdateBomMatching(c *gin.Context) { ...@@ -49,4 +49,4 @@ func UpdateBomMatching(c *gin.Context) {
} }
c.JSON(200, response) c.JSON(200, response)
return return
} }
\ No newline at end of file
...@@ -2,38 +2,39 @@ package main ...@@ -2,38 +2,39 @@ package main
import ( import (
"fmt" "fmt"
"github.com/hprose/hprose-golang/rpc" "github.com/shopspring/decimal"
"time"
) )
type Stub struct { type abc struct {
Hello func(string) (string, error) Goods_id float64 `json:"goods_id"`
Export func(int) interface{} Goods_name string `json:"goods_name"`
AsyncHello func(func(string, error), string) `name:"hello"`
}
func testHprose() {
client := rpc.NewClient("http://127.0.0.1:8080/")
var stub *Stub
client.UseService(&stub)
//stub.AsyncHello(func(result string, err error) {
// fmt.Println(result, err)
//}, "async world")
//fmt.Println(stub.Hello("sd"))
start:=time.Now()
fmt.Println(stub.Export(48))
fmt.Println(time.Now().Sub(start))
} }
func main() { func main() {
//var path string //a := `{"goods_id":1.1572417766286e+18,"goods_name":"LM358"}`
//flag.StringVar(&path, "config", "conf/config.ini", "../conf/config.ini") //
//flag.Parse() //aaa := &abc{}
//configs.Setup(path) //err := json.Unmarshal([]byte(a),aaa)
//model.Setup() //
//osspath,err:=service.Export(48) //if err !=nil{
//fmt.Println(err) // fmt.Println(err)
//fmt.Println(osspath) //}
testHprose() //
//fmt.Println(aaa)
//
//d := json.NewDecoder(bytes.NewReader([]byte(a)))
//d.UseNumber()
//err = d.Decode(&aaa)
//if err != nil {
// // 错误处理
//}
//fmt.Println(aaa)
//fmt.Printf("%f\n", aaa.Goods_id)
numStr := 1.1572417766286e+18
decimalNum := decimal.NewFromFloat(numStr)
//if err != nil {
// return
//}
fmt.Println(decimalNum.String())
} }
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