Commit 51040247 by mushishixian

修复数量问题

parent 19462d7e
......@@ -22,14 +22,14 @@ func GetBomInfoWithItems(bomId int) (bom model.Bom) {
bomItems []model.BomItem
)
bom = GetBomInfo(bomId)
bomItems = GetBomItems(bomId)
bomItems = GetBomItems(bom)
bom.BomItems = bomItems
return bom
}
func GetBomCompleteInfo(bomId int) (bom model.Bom) {
bom = GetBomInfo(bomId)
bomItems := GetBomItems(bomId)
bomItems := GetBomItems(bom)
bom.BomItems = bomItems
bomMatchings := GetBomMatchings(bomId)
bom.BomIMatchings = bomMatchings
......
......@@ -11,11 +11,14 @@ import (
)
//根据bom_id查出bom表信息
func GetBomItems(bomId int) (bomItems []model.BomItem) {
bomIdStr := strconv.FormatInt(int64(bomId), 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
}
......
......@@ -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 {
......
......@@ -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))
......
......@@ -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"`
......
......@@ -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:需要修正
......
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