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
2b937f1c
authored
Jun 02, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
相同型号的数据获取问题
parent
8cc30883
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
39 deletions
internal/logic/bom_matching.go
internal/logic/goods.go
internal/logic/bom_matching.go
View file @
2b937f1c
...
@@ -35,11 +35,12 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
...
@@ -35,11 +35,12 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
//批量更新每一条记录之前,要去批量更新item表的item_status
//批量更新每一条记录之前,要去批量更新item表的item_status
for
_
,
matching
:=
range
matchingList
{
for
_
,
matching
:=
range
matchingList
{
//先去数据库查询是否存在该记录,有的话修改,没有就新增
//先去数据库查询是否存在该记录,有的话修改,没有就新增
updateData
:=
getUpdateData
(
matching
)
var
match
model
.
BomItemMatching
var
match
model
.
BomItemMatching
model
.
Db
.
Table
(
tableName
)
.
Where
(
"bom_item_id = ?"
,
matching
.
BomItemID
)
.
First
(
&
match
)
model
.
Db
.
Table
(
tableName
)
.
Where
(
"bom_item_id = ?"
,
matching
.
BomItemID
)
.
First
(
&
match
)
if
match
.
BomItemID
!=
0
{
if
match
.
BomItemID
!=
0
{
matching
.
UpdateTime
=
int
(
time
.
Now
()
.
Unix
())
matching
.
UpdateTime
=
int
(
time
.
Now
()
.
Unix
())
if
err
=
model
.
Db
.
Table
(
tableName
)
.
Model
(
&
match
)
.
Updates
(
matching
)
.
Error
;
err
!=
nil
{
if
err
=
model
.
Db
.
Table
(
tableName
)
.
Model
(
&
match
)
.
Updates
(
updateData
)
.
Error
;
err
!=
nil
{
return
return
}
}
}
else
{
}
else
{
...
@@ -145,43 +146,25 @@ func RefreshBomMatchingGoods(bomId int) (err error) {
...
@@ -145,43 +146,25 @@ func RefreshBomMatchingGoods(bomId int) (err error) {
return
return
}
}
//刷新bom匹配的商品信息
func
getUpdateData
(
matching
model
.
BomItemMatching
)
map
[
string
]
interface
{}
{
func
RefreshBomMatchingGoodsAbandon
(
bomId
int
)
(
err
error
)
{
return
map
[
string
]
interface
{}{
//先找出bom相关信息
"goods_id"
:
matching
.
GoodsID
,
var
goodsIds
[]
string
"goods_name"
:
matching
.
GoodsName
,
bomMatchings
:=
GetBomMatchings
(
bomId
)
"brand_id"
:
matching
.
BrandId
,
for
_
,
matching
:=
range
bomMatchings
{
"brand_name"
:
matching
.
BrandName
,
goodsIds
=
append
(
goodsIds
,
matching
.
GoodsID
)
"goods_type"
:
matching
.
GoodsType
,
}
"supplier_id"
:
matching
.
SupplierID
,
goodsIdsStr
:=
strings
.
Join
(
goodsIds
,
","
)
"supplier_name"
:
matching
.
SupplierName
,
//去请求商品服务
"delivery"
:
matching
.
Delivery
,
goodsList
,
err
:=
GetGoodsInfo
(
goodsIdsStr
)
"price"
:
matching
.
Price
,
if
err
!=
nil
{
"stock"
:
matching
.
Stock
,
return
"moq"
:
matching
.
Moq
,
"mpq"
:
matching
.
Mpq
,
"pdf"
:
matching
.
Pdf
,
"encap"
:
matching
.
Encap
,
"status"
:
matching
.
Status
,
"update_time"
:
time
.
Now
()
.
Unix
(),
"ladder_price"
:
matching
.
LadderPrice
,
"delivery_type"
:
matching
.
DeliveryType
,
}
}
var
bomMatchingList
[]
model
.
BomItemMatching
for
_
,
matching
:=
range
bomMatchings
{
for
_
,
goods
:=
range
goodsList
{
if
matching
.
GoodsID
==
goods
.
GoodsID
{
var
goodsMap
GoodsMap
goodsMap
.
Number
=
matching
.
Number
goodsMap
.
GoodsName
=
matching
.
GoodsName
goodsMap
.
DeliveryType
=
matching
.
DeliveryType
goodsMap
.
BomId
=
matching
.
BomID
goodsMap
.
BomItemId
=
matching
.
BomItemID
goodsMap
.
GoodsId
=
matching
.
GoodsID
//组装需要去更新的商品信息
bomMatching
,
err
:=
MatchGoodsInfo
(
goods
,
goodsMap
)
if
err
!=
nil
{
return
err
}
bomMatchingList
=
append
(
bomMatchingList
,
bomMatching
)
}
}
}
err
=
BatchSaveMatchings
(
bomId
,
bomMatchingList
)
if
err
!=
nil
{
return
}
return
}
}
internal/logic/goods.go
View file @
2b937f1c
...
@@ -133,6 +133,7 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []model.ApiGoods, err error) {
...
@@ -133,6 +133,7 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []model.ApiGoods, err error) {
func
MatchGoodsInfo
(
goods
model
.
ApiGoods
,
goodsMap
GoodsMap
)
(
bomMatching
model
.
BomItemMatching
,
err
error
)
{
func
MatchGoodsInfo
(
goods
model
.
ApiGoods
,
goodsMap
GoodsMap
)
(
bomMatching
model
.
BomItemMatching
,
err
error
)
{
//组装需要去更新的商品信息
//组装需要去更新的商品信息
var
delivery
string
var
delivery
string
if
goodsMap
.
DeliveryType
==
1
{
if
goodsMap
.
DeliveryType
==
1
{
delivery
=
goods
.
CnDeliveryTime
delivery
=
goods
.
CnDeliveryTime
}
else
{
}
else
{
...
...
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