aa
This commit is contained in:
@@ -2899,3 +2899,54 @@ func ReorderVendorCategories(ctx *jxcontext.Context, parentID, vendorID int, ven
|
||||
SyncReorderCategories(ctx, parentID, true)
|
||||
return err
|
||||
}
|
||||
|
||||
func LoadStoreVendorCategories(ctx *jxcontext.Context, vendorOrgCode string, vendorID, storeID int) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
|
||||
if storeCats, err := dao.GetStoreCategoryMap(db, -1, 0, storeID, 0); err == nil {
|
||||
if len(storeCats) == 0 {
|
||||
return fmt.Errorf("未查询到该门店有门店分类,请重新选择! [%v]", storeID)
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
sql := `
|
||||
DELETE FROM vendor_category_map WHERE vendor_id = ? AND vendor_org_code = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
vendorID, vendorOrgCode,
|
||||
}
|
||||
if _, err = dao.ExecuteSQL(db, sql, sqlParams); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
sql2 := `
|
||||
INSERT INTO vendor_category_map
|
||||
(created_at, updated_at, last_operator, deleted_at, vendor_id, vendor_org_code, category_id, vendor_category_name, vendor_category_seq, level, parent_id)
|
||||
SELECT ?, ?, ?, ?, ?, ?, category_id, store_category_name, store_category_seq, level, parent_id
|
||||
FROM store_category_map
|
||||
WHERE deleted_at = ?
|
||||
AND store_id = ?
|
||||
`
|
||||
sqlParams2 := []interface{}{
|
||||
time.Now(), time.Now(), ctx.GetUserName(), utils.DefaultTimeValue,
|
||||
vendorID, vendorOrgCode,
|
||||
utils.DefaultTimeValue,
|
||||
storeID,
|
||||
}
|
||||
if _, err = dao.ExecuteSQL(db, sql2, sqlParams2); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
dao.Commit(db)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -665,3 +665,19 @@ func (c *SkuController) CopyVendorCategories() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 平台分类读取门店分类
|
||||
// @Description 平台分类读取门店分类
|
||||
// @Param token header string true "认证token"
|
||||
// @Param vendorOrgCode formData string true "账号ID"
|
||||
// @Param vendorID formData int true "平台ID"
|
||||
// @Param storeID formData int true "门店ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /LoadStoreVendorCategories [post]
|
||||
func (c *SkuController) LoadStoreVendorCategories() {
|
||||
c.callLoadStoreVendorCategories(func(params *tSkuLoadStoreVendorCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||||
err = cms.LoadStoreVendorCategories(params.Ctx, params.VendorOrgCode, params.VendorID, params.StoreID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1800,6 +1800,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "LoadStoreVendorCategories",
|
||||
Router: `/LoadStoreVendorCategories`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "RefreshJdDepot",
|
||||
|
||||
Reference in New Issue
Block a user