- 新版活动,京西补贴
This commit is contained in:
@@ -74,14 +74,22 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
|
||||
storeIDMap := make(map[int]int)
|
||||
skuIDMap := make(map[int]int)
|
||||
storeSkuParamMap := make(map[int][]*ActStoreSkuParam)
|
||||
var wrongSkuList []*ActStoreSkuParam
|
||||
for _, v := range actStoreSku {
|
||||
storeIDMap[v.StoreID] = 1
|
||||
skuIDMap[v.SkuID] = 1
|
||||
storeSkuParamMap[v.StoreID] = append(storeSkuParamMap[v.StoreID], v)
|
||||
if act.Type == model.ActSkuFake && v.EarningPrice == 0 {
|
||||
wrongSkuList = append(wrongSkuList, v)
|
||||
} else {
|
||||
storeIDMap[v.StoreID] = 1
|
||||
skuIDMap[v.SkuID] = 1
|
||||
storeSkuParamMap[v.StoreID] = append(storeSkuParamMap[v.StoreID], v)
|
||||
}
|
||||
}
|
||||
if len(wrongSkuList) > 0 {
|
||||
return nil, nil, nil, jsonerr.New(wrongSkuList, model.ErrCodeJsonActEarningPriceIsZero)
|
||||
}
|
||||
storeIDs := jxutils.IntMap2List(storeIDMap)
|
||||
skuIDs := jxutils.IntMap2List(skuIDMap)
|
||||
if !(len(vendorIDs) == 1 && vendorIDs[0] == model.VendorIDJD) {
|
||||
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)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err)
|
||||
@@ -101,7 +109,6 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
|
||||
storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)] = v
|
||||
}
|
||||
|
||||
var wrongSkuList []*ActStoreSkuParam
|
||||
for storeID, oneStoreSkuParam := range storeSkuParamMap {
|
||||
validVendorMap := make(map[int]int)
|
||||
validSkuMap := make(map[int]int)
|
||||
@@ -132,6 +139,9 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
|
||||
}
|
||||
actSkuMap.ActualActPrice = int64(jxutils.CaculateSkuVendorPrice(int(actSkuMap.VendorPrice), percentage, 0))
|
||||
}
|
||||
if actSkuMap.ActualActPrice <= 0 {
|
||||
actSkuMap.ActualActPrice = 1
|
||||
}
|
||||
if actSkuMap.ActualActPrice >= actSkuMap.VendorPrice {
|
||||
wrongSkuList = append(wrongSkuList, v)
|
||||
} else {
|
||||
@@ -276,6 +286,8 @@ func checkActValidation(act *model.Act, vendorIDs []int) (err error) {
|
||||
errList = append(errList, fmt.Errorf("%s活动折扣必须小于:%d", model.ActTypeName[act.Type], maxDiscount4SkuSecKill))
|
||||
}
|
||||
}
|
||||
} else if act.Type == model.ActSkuFake {
|
||||
|
||||
} else {
|
||||
errList = append(errList, fmt.Errorf("当前只支持直降与秒杀活动"))
|
||||
}
|
||||
@@ -657,6 +669,9 @@ func SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITask, actID int, vendor
|
||||
if vendorIDs == nil {
|
||||
vendorIDs = partner.GetVendorIDsFromActMap(actMap)
|
||||
}
|
||||
if len(vendorIDs) == 0 || actMap[vendorIDs[0]].Type == model.ActSkuFake {
|
||||
return "", nil
|
||||
}
|
||||
task := tasksch.NewParallelTask("SyncAct", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
vendorID := batchItemList[0].(int)
|
||||
|
||||
@@ -31,6 +31,7 @@ const (
|
||||
|
||||
var (
|
||||
ActTypeName = map[int]string{
|
||||
ActSkuFake: "补贴",
|
||||
ActSkuDirectDown: "直降",
|
||||
ActSkuSecKill: "秒杀",
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ const (
|
||||
ErrCodeUserNotExist = "-3"
|
||||
ErrCodeUserAlreadyExist = "-4"
|
||||
|
||||
ErrCodeJsonActSkuConflict = "-101" // 这个错误号表示description中的是一个json对象,不是错误文本
|
||||
ErrCodeJsonActPriceTooLarger = "-102" // 这个错误号表示description中的是一个json对象,不是错误文本
|
||||
ErrCodeJsonActSkuConflict = "-101" // 这个错误号表示description中的是一个json对象,不是错误文本
|
||||
ErrCodeJsonActPriceTooLarger = "-102" // 这个错误号表示description中的是一个json对象,不是错误文本
|
||||
ErrCodeJsonActEarningPriceIsZero = "-103"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user