- check level in AddCategory.
- fix bug, jd outSystemId is string
This commit is contained in:
@@ -47,10 +47,28 @@ func GetCategories(ctx *jxcontext.Context, parentID int) (cats []*model.SkuCateg
|
|||||||
}
|
}
|
||||||
|
|
||||||
func AddCategory(ctx *jxcontext.Context, cat *model.SkuCategory, userName string) (outCat *model.SkuCategory, err error) {
|
func AddCategory(ctx *jxcontext.Context, cat *model.SkuCategory, userName string) (outCat *model.SkuCategory, err error) {
|
||||||
|
db := dao.GetDB()
|
||||||
|
if cat.Level < 0 || cat.Level > 2 {
|
||||||
|
return nil, errors.New("Level必须为1或2")
|
||||||
|
} else if cat.Level == 1 && cat.ParentID != 0 {
|
||||||
|
return nil, errors.New("Level1的分类其父分类必须为0")
|
||||||
|
} else if cat.Level == 2 {
|
||||||
|
if cat.ParentID == 0 {
|
||||||
|
return nil, errors.New("Level2的分类其父分类必须不为0")
|
||||||
|
}
|
||||||
|
parentCat := &model.SkuCategory{}
|
||||||
|
parentCat.ID = cat.ParentID
|
||||||
|
if err = dao.GetEntity(db, parentCat); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if parentCat.Level != 1 {
|
||||||
|
return nil, errors.New("Level2的分类其父分类必须为Level1分类")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dao.WrapAddIDCULDEntity(cat, userName)
|
dao.WrapAddIDCULDEntity(cat, userName)
|
||||||
cat.JdSyncStatus = model.SyncFlagNewMask
|
cat.JdSyncStatus = model.SyncFlagNewMask
|
||||||
cat.JdID = jxutils.GenFakeID()
|
cat.JdID = jxutils.GenFakeID()
|
||||||
db := dao.GetDB()
|
|
||||||
if cat.Seq <= 0 {
|
if cat.Seq <= 0 {
|
||||||
var maxSeq struct {
|
var maxSeq struct {
|
||||||
MaxSeq int
|
MaxSeq int
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
|
|||||||
task1 := tasksch.NewParallelTask(taskName, nil, ctx.GetUserName(), func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
task1 := tasksch.NewParallelTask(taskName, nil, ctx.GetUserName(), func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
store := batchItemList[0].(*tJdStoreInfo)
|
store := batchItemList[0].(*tJdStoreInfo)
|
||||||
storeParams := map[string]interface{}{
|
storeParams := map[string]interface{}{
|
||||||
"outSystemId": store.ID,
|
"outSystemId": utils.Int2Str(int(store.ID)),
|
||||||
}
|
}
|
||||||
if step == 1 {
|
if step == 1 {
|
||||||
storeParams["outSystemId"] = utils.GetUUID()
|
storeParams["outSystemId"] = utils.GetUUID()
|
||||||
|
|||||||
Reference in New Issue
Block a user