- 修复GetEffectiveActStoreSkuInfo的有效时间相交判断错误

This commit is contained in:
gazebo
2019-07-10 11:18:18 +08:00
parent 32bc876113
commit 52009c345c
2 changed files with 8 additions and 8 deletions

View File

@@ -81,7 +81,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
}
storeIDs := jxutils.IntMap2List(storeIDMap)
skuIDs := jxutils.IntMap2List(skuIDMap)
effectActStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, nil, storeIDs, skuIDs, time.Now(), time.Now())
effectActStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, nil, storeIDs, skuIDs, act.BeginAt, act.EndAt)
if err != nil {
globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err)
return nil, nil, nil, err

View File

@@ -268,20 +268,20 @@ func QueryActs(db *DaoDB, actID int, offset, pageSize int, keyword string, vendo
return pagedInfo, err
}
func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs []int, fromTime, toTime time.Time) (actStoreSkuList []*model.ActStoreSku2, err error) {
if utils.IsTimeZero(fromTime) {
return nil, fmt.Errorf("GeActStoreSkuInfo必须指定fromTime")
func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs []int, beginAt, endAt time.Time) (actStoreSkuList []*model.ActStoreSku2, err error) {
if utils.IsTimeZero(beginAt) {
return nil, fmt.Errorf("GeActStoreSkuInfo必须指定活动开始时间")
}
if utils.IsTimeZero(toTime) {
toTime = fromTime
if utils.IsTimeZero(endAt) {
endAt = beginAt
}
sqlParams := []interface{}{}
sql := `
SELECT t2.*
FROM act t1
JOIN act_store_sku t2 ON t2.act_id = t1.id AND t2.deleted_at = ?
WHERE t1.status = ? AND t1.begin_at <= ? AND t1.end_at >= ?`
sqlParams = append(sqlParams, utils.DefaultTimeValue, model.ActStatusCreated, fromTime, toTime)
WHERE t1.status = ? AND NOT (t1.begin_at > ? OR t1.end_at < ?)`
sqlParams = append(sqlParams, utils.DefaultTimeValue, model.ActStatusCreated, endAt, beginAt)
if len(vendorIDs) > 0 {
sql += " AND t1.vendor_mask & ? <> 0"
sqlParams = append(sqlParams, model.GetVendorMask(vendorIDs...))