Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop
This commit is contained in:
@@ -98,6 +98,13 @@ func GetVendorCategories(ctx *jxcontext.Context, vendorID int, parentID string)
|
||||
return vendorCats, dao.GetEntitiesByKV(nil, &vendorCats, cond, false)
|
||||
}
|
||||
|
||||
// 获取正确分类根据分类名称
|
||||
func GetVendorCategoriesByName(vendorId int, name string) (vendorCats *model.SkuVendorCategory, err error) {
|
||||
sql := ` SELECT * FROM sku_vendor_category WHERE vendor_id = ? AND name LIKE ? `
|
||||
err = dao.GetRow(dao.GetDB(), &vendorCats, sql, []interface{}{vendorId, "%" + name + "%"}...)
|
||||
return vendorCats, err
|
||||
}
|
||||
|
||||
// parentID 为-1表示所有
|
||||
func GetCategories(ctx *jxcontext.Context, parentID int, isExd bool) (catList []*dao.SkuCategoryWithVendor, err error) {
|
||||
db := dao.GetDB()
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -433,3 +434,28 @@ func (p *PurchaseHandler) UpdateStoreSkusSpecTag(ctx *jxcontext.Context, vendorO
|
||||
//}
|
||||
return err
|
||||
}
|
||||
|
||||
func GetProductAuditList(vendorOrgCode string) map[string]string {
|
||||
var page int64 = 1
|
||||
var pageSize int64 = 100
|
||||
|
||||
updateCategory := make(map[string]string, 0) // 修改分类的Map
|
||||
for {
|
||||
data, err := getAPI(vendorOrgCode, 0, "").GetProductAuditList(page, pageSize, 2)
|
||||
if err != nil || len(data) == 0 {
|
||||
break
|
||||
}
|
||||
for _, v := range data {
|
||||
if _, ok := v.AuditReason["综合原因"]; ok {
|
||||
if strings.Contains(v.AuditReason["综合原因"][0], "该商品类目选择错误,推荐放置在") {
|
||||
list := strings.Split(v.AuditReason["综合原因"][0], `“`)
|
||||
categoryNameList := strings.Split(list[1], "/")
|
||||
updateCategory[utils.Int64ToStr(v.ProductId)] = categoryNameList[len(categoryNameList)]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break
|
||||
}
|
||||
return updateCategory
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"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/purchase/tiktok_store"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego/server/web"
|
||||
)
|
||||
|
||||
@@ -829,3 +830,26 @@ func (c *SkuController) BatchSetRestockingPrice() {
|
||||
return nil, "", nil
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 抖店商品类目修改
|
||||
// @Description 抖店商品类目修改
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateTiktokCategory [post]
|
||||
func (c *SkuController) UpdateTiktokCategory() {
|
||||
c.callUpdateCategory(func(params *tSkuUpdateCategoryParams) (interface{}, string, error) {
|
||||
data := tiktok_store.GetProductAuditList("57939570")
|
||||
globals.SugarLogger.Debugf("==========111 %s", utils.Format4Output(data, false))
|
||||
for k, v := range data {
|
||||
vendorCatgory, err := cms.GetVendorCategoriesByName(14, v)
|
||||
if err != nil || vendorCatgory == nil {
|
||||
data[k] = v
|
||||
globals.SugarLogger.Debugf("err := %s", err)
|
||||
continue
|
||||
}
|
||||
data[k] = vendorCatgory.VendorCategoryID
|
||||
}
|
||||
globals.SugarLogger.Debugf("==========222 %s", utils.Format4Output(data, false))
|
||||
return data, "", nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1881,6 +1881,16 @@ 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: "UpdateTiktokCategory",
|
||||
Router: `/UpdateTiktokCategory`,
|
||||
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",
|
||||
|
||||
Reference in New Issue
Block a user