aa
This commit is contained in:
@@ -79,6 +79,13 @@ var (
|
||||
// return ebaiUploadRTFShopID
|
||||
// }
|
||||
|
||||
func GetVendorCategoriesWithMap(ctx *jxcontext.Context, vendorID int) (vendorCats []*dao.GetVendorCategoriesWithMapResult, err error) {
|
||||
if vendorID != model.VendorIDMTWM {
|
||||
return nil, fmt.Errorf("只支持美团!")
|
||||
}
|
||||
return dao.GetVendorCategoriesWithMap(dao.GetDB(), vendorID)
|
||||
}
|
||||
|
||||
// parentID 为-1表示所有
|
||||
func GetVendorCategories(ctx *jxcontext.Context, vendorID int, parentID string) (vendorCats []*model.SkuVendorCategory, err error) {
|
||||
cond := map[string]interface{}{
|
||||
|
||||
@@ -5734,3 +5734,29 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
|
||||
task.GetResult(0)
|
||||
return err
|
||||
}
|
||||
|
||||
func UpdateMtCatToJd(ctx *jxcontext.Context, mtCatID, jdCatID string) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
list, _ := dao.GetMtJdCategoryMap(db, mtCatID, jdCatID)
|
||||
if len(list) > 0 {
|
||||
return
|
||||
}
|
||||
list2, _ := dao.GetMtJdCategoryMap(db, mtCatID, "")
|
||||
if len(list2) > 0 {
|
||||
if list2[0].JdID == jdCatID {
|
||||
return
|
||||
} else {
|
||||
list2[0].JdID = jdCatID
|
||||
dao.UpdateEntity(db, list2[0], "JdID")
|
||||
}
|
||||
} else {
|
||||
catMap := &model.MtJdCategoryMap{
|
||||
MtID: mtCatID,
|
||||
JdID: jdCatID,
|
||||
}
|
||||
dao.CreateEntity(db, catMap)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -598,3 +598,21 @@ func GetMtJdCategoryMap(db *DaoDB, mtID, jdID string) (cats []*model.MtJdCategor
|
||||
}
|
||||
return cats, err
|
||||
}
|
||||
|
||||
type GetVendorCategoriesWithMapResult struct {
|
||||
model.SkuVendorCategory
|
||||
|
||||
CatMapID string `orm:"column(cat_map_id)" json:"catMapID"`
|
||||
}
|
||||
|
||||
func GetVendorCategoriesWithMap(db *DaoDB, vendorID int) (results []*GetVendorCategoriesWithMapResult, err error) {
|
||||
sql := `
|
||||
SELECT a.*, b.jd_id cat_map_id
|
||||
FROM sku_vendor_category a
|
||||
LEFT JOIN mt_jd_category_map b ON a.vendor_category_id = b.mt_id
|
||||
WHERE vendor_id = ?
|
||||
`
|
||||
sqlParams := []interface{}{vendorID}
|
||||
GetRows(db, &results, sql, sqlParams)
|
||||
return results, err
|
||||
}
|
||||
|
||||
@@ -30,6 +30,20 @@ func (c *SkuController) GetVendorCategories() {
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到厂商商品类别2
|
||||
// @Description 得到厂商商品类别2(区别于商家SKU类别)
|
||||
// @Param token header string true "认证token"
|
||||
// @Param vendorID query int true "厂商ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetVendorCategoriesWithMap [get]
|
||||
func (c *SkuController) GetVendorCategoriesWithMap() {
|
||||
c.callGetVendorCategoriesWithMap(func(params *tSkuGetVendorCategoriesWithMapParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.GetVendorCategoriesWithMap(params.Ctx, params.VendorID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到商品类别
|
||||
// @Description 得到商品类别(区别于厂商家SKU类别)
|
||||
// @Param token header string false "认证token"
|
||||
@@ -720,3 +734,18 @@ func (c *SkuController) GetSkuNamesNew() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 更新美团到京东分类映射
|
||||
// @Description 更新美团到京东分类映射
|
||||
// @Param token header string true "认证token"
|
||||
// @Param mtCatID formData string true "美团分类ID"
|
||||
// @Param jdCatID formData string true "京东分类ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateMtCatToJd [post]
|
||||
func (c *SkuController) UpdateMtCatToJd() {
|
||||
c.callUpdateMtCatToJd(func(params *tSkuUpdateMtCatToJdParams) (retVal interface{}, errCode string, err error) {
|
||||
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1719,6 +1719,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
web.ControllerComments{
|
||||
Method: "UpdateMtCatToJd",
|
||||
Router: `/UpdateMtCatToJd`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
web.ControllerComments{
|
||||
Method: "AddSku",
|
||||
@@ -1872,6 +1881,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
web.ControllerComments{
|
||||
Method: "GetVendorCategoriesWithMap",
|
||||
Router: `/GetVendorCategoriesWithMap`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
web.ControllerComments{
|
||||
Method: "GetVendorCategoryMap",
|
||||
|
||||
Reference in New Issue
Block a user