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