- initdata.InitVendorCategory
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func (p *PurchaseHandler) GetVendorCategories() (vendorCats []*model.SkuVendorCa
|
||||
cat := &model.SkuVendorCategory{
|
||||
VendorID: model.VendorIDMTWM,
|
||||
Name: utils.Interface2String(v["name"]),
|
||||
Level: int(utils.MustInterface2Int64(v["level"])),
|
||||
Level: i + 1, //int(utils.MustInterface2Int64(v["level"])),
|
||||
}
|
||||
cat.LastOperator = "builder"
|
||||
vendorCats = append(vendorCats, cat)
|
||||
|
||||
@@ -37,3 +37,16 @@ func (c *InitDataController) InitSkuName() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 初始化vendor category
|
||||
// @Description 初始化vendor category(当前只有美团外卖的通过这个设置)
|
||||
// @Param token header string true "认证token"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /InitVendorCategory [post]
|
||||
func (c *InitDataController) InitVendorCategory() {
|
||||
c.callInitVendorCategory(func(params *tInitdataInitVendorCategoryParams) (retVal interface{}, errCode string, err error) {
|
||||
err = initdata.InitVendorCategory(params.Ctx)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -167,6 +167,14 @@ func init() {
|
||||
MethodParams: param.Make(),
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"],
|
||||
beego.ControllerComments{
|
||||
Method: "InitVendorCategory",
|
||||
Router: `/InitVendorCategory`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||
beego.ControllerComments{
|
||||
Method: "CreateWaybillOnProviders",
|
||||
|
||||
Reference in New Issue
Block a user