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
51040247
authored
Aug 10, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复数量问题
parent
19462d7e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
10 deletions
internal/logic/bom.go
internal/logic/bom_item.go
internal/logic/goods.go
internal/logic/match.go
internal/model/bom.go
internal/model/bom_item.go
internal/logic/bom.go
View file @
51040247
...
...
@@ -22,14 +22,14 @@ func GetBomInfoWithItems(bomId int) (bom model.Bom) {
bomItems
[]
model
.
BomItem
)
bom
=
GetBomInfo
(
bomId
)
bomItems
=
GetBomItems
(
bom
Id
)
bomItems
=
GetBomItems
(
bom
)
bom
.
BomItems
=
bomItems
return
bom
}
func
GetBomCompleteInfo
(
bomId
int
)
(
bom
model
.
Bom
)
{
bom
=
GetBomInfo
(
bomId
)
bomItems
:=
GetBomItems
(
bom
Id
)
bomItems
:=
GetBomItems
(
bom
)
bom
.
BomItems
=
bomItems
bomMatchings
:=
GetBomMatchings
(
bomId
)
bom
.
BomIMatchings
=
bomMatchings
...
...
internal/logic/bom_item.go
View file @
51040247
...
...
@@ -11,11 +11,14 @@ import (
)
//根据bom_id查出bom表信息
func
GetBomItems
(
bom
Id
int
)
(
bomItems
[]
model
.
BomItem
)
{
bomIdStr
:=
strconv
.
FormatInt
(
int64
(
bom
Id
),
10
)
func
GetBomItems
(
bom
model
.
Bom
)
(
bomItems
[]
model
.
BomItem
)
{
bomIdStr
:=
strconv
.
FormatInt
(
int64
(
bom
.
BomID
),
10
)
tableEnd
:=
string
(
bomIdStr
[
len
(
bomIdStr
)
-
1
])
model
.
Db
.
Table
(
"lie_bom_item_"
+
tableEnd
)
.
Where
(
"del_status = ?"
,
1
)
.
Where
(
"bom_id = ?"
,
bomId
)
.
Find
(
&
bomItems
)
Where
(
"bom_id = ?"
,
bom
.
BomID
)
.
Find
(
&
bomItems
)
for
key
,
_
:=
range
bomItems
{
bomItems
[
key
]
.
Amount
=
bom
.
Amount
}
return
bomItems
}
...
...
internal/logic/goods.go
View file @
51040247
...
...
@@ -12,9 +12,11 @@ import (
)
type
GoodsMap
struct
{
GoodsId
string
GoodsName
string
BomItemId
int
GoodsId
string
GoodsName
string
BomItemId
int
//套数
Amount
int
BomId
int
Number
int
DeliveryType
int
...
...
@@ -200,7 +202,7 @@ func MatchGoodsInfo(goods model.ApiGoods, goodsMap GoodsMap) (bomMatching model.
var
ladder
model
.
LadderPrice
for
key
,
price
:=
range
goods
.
LadderPrice
{
//需要用于获取价格的阶梯价
if
bomMatching
.
Number
<
price
.
Purchases
{
if
bomMatching
.
Number
*
goodsMap
.
Amount
<
price
.
Purchases
{
//ladder = price
var
index
int
if
key
==
0
{
...
...
internal/logic/match.go
View file @
51040247
...
...
@@ -276,6 +276,7 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
}
var
goodsMap
GoodsMap
goodsMap
.
GoodsId
=
hit
.
Id
goodsMap
.
Amount
=
bomItems
[
key
]
.
Amount
goodsMap
.
Number
=
bomItems
[
key
]
.
Number
goodsMap
.
GoodsName
=
bomItems
[
key
]
.
GoodsName
goodsMap
.
BomItemId
=
bomItems
[
key
]
.
BomItemID
...
...
@@ -334,7 +335,7 @@ func getTermQuery(index string, bomItem model.BomItem, sort int, flag bool) (que
query
=
query
.
Should
(
es
.
NewConstantScoreQuery
(
es
.
NewTermQuery
(
"brand_name"
,
bomItem
.
BrandName
))
.
Boost
(
2
))
}
//搜索库存
query
=
query
.
Should
(
es
.
NewConstantScoreQuery
(
es
.
NewRangeQuery
(
"stock"
)
.
Gte
(
bomItem
.
Number
)))
query
=
query
.
Should
(
es
.
NewConstantScoreQuery
(
es
.
NewRangeQuery
(
"stock"
)
.
Gte
(
bomItem
.
Number
*
bomItem
.
Amount
)))
}
else
{
field
:=
"auto_goods_name"
query
=
query
.
Must
(
es
.
NewTermQuery
(
field
,
bomItem
.
GoodsName
))
...
...
internal/model/bom.go
View file @
51040247
...
...
@@ -18,6 +18,7 @@ type Bom struct {
// UpdateTime 更新时间
UpdateTime
int
`json:"update_time"`
// Status 状态 1:正常 2:删除
Amount
int
`json:"amount"`
Status
int
`json:"status"`
// IsSyncCrm 是否同步过crm 1:否 2:是
IsSyncCrm
int
`json:"is_sync_crm"`
...
...
internal/model/bom_item.go
View file @
51040247
...
...
@@ -11,6 +11,7 @@ type BomItem struct {
BrandName
string
`json:"brand_name"`
// Number 需求数量
Number
int
`json:"number"`
Amount
int
`json:"amount"`
Attrs
string
`json:"attrs"`
Encap
string
`json:"encap"`
// ItemStatus 匹配状态 1:等待匹配 2:可购现货 3:待询价 4:需要修正
...
...
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