204 lines
10 KiB
Go
204 lines
10 KiB
Go
package controllers
|
||
|
||
import (
|
||
"git.rosy.net.cn/baseapi/utils"
|
||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||
"github.com/astaxie/beego"
|
||
)
|
||
|
||
type SyncController struct {
|
||
beego.Controller
|
||
}
|
||
|
||
// @Title 同步商家商品信息
|
||
// @Description 同步商家商品信息
|
||
// @Param token header string true "认证token"
|
||
// @Param storeIDs formData string true "门店ID列表"
|
||
// @Param vendorIDs formData string true "厂商ID列表"
|
||
// @Param skuIDs formData string false "SKU ID列表,缺省为全部"
|
||
// @Param isForce formData bool false "是否强制(设置修改标志)"
|
||
// @Param isAsync formData bool true "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /SyncStoresSkus [put]
|
||
func (c *SyncController) SyncStoresSkus() {
|
||
c.callSyncStoresSkus(func(params *tSyncSyncStoresSkusParams) (retVal interface{}, errCode string, err error) {
|
||
db := dao.GetDB()
|
||
var storeIDs, skuIDs, vendorIDs []int
|
||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||
return retVal, "", err
|
||
}
|
||
retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, skuIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 同步商家分类信息
|
||
// @Description 同步商家分类信息
|
||
// @Param token header string true "认证token"
|
||
// @Param storeIDs formData string true "门店ID列表"
|
||
// @Param vendorIDs formData string true "厂商ID列表"
|
||
// @Param isForce formData bool false "是否强制(设置修改标志)"
|
||
// @Param isAsync formData bool true "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /SyncStoresCategory [put]
|
||
func (c *SyncController) SyncStoresCategory() {
|
||
c.callSyncStoresCategory(func(params *tSyncSyncStoresCategoryParams) (retVal interface{}, errCode string, err error) {
|
||
db := dao.GetDB()
|
||
var storeIDs, vendorIDs []int
|
||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||
return retVal, "", err
|
||
}
|
||
retVal, err = cms.CurVendorSync.SyncStoresCategory(params.Ctx, db, vendorIDs, storeIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 全部刷新所有门店商家ID
|
||
// @Description 全部刷新所有门店商家ID
|
||
// @Param token header string true "认证token"
|
||
// @Param vendorIDs query string true "需要刷新的厂商ID列表"
|
||
// @Param isAsync query bool false "起始状态"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /RefreshAllStoresID [put]
|
||
func (c *SyncController) RefreshAllStoresID() {
|
||
c.callRefreshAllStoresID(func(params *tSyncRefreshAllStoresIDParams) (retVal interface{}, errCode string, err error) {
|
||
var vendorIDs []int
|
||
if err = utils.UnmarshalUseNumber([]byte(params.VendorIDs), &vendorIDs); err != nil {
|
||
return retVal, "", err
|
||
}
|
||
retVal, err = cms.CurVendorSync.RefreshAllStoresID(params.Ctx, params.IsAsync, vendorIDs)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 重新刷新商家SKU ID
|
||
// @Description 重新刷新商家SKU ID,单门店厂商必须指定storeIDs
|
||
// @Param token header string true "认证token"
|
||
// @Param vendorIDs query string true "需要刷新的厂商ID列表"
|
||
// @Param storeIDs query string false "需要刷新的门店ID列表(对于单门店必须指定)"
|
||
// @Param isAsync query bool false "起始状态"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /RefreshAllSkusID [put]
|
||
func (c *SyncController) RefreshAllSkusID() {
|
||
// c.callRefreshAllSkusID(func(params *tSyncRefreshAllSkusIDParams) (retVal interface{}, errCode string, err error) {
|
||
// var vendorIDs, storeIDs []int
|
||
// if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||
// return retVal, "", err
|
||
// }
|
||
// retVal, err = cms.CurVendorSync.RefreshAllSkusID(params.Ctx, params.IsAsync, vendorIDs, storeIDs)
|
||
// return retVal, "", err
|
||
// })
|
||
}
|
||
|
||
// @Title 全新初始化商家商品信息
|
||
// @Description 全新初始化商家商品信息(!!!此操作会先清除平台上已有的商品及分类信息),此操作只适用于单门店模式平台
|
||
// @Param token header string true "认证token"
|
||
// @Param storeIDs formData string true "门店ID列表"
|
||
// @Param vendorIDs formData string true "厂商ID列表"
|
||
// @Param isAsync formData bool true "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /FullSyncStoresSkus [put]
|
||
func (c *SyncController) FullSyncStoresSkus() {
|
||
c.callFullSyncStoresSkus(func(params *tSyncFullSyncStoresSkusParams) (retVal interface{}, errCode string, err error) {
|
||
db := dao.GetDB()
|
||
var vendorIDs, storeIDs []int
|
||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||
return retVal, "", err
|
||
}
|
||
retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, true, nil, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 删除门店平台商品信息(包括分类)
|
||
// @Description 删除门店平台商品信息(包括分类)(!!!此操作会先清除平台上已有的商品及分类信息),此操作只适用于单门店模式平台
|
||
// @Param token header string true "认证token"
|
||
// @Param storeIDs query string true "门店ID列表"
|
||
// @Param vendorIDs query string true "厂商ID列表"
|
||
// @Param isAsync query bool true "是否异步操作"
|
||
// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /DeleteRemoteStoreSkus [delete]
|
||
func (c *SyncController) DeleteRemoteStoreSkus() {
|
||
c.callDeleteRemoteStoreSkus(func(params *tSyncDeleteRemoteStoreSkusParams) (retVal interface{}, errCode string, err error) {
|
||
db := dao.GetDB()
|
||
var vendorIDs, storeIDs []int
|
||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||
return retVal, "", err
|
||
}
|
||
retVal, err = cms.CurVendorSync.DeleteRemoteStoreSkus(params.Ctx, db, vendorIDs, storeIDs, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 同步SkuName(多门店平台)
|
||
// @Description 同步SkuName(多门店平台)
|
||
// @Param token header string true "认证token"
|
||
// @Param nameIDs formData string false "name ID列表"
|
||
// @Param isForce formData bool false "是否强制(设置修改标志)"
|
||
// @Param isAsync formData bool false "是否异步"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /SyncSkuNames [put]
|
||
func (c *SyncController) SyncSkuNames() {
|
||
c.callSyncSkuNames(func(params *tSyncSyncSkuNamesParams) (retVal interface{}, errCode string, err error) {
|
||
var nameIDs []int
|
||
if err = jxutils.Strings2Objs(params.NameIDs, &nameIDs); err == nil {
|
||
retVal, err = cms.CurVendorSync.SyncSkuNames(params.Ctx, nameIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 删除本地没有的平台门店商品信息
|
||
// @Description 删除本地没有的平台门店商品信息
|
||
// @Param token header string true "认证token"
|
||
// @Param storeIDs query string true "门店ID列表"
|
||
// @Param vendorIDs query string true "厂商ID列表"
|
||
// @Param isAsync query bool false "是否异步操作"
|
||
// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /PruneMissingStoreSkus [delete]
|
||
func (c *SyncController) PruneMissingStoreSkus() {
|
||
c.callPruneMissingStoreSkus(func(params *tSyncPruneMissingStoreSkusParams) (retVal interface{}, errCode string, err error) {
|
||
var storeIDs, vendorIDs []int
|
||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err == nil {
|
||
retVal, err = cms.CurVendorSync.PruneMissingStoreSkus(params.Ctx, vendorIDs, storeIDs, params.IsAsync, params.IsContinueWhenError)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 把京西有,平台无且没有待创建标记的商品加上待创建标记
|
||
// @Description 把京西有,平台无且没有待创建标记的商品加上待创建标记
|
||
// @Param token header string true "认证token"
|
||
// @Param storeIDs formData string false "门店ID列表"
|
||
// @Param vendorIDs formData string false "运营商ID列表(京东0 美团1 饿百3)"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /AddCreateFlagForJxStoreSku [post]
|
||
func (c *SyncController) AddCreateFlagForJxStoreSku() {
|
||
c.callAddCreateFlagForJxStoreSku(func(params *tSyncAddCreateFlagForJxStoreSkuParams) (retVal interface{}, errCode string, err error) {
|
||
var storeIDs, vendorIDs []int
|
||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err == nil {
|
||
retVal, err = cms.CurVendorSync.AddCreateFlagForJxStoreSku(params.Ctx, vendorIDs, storeIDs, params.IsAsync, params.IsContinueWhenError)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|