+ GetEffectiveActStoreSkuInfo
This commit is contained in:
@@ -2,6 +2,7 @@ package act
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -209,6 +210,10 @@ func AddActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, actSto
|
||||
}
|
||||
|
||||
func checkActValidation(act *model.Act, vendorIDs []int) (err error) {
|
||||
var errList []error
|
||||
if utils.IsTimeZero(act.BeginAt) || utils.IsTimeZero(act.EndAt) {
|
||||
errList = append(errList, fmt.Errorf("活动开始与结束时间必须指定"))
|
||||
}
|
||||
vendorIDMap := make(map[int]int)
|
||||
for _, vendorID := range vendorIDs {
|
||||
vendorIDMap[vendorID] = 1
|
||||
@@ -216,21 +221,28 @@ func checkActValidation(act *model.Act, vendorIDs []int) (err error) {
|
||||
|
||||
if act.Type == model.ActSkuDirectDown || act.Type == model.ActSkuSecKill {
|
||||
if act.PricePercentage == 0 {
|
||||
return fmt.Errorf("活动必须指定价格折扣")
|
||||
errList = append(errList, fmt.Errorf("活动必须指定价格折扣"))
|
||||
}
|
||||
if act.Type == model.ActSkuDirectDown && act.PricePercentage <= minDiscount4SkuDirectDown || act.PricePercentage >= 100 {
|
||||
return fmt.Errorf("%s活动折扣必须大于:%d, 且必须有折扣", model.ActTypeName[act.Type], minDiscount4SkuDirectDown)
|
||||
errList = append(errList, fmt.Errorf("%s活动折扣必须大于:%d, 且必须有折扣", model.ActTypeName[act.Type], minDiscount4SkuDirectDown))
|
||||
}
|
||||
if act.Type == model.ActSkuSecKill && act.PricePercentage >= maxDiscount4SkuSecKill {
|
||||
if vendorIDMap[model.VendorIDMTWM] == 1 {
|
||||
return fmt.Errorf("平台%s暂不支持%s活动", model.VendorChineseNames[model.VendorIDMTWM], model.ActTypeName[act.Type])
|
||||
errList = append(errList, fmt.Errorf("平台%s暂不支持%s活动", model.VendorChineseNames[model.VendorIDMTWM], model.ActTypeName[act.Type]))
|
||||
}
|
||||
return fmt.Errorf("%s活动折扣必须小于:%d", model.ActTypeName[act.Type], maxDiscount4SkuSecKill)
|
||||
errList = append(errList, fmt.Errorf("%s活动折扣必须小于:%d", model.ActTypeName[act.Type], maxDiscount4SkuSecKill))
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("当前只支持直降与秒杀活动")
|
||||
errList = append(errList, fmt.Errorf("当前只支持直降与秒杀活动"))
|
||||
}
|
||||
return nil
|
||||
if errList == nil {
|
||||
return nil
|
||||
}
|
||||
strList := make([]string, len(errList))
|
||||
for k, v := range errList {
|
||||
strList[k] = v.Error()
|
||||
}
|
||||
return fmt.Errorf("%s", strings.Join(strList, ",\n"))
|
||||
}
|
||||
|
||||
func CreateAct(ctx *jxcontext.Context, act *model.Act, vendorIDs []int, actRules []*ActOrderRuleParam, actStoreSku []*ActStoreSkuParam, isAsync bool) (hint string, err error) {
|
||||
|
||||
Reference in New Issue
Block a user