GetEffectiveActStoreSkuInfo添加actType参数
修复ActStoreSkuParam2Model中调用GetEffectiveActStoreSkuInfo的bug
This commit is contained in:
@@ -394,7 +394,7 @@ func updateSingleOrderEarningPrice(order *model.GoodsOrder, db *dao.DaoDB) {
|
|||||||
skuIDMap[v.SkuID] = 1
|
skuIDMap[v.SkuID] = 1
|
||||||
}
|
}
|
||||||
if len(skuIDMap) > 0 {
|
if len(skuIDMap) > 0 {
|
||||||
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt)
|
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, 0, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
|
globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ func (c *OrderManager) updateAfsOrderSkuOtherInfo(db *dao.DaoDB, order *model.Af
|
|||||||
var actStoreSkuMap *jxutils.ActStoreSkuMap
|
var actStoreSkuMap *jxutils.ActStoreSkuMap
|
||||||
if len(skuIDMap) > 0 {
|
if len(skuIDMap) > 0 {
|
||||||
if order2, err2 := c.LoadOrder(order.VendorOrderID, order.VendorID); err2 == nil {
|
if order2, err2 := c.LoadOrder(order.VendorOrderID, order.VendorID); err2 == nil {
|
||||||
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order2.OrderCreatedAt, order2.OrderCreatedAt)
|
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, 0, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order2.OrderCreatedAt, order2.OrderCreatedAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
globals.SugarLogger.Errorf("updateAfsOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
|
globals.SugarLogger.Errorf("updateAfsOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
|
|||||||
skuIDs := jxutils.IntMap2List(skuIDMap)
|
skuIDs := jxutils.IntMap2List(skuIDMap)
|
||||||
// 判断活动是否重叠的检查,当前忽略京东平台及所有结算信息
|
// 判断活动是否重叠的检查,当前忽略京东平台及所有结算信息
|
||||||
if !(len(vendorIDs) == 1 && vendorIDs[0] == model.VendorIDJD || act.Type == model.ActSkuFake) {
|
if !(len(vendorIDs) == 1 && vendorIDs[0] == model.VendorIDJD || act.Type == model.ActSkuFake) {
|
||||||
effectActStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, storeIDs, skuIDs, act.BeginAt, act.EndAt)
|
effectActStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, act.Type, storeIDs, skuIDs, act.BeginAt, act.EndAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
globals.SugarLogger.Errorf("GetEffectiveActStoreSkuInfo can not get sku promotion info for error:%v", err)
|
globals.SugarLogger.Errorf("GetEffectiveActStoreSkuInfo can not get sku promotion info for error:%v", err)
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ func ScorePromotionSku(storeInfo *cms.StoreExt) {
|
|||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
beginTime := time.Now()
|
beginTime := time.Now()
|
||||||
endTime := time.Now()
|
endTime := time.Now()
|
||||||
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, -1, nil, []int{storeID}, nil, beginTime, endTime)
|
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, -1, nil, 0, []int{storeID}, nil, beginTime, endTime)
|
||||||
finalScore := 0
|
finalScore := 0
|
||||||
if err == nil && len(actStoreSkuList) > 0 {
|
if err == nil && len(actStoreSkuList) > 0 {
|
||||||
actStoreSkuMap := make(map[int]int)
|
actStoreSkuMap := make(map[int]int)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ type ActStoreSkuMap struct {
|
|||||||
actStoreSkuMap map[int64]map[int]*model.ActStoreSku2
|
actStoreSkuMap map[int64]map[int]*model.ActStoreSku2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isActPrice为true表示是活动,false表示是结算
|
||||||
func NewActStoreSkuMap(actStoreSkuList []*model.ActStoreSku2, isActPrice bool) (actMap *ActStoreSkuMap) {
|
func NewActStoreSkuMap(actStoreSkuList []*model.ActStoreSku2, isActPrice bool) (actMap *ActStoreSkuMap) {
|
||||||
actMap = &ActStoreSkuMap{}
|
actMap = &ActStoreSkuMap{}
|
||||||
actStoreSkuMap := make(map[int64]map[int]*model.ActStoreSku2)
|
actStoreSkuMap := make(map[int64]map[int]*model.ActStoreSku2)
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ func GetExistVendorActIDs(db *DaoDB, vendorID int) (vendorActIDs []string, err e
|
|||||||
return vendorActIDs, err
|
return vendorActIDs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs []int, storeIDs, skuIDs []int, beginAt, endAt time.Time) (actStoreSkuList []*model.ActStoreSku2, err error) {
|
func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs []int, actType int, storeIDs, skuIDs []int, beginAt, endAt time.Time) (actStoreSkuList []*model.ActStoreSku2, err error) {
|
||||||
if utils.IsTimeZero(beginAt) {
|
if utils.IsTimeZero(beginAt) {
|
||||||
return nil, fmt.Errorf("GeActStoreSkuInfo必须指定活动开始时间")
|
return nil, fmt.Errorf("GeActStoreSkuInfo必须指定活动开始时间")
|
||||||
}
|
}
|
||||||
@@ -406,9 +406,13 @@ func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs []int, storeIDs
|
|||||||
sqlParams = append(sqlParams, model.GetVendorMask(vendorIDs...), vendorIDs)
|
sqlParams = append(sqlParams, model.GetVendorMask(vendorIDs...), vendorIDs)
|
||||||
}
|
}
|
||||||
if actID > 0 {
|
if actID > 0 {
|
||||||
sql = " AND t1.id = ?"
|
sql = " AND t1.act_type = ?"
|
||||||
sqlParams = append(sqlParams, actID)
|
sqlParams = append(sqlParams, actID)
|
||||||
}
|
}
|
||||||
|
if actType > 0 {
|
||||||
|
sql = " AND t1.type = ?"
|
||||||
|
sqlParams = append(sqlParams, actType)
|
||||||
|
}
|
||||||
if len(storeIDs) > 0 {
|
if len(storeIDs) > 0 {
|
||||||
sql += " AND t2.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
sql += " AND t2.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||||
sqlParams = append(sqlParams, storeIDs)
|
sqlParams = append(sqlParams, storeIDs)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func TestGetEffectiveActStoreSkuInfo(t *testing.T) {
|
|||||||
ToTime: utils.Str2Time("2019-08-06 12:34:56"),
|
ToTime: utils.Str2Time("2019-08-06 12:34:56"),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
result, err := GetEffectiveActStoreSkuInfo(GetDB(), v.ActID, v.VendorIDs, v.StoreIDs, v.SkuIDs, v.FromTime, v.ToTime)
|
result, err := GetEffectiveActStoreSkuInfo(GetDB(), v.ActID, v.VendorIDs, 0, v.StoreIDs, v.SkuIDs, v.FromTime, v.ToTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1136,7 +1136,7 @@ func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesI
|
|||||||
if actVendorID >= 0 {
|
if actVendorID >= 0 {
|
||||||
vendorIDs = []int{actVendorID}
|
vendorIDs = []int{actVendorID}
|
||||||
}
|
}
|
||||||
actStoreSkuList, err := GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, storeIDs, skuIDs, time.Now(), time.Now())
|
actStoreSkuList, err := GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, 0, storeIDs, skuIDs, time.Now(), time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err)
|
globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err)
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user