+ 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) {
|
||||
|
||||
@@ -2,10 +2,12 @@ package act
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -25,7 +27,7 @@ func TestInitDb(t *testing.T) {
|
||||
`)
|
||||
}
|
||||
|
||||
func TestCreateAct(t *testing.T) {
|
||||
func TestCreateActOnAlpha(t *testing.T) {
|
||||
actStoreSkuList := []*ActStoreSkuParam{
|
||||
&ActStoreSkuParam{
|
||||
ActStoreSku: model.ActStoreSku{
|
||||
@@ -64,6 +66,46 @@ func TestCreateAct(t *testing.T) {
|
||||
// globals.SugarLogger.Debug(actID)
|
||||
}
|
||||
|
||||
func TestCreateActOnDev(t *testing.T) {
|
||||
actStoreSkuList := []*ActStoreSkuParam{
|
||||
&ActStoreSkuParam{
|
||||
ActStoreSku: model.ActStoreSku{
|
||||
StoreID: 100884,
|
||||
SkuID: 22716,
|
||||
},
|
||||
},
|
||||
&ActStoreSkuParam{
|
||||
ActStoreSku: model.ActStoreSku{
|
||||
StoreID: 100884,
|
||||
SkuID: 22717,
|
||||
},
|
||||
},
|
||||
&ActStoreSkuParam{
|
||||
ActStoreSku: model.ActStoreSku{
|
||||
StoreID: 100920,
|
||||
SkuID: 22714,
|
||||
},
|
||||
},
|
||||
&ActStoreSkuParam{
|
||||
ActStoreSku: model.ActStoreSku{
|
||||
StoreID: 100920,
|
||||
SkuID: 22715,
|
||||
},
|
||||
},
|
||||
}
|
||||
actID, err := CreateAct(jxcontext.AdminCtx, &model.Act{
|
||||
Name: "测试活动",
|
||||
PricePercentage: 80,
|
||||
Type: model.ActSkuDirectDown,
|
||||
BeginAt: time.Now().Add(-24 * time.Hour),
|
||||
EndAt: time.Now().Add(10 * 24 * time.Hour),
|
||||
}, []int{model.VendorIDJD, model.VendorIDMTWM /*, model.VendorIDEBAI*/}, nil, actStoreSkuList, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
globals.SugarLogger.Debug(actID)
|
||||
}
|
||||
|
||||
func TestCancelAct(t *testing.T) {
|
||||
err := CancelAct(jxcontext.AdminCtx, 1)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user