- initdata.InitVendorCategory

This commit is contained in:
gazebo
2018-12-13 16:47:27 +08:00
parent c0effbbf2b
commit 03198c0683
4 changed files with 53 additions and 1 deletions

View File

@@ -12,6 +12,8 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
"git.rosy.net.cn/jx-callback/globals/api"
)
@@ -161,3 +163,32 @@ func InitSkuName(ctx *jxcontext.Context, isForce, isAsync, isContinueWhenError b
}
return hint, err
}
func InitVendorCategory(ctx *jxcontext.Context) (err error) {
if handler, ok := partner.PurchasePlatformHandlers[model.VendorIDMTWM].(*mtwm.PurchaseHandler); ok {
cats, err2 := handler.GetVendorCategories()
if err2 != nil {
return err2
}
db := dao.GetDB()
dao.Begin(db)
defer dao.Rollback(db)
sql := `
DELETE
FROM sku_vendor_category
WHERE vendor_id = ?
`
if _, err = dao.ExecuteSQL(db, sql, model.VendorIDMTWM); err != nil {
return err
}
for _, cat := range cats {
dao.WrapAddIDCULEntity(cat, ctx.GetUserName())
if err = dao.CreateEntity(db, cat); err != nil {
return err
}
}
dao.Commit(db)
}
return err
}