1072 lines
48 KiB
Go
1072 lines
48 KiB
Go
package controllers
|
||
|
||
import (
|
||
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
||
"strings"
|
||
"time"
|
||
|
||
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||
|
||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||
"git.rosy.net.cn/baseapi/utils"
|
||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||
"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"
|
||
)
|
||
|
||
type SkuController struct {
|
||
web.Controller
|
||
}
|
||
|
||
// @Title 得到厂商商品类别
|
||
// @Description 得到厂商商品类别(区别于商家SKU类别)
|
||
// @Param token header string true "认证token"
|
||
// @Param vendorID query int true "厂商ID"
|
||
// @Param parentID query string false "父ID,-1表示所有,缺省为空"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetVendorCategories [get]
|
||
func (c *SkuController) GetVendorCategories() {
|
||
c.callGetVendorCategories(func(params *tSkuGetVendorCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.GetVendorCategories(params.Ctx, params.VendorID, params.ParentID)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @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"
|
||
// @Param parentID query int false "父ID,-1表示所有,缺省为-1"
|
||
// @Param isExd query bool false "是否要查饿鲜达分类"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetCategories [get]
|
||
func (c *SkuController) GetCategories() {
|
||
c.callGetCategories(func(params *tSkuGetCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||
if c.GetString("parentID") == "" {
|
||
params.ParentID = -1
|
||
}
|
||
retVal, err = cms.GetCategories(params.Ctx, params.ParentID, params.IsExd)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 新增商品类别
|
||
// @Description 新增商品类别(区别于厂商家SKU类别)
|
||
// @Param token header string true "认证token"
|
||
// @Param payload formData string true "json数据,skuCategory对象()"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /AddCategory [post]
|
||
func (c *SkuController) AddCategory() {
|
||
c.callAddCategory(func(params *tSkuAddCategoryParams) (retVal interface{}, errCode string, err error) {
|
||
cat := &model.SkuCategory{}
|
||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), cat); err == nil {
|
||
retVal, err = cms.AddCategory(params.Ctx, cat, params.Ctx.GetUserName())
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 修改商品类别
|
||
// @Description 修改商品类别(区别于厂商家SKU类别)
|
||
// @Param token header string true "认证token"
|
||
// @Param categoryID formData int true "类别ID,payload中的相应字段会被忽略"
|
||
// @Param payload formData string true "json数据,skuCategory对象()"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateCategory [put]
|
||
func (c *SkuController) UpdateCategory() {
|
||
c.callUpdateCategory(func(params *tSkuUpdateCategoryParams) (retVal interface{}, errCode string, err error) {
|
||
payload := make(map[string]interface{})
|
||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
|
||
retVal, err = cms.UpdateCategory(params.Ctx, params.CategoryID, payload, params.Ctx.GetUserName())
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 商品类别重排序
|
||
// @Description 商品类别重排序(区别于厂商家SKU类别)
|
||
// @Param token header string true "认证token"
|
||
// @Param categoryID formData int true "父ID"
|
||
// @Param categoryIDs formData string true "同一父类别下的所有子类别ID列表([1,2,3,4])"
|
||
// @Param isExd query bool false "是否要查饿鲜达分类"
|
||
// @Param onlySort query int false "1-仅仅排序/其他就是排序加同步分类"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /ReorderCategories [put]
|
||
func (c *SkuController) ReorderCategories() {
|
||
c.callReorderCategories(func(params *tSkuReorderCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||
var idList []int
|
||
if err = utils.UnmarshalUseNumber([]byte(params.CategoryIDs), &idList); err == nil {
|
||
err = cms.ReorderCategories(params.Ctx, params.CategoryID, idList, params.Ctx.GetUserName(), params.IsExd, params.OnlySort)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 删除商品类别
|
||
// @Description 删除商品类别,只有无商品且无子类别的才能删除
|
||
// @Param token header string true "认证token"
|
||
// @Param categoryID query int true "商品类别ID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /DeleteCategory [delete]
|
||
func (c *SkuController) DeleteCategory() {
|
||
c.callDeleteCategory(func(params *tSkuDeleteCategoryParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.DeleteCategory(params.Ctx, params.CategoryID, params.Ctx.GetUserName())
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 同步商家SKU类别
|
||
// @Description 同步商家SKU类别
|
||
// @Param token header string true "认证token"
|
||
// @Param categoryID query int true "SKU类别ID, -1表示所有"
|
||
// @Param isAsync query bool false "是否异步"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /SyncCategory [put]
|
||
func (c *SkuController) SyncCategory() {
|
||
c.callSyncCategory(func(params *tSkuSyncCategoryParams) (retVal interface{}, errCode string, err error) {
|
||
db := dao.GetDB()
|
||
retVal, err = cms.CurVendorSync.SyncCategory(params.Ctx, db, params.CategoryID, params.IsAsync, params.Ctx.GetUserName())
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 得到商品信息
|
||
// @Description 得到商品信息,如下条件之间是与的关系
|
||
// @Param token header string true "认证token"
|
||
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
||
// @Param nameIDs query string false "SkuName IDs列表"
|
||
// @Param skuIDs query string false "Sku ID列表"
|
||
// @Param vendorSkuIDs query string false "厂商SKU ID列表"
|
||
// @Param name query string false "商品名称(不要求完全一致)"
|
||
// @Param prefix query string false "商品前缀(不要求完全一致)"
|
||
// @Param placeCond query string false "查询地点的条件(如果此字段没有设置,placeCode与isGlobal无效),and:与,or:或,指的是placeCode,isGlobal这两个条件间的关系,这组条件与其它条件都是与的关系"
|
||
// @Param placeCode query int false "可售地点Code"
|
||
// @Param isGlobal query bool false "是否全球可售"
|
||
// @Param categoryID query int false "商品名所属类别ID"
|
||
// @Param skuCategoryID query int false "商品所属类别ID"
|
||
// @Param unit query string false "商品单位"
|
||
// @Param isSpu query bool false "是否是SPU"
|
||
// @Param isExd query bool false "是否是饿鲜达商品"
|
||
// @Param fromStatus query int false "查询起始状态(0:下架,1:正常)"
|
||
// @Param toStatus query int false "查询起始状态(0:下架,1:正常)"
|
||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
||
// @Param isBySku query bool false "是否将sku拆开,缺省为false"
|
||
// @Param isQueryMidPrice query bool false "是否查询中位价缺省为false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetSkuNames [get,post]
|
||
func (c *SkuController) GetSkuNames() {
|
||
c.callGetSkuNames(func(params *tSkuGetSkuNamesParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.GetSkuNames(params.Ctx, params.Keyword, params.IsBySku, params.IsQueryMidPrice, params.MapData, params.Offset, params.PageSize)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 新增商品名(及商品)信息
|
||
// @Description 新增商品名(及商品)信息
|
||
// @Param token header string true "认证token"
|
||
// @Param payload formData string true "json数据,SkuNameExt对象(),可传Skus及Places"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /AddSkuName [post]
|
||
func (c *SkuController) AddSkuName() {
|
||
c.callAddSkuName(func(params *tSkuAddSkuNameParams) (retVal interface{}, errCode string, err error) {
|
||
skuName := &model.SkuNameExt{}
|
||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), skuName); err == nil {
|
||
retVal, err = cms.AddSkuName(params.Ctx, skuName, params.Ctx.GetUserName())
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 获取美团商品信息添加到本地
|
||
// @Description 获取美团商品信息添加到本地
|
||
// @Param token header string true "认证token"
|
||
// @Param vendorSkuName formData string true "平台商品名称"
|
||
// @Param vendorOrderID formData string true "订单id"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /MTSku2Local [post]
|
||
func (c *SkuController) MTSku2Local() {
|
||
c.callMTSku2Local(func(params *tSkuMTSku2LocalParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.GetMtSkuDetailInfo(params.Ctx, params.VendorOrderID, params.VendorSkuName)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 修改商品名信息
|
||
// @Description 修改商品名信息,注意:如果Places没有变动,不要传此字段,否则会导致不必要的删除与新增
|
||
// @Param token header string true "认证token"
|
||
// @Param nameID formData int true "需要修改的商品名ID,payload中的相应数据会被忽略"
|
||
// @Param payload formData string true "json数据,SkuNameExt对象(),Skus无效, Places有效"
|
||
// @Param isExd formData bool fasle "是否要修改饿鲜达商品"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateSkuName [put]
|
||
func (c *SkuController) UpdateSkuName() {
|
||
c.callUpdateSkuName(func(params *tSkuUpdateSkuNameParams) (retVal interface{}, errCode string, err error) {
|
||
// var payload map[string]interface{}
|
||
// dummySkuName := &model.SkuName{}
|
||
payload := make(map[string]interface{})
|
||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
|
||
delete(payload, "exPrefix")
|
||
delete(payload, "exPrefixBegin")
|
||
delete(payload, "exPrefixEnd")
|
||
delete(payload, "imgWaterMark")
|
||
delete(payload, "exVendorID")
|
||
retVal, err = cms.UpdateSkuName(params.Ctx, params.NameID, payload, params.IsExd)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 仅修改商品图片
|
||
// @Description 仅在本地数据库修改商品图片
|
||
// @Param token header string true "认证token"`
|
||
// @Param skuID formData int true "商品名ID"
|
||
// @Param payload formData string true "商品图片"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateSkuImg [put]
|
||
func (c *SkuController) UpdateSkuImg() {
|
||
c.callUpdateSkuImg(func(params *tSkuUpdateSkuImgParams) (retVal interface{}, errCode string, err error) {
|
||
payload := make(map[string]interface{})
|
||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
|
||
retVal, err = cms.UpdateSkuImg(params.Ctx, params.SkuID, payload)
|
||
}
|
||
return retVal, "", nil
|
||
})
|
||
}
|
||
|
||
// @Title 删除商品名
|
||
// @Description 此前商品名下的所有商品也会被级连删除
|
||
// @Param token header string true "认证token"
|
||
// @Param nameID query int true "商品名ID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /DeleteSkuName [delete]
|
||
func (c *SkuController) DeleteSkuName() {
|
||
c.callDeleteSkuName(func(params *tSkuDeleteSkuNameParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.DeleteSkuName(params.Ctx, params.NameID, params.Ctx.GetUserName())
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 新增商品
|
||
// @Description 新增商品
|
||
// @Param token header string true "认证token"
|
||
// @Param nameID formData int true "商品名ID, playload中的相应字段会被忽略"
|
||
// @Param payload formData string true "json数据,Sku对象()"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /AddSku [post]
|
||
func (c *SkuController) AddSku() {
|
||
c.callAddSku(func(params *tSkuAddSkuParams) (retVal interface{}, errCode string, err error) {
|
||
sku := &model.Sku{}
|
||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), sku); err == nil {
|
||
retVal, err = cms.AddSku(params.Ctx, params.NameID, sku, params.Ctx.GetUserName())
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 修改商品信息
|
||
// @Description 修改商品信息
|
||
// @Param token header string true "认证token"
|
||
// @Param skuID formData int true "需要修改的商品名ID,payload中的相应数据会被忽略"
|
||
// @Param payload formData string true "json数据,Sku对象"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateSku [put]
|
||
func (c *SkuController) UpdateSku() {
|
||
c.callUpdateSku(func(params *tSkuUpdateSkuParams) (retVal interface{}, errCode string, err error) {
|
||
payload := make(map[string]interface{})
|
||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
|
||
retVal, err = cms.UpdateSku(params.Ctx, params.SkuID, payload)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 删除商品
|
||
// @Description 删除商品
|
||
// @Param token header string true "认证token"
|
||
// @Param skuID query int true "商品ID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /DeleteSku [delete]
|
||
func (c *SkuController) DeleteSku() {
|
||
c.callDeleteSku(func(params *tSkuDeleteSkuParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.DeleteSku(params.Ctx, params.SkuID, params.Ctx.GetUserName())
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 新增商品名可售地点绑定(不推荐使用)
|
||
// @Description 新增商品名可售地点绑定(不推荐使用)
|
||
// @Param token header string true "认证token"
|
||
// @Param nameID formData int true "商品名ID"
|
||
// @Param placeCode formData int true "地点代码"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /AddSkuNamePlace [post]
|
||
func (c *SkuController) AddSkuNamePlace() {
|
||
c.callAddSkuNamePlace(func(params *tSkuAddSkuNamePlaceParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.AddSkuNamePlace(params.Ctx, params.NameID, params.PlaceCode, params.Ctx.GetUserName())
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 删除商品名可售地点绑定(不推荐使用)
|
||
// @Description 删除商品名可售地点绑定(不推荐使用)
|
||
// @Param token header string true "认证token"
|
||
// @Param nameID query int true "商品名ID"
|
||
// @Param placeCode query int true "地点代码"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /DeleteSkuNamePlace [delete]
|
||
func (c *SkuController) DeleteSkuNamePlace() {
|
||
c.callDeleteSkuNamePlace(func(params *tSkuDeleteSkuNamePlaceParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.DeleteSkuNamePlace(params.Ctx, params.NameID, params.PlaceCode, params.Ctx.GetUserName())
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// // @Title 远程查询厂商SKU信息
|
||
// // @Description 远程查询厂商SKU信息,这个是实时调用API远程查询(不推荐使用)
|
||
// // @Param token header string true "认证token"
|
||
// // @Param vendorSkuID query string true "sku ID"
|
||
// // @Param vendorID query int true "门店所属的厂商ID"
|
||
// // @Param vendorOrgCode query string false "厂商内组织代码"
|
||
// // @Success 200 {object} controllers.CallResult
|
||
// // @Failure 200 {object} controllers.CallResult
|
||
// // @router /GetVendorSku [get]
|
||
// func (c *SkuController) GetVendorSku() {
|
||
// c.callGetVendorSku(func(params *tSkuGetVendorSkuParams) (retVal interface{}, errCode string, err error) {
|
||
// retVal, err = cms.GetVendorSku(params.Ctx, params.VendorID, params.VendorOrgCode, params.VendorSkuID)
|
||
// return retVal, "", err
|
||
// })
|
||
// }
|
||
|
||
// @Title 同步商家SKU
|
||
// @Description 同步商家SKU
|
||
// @Param token header string true "认证token"
|
||
// @Param nameID formData int true "name ID, -1表示所有"
|
||
// @Param skuID formData int true "sku ID, -1表示所有"
|
||
// @Param isAsync formData bool false "是否异步"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /SyncSku [put]
|
||
func (c *SkuController) SyncSku() {
|
||
c.callSyncSku(func(params *tSkuSyncSkuParams) (retVal interface{}, errCode string, err error) {
|
||
db := dao.GetDB()
|
||
retVal, err = cms.CurVendorSync.SyncSku(params.Ctx, db, params.NameID, params.SkuID, params.IsAsync, params.IsContinueWhenError, params.Ctx.GetUserName())
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 获取敏感词列表
|
||
// @Description 获取敏感词列表
|
||
// @Param token header string true "认证token"
|
||
// @Param vendorID query int false "VendorID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetSensitiveWordList [get]
|
||
func (c *SkuController) GetSensitiveWordList() {
|
||
c.callGetSensitiveWordList(func(params *tSkuGetSensitiveWordListParams) (retVal interface{}, errCode string, err error) {
|
||
sensitiveWordList, err := dao.GetSensitiveWordList(params.VendorID)
|
||
var wordList []string
|
||
for _, value := range sensitiveWordList {
|
||
wordList = append(wordList, value.Word)
|
||
}
|
||
retVal = wordList
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 插入敏感词列表
|
||
// @Description 插入敏感词列表
|
||
// @Param token header string true "认证token"
|
||
// @Param word formData string true "关键词名字"
|
||
// @Param vendorID formData int false "VendorID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /InsertSensitiveWord [post]
|
||
func (c *SkuController) InsertSensitiveWord() {
|
||
c.callInsertSensitiveWord(func(params *tSkuInsertSensitiveWordParams) (retVal interface{}, errCode string, err error) {
|
||
err = dao.InsertSensitiveWord(params.Word, params.VendorID, params.Ctx.GetUserName())
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 修改敏感词列表
|
||
// @Description 修改敏感词列表
|
||
// @Param token header string true "认证token"
|
||
// @Param word formData string true "关键词名字"
|
||
// @Param vendorID formData int false "VendorID"
|
||
// @Param ID formData int false "关键词ID"
|
||
// @Param Status formData int false "状态,0为修改默认,1为删除"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateSensitiveWord [put]
|
||
func (c *SkuController) UpdateSensitiveWord() {
|
||
c.callUpdateSensitiveWord(func(params *tSkuUpdateSensitiveWordParams) (retVal interface{}, errCode string, err error) {
|
||
//word := &model.SensitiveWord{
|
||
// VendorID: params.VendorID,
|
||
// Word: params.Word,
|
||
//}
|
||
words, err := dao.GetSensitiveWordList(params.VendorID)
|
||
word := words[0]
|
||
word.Word = params.Word
|
||
if params.ID != 0 {
|
||
word.ModelIDCULD.ID = params.ID
|
||
}
|
||
if params.Status == 1 {
|
||
retVal, err = dao.DeleteSensitiveWord(word, params.ID, params.Ctx.GetUserName(), params.VendorID)
|
||
} else {
|
||
retVal, err = dao.UpdateSensitiveWord(word, params.VendorID, params.ID, params.Ctx.GetUserName())
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 子分类下商品的重排序
|
||
// @Description 子分类下商品的重排序
|
||
// @Param token header string true "认证token"
|
||
// @Param catID formData int true "商品子分类"
|
||
// @Param skuIDs formData string true "商品子分类下商品列表"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /SortCategorySkus [post]
|
||
func (c *SkuController) SortCategorySkus() {
|
||
c.callSortCategorySkus(func(params *tSkuSortCategorySkusParams) (retVal interface{}, errCode string, err error) {
|
||
var skuIDList []int
|
||
if err = jxutils.Strings2Objs(params.SkuIDs, &skuIDList); err == nil {
|
||
err = cms.SortCategorySkus(params.Ctx, params.CatID, skuIDList)
|
||
}
|
||
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 按照当前城市近30天销量排序,显示本店价格,附近5公里平均价格,差评数量,本店销量情况,本市总销量,
|
||
// @Description 按照当前城市近30天销量排序,显示本店价格,附近5公里平均价格,差评数量,本店销量情况,本市总销量,
|
||
// @Param token header string true "认证token"
|
||
// @Param storeID query int true "京西门店ID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetStoreSkuSalesInfo [get]
|
||
func (c *SkuController) GetStoreSkuSalesInfo() {
|
||
c.callGetStoreSkuSalesInfo(func(params *tSkuGetStoreSkuSalesInfoParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = misc.GetStoreSkuSalesInfo(params.Ctx, params.StoreID)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 根据名字查询京东商品UPC信息
|
||
// @Description 根据名字查询京东商品UPC信息
|
||
// @Param token header string true "认证token"
|
||
// @Param name query string false "商品名"
|
||
// @Param upcCode query string false "upcCode,不支持模糊"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetJdUpcCodeByName [get]
|
||
func (c *SkuController) GetJdUpcCodeByName() {
|
||
c.callGetJdUpcCodeByName(func(params *tSkuGetJdUpcCodeByNameParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.GetJdUpcCodeByName(params.Ctx, params.Name, params.UpcCode)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 批量设置商品额外前缀
|
||
// @Description 批量设置商品额外前缀
|
||
// @Param token header string true "认证token"
|
||
// @Param nameIDs formData string true "商品nameIDs"
|
||
// @Param exPrefix formData string false "商品额外前缀"
|
||
// @Param fromDate formData string true "生效开始时间,格式 2006-01-01 "
|
||
// @Param toDate formData string true "生效结束时间,格式 2006-01-01 "
|
||
// @Param imgWaterMark formData string false "商品水印图"
|
||
// @Param vendorID formData int true "平台ID"
|
||
// @Param isAsync formData bool false "是否异步"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateSkuNamesExPrefix [put]
|
||
func (c *SkuController) UpdateSkuNamesExPrefix() {
|
||
c.callUpdateSkuNamesExPrefix(func(params *tSkuUpdateSkuNamesExPrefixParams) (retVal interface{}, errCode string, err error) {
|
||
var skuIDList []int
|
||
if err = jxutils.Strings2Objs(params.NameIDs, &skuIDList); err == nil {
|
||
retVal, err = cms.UpdateSkuNamesExPrefix(params.Ctx, skuIDList, params.ImgWaterMark, params.VendorID, params.ExPrefix, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 合并饿鲜达商品库(必须要在饿鲜达系统中先导入商品)
|
||
// @Description 合并饿鲜达商品库(必须要在饿鲜达系统中先导入商品)
|
||
// @Param token header string true "认证token"
|
||
// @Param isAsync formData bool false "是否异步"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /SumExianDaDepot [put]
|
||
func (c *SkuController) SumExianDaDepot() {
|
||
c.callSumExianDaDepot(func(params *tSkuSumExianDaDepotParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.SumExianDaDepot(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 根据饿百上已经分类的商品刷新京西库中饿鲜达商品分类
|
||
// @Description 根据饿百上已经分类的商品刷新京西库中饿鲜达商品分类
|
||
// @Param token header string true "认证token"
|
||
// @Param isAsync formData bool false "是否异步"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateExianDaSkuCategory [put]
|
||
func (c *SkuController) UpdateExianDaSkuCategory() {
|
||
c.callUpdateExianDaSkuCategory(func(params *tSkuUpdateExianDaSkuCategoryParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.UpdateExianDaSkuCategory(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 根据Excel创建标品
|
||
// @Description 根据Excel创建标品
|
||
// @Param token header string true "认证token"
|
||
// @Param categroyID formData int true "分类ID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /CreateUpcSkuByExcel [post]
|
||
func (c *SkuController) CreateUpcSkuByExcel() {
|
||
c.callCreateUpcSkuByExcel(func(params *tSkuCreateUpcSkuByExcelParams) (retVal interface{}, errCode string, err error) {
|
||
r := c.Ctx.Request
|
||
files := r.MultipartForm.File["userfiles"]
|
||
retVal, err = cms.CreateUpcSkuByExcel(params.Ctx, files, params.CategroyID)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 恢复被删除的京东商品库
|
||
// @Description
|
||
// @Param token header string true "认证token"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /RefreshJdDepot [post]
|
||
func (c *SkuController) RefreshJdDepot() {
|
||
c.callRefreshJdDepot(func(params *tSkuRefreshJdDepotParams) (retVal interface{}, errCode string, err error) {
|
||
err = cms.RefreshJdDepot(params.Ctx)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 批量设置商品额外信息
|
||
// @Description 批量设置商品额外信息
|
||
// @Param token header string true "认证token"
|
||
// @Param nameIDs formData string true "商品nameIDs"
|
||
// @Param exPrefix formData string false "商品额外前缀"
|
||
// @Param fromDate formData string true "生效开始时间,格式 2006-01-01 "
|
||
// @Param toDate formData string true "生效结束时间,格式 2006-01-01 "
|
||
// @Param imgWaterMark formData string false "商品水印图"
|
||
// @Param brandID formData int false "品牌ID"
|
||
// @Param vendorID formData int true "平台ID"
|
||
// @Param vendorOrgCode formData string true "平台账号"
|
||
// @Param isAsync formData bool false "是否异步"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateSkuExinfoMap [put]
|
||
func (c *SkuController) UpdateSkuExinfoMap() {
|
||
c.callUpdateSkuExinfoMap(func(params *tSkuUpdateSkuExinfoMapParams) (retVal interface{}, errCode string, err error) {
|
||
var skuIDList []int
|
||
if err = jxutils.Strings2Objs(params.NameIDs, &skuIDList); err == nil {
|
||
retVal, err = cms.UpdateSkuExinfoMap(params.Ctx, skuIDList, params.ImgWaterMark, params.BrandID, params.VendorID, params.VendorOrgCode, params.ExPrefix, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 批量设置商品额外信息
|
||
// @Description 批量设置商品额外信息
|
||
// @Param token header string true "认证token"
|
||
// @Param exPrefix formData string false "商品额外前缀"
|
||
// @Param fromDate formData string true "生效开始时间,格式 2006-01-01 "
|
||
// @Param toDate formData string true "生效结束时间,格式 2006-01-01 "
|
||
// @Param imgWaterMark formData string false "商品水印图"
|
||
// @Param vendorID formData int true "平台ID"
|
||
// @Param storeId formData int true "京西门店ID"
|
||
// @Param isAsync formData bool false "是否异步"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateVendorSkuImg [put]
|
||
func (c *SkuController) UpdateVendorSkuImg() {
|
||
c.callUpdateVendorSkuImg(func(params *tSkuUpdateVendorSkuImgParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.UpdateVendorImg(params.Ctx, params.StoreId, params.ImgWaterMark, params.VendorID, params.ExPrefix, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 删除已经存在文件
|
||
// @Description 删除已经存在文件
|
||
// @Param token header string true "认证token"
|
||
// @Param name formData string true "文件名称"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /DeleteVendorSkuImg [post]
|
||
func (c *SkuController) DeleteVendorSkuImg() {
|
||
c.callDeleteVendorSkuImg(func(params *tSkuDeleteVendorSkuImgParams) (retVal interface{}, errCode string, err error) {
|
||
err = jxutils.DeleteExportContent(params.Name)
|
||
return retVal, "", err
|
||
})
|
||
|
||
}
|
||
|
||
// @Title 得到平台类别
|
||
// @Description 得到平台类别
|
||
// @Param token header string true "认证token"
|
||
// @Param parentID query int false "父ID"
|
||
// @Param level query int false "分类等级"
|
||
// @Param vendorOrgCode query string true "账号ID"
|
||
// @Param vendorID query int true "平台ID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetVendorCategoryMap [get]
|
||
func (c *SkuController) GetVendorCategoryMap() {
|
||
c.callGetVendorCategoryMap(func(params *tSkuGetVendorCategoryMapParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.GetVendorCategoryMap(params.Ctx, params.ParentID, params.Level, params.VendorID, params.VendorOrgCode)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 新增平台类别
|
||
// @Description 新增平台类别
|
||
// @Param token header string true "认证token"
|
||
// @Param vendorID formData int true "平台ID"
|
||
// @Param vendorOrgCode formData string true "账号ID"
|
||
// @Param categroyID formData int false "京西分类id"
|
||
// @Param level formData int true "分类级别"
|
||
// @Param parentID formData int true "分类父ID"
|
||
// @Param vendorCategoryName formData string true "类别name"
|
||
// @Param vendorCategorySeq formData int true "类别序号"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /AddVendorCategoryMap [post]
|
||
func (c *SkuController) AddVendorCategoryMap() {
|
||
c.callAddVendorCategoryMap(func(params *tSkuAddVendorCategoryMapParams) (retVal interface{}, errCode string, err error) {
|
||
vendorCategoryMap := &model.VendorCategoryMap{
|
||
VendorID: params.VendorID,
|
||
VendorOrgCode: params.VendorOrgCode,
|
||
CategoryID: params.CategroyID,
|
||
VendorCategoryName: params.VendorCategoryName,
|
||
VendorCategorySeq: params.VendorCategorySeq,
|
||
Level: params.Level,
|
||
ParentID: params.ParentID,
|
||
}
|
||
retVal, err = cms.AddVendorCategoryMap(params.Ctx, vendorCategoryMap)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 修改平台类别
|
||
// @Description 修改平台类别
|
||
// @Param token header string true "认证token"
|
||
// @Param ID formData int true "记录ID"
|
||
// @Param categoryID formData int false "京西分类id"
|
||
// @Param vendorCategoryName formData string false "类别name"
|
||
// @Param level formData int true "分类级别"
|
||
// @Param parentID formData int true "分类父ID"
|
||
// @Param isDelete formData bool false "是否是删除操作,默认false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateVendorCategoryMap [put]
|
||
func (c *SkuController) UpdateVendorCategoryMap() {
|
||
c.callUpdateVendorCategoryMap(func(params *tSkuUpdateVendorCategoryMapParams) (retVal interface{}, errCode string, err error) {
|
||
vendorCategoryMap := &model.VendorCategoryMap{
|
||
CategoryID: params.CategoryID,
|
||
VendorCategoryName: params.VendorCategoryName,
|
||
Level: params.Level,
|
||
ParentID: params.ParentID,
|
||
}
|
||
retVal, err = cms.UpdateVendorCategoryMap(params.Ctx, params.ID, vendorCategoryMap, params.IsDelete)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 平台类别重排序
|
||
// @Description 平台类别重排序
|
||
// @Param token header string true "认证token"
|
||
// @Param categoryID formData int true "父ID"
|
||
// @Param vendorID formData int true "平台ID"
|
||
// @Param vendorOrgCode formData string true "账号ID"
|
||
// @Param categoryIDs formData string true "同一父类别下的所有子类别ID列表([1,2,3,4])"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /ReorderVendorCategories [put]
|
||
func (c *SkuController) ReorderVendorCategories() {
|
||
c.callReorderVendorCategories(func(params *tSkuReorderVendorCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||
var idList []int
|
||
if err = utils.UnmarshalUseNumber([]byte(params.CategoryIDs), &idList); err == nil {
|
||
err = cms.ReorderVendorCategories(params.Ctx, params.CategoryID, params.VendorID, params.VendorOrgCode, idList)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 复制平台类别
|
||
// @Description 复制平台类别
|
||
// @Param token header string true "认证token"
|
||
// @Param fromVendorOrgCode formData int true "源平台ID"
|
||
// @Param vendorID formData int true "平台ID"
|
||
// @Param toVendorOrgCodes formData string true "目标平台的IDs"
|
||
// @Param categoryIDs formData string false "原平台的分类IDs,不传代表整个复制"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /CopyVendorCategories [put]
|
||
func (c *SkuController) CopyVendorCategories() {
|
||
c.callCopyVendorCategories(func(params *tSkuCopyVendorCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||
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
|
||
})
|
||
}
|
||
|
||
// @Title 刷新没图的商品
|
||
// @Description 刷新没图的商品
|
||
// @Param token header string true "认证token"
|
||
// @Param skuNameID formData int false "门店ID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /RefreshNoImgSku [post]
|
||
func (c *SkuController) RefreshNoImgSku() {
|
||
c.callRefreshNoImgSku(func(params *tSkuRefreshNoImgSkuParams) (retVal interface{}, errCode string, err error) {
|
||
err = cms.RefreshNoImgSku(params.Ctx, params.SkuNameID)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 得到商品信息2
|
||
// @Description 得到商品信息2
|
||
// @Param token header string true "认证token"
|
||
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
||
// @Param nameIDs query string false "SkuName IDs列表"
|
||
// @Param skuIDs query string false "Sku ID列表"
|
||
// @Param categoryID query int false "商品名所属类别ID"
|
||
// @Param status query int false "查询起始状态(0:下架,1:正常, -1全部)"
|
||
// @Param isBySku query bool false "是否将sku拆开,缺省为false"
|
||
// @Param bestSeller query int false "是否为畅销品[0-不是/1-是]"
|
||
// @Param minPrice query int false "最低价"
|
||
// @Param maxPrice query int false "最高价"
|
||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetSkuNamesNew [get]
|
||
func (c *SkuController) GetSkuNamesNew() {
|
||
c.callGetSkuNamesNew(func(params *tSkuGetSkuNamesNewParams) (retVal interface{}, errCode string, err error) {
|
||
var skuIDs, skuNameIDs []int
|
||
if err = jxutils.Strings2Objs(params.SkuIDs, &skuIDs, params.NameIDs, &skuNameIDs); err == nil {
|
||
retVal, err = cms.GetSkuNamesNew(params.Ctx, params.Keyword, skuIDs, skuNameIDs, params.CategoryID, params.Status, params.IsBySku, params.Offset, params.PageSize, params.BestSeller, params.MaxPrice, params.MinPrice)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 设置商品为热销/取消热销商品
|
||
// @Description 设置商品为热销/取消热销商品
|
||
// @Param token header string true "认证token"
|
||
// @Param skuNameId query string true "商品nameId,多个用逗号分割"
|
||
// @Param bestSeller query int true "是否为热销[0不是/1是]"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /SetSkuBestSeller [post]
|
||
func (c *SkuController) SetSkuBestSeller() {
|
||
c.callSetSkuBestSeller(func(params *tSkuSetSkuBestSellerParams) (retVal interface{}, errCode string, err error) {
|
||
nameIds := strings.Split(params.SkuNameId, ",")
|
||
err = cms.SetSkuNameSeller(utils.StringSlice2Int64(nameIds), params.BestSeller)
|
||
return nil, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 根据分类id获取平台属性值
|
||
// @Description 根据分类id获取平台属性值
|
||
// @Param token header string true "认证token"
|
||
// @Param categoryId query int64 false "抖音分类id"
|
||
// @Param vendorOrgCode query string false "默认的平台id(现在是测试门店id/后面改成京西的id)"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetTiktokCategoryValue [get]
|
||
func (c *SkuController) GetTiktokCategoryValue() {
|
||
c.callGetTiktokCategoryValue(func(params *tSkuGetTiktokCategoryValueParams) (interface{}, string, error) {
|
||
data, err := tiktok_store.GetProductFormatNew(int64(params.CategoryId), params.VendorOrgCode)
|
||
return data, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 更新最新的分类树
|
||
// @Description 更新最新的分类树
|
||
// @Param token header string true "认证token"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /BatchGetChannelCategoryMapping [get]
|
||
func (c *SkuController) BatchGetChannelCategoryMapping() {
|
||
c.callGetTiktokCategoryValue(func(params *tSkuGetTiktokCategoryValueParams) (interface{}, string, error) {
|
||
err := tiktok_store.BatchGetChannelCategoryMapping()
|
||
return nil, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 根据美团分类id获取平台扩展规则
|
||
// @Description 根据美团分类id获取平台扩展规则
|
||
// @Param token header string true "认证token"
|
||
// @Param categoryId query int64 true "类目id"
|
||
// @Param vendorId query int64 true "平台分类ID"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetMTProductRule [get]
|
||
func (c *SkuController) GetMTProductRule() {
|
||
c.callGetMTProductRule(func(params *tSkuGetMTProductRuleParams) (retVal interface{}, errCode string, err error) {
|
||
switch params.VendorId {
|
||
case model.VendorIDMTWM:
|
||
retVal, err = mtwm.GetMTProductRule(params.CategoryId)
|
||
case model.VendorIDEBAI:
|
||
retVal, err = ebai.GetCategoryAttrValueList(int64(params.CategoryId))
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
|
||
}
|
||
|
||
// @Title 根据美团分类id获取平台属性值
|
||
// @Description 根据美团分类id获取平台属性值
|
||
// @Param token header string true "认证token"
|
||
// @Param appOrgCode query string true "美团app"
|
||
// @Param categoryId query int64 true "美团类目id"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetMTCategoryAttrList [get]
|
||
func (c *SkuController) GetMTCategoryAttrList() {
|
||
c.callGetMTCategoryAttrList(func(params *tSkuGetMTCategoryAttrListParams) (interface{}, string, error) {
|
||
data, err := mtwm.GetCategoryAttrList(params.AppOrgCode, params.CategoryId)
|
||
return data, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 根据美团属性id 查询特殊属性(品牌、产地)
|
||
// @Description 根据美团属性id 查询特殊属性(品牌、产地)
|
||
// @Param token header string true "认证token"
|
||
// @Param appOrgCode query string true "平台code"
|
||
// @Param attrId query int64 true "属性id"
|
||
// @Param keyword query string true "属性值的关键词"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetMTCategoryAttrValueList [get]
|
||
func (c *SkuController) GetMTCategoryAttrValueList() {
|
||
c.callGetMTCategoryAttrValueList(func(params *tSkuGetMTCategoryAttrValueListParams) (retVal interface{}, code string, err error) {
|
||
retVal, err = mtwm.GetCategoryAttrValueList(params.AppOrgCode, params.Keyword, params.AttrId)
|
||
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) {
|
||
err = cms.UpdateMtCatToJd(params.Ctx, params.MtCatID, params.JdCatID)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// SyncTiktokMainSkuToLocalSku 同步抖店商品主商品id和本地商品id映射关系
|
||
// @Title 同步抖店商品主商品id和本地商品id映射关系
|
||
// @Description 同步抖店商品主商品id和本地商品id映射关系
|
||
// @Param token header string true "认证token"
|
||
// @Param startTime query int64 true "同步商品开始时间戳"
|
||
// @Param endTime query int64 true "同步商品结束时间戳"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /SyncTiktokMainSkuToLocalSku [post]
|
||
func (c *SkuController) SyncTiktokMainSkuToLocalSku() {
|
||
c.callSyncTiktokMainSkuToLocalSku(func(params *tSkuSyncTiktokMainSkuToLocalSkuParams) (interface{}, string, error) {
|
||
var checkStatus = []int64{2, 3, 7}
|
||
var errs = make([]error, 0)
|
||
for _, v := range checkStatus {
|
||
err := cms.SyncTiktokMainIdToLocal(params.Ctx, &tiktok_store.MainSku{
|
||
AppOrgCode: "",
|
||
CheckStatus: v,
|
||
StartTime: int64(params.StartTime),
|
||
EndTime: int64(params.EndTime),
|
||
Page: 0,
|
||
PageSize: 0,
|
||
})
|
||
errs = append(errs, err)
|
||
}
|
||
|
||
return errs, "", errs[0]
|
||
})
|
||
}
|
||
|
||
// @Title 批量设置美团商品进货价
|
||
// @Description 批量设置美团商品进货价
|
||
// @Param token header string true "认证token"
|
||
// @Param payload formData string true "json数据,SpuData对象()"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /BatchSetRestockingPrice [post]
|
||
func (c *SkuController) BatchSetRestockingPrice() {
|
||
c.callBatchSetRestockingPrice(func(params *tSkuBatchSetRestockingPriceParams) (interface{}, string, error) {
|
||
payload := make(map[string][]mtwmapi.SpuData)
|
||
if err := utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
|
||
err = cms.BatchSetRestockingPrice(params.Ctx, payload)
|
||
}
|
||
return nil, "", nil
|
||
})
|
||
}
|
||
|
||
// @Title 批量设置美团商品打包费为零
|
||
// @Description 批量设置美团商品打包费为零
|
||
// @Param storeIDs query string false "门店ID列表"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /BatchSetBoxPrice [post]
|
||
func (c *SkuController) BatchSetBoxPrice() {
|
||
c.callBatchSetBoxPrice(func(params *tSkuBatchSetBoxPriceParams) (retVal interface{}, errCode string, err error) {
|
||
var storeIDs []int
|
||
err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs)
|
||
|
||
err = cms.BatchSetMTBoxPrice(params.Ctx, storeIDs)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
type CategoryList struct {
|
||
DdId string `json:"dd_id"`
|
||
Id int `json:"id"`
|
||
NameId int `json:"name_id"`
|
||
StoreId int `json:"store_id"`
|
||
}
|
||
|
||
// @Title 抖店商品类目修改
|
||
// @Description 抖店商品类目修改
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateTiktokCategory [post]
|
||
func (c *SkuController) UpdateTiktokCategory() {
|
||
c.callUpdateTiktokCategory(func(params *tSkuUpdateTiktokCategoryParams) (interface{}, string, error) {
|
||
var page int64 = 50
|
||
var pageSize int64 = 100
|
||
var count int64 = 0
|
||
for {
|
||
data1, total := tiktok_store.GetProductAuditList("57939570", page, pageSize)
|
||
ddIDList := make([]string, 0, 0)
|
||
skuList := make([]CategoryList, 0, 0)
|
||
data2 := make(map[string]string, 0)
|
||
db := dao.GetDB()
|
||
|
||
for k, v := range data1 {
|
||
vendorCatgory, _ := cms.GetVendorCategoriesByName(14, v)
|
||
if vendorCatgory == nil || vendorCatgory.VendorCategoryID == "" {
|
||
continue
|
||
}
|
||
ddIDList = append(ddIDList, k)
|
||
data2[k] = vendorCatgory.VendorCategoryID
|
||
}
|
||
|
||
sql := " SELECT b.dd_id,b.store_id,s.id,s.name_id FROM store_sku_bind b INNER JOIN sku s ON b.sku_id = s.id AND s.deleted_at = ? WHERE b.dd_id IN (" + dao.GenQuestionMarks(len(ddIDList)) + ") AND b.deleted_at = ?"
|
||
param := []interface{}{utils.DefaultTimeValue, ddIDList, utils.DefaultTimeValue}
|
||
if err := dao.GetRows(db, &skuList, sql, param...); err != nil {
|
||
return nil, "", err
|
||
}
|
||
for _, v := range skuList {
|
||
count++
|
||
item := &model.SkuVendorCategoryMap{
|
||
ModelIDCULD: model.ModelIDCULD{
|
||
CreatedAt: time.Now(),
|
||
UpdatedAt: time.Now(),
|
||
DeletedAt: utils.DefaultTimeValue,
|
||
LastOperator: "18981810340",
|
||
},
|
||
NameID: v.NameId,
|
||
VendorID: model.VendorIDDD,
|
||
}
|
||
|
||
item.VendorCategoryID = data2[v.DdId]
|
||
skuVendorCategoryMap := &model.SkuVendorCategoryMap{}
|
||
if err := dao.GetRow(db, skuVendorCategoryMap, `SELECT * FROM sku_vendor_category_map WHERE name_id = ? AND vendor_id = ? AND deleted_at = ?`, []interface{}{v.NameId, model.VendorIDDD, utils.DefaultTimeValue}); err != nil {
|
||
globals.SugarLogger.Errorf("get row err : %v", err)
|
||
}
|
||
if skuVendorCategoryMap != nil && skuVendorCategoryMap.ID > 0 {
|
||
if _, err := dao.UpdateEntity(db, skuVendorCategoryMap, "VendorCategoryID"); err != nil {
|
||
globals.SugarLogger.Errorf("update err : %v", err)
|
||
}
|
||
} else {
|
||
if err := dao.CreateEntity(db, item); err != nil {
|
||
globals.SugarLogger.Errorf("create err : %v", err)
|
||
}
|
||
}
|
||
go func() {
|
||
time.Sleep(500 * time.Millisecond)
|
||
hit, err := cms.CurVendorSync.SyncStoresSkus(params.Ctx, nil, 0, db, []int{14}, []int{v.StoreId}, []int{v.Id}, true, false, true)
|
||
globals.SugarLogger.Debugf("hit:%s err: %v", hit, err)
|
||
}()
|
||
}
|
||
if page*pageSize < total {
|
||
page++
|
||
} else {
|
||
break
|
||
}
|
||
}
|
||
return count, "", nil
|
||
})
|
||
}
|