Commit 51040247 by mushishixian

修复数量问题

parent 19462d7e
...@@ -22,14 +22,14 @@ func GetBomInfoWithItems(bomId int) (bom model.Bom) { ...@@ -22,14 +22,14 @@ func GetBomInfoWithItems(bomId int) (bom model.Bom) {
bomItems []model.BomItem bomItems []model.BomItem
) )
bom = GetBomInfo(bomId) bom = GetBomInfo(bomId)
bomItems = GetBomItems(bomId) bomItems = GetBomItems(bom)
bom.BomItems = bomItems bom.BomItems = bomItems
return bom return bom
} }
func GetBomCompleteInfo(bomId int) (bom model.Bom) { func GetBomCompleteInfo(bomId int) (bom model.Bom) {
bom = GetBomInfo(bomId) bom = GetBomInfo(bomId)
bomItems := GetBomItems(bomId) bomItems := GetBomItems(bom)
bom.BomItems = bomItems bom.BomItems = bomItems
bomMatchings := GetBomMatchings(bomId) bomMatchings := GetBomMatchings(bomId)
bom.BomIMatchings = bomMatchings bom.BomIMatchings = bomMatchings
......
...@@ -11,11 +11,14 @@ import ( ...@@ -11,11 +11,14 @@ import (
) )
//根据bom_id查出bom表信息 //根据bom_id查出bom表信息
func GetBomItems(bomId int) (bomItems []model.BomItem) { func GetBomItems(bom model.Bom) (bomItems []model.BomItem) {
bomIdStr := strconv.FormatInt(int64(bomId), 10) bomIdStr := strconv.FormatInt(int64(bom.BomID), 10)
tableEnd := string(bomIdStr[len(bomIdStr)-1]) tableEnd := string(bomIdStr[len(bomIdStr)-1])
model.Db.Table("lie_bom_item_"+tableEnd).Where("del_status = ?", 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 return bomItems
} }
......
...@@ -15,6 +15,8 @@ type GoodsMap struct { ...@@ -15,6 +15,8 @@ type GoodsMap struct {
GoodsId string GoodsId string
GoodsName string GoodsName string
BomItemId int BomItemId int
//套数
Amount int
BomId int BomId int
Number int Number int
DeliveryType int DeliveryType int
...@@ -200,7 +202,7 @@ func MatchGoodsInfo(goods model.ApiGoods, goodsMap GoodsMap) (bomMatching model. ...@@ -200,7 +202,7 @@ func MatchGoodsInfo(goods model.ApiGoods, goodsMap GoodsMap) (bomMatching model.
var ladder model.LadderPrice var ladder model.LadderPrice
for key, price := range goods.LadderPrice { for key, price := range goods.LadderPrice {
//需要用于获取价格的阶梯价 //需要用于获取价格的阶梯价
if bomMatching.Number < price.Purchases { if bomMatching.Number*goodsMap.Amount < price.Purchases {
//ladder = price //ladder = price
var index int var index int
if key == 0 { if key == 0 {
......
...@@ -276,6 +276,7 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor ...@@ -276,6 +276,7 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
} }
var goodsMap GoodsMap var goodsMap GoodsMap
goodsMap.GoodsId = hit.Id goodsMap.GoodsId = hit.Id
goodsMap.Amount = bomItems[key].Amount
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
...@@ -334,7 +335,7 @@ func getTermQuery(index string, bomItem model.BomItem, sort int, flag bool) (que ...@@ -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.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 { } else {
field := "auto_goods_name" field := "auto_goods_name"
query = query.Must(es.NewTermQuery(field, bomItem.GoodsName)) query = query.Must(es.NewTermQuery(field, bomItem.GoodsName))
......
...@@ -18,6 +18,7 @@ type Bom struct { ...@@ -18,6 +18,7 @@ type Bom struct {
// UpdateTime 更新时间 // UpdateTime 更新时间
UpdateTime int `json:"update_time"` UpdateTime int `json:"update_time"`
// Status 状态 1:正常 2:删除 // Status 状态 1:正常 2:删除
Amount int `json:"amount"`
Status int `json:"status"` Status int `json:"status"`
// IsSyncCrm 是否同步过crm 1:否 2:是 // IsSyncCrm 是否同步过crm 1:否 2:是
IsSyncCrm int `json:"is_sync_crm"` IsSyncCrm int `json:"is_sync_crm"`
......
...@@ -11,6 +11,7 @@ type BomItem struct { ...@@ -11,6 +11,7 @@ type BomItem struct {
BrandName string `json:"brand_name"` BrandName string `json:"brand_name"`
// Number 需求数量 // Number 需求数量
Number int `json:"number"` Number int `json:"number"`
Amount int `json:"amount"`
Attrs string `json:"attrs"` Attrs string `json:"attrs"`
Encap string `json:"encap"` Encap string `json:"encap"`
// ItemStatus 匹配状态 1:等待匹配 2:可购现货 3:待询价 4:需要修正 // 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