diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index f51f7250a..e4c5030ed 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -2740,3 +2740,7 @@ func UpdateSkuExinfoMap(ctx *jxcontext.Context, nameIDs []int, imgWaterMark stri } return hint, err } + +func GetThingMap(ctx *jxcontext.Context, vendorOrgCode string) (getThingMapResult []*dao.GetThingMapCategoryResult, err error) { + return dao.GetThingMapCategory(dao.GetDB(), []int{model.VendorIDJD}, nil, []string{vendorOrgCode}) +} diff --git a/business/model/dao/thing_map.go b/business/model/dao/thing_map.go index 15f312ac4..a97a8287c 100644 --- a/business/model/dao/thing_map.go +++ b/business/model/dao/thing_map.go @@ -6,7 +6,7 @@ import ( "git.rosy.net.cn/jx-callback/globals" ) -func GetThingMapList(db *DaoDB, thingType int, vendorIDs, thingIDs []int) (cats []*model.ThingMap, err error) { +func GetThingMapList(db *DaoDB, thingType int, vendorIDs, thingIDs []int, vendorOrgCodes []string) (cats []*model.ThingMap, err error) { sql := ` SELECT t1.* FROM thing_map t1 @@ -19,13 +19,49 @@ func GetThingMapList(db *DaoDB, thingType int, vendorIDs, thingIDs []int) (cats if len(thingIDs) > 0 { // 必须要指定ID sql += " AND t1.thing_id IN (" + GenQuestionMarks(len(thingIDs)) + ")" sqlParams = append(sqlParams, thingIDs) - err = GetRows(db, &cats, sql, sqlParams...) } + if len(vendorOrgCodes) > 0 { + sql += " AND t1.vendor_org_code IN (" + GenQuestionMarks(len(vendorOrgCodes)) + ")" + sqlParams = append(sqlParams, vendorOrgCodes) + } + err = GetRows(db, &cats, sql, sqlParams...) + return cats, err +} + +type GetThingMapCategoryResult struct { + model.ThingMap + Name string `orm:"size(255)" json:"name"` + ParentID int `orm:"column(parent_id)" json:"parentID"` + Level int8 `json:"level"` + Seq int `json:"seq"` +} + +func GetThingMapCategory(db *DaoDB, vendorIDs, thingIDs []int, vendorOrgCodes []string) (cats []*GetThingMapCategoryResult, err error) { + sql := ` + SELECT t1.*, t2.name, t2.parent_id, t2.level, t2.seq + FROM thing_map t1 + JOIN sku_category t2 ON t2.id = t1.thing_id AND t2.deleted_at = ? + WHERE t1.deleted_at = ? AND t1.thing_type = ? + ` + sqlParams := []interface{}{ + utils.DefaultTimeValue, + utils.DefaultTimeValue, + model.ThingTypeCategory, + } + if len(thingIDs) > 0 { + sql += " AND t1.thing_id IN (" + GenQuestionMarks(len(thingIDs)) + ")" + sqlParams = append(sqlParams, thingIDs) + } + if len(vendorOrgCodes) > 0 { + sql += " AND t1.vendor_org_code IN (" + GenQuestionMarks(len(vendorOrgCodes)) + ")" + sqlParams = append(sqlParams, vendorOrgCodes) + } + err = GetRows(db, &cats, sql, sqlParams...) return cats, err } func GetThingMapMap(db *DaoDB, thingType int, vendorIDs, thingIDs []int) (thingMapMap map[int64][]*model.ThingMap, err error) { - thingMapList, err := GetThingMapList(db, thingType, vendorIDs, thingIDs) + thingMapList, err := GetThingMapList(db, thingType, vendorIDs, thingIDs, nil) if err == nil { thingMapMap = make(map[int64][]*model.ThingMap) for _, thingMap := range thingMapList { diff --git a/business/model/sync_map.go b/business/model/sync_map.go index 6fc3a7d09..518b2198f 100644 --- a/business/model/sync_map.go +++ b/business/model/sync_map.go @@ -21,6 +21,9 @@ type ThingMap struct { SyncStatus int8 `orm:"default(2)" json:"syncStatus"` Remark string `orm:"size(255)" json:"remark"` + + ThingName string `json:"thingName"` + ThingSeq int `json:"thingSeq"` } func (*ThingMap) TableUnique() [][]string { diff --git a/business/model/vendor_org_code.go b/business/model/vendor_org_code.go new file mode 100644 index 000000000..951e48014 --- /dev/null +++ b/business/model/vendor_org_code.go @@ -0,0 +1,12 @@ +package model + +type VendorOrgCode struct { + ModelIDCULD + + VendorID int `orm:"column(vendor_id)" json:"vendorID"` + VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空 + Comment string `json:"comment"` //备注 + //appkey,secret token等 + + IsJxCat int `json:"isJxCat"` //是否使用京西分类,0默认使用 +} diff --git a/controllers/cms_sku.go b/controllers/cms_sku.go index 79b183b6b..d93d23b7d 100644 --- a/controllers/cms_sku.go +++ b/controllers/cms_sku.go @@ -556,3 +556,84 @@ func (c *SkuController) UpdateSkuExinfoMap() { return retVal, "", err }) } + +// @Title 得到京东账号分类 +// @Description 得到京东账号分类 +// @Param token header string true "认证token" +// @Param vendorOrgCode query string true "账号ID" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetThingMap [get] +func (c *SkuController) GetThingMap() { + c.callGetThingMap(func(params *tSkuGetThingMapParams) (retVal interface{}, errCode string, err error) { + return retVal, "", err + }) +} + +// @Title 新增京东账号分类 +// @Description 新增京东账号分类 +// @Param token header string true "认证token" +// @Param vendorOrgCode formData string true "账号ID" +// @Param categroyID formData int false "京西分类id" +// @Param level formData int true "分类级别" +// @Param parentID formData int true "分类父ID" +// @Param vendorCategroyName formData string true "类别name" +// @Param vendorCategroySeq formData int true "类别序号" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /AddThingMap [post] +func (c *SkuController) AddThingMap() { + c.callAddThingMap(func(params *tSkuAddThingMapParams) (retVal interface{}, errCode string, err error) { + return retVal, "", err + }) +} + +// @Title 修改京东账号分类 +// @Description 修改京东账号分类 +// @Param token header string true "认证token" +// @Param ID formData int true "记录ID" +// @Param categoryID formData int false "京西分类id" +// @Param storeCategroyName 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 /UpdateThingMap [put] +func (c *SkuController) UpdateThingMap() { + c.callUpdateThingMap(func(params *tSkuUpdateThingMapParams) (retVal interface{}, errCode string, err error) { + return retVal, "", err + }) +} + +// @Title 京东账号分类重排序 +// @Description 京东账号分类重排序 +// @Param token header string true "认证token" +// @Param categoryID 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 /ReorderJdCategories [put] +func (c *SkuController) ReorderJdCategories() { + c.callReorderJdCategories(func(params *tSkuReorderJdCategoriesParams) (retVal interface{}, errCode string, err error) { + return retVal, "", err + }) +} + +// @Title 复制京东账号分类 +// @Description 复制京东账号分类 +// @Param token header string true "认证token" +// @Param fromVendorOrgCode formData string 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 /CopyJdStoreCategories [put] +func (c *SkuController) CopyJdStoreCategories() { + c.callCopyJdStoreCategories(func(params *tSkuCopyJdStoreCategoriesParams) (retVal interface{}, errCode string, err error) { + return retVal, "", err + }) +} diff --git a/controllers/sys.go b/controllers/sys.go index 089f2156f..5b5d80a50 100644 --- a/controllers/sys.go +++ b/controllers/sys.go @@ -124,3 +124,18 @@ func (c *SysController) GetEbaiRTFDetail() { w.WriteHeader(http.StatusOK) io.WriteString(w, html) } + +// @Title 得到平台账号信息 +// @Description 得到平台账号信息 +// @Param token header string true "token" +// @Param vendorID query int false "平台ID" +// @Param vendorOrgCode query string false "平台账号" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetVendorOrgCode [get] +func (c *SysController) GetVendorOrgCode() { + c.callGetVendorOrgCode(func(params *tSysGetVendorOrgCodeParams) (retVal interface{}, errCode string, err error) { + + return retVal, "", err + }) +}