Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
bom_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8121d69d
authored
May 26, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复json值类型不确定的问题
parent
6cb45872
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
8 deletions
cmd/cmd.exe~
cmd/main.go
cmd/queue/bom.go
internal/logic/goods.go
internal/logic/match.go
internal/model/goods.go
cmd/cmd.exe~
View file @
8121d69d
The file could not be displayed because it is too large.
cmd/main.go
View file @
8121d69d
...
...
@@ -3,7 +3,6 @@ package main
import
(
"bom_server/cmd/queue"
"bom_server/configs"
"bom_server/internal/logic"
"bom_server/internal/model"
"flag"
)
...
...
@@ -14,6 +13,5 @@ func main() {
flag
.
Parse
()
configs
.
Setup
(
path
)
model
.
Setup
()
logic
.
MatchGoods
(
46
)
queue
.
Sync
()
}
cmd/queue/bom.go
View file @
8121d69d
...
...
@@ -2,14 +2,42 @@ package queue
import
(
"bom_server/configs"
"bom_server/internal/logic"
"fmt"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"strconv"
"time"
)
type
RecvPro
struct
{
}
func
init
(){
queueExchange
:=
rabbitmq
.
QueueExchange
{
"bom_match"
,
"bom_match"
,
"bom"
,
"direct"
,
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
,
}
rabbitmq
.
Send
(
queueExchange
,
"1"
)
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
start
:=
time
.
Now
()
bomIdStr
:=
string
(
dataByte
)
bomId
,
err
:=
strconv
.
ParseInt
(
bomIdStr
,
10
,
64
)
fmt
.
Println
(
bomId
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
err
=
logic
.
MatchGoods
(
int
(
bomId
))
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
duration
:=
time
.
Now
()
.
Sub
(
start
)
fmt
.
Println
(
duration
)
return
nil
}
...
...
internal/logic/goods.go
View file @
8121d69d
...
...
@@ -81,7 +81,9 @@ func UpdateGoodsData(goodsMapList []GoodsMap) (err error) {
if
value
==
"string"
{
tempNumber
,
_
:=
strconv
.
ParseInt
(
price
.
Purchases
.
(
string
),
10
,
10
)
purchases
=
int
(
tempNumber
)
}
else
{
}
else
if
value
==
"float64"
{
purchases
=
int
(
price
.
Purchases
.
(
float64
))
}
else
{
purchases
=
price
.
Purchases
.
(
int
)
}
if
goodsMap
.
Number
<=
purchases
{
...
...
internal/logic/match.go
View file @
8121d69d
...
...
@@ -21,7 +21,7 @@ import (
4.得到具体的商品数据以后,针对对应的商品进行修改
**/
func
MatchGoods
(
bomId
int
)
{
func
MatchGoods
(
bomId
int
)
(
err
error
)
{
//获取bom
bom
:=
GetBomInfoWithItems
(
bomId
)
bomItems
:=
bom
.
BomItems
...
...
@@ -55,7 +55,7 @@ func MatchGoods(bomId int) {
// Number: 1,
// },
//}
SearchGoods
(
bomId
,
bomItems
)
return
SearchGoods
(
bomId
,
bomItems
)
}
//去es搜索商品,得到对应的商品对应关系
...
...
internal/model/goods.go
View file @
8121d69d
...
...
@@ -11,7 +11,7 @@ type Goods struct {
ClassID1
int
`json:"class_id1"`
ClassID2
int
`json:"class_id2"`
ClassID3
int
`json:"class_id3"`
SpuID
string
`json:"spu_id"`
//
SpuID string `json:"spu_id"`
SaleTime
int
`json:"sale_time"`
GoodsDetails
string
`json:"goods_details"`
CreateTime
int
`json:"create_time"`
...
...
@@ -39,7 +39,7 @@ type Data map[string]ApiGoods
type
ApiGoods
struct
{
GoodsID
string
`json:"goods_id"`
GoodsSn
string
`json:"goods_sn"`
SpuID
string
`json:"spu_id"`
//
SpuID string `json:"spu_id"`
UpdateTime
int
`json:"update_time"`
GoodsStatus
int
`json:"goods_status"`
GoodsName
string
`json:"goods_name"`
...
...
@@ -102,5 +102,5 @@ type ApiGoods struct {
SpuBrief
string
`json:"spu_brief"`
SpuDetail
string
`json:"spu_detail"`
ClassName
string
`json:"class_name"`
ErpTax
bool
`json:"erp_tax"`
//
ErpTax bool `json:"erp_tax"`
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment