+ jxutils_act.go, ActStoreSkuMap
This commit is contained in:
39
business/jxutils/jxutils_act.go
Normal file
39
business/jxutils/jxutils_act.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package jxutils
|
||||
|
||||
import "git.rosy.net.cn/jx-callback/business/model"
|
||||
|
||||
type ActStoreSkuMap struct {
|
||||
actStoreSkuMap map[int64]map[int]*model.ActStoreSku2
|
||||
}
|
||||
|
||||
func NewActStoreSkuMap(actStoreSkuList []*model.ActStoreSku2, isActPrice bool) (actMap *ActStoreSkuMap) {
|
||||
actMap = &ActStoreSkuMap{}
|
||||
actStoreSkuMap := make(map[int64]map[int]*model.ActStoreSku2)
|
||||
for _, v := range actStoreSkuList {
|
||||
index := Combine2Int(v.StoreID, v.SkuID)
|
||||
if actStoreSkuMap[index] == nil {
|
||||
actStoreSkuMap[index] = make(map[int]*model.ActStoreSku2)
|
||||
}
|
||||
if actStoreSkuMap[index][v.VendorID] == nil ||
|
||||
(isActPrice && actStoreSkuMap[index][v.VendorID].ActualActPrice > v.ActualActPrice) ||
|
||||
(!isActPrice && actStoreSkuMap[index][v.VendorID].EarningPrice > v.EarningPrice) {
|
||||
actStoreSkuMap[index][v.VendorID] = v
|
||||
}
|
||||
}
|
||||
actMap.actStoreSkuMap = actStoreSkuMap
|
||||
return actMap
|
||||
}
|
||||
|
||||
func (a *ActStoreSkuMap) GetActStoreSku(storeID, skuID, vendorID int) (storeSku *model.ActStoreSku2) {
|
||||
index := Combine2Int(storeID, skuID)
|
||||
if a.actStoreSkuMap[index] != nil {
|
||||
if vendorID < 0 {
|
||||
for k := range a.actStoreSkuMap[index] {
|
||||
vendorID = k
|
||||
break
|
||||
}
|
||||
}
|
||||
storeSku = a.actStoreSkuMap[index][vendorID]
|
||||
}
|
||||
return storeSku
|
||||
}
|
||||
Reference in New Issue
Block a user