Files
jx-callback/business/jxutils/jxutils_act.go
gazebo 84f2c8930c GetEffectiveActStoreSkuInfo添加actType参数
修复ActStoreSkuParam2Model中调用GetEffectiveActStoreSkuInfo的bug
2019-12-16 16:39:39 +08:00

42 lines
1.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package jxutils
import (
"git.rosy.net.cn/jx-callback/business/model"
)
type ActStoreSkuMap struct {
actStoreSkuMap map[int64]map[int]*model.ActStoreSku2
}
// isActPrice为true表示是活动false表示是结算
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 (isActPrice && v.ActualActPrice > 0 && (actStoreSkuMap[index][v.VendorID] == nil || actStoreSkuMap[index][v.VendorID].ActualActPrice > v.ActualActPrice)) ||
(!isActPrice && v.EarningPrice > 0 && (actStoreSkuMap[index][v.VendorID] == nil || 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
}