package controllers

import (
	"errors"
	"git.rosy.net.cn/baseapi/platformapi/jdapi"
	"git.rosy.net.cn/jx-callback/business/auth2"
	"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"
	"git.rosy.net.cn/jx-callback/business/model/dao"
	"github.com/astaxie/beego/server/web"
)

type StoreSkuController struct {
	web.Controller
}

// @Title 得到商家商品信息
// @Description 得到商家商品信息，如下条件之间是与的关系。对于没有认领的商品，按城市限制。但对于已经认领的商品就不限制了，因为已经在平台上可售，可以操作（改价等等）
// @Param	token			header		string	true	"认证token"
// @Param	storeID			query		int		true	"门店ID"
// @Param	isFocus			query		bool	true	"是否已关注（认领）"
// @Param	keyword			query		string	false	"查询关键字（可以为空，为空表示不限制）"
// @Param	nameID			query		int		false	"SkuName ID"
// @Param	nameIDs			query		string	false	"SkuName ID列表对象"
// @Param	skuID			query		int		false	"Sku ID"
// @Param	skuIDs			query		string	false	"Sku ID列表对象"
// @Param	name			query		string	false	"商品名称（不要求完全一致）"
// @Param	prefix			query		string	false	"商品前缀（不要求完全一致）"
// @Param	categoryID		query		int		false	"商品所属类别ID"
// @Param	unit			query		string	false	"商品单位"
// @Param	fromStatus		query		int		false	"查询起始状态（0：不可售，1：可售）"
// @Param	toStatus		query		int		false	"查询结束状态（0：不可售，1：可售）"
// @Param	stFromTime		query		string	false	"统计SKU开始时间"
// @Param	stToTime		query		string	false	"统计SKU结束时间"
// @Param	stFromCount		query		int		false	"统计SKU，结果集起始数量（包括）"
// @Param	stToCount		query		int		false	"统计SKU，结果集结束数量（包括）"
// @Param	isGetOpRequest	query		bool	false	"是否返回相应的待审核变动请求，缺省为false不返回"
// @Param	offset			query		int		false	"门店列表起始序号（以0开始，缺省为0）"
// @Param	pageSize		query		int		false	"门店列表页大小（缺省为50，-1表示全部）"
// @Param	isBySku			query		bool	false	"是否按SKU分拆"
// @Param	isAct			query		bool	false	"是否活动商品（包括正常活动与补贴）"
// @Param	actVendorID		query		int		false	"要得到哪个平台的活动信息（缺省不限制，非零最小值）"
// @Param	jdSyncStatus	query		int		false	"京东同步标识"
// @Param	ebaiSyncStatus	query		int		false	"饿百同步标识"
// @Param	mtwmSyncStatus	query		int		false	"美团外卖同步标识"
// @Param	taoSyncStatus	query		int		false	"淘鲜达同步标识"
// @Param	lockTime		query		string	false	"价格锁定时间"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetStoreSkus [get]
func (c *StoreSkuController) GetStoreSkus() {
	c.callGetStoreSkus(func(params *tStoreSkuGetStoreSkusParams) (retVal interface{}, errCode string, err error) {
		var skuIDs []int
		if err = jxutils.Strings2Objs(params.SkuIDs, &skuIDs); err == nil {
			retVal, err = cms.GetStoreSkus(params.Ctx, params.StoreID, skuIDs, params.IsFocus, params.Keyword, params.IsBySku, params.IsAct, params.MapData, params.Offset, params.PageSize)
		}
		return retVal, "", err
	})
}

// @Title 得到商家商品信息
// @Description 得到商家商品信息，如下条件之间是与的关系。对于没有认领的商品，按城市限制。但对于已经认领的商品就不限制了，因为已经在平台上可售，可以操作（改价等等）
// @Param	token			header		string	false	"认证token"
// @Param	storeIDs		query		string	false	"门店ID"
// @Param	isFocus			query		bool	true	"是否已关注（认领）"
// @Param	keyword			query		string	false	"查询关键字（可以为空，为空表示不限制）"
// @Param	nameIDs			query		string	false	"SkuName ID列表对象"
// @Param	skuIDs			query		string	false	"Sku ID列表对象"
// @Param	upcs			query		string	false	"upc列表对象"
// @Param	name			query		string	false	"商品名称（不要求完全一致）"
// @Param	prefix			query		string	false	"商品前缀（不要求完全一致）"
// @Param	categoryID		query		int		false	"商品所属类别ID"
// @Param	unit			query		string	false	"商品单位"
// @Param	fromStatus		query		int		false	"查询起始状态（0：不可售，1：可售）"
// @Param	toStatus		query		int		false	"查询结束状态（0：不可售，1：可售）"
// @Param	stFromTime		query		string	false	"统计SKU开始时间"
// @Param	stToTime		query		string	false	"统计SKU结束时间"
// @Param	stFromCount		query		int		false	"统计SKU，结果集起始数量（包括）"
// @Param	stToCount		query		int		false	"统计SKU，结果集结束数量（包括）"
// @Param	isGetOpRequest	query		bool	false	"是否返回相应的待审核变动请求，缺省为false不返回"
// @Param	offset			query		int		false	"门店列表起始序号（以0开始，缺省为0）"
// @Param	pageSize		query		int		false	"门店列表页大小（缺省为50，-1表示全部）"
// @Param	isBySku			query		bool	false	"是否按SKU分拆"
// @Param	isAct			query		bool	false	"是否活动商品（包括正常活动与补贴）"
// @Param	actVendorID		query		int		false	"要得到哪个平台的活动信息（缺省不限制，非零最小值）"
// @Param	jdSyncStatus	query		int		false	"京东同步标识"
// @Param	ebaiSyncStatus	query		int		false	"饿百同步标识"
// @Param	mtwmSyncStatus	query		int		false	"美团外卖同步标识"
// @Param	taoSyncStatus	query		int		false	"陶先达同步标识"
// @Param	lockTime		query		string	false	"价格锁定时间"
// @Param	isHighPrice		query		bool	false	"是否查过高价格商品,0是忽略，1是高价，-1是低价"
// @Param	priceType		query		int		false	"是否查过高价格商品,0是忽略，1是高价，-1是低价"
// @Param   highestPrice    query       string  false   "查询最高价"
// @Param   minimumPrice    query		string  false 	"查询最低价"
// @Param   minStock	    query		int	  	false 	"最小库存"
// @Param   maxStock	    query		int 	false 	"最大库存"
// @Param   isLocationCode	query		bool 	false 	"是否有货架码"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetStoresSkus [get,post]
func (c *StoreSkuController) GetStoresSkus() {
	c.callGetStoresSkus(func(params *tStoreSkuGetStoresSkusParams) (retVal interface{}, errCode string, err error) {
		var storeIDs, skuIDs []int
		var upcs []string
		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs, params.Upcs, &upcs); err == nil {
			// 获取商品列表
			storeSku, err := cms.GetStoresSkus(params.Ctx, storeIDs, skuIDs, upcs, params.IsFocus, params.IsHighPrice, params.PriceType, params.Keyword, params.IsBySku, params.IsAct, params.MapData, params.Offset, params.PageSize)
			if err != nil {
				return nil, "", err
			}

			// 获取用户权限，如果是普通用户不展示b2b相关目录，如果是门店老板或者管理则展示全部
			userAuth, _ := auth2.GetTokenInfo(params.Token)

			var userType int8 = 0
			if userAuth != nil {
				user, total, err := dao.GetUsers(dao.GetDB(), 1, "", []string{userAuth.UserID}, nil, nil, 0, 1)
				if err != nil {
					return nil, "", err
				}
				if total != model.YES {
					return nil, "", errors.New("未注册用户")
				}
				userType = user[0].Type
				if user[0].Type != model.YES {
					return storeSku, "", nil
				}
			}

			// 判断门店是不是b2b门店，如果是，用户必须为系统管理员（门店老板和运营人员）
			store, err := dao.GetStoreList(dao.GetDB(), storeIDs, nil, nil, nil, nil, "")
			if err != nil {
				return nil, "", err
			}

			isMatterStore := false
			for _, v := range storeIDs {
				if v == model.MatterStoreID {
					isMatterStore = true
				}
			}

			result := &dao.StoreSkuNamesInfo{}
			result.TotalCount = 0
			for _, v := range store {
				for _, s := range storeSku.SkuNames {
					if v.ID == s.StoreID {
						if (v.BrandID == model.B2BNumberId || isMatterStore) && (userType == model.YES || userType == model.NO) { // 普通用户进入物料店和b2b店
							continue
						} else {
							result.TotalCount += len(s.Skus)
							result.SkuNames = append(result.SkuNames, s)
						}
					}
				}
			}

			return result, "", nil
		}
		return retVal, "", err
	})
}

// @Title 得到异常门店商品数量
// @Description 得到异常门店商品数量
// @Param	token			header		string	true	"认证token"
// @Param	storeID			query		int		true	"门店ID"
// @Param	syncStatus		query		int		true	"同步标志掩码"
// @Param	isBySku			query		bool	false	"是否按SKU分拆"
// @Param	fromStatus		query		int		false	"查询起始状态（0：不可售，1：可售）"
// @Param	toStatus		query		int		false	"查询结束状态（0：不可售，1：可售）"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetStoreAbnormalSkuCount [get]
func (c *StoreSkuController) GetStoreAbnormalSkuCount() {
	c.callGetStoreAbnormalSkuCount(func(params *tStoreSkuGetStoreAbnormalSkuCountParams) (retVal interface{}, errCode string, err error) {
		retVal, err = cms.GetStoreAbnormalSkuCount(params.Ctx, params.StoreID, params.SyncStatus, params.IsBySku, params.MapData)
		return retVal, "", err
	})
}

// @Title 得到门店商品全信息
// @Description 得到异常门店商品数量
// @Param	token			header		string	true	"认证token"
// @Param	storeID			query		int		true	"门店ID"
// @Param	vendorIDs		query		string	false	"厂商ID列表"
// @Param	skuIDs			query		string	true	"Sku ID列表对象"
// @Param	isContinueWhenError	query	bool	false	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetVendorStoreSkusInfo [get]
func (c *StoreSkuController) GetVendorStoreSkusInfo() {
	c.callGetVendorStoreSkusInfo(func(params *tStoreSkuGetVendorStoreSkusInfoParams) (retVal interface{}, errCode string, err error) {
		var vendorIDs, skuIDs []int
		err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs, params.SkuIDs, &skuIDs)
		if err == nil {
			retVal, err = cms.GetVendorStoreSkusInfo(params.Ctx, params.StoreID, vendorIDs, skuIDs, params.IsContinueWhenError)
		}
		return retVal, "", err
	})
}

// @Title 修改商家商品绑定
// @Description 修改商家商品绑定，请换用UpdateStoresSkus
// @Param	token			header		string	true	"认证token"
// @Param	storeID			formData	int		true	门店ID"
// @Param	payload			formData	string	true	"json数据，StoreSkuBindInfo对象"
// @Param	causeFlag		formData	int		false	"操作类型"
// @Param	isContinueWhenError	formData	bool	false	"单个同步失败是否继续，缺省false"
// @Param	isAsync			formData	bool	false	"是否异步操作"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /UpdateStoreSku [put]
func (c *StoreSkuController) UpdateStoreSku() {
	c.callUpdateStoreSku(func(params *tStoreSkuUpdateStoreSkuParams) (retVal interface{}, errCode string, err error) {
		var skuBindInfo cms.StoreSkuBindInfo
		if err = jxutils.Strings2Objs(params.Payload, &skuBindInfo); err == nil {
			retVal, err = cms.UpdateStoreSku(params.Ctx, params.CauseFlag, params.StoreID, &skuBindInfo, params.IsAsync, params.IsContinueWhenError)
		}
		return retVal, "", err
	})
}

// @Title 批量修改商家商品绑定
// @Description 批量修改商家商品绑定，请换用UpdateStoresSkus
// @Param	token			header		string	true	"认证token"
// @Param	storeID			formData	int		true	"门店ID"
// @Param	payload			formData	string	true	"json数据，StoreSkuBindInfo对象数组"
// @Param	causeFlag		formData	int		false	"操作类型"
// @Param	isContinueWhenError	formData	bool	false	"单个同步失败是否继续，缺省false"
// @Param	isAsync			formData	bool	false	"是否异步操作"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /UpdateStoreSkus [put]
func (c *StoreSkuController) UpdateStoreSkus() {
	c.callUpdateStoreSkus(func(params *tStoreSkuUpdateStoreSkusParams) (retVal interface{}, errCode string, err error) {
		var skuBindInfos []*cms.StoreSkuBindInfo
		if err = jxutils.Strings2Objs(params.Payload, &skuBindInfos); err == nil {
			retVal, err = cms.UpdateStoreSkus(params.Ctx, params.CauseFlag, params.StoreID, skuBindInfos, params.IsAsync, params.IsContinueWhenError)
		}
		return retVal, "", err
	})
}

// @Title 同步商家商品信息
// @Description 同步商家商品信息
// @Param	token			header		string	true	"认证token"
// @Param	vendorIDs		formData	string	false	"厂商ID列表"
// @Param	storeIDs		formData	string	false	"门店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 *StoreSkuController) SyncStoresSkus() {
	c.callSyncStoresSkus(func(params *tStoreSkuSyncStoresSkusParams) (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, nil, 0, 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	payload			formData	string	true	"json数据，StoreSkuBindInfo对象数组"
// @Param	isScale			formData	bool	false	"是否按门店结算比例缩放"
// @Param	causeFlag		formData	int		false	"操作类型"
// @Param	isRefreshHigh	formData	bool	false	"是否只刷门店价高于给的价"
// @Param	isContinueWhenError	formData	bool	false	"单个同步失败是否继续，缺省false"
// @Param	isAsync			formData	bool	false	"是否异步操作"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router 	/UpdateStoresSkus [put]
func (c *StoreSkuController) UpdateStoresSkus() {
	c.callUpdateStoresSkus(func(params *tStoreSkuUpdateStoresSkusParams) (retVal interface{}, errCode string, err error) {
		var storeIDs []int
		var skuBindInfos []*cms.StoreSkuBindInfo
		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Payload, &skuBindInfos); err != nil {
			return retVal, "", err
		}
		retVal, err = cms.UpdateStoresSkus(params.Ctx, params.CauseFlag, storeIDs, skuBindInfos, params.IsScale, params.IsRefreshHigh, params.IsAsync, params.IsContinueWhenError)
		return retVal, "", err
	})
}

// @Title 批量修改多商家商品绑定(不同步)
// @Description 批量修改多商家商品绑定(不同步)
// @Param	token			header		string	true	"认证token"
// @Param	storeIDs		formData	string	false	"门店ID列表"
// @Param	payload			formData	string	true	"json数据，StoreSkuBindInfo对象数组"
// @Param	isRefreshHigh	formData	bool	true	"是否只刷门店价高于给的价"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /UpdateStoresSkusWithoutSync [put]
func (c *StoreSkuController) UpdateStoresSkusWithoutSync() {
	c.callUpdateStoresSkusWithoutSync(func(params *tStoreSkuUpdateStoresSkusWithoutSyncParams) (retVal interface{}, errCode string, err error) {
		var storeIDs []int
		var skuBindInfos []*cms.StoreSkuBindInfo
		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Payload, &skuBindInfos); err != nil {
			return retVal, "", err
		}
		err = cms.UpdateStoresSkusWithoutSync(params.Ctx, storeIDs, skuBindInfos, params.IsRefreshHigh)
		return retVal, "", err
	})
}

// @Title 按门店商品维度批量修改多商家商品绑定
// @Description 按门店商品维度批量修改多商家商品绑定
// @Param	token			header		string	true	"认证token"
// @Param	payload			formData	string	true	"json数据，StoreSkuBindInfo对象数组"
// @Param	isContinueWhenError	formData	bool	false	"单个同步失败是否继续，缺省false"
// @Param	isAsync			formData	bool	false	"是否异步操作"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /UpdateStoresSkusByBind [put]
func (c *StoreSkuController) UpdateStoresSkusByBind() {
	c.callUpdateStoresSkusByBind(func(params *tStoreSkuUpdateStoresSkusByBindParams) (retVal interface{}, errCode string, err error) {
		var skuBindInfos []*cms.StoreSkuBindInfo
		if err = jxutils.Strings2Objs(params.Payload, &skuBindInfos); err != nil {
			return retVal, "", err
		}
		retVal, err = cms.UpdateStoresSkusByBind(params.Ctx, nil, skuBindInfos, params.IsAsync, params.IsContinueWhenError, false)
		return retVal, "", err
	})
}

// @Title 拷贝门店SKU信息
// @Description 拷贝门店SKU信息（此函数当前只是本地数据操作，要同步到远端需要调用SyncStoresSkus）
// @Param	token			header		string	true	"认证token"
// @Param	fromStoreID		formData	int		true	"源门店ID"
// @Param	toStoreID		formData	int		false	"目标门店ID"
// @Param	toStoreIDs		formData	string	false	"目标门店ID列表"
// @Param	copyMode		formData	string	true	"拷贝模式，fresh:目标门店数据全部清除后拷贝，update:确保指定的源数据全部拷贝，已有的忽略"
// @Param	pricePercentage	formData	int		false	"价格调整百分比，缺省为100%"
// @Param	categoryIDs		formData	string	false	"json数据，skuName所属的类别，[1,2,3]"
// @Param	skuIDs			formData	string	false	"json数据，skuID列表，[1,2,3]"
// @Param	isScale			formData	bool	false	"是否按门店结算比例缩放"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /CopyStoreSkus [post]
func (c *StoreSkuController) CopyStoreSkus() {
	c.callCopyStoreSkus(func(params *tStoreSkuCopyStoreSkusParams) (retVal interface{}, errCode string, err error) {
		var toStoreIDs []int
		if err = jxutils.Strings2Objs(params.ToStoreIDs, &toStoreIDs); err == nil {
			if params.ToStoreID > 0 {
				toStoreIDs = append(toStoreIDs, params.ToStoreID)
			}
			retVal, err = cms.CopyStoreSkus(params.Ctx, params.FromStoreID, toStoreIDs, params.CopyMode, params.IsScale, params.MapData, params.Ctx.GetUserName())
		}
		return retVal, "", err
	})
}

// @Title 批量修改多商家商品可售状态
// @Description 批量修改多商家商品可售状态
// @Param	token			header		string	true	"认证token"
// @Param	storeIDs		formData	string	true	"门店ID列表"
// @Param	payload			formData	string	true	"json数据，StoreSkuBindSkuInfo对象数组"
// @Param	isContinueWhenError	formData	bool	false	"单个同步失败是否继续，缺省false"
// @Param	autoSaleAt		formData	string	false	"临时不可售到期时间"
// @Param	ignoreDontSale	formData	bool	false	"在临时不可售时，是否忽略当前是不可售的商品"
// @Param	isAsync			formData	bool	false	"是否异步操作"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /UpdateStoresSkusSale [put]
func (c *StoreSkuController) UpdateStoresSkusSale() {
	c.callUpdateStoresSkusSale(func(params *tStoreSkuUpdateStoresSkusSaleParams) (retVal interface{}, errCode string, err error) {
		var storeIDs []int
		var skuBindSkuInfos []*cms.StoreSkuBindSkuInfo
		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Payload, &skuBindSkuInfos); err != nil {
			return retVal, "", err
		}
		timeList, err := jxutils.BatchStr2Time(params.AutoSaleAt)
		if err != nil {
			return retVal, "", err
		}
		retVal, err = cms.UpdateStoresSkusSale(params.Ctx, storeIDs, skuBindSkuInfos, timeList[0], params.IgnoreDontSale, params.Ctx.GetUserName(), params.IsAsync, params.IsContinueWhenError)
		return retVal, "", err
	})
}

// @Title 得到商家商品销售情况
// @Description 得到商家商品销售情况
// @Param	token			header		string	true	"认证token"
// @Param	storeIDs		query		string	false	"门店ID列表"
// @Param	skuIDs			query		string	false	"Sku ID列表"
// @Param	skuNameIDs		query		string	false	"Skuname ID列表"
// @Param	fromTime		query		string	false	"开始时间"
// @Param	toTime			query		string	false	"结束时间"
// @Param	saleCountBegin	query		int		false	"销量begin"
// @Param	saleCountEnd	query		int		false	"销量end"
// @Param	sortType		query		int		false	"排序类型，1为按销量排，正为升序，负为倒序"
// @Param	keyword			query		string	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 /GetStoresSkusSaleInfo [get]
func (c *StoreSkuController) GetStoresSkusSaleInfo() {
	c.callGetStoresSkusSaleInfo(func(params *tStoreSkuGetStoresSkusSaleInfoParams) (retVal interface{}, errCode string, err error) {
		var (
			storeIDs, skuIDs, skuNameIDs []int
		)
		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs, params.SkuNameIDs, &skuNameIDs); err != nil {
			return retVal, "", err
		}
		retVal, err = cms.GetStoresSkusSaleInfoNew(params.Ctx, storeIDs, skuIDs, skuNameIDs, params.FromTime, params.ToTime, params.MapData, params.SortType, params.Keyword, params.Offset, params.PageSize)
		return retVal, "", err
	})
}

// // @Title 得到商家商品修改价格请求信息
// // @Description 得到商家商品修改价格请求信息
// // @Param	token			header		string	true	"认证token"
// // @Param	fromTime		query		string	false	"申请开始时间"
// // @Param	toTime			query		string	false	"申请结束时间"
// // @Param	keyword			query		string	false	"查询关键字（可以为空，为空表示不限制）"
// // @Param	storeIDs		query		string	false	"门店ID列表"
// // @Param	itemIDs			query		string	false	"id列表对象，当前指skuname id"
// // @Param	types			query		string	false	"类型列表对象"
// // @Param	statuss			query		string	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 /GetStoreOpRequests [get]
// func (c *StoreSkuController) GetStoreOpRequests() {
// 	c.callGetStoreOpRequests(func(params *tStoreSkuGetStoreOpRequestsParams) (retVal interface{}, errCode string, err error) {
// 		var (
// 			timeList                                []time.Time
// 			storeIDs, typeList, statusList, itemIDs []int
// 		)
// 		if timeList, err = jxutils.BatchStr2Time(params.FromTime, params.ToTime); err != nil {
// 			return retVal, "", err
// 		}
// 		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Types, &typeList, params.Statuss, &statusList, params.ItemIDs, &itemIDs); err != nil {
// 			return retVal, "", err
// 		}
// 		retVal, err = cms.GetStoreOpRequests(params.Ctx, timeList[0], timeList[1], params.Keyword, storeIDs, itemIDs, typeList, statusList, params.Offset, params.PageSize)
// 		return retVal, "", err
// 	})
// }

// // @Title 处理商家商品价格申请
// // @Description 处理商家商品价格申请
// // @Param	token			header		string	true	"认证token"
// // @Param	reqIDs			formData	string	true	"请求ID列表对象"
// // @Param	handleType		formData	int		true	"-1拒绝，1批准"
// // @Param	rejectReason	formData	string	false	"拒绝理由，拒绝时要求"
// // @Success 200 {object} controllers.CallResult
// // @Failure 200 {object} controllers.CallResult
// // @router /HandleStoreOpRequest [put]
// func (c *StoreSkuController) HandleStoreOpRequest() {
// 	c.callHandleStoreOpRequest(func(params *tStoreSkuHandleStoreOpRequestParams) (retVal interface{}, errCode string, err error) {
// 		var reqIDs []int
// 		if err = jxutils.Strings2Objs(params.ReqIDs, &reqIDs); err != nil {
// 			return retVal, "", err
// 		}
// 		if params.HandleType == 1 {
// 			err = cms.AcceptStoreOpRequests(params.Ctx, reqIDs)
// 		} else if params.HandleType == -1 {
// 			err = cms.RejectStoreOpRequests(params.Ctx, reqIDs, params.RejectReason)
// 		} else {
// 			err = fmt.Errorf("handleType=%d是非法值", params.HandleType)
// 		}
// 		return retVal, "", err
// 	})
// }

// @Title 根据厂家门店商品信息相应刷新本地数据
// @Description 根据厂家门店商品信息相应刷新本地数据
// @Param	token			header		string	true	"认证token"
// @Param	storeIDs		formData	string	true	"门店ID列表"
// @Param	vendorID		formData	int		true	"厂商ID（当前只支持京东）"
// @Param	isAsync			formData		bool	false	"是否异步操作"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /RefreshStoresSkuByVendor [put]
func (c *StoreSkuController) RefreshStoresSkuByVendor() {
	c.callRefreshStoresSkuByVendor(func(params *tStoreSkuRefreshStoresSkuByVendorParams) (retVal interface{}, errCode string, err error) {
		var storeIDList []int
		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
			retVal, err = cms.RefreshStoresSkuByVendor(params.Ctx, storeIDList, params.VendorID, params.IsAsync)
		}
		return retVal, "", err
	})
}

// @Title 京东商家商品状态同步
// @Description 京东商家商品状态同步
// @Param	token			header		string	true	"认证token"
// @Param	storeIDs		formData	string	true	"门店ID列表"
// @Param	skuIDs			formData	string	false	"SKU ID列表，缺省为全部"
// @Param	isAsync			formData		bool	false	"是否异步操作"
// @Param	isContinueWhenError	formData	bool	false	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /SyncJdStoreProducts [put]
func (c *StoreSkuController) SyncJdStoreProducts() {
	c.callSyncJdStoreProducts(func(params *tStoreSkuSyncJdStoreProductsParams) (retVal interface{}, errCode string, err error) {
		var storeIDList, skuIDList []int
		err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.SkuIDs, &skuIDList)
		if err == nil {
			retVal, err = cms.SyncJdStoreProducts(params.Ctx, storeIDList, skuIDList, params.IsAsync, params.IsContinueWhenError)
		}
		return retVal, "", err
	})
}

// @Title 从订单得到本地没有关注的商品信息
// @Description 从订单得到本地没有关注的商品信息
// @Param	token			header		string	true	"认证token"
// @Param	fromTime		query		string	true	"扫描的订单开始时间"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetMissingStoreSkuFromOrder [get]
func (c *StoreSkuController) GetMissingStoreSkuFromOrder() {
	c.callGetMissingStoreSkuFromOrder(func(params *tStoreSkuGetMissingStoreSkuFromOrderParams) (retVal interface{}, errCode string, err error) {
		timeList, err := jxutils.BatchStr2Time(params.FromTime)
		if err == nil {
			retVal, err = cms.GetMissingStoreSkuFromOrder(params.Ctx, timeList[0])
		}
		return retVal, "", err
	})
}

// @Title 根据门店信息查找推荐商品(按销量)
// @Description 根据门店信息查找推荐商品(按销量)
// @Param	token			header		string	false	"认证token"
// @Param	storeIDs		query		string	true	"门店列表"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetTopSkusByStoreIDs [get]
func (c *StoreSkuController) GetTopSkusByStoreIDs() {
	var storeIDList []int
	c.callGetTopSkusByStoreIDs(func(params *tStoreSkuGetTopSkusByStoreIDsParams) (retVal interface{}, errCode string, err error) {
		if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
			retVal, err = cms.GetTopSkusByStoreIDs(params.Ctx, storeIDList)
		}
		return retVal, "", err
	})
}

// @Title 根据城市信息查找推荐商品(按销量)
// @Description 根据城市信息查找推荐商品(按销量)
// @Param	token			header		string	true	"认证token"
// @Param	cityCode		query		int		false	"城市id"
// @Param	storeID			query		int		false	"门店id"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetTopSkusByCityCode [get]
func (c *StoreSkuController) GetTopSkusByCityCode() {
	c.callGetTopSkusByCityCode(func(params *tStoreSkuGetTopSkusByCityCodeParams) (retVal interface{}, errCode string, err error) {
		retVal, err = cms.GetTopSkusByCityCode(params.Ctx, params.CityCode, params.StoreID)
		return retVal, "", err
	})
}

// @Title 根据门店信息查找推荐分类(按商品销量)
// @Description 根据门店信息查找推荐分类(按商品销量)
// @Param	token			header		string	false	"认证token"
// @Param	storeIDs		query		string	true	"门店列表"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetTopCategoriesByStoreIDs [get]
func (c *StoreSkuController) GetTopCategoriesByStoreIDs() {
	var storeIDList []int
	c.callGetTopCategoriesByStoreIDs(func(params *tStoreSkuGetTopCategoriesByStoreIDsParams) (retVal interface{}, errCode string, err error) {
		if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
			retVal, err = cms.GetTopCategoriesByStoreIDs(params.Ctx, storeIDList)
		}
		return retVal, "", err
	})
}

// @Title 根据门店刷新中位价
// @Description 根据门店刷新中位价
// @Param	token			header		string	true	"认证token"
// @Param	isCountry		formData	bool	true	"是否按全国中位价刷新"
// @Param	storeIDs		formData	string	true	"门店列表"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /RefershStoreSkusMidPrice [put]
func (c *StoreSkuController) RefershStoreSkusMidPrice() {
	var storeIDList []int
	c.callRefershStoreSkusMidPrice(func(params *tStoreSkuRefershStoreSkusMidPriceParams) (retVal interface{}, errCode string, err error) {
		if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
			err = cms.RefershStoreSkusMidPrice(params.Ctx, storeIDList, params.IsCountry)
		}
		return retVal, "", err
	})
}

// @Title 根据Excel刷新京西门店商品价
// @Description 根据Excel刷新京西门店商品价
// @Param	token				header			string	true	"认证token"
// @Param	storeIDs			formData		string	true	"门店列表"
// @Param	isAsync				formData		bool	true	"是否异步，缺省是同步"
// @Param	isContinueWhenError	formData		bool	true	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /RefreshJxPriceByExcel [post]
func (c *StoreSkuController) RefreshJxPriceByExcel() {
	var storeIDList []int
	c.callRefreshJxPriceByExcel(func(params *tStoreSkuRefreshJxPriceByExcelParams) (retVal interface{}, errCode string, err error) {
		if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
			r := c.Ctx.Request
			files := r.MultipartForm.File["userfiles"]
			retVal, err = cms.RefreshJxPriceByExcel(params.Ctx, storeIDList, files, params.IsAsync, params.IsContinueWhenError)
		}
		return retVal, "", err
	})
}

// @Title 根据Excel导入订单,订单状态设置为待拣货
// @Description 根据Excel导入订单,订单状态设置为待拣货
// @Param	token				header			string	true	"认证token"
// @Param	isAsync				formData		bool	true	"是否异步，缺省是同步"
// @Param	isContinueWhenError	formData		bool	true	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /RefreshJxOrderByExcel [post]
//func (c *StoreSkuController) RefreshJxOrderByExcel() {
//	c.callRefreshJxOrderByExcel(func(params *tStoreSkuRefreshJxOrderByExcelParams) (retVal interface{}, errCode string, err error) {
//		r := c.Ctx.Request
//		files := r.MultipartForm.File["userfiles"]
//		retVal, err = cms.RefreshJxPriceByExcel(params.Ctx, storeIDList, files, params.IsAsync, params.IsContinueWhenError)
//		return retVal, "", err
//	})
//}

// @Title 根据Excel中SkuID批量关注商品
// @Description 根据Excel中SkuID批量关注商品
// @Param	token				header			string	true	"认证token"
// @Param	isAsync				formData		bool	true	"是否异步，缺省是同步"
// @Param	isContinueWhenError	formData		bool	true	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /FocusStoreSkusByExcel [post]
func (c *StoreSkuController) FocusStoreSkusByExcel() {
	c.callFocusStoreSkusByExcel(func(params *tStoreSkuFocusStoreSkusByExcelParams) (retVal interface{}, errCode string, err error) {
		r := c.Ctx.Request
		files := r.MultipartForm.File["userfiles"]
		retVal, err = cms.FocusStoreSkusByExcel(params.Ctx, files, params.IsAsync, params.IsContinueWhenError)
		// file, head, err := c.GetFile("userfiles")
		// defer file.Close()
		// if path.Ext(head.Filename) != ".jpg" && path.Ext(head.Filename) != ".png" {
		// 	err = fmt.Errorf("文件格式不对！")
		// }
		// c.SaveToFile("userfiles", "./"+head.Filename)
		return retVal, "", err
	})
}

// @Title 得到门店的分类列表
// @Description 得到门店的分类列表(按商品销量)
// @Param	token			header		string	false	"认证token"
// @Param	storeID			query		int		true	"门店ID"
// @Param	parentID		query		int		false	"父分类id"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetStoreCategories [get]
func (c *StoreSkuController) GetStoreCategories() {
	c.callGetStoreCategories(func(params *tStoreSkuGetStoreCategoriesParams) (retVal interface{}, errCode string, err error) {
		if params.MapData["parentID"] == nil {
			params.ParentID = -1
		}
		retVal, err = cms.GetStoreCategories(params.Ctx, params.StoreID, params.ParentID)
		return retVal, "", err
	})
}

// @Title 获取各平台所有门店某商品的价格
// @Description 获取各平台所有门店某商品的价格
// @Param	token				header			string	true	"认证token"
// @Param	skuID				formData		int		true	"商品ID"
// @Param	vendorIDs			formData		string	true	"厂商ID列表"
// @Param	isAsync				formData		bool	true	"是否异步，缺省是同步"
// @Param	isContinueWhenError	formData		bool	true	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetVendorStoreSkuPrice [post]
func (c *StoreSkuController) GetVendorStoreSkuPrice() {
	var vendorIDList []int
	c.callGetVendorStoreSkuPrice(func(params *tStoreSkuGetVendorStoreSkuPriceParams) (retVal interface{}, errCode string, err error) {
		if jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil {
			retVal, err = cms.GetVendorStoreSkuPrice(params.Ctx, vendorIDList, params.SkuID, params.IsAsync, params.IsContinueWhenError)
		}
		return retVal, "", err
	})
}

// @Title 根据skuID关注商品，价格为中位价，部分可售
// @Description 根据skuID关注商品，价格为中位价，部分可售
// @Param	token				header			string	true	"认证token"
// @Param	payload				formData		string	true	"json数据，StoreSkuBindInfo对象数组"
// @Param	isAsync				formData		bool	true	"是否异步，缺省是同步"
// @Param	isContinueWhenError	formData		bool	true	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /FocusStoreSkusBySku [post]
func (c *StoreSkuController) FocusStoreSkusBySku() {
	var skuBindInfos []*cms.StoreSkuBindInfo
	c.callFocusStoreSkusBySku(func(params *tStoreSkuFocusStoreSkusBySkuParams) (retVal interface{}, errCode string, err error) {
		if err = jxutils.Strings2Objs(params.Payload, &skuBindInfos); err != nil {
			return retVal, "", err
		}
		retVal, err = cms.FocusStoreSkusBySku(params.Ctx, skuBindInfos, params.IsAsync, params.IsContinueWhenError)
		return retVal, "", err
	})
}

// @Title 自动关注畅销品
// @Description 自动关注畅销品
// @Param	token				header			string	true	"认证token"
// @Param	isAsync				formData		bool	true	"是否异步，缺省是同步"
// @Param	isContinueWhenError	formData		bool	true	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /AutoFocusStoreSkusForTopSkus [post]
func (c *StoreSkuController) AutoFocusStoreSkusForTopSkus() {
	c.callAutoFocusStoreSkusForTopSkus(func(params *tStoreSkuAutoFocusStoreSkusForTopSkusParams) (retVal interface{}, errCode string, err error) {
		retVal, err = cms.AutoFocusStoreSkusForTopSkus(params.Ctx, params.IsAsync, params.IsContinueWhenError)
		return retVal, "", err
	})
}

// @Title 设置平台商品力荐标志
// @Description 设置平台商品力荐标志
// @Param	token				header			string	true	"认证token"
// @Param	vendorIDs			formData		string	true	"厂商ID列表"
// @Param	isAsync				formData		bool	true	"是否异步，缺省是同步"
// @Param	isContinueWhenError	formData		bool	true	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /UpdateStoreSkusSpecTag [post]
func (c *StoreSkuController) UpdateStoreSkusSpecTag() {
	var vendorIDList []int
	c.callUpdateStoreSkusSpecTag(func(params *tStoreSkuUpdateStoreSkusSpecTagParams) (retVal interface{}, errCode string, err error) {
		r := c.Ctx.Request
		files := r.MultipartForm.File["userfiles"]
		if jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil {
			retVal, err = cms.UpdateStoreSkusSpecTag(params.Ctx, vendorIDList, files, params.IsAsync, params.IsContinueWhenError)
		}
		return retVal, "", err
	})
}

// @Title 手动爆品预警
// @Description 手动爆品预警
// @Param	token				header			string	true	"认证token"
// @Param	vendorIDs			formData		string	true	"厂商ID列表"
// @Param	isAsync				formData		bool	true	"是否异步，缺省是同步"
// @Param	isContinueWhenError	formData		bool	true	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /SendSeckillSkusCountMsg [post]
func (c *StoreSkuController) SendSeckillSkusCountMsg() {
	var vendorIDList []int
	c.callSendSeckillSkusCountMsg(func(params *tStoreSkuSendSeckillSkusCountMsgParams) (retVal interface{}, errCode string, err error) {
		if jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil {
			retVal, err = cms.SendSeckillSkusCountMsg(params.Ctx, vendorIDList, params.IsAsync, params.IsContinueWhenError)
		}
		return retVal, "", err
	})
}

// @Title 根据平台价反算京西价
// @Description 根据平台价反算京西价
// @Param	token				header			string	true	"认证token"
// @Param	payload				formData		string	true	"json数据，JdStoreSkus对象"
// @Param	vendorID			formData		int		true	"厂商ID"
// @Param	ignoreLow			formData		bool	true	"是否忽略低价商品"
// @Param	isAsync				formData		bool	true	"是否异步，缺省是同步"
// @Param	isContinueWhenError	formData		bool	true	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /RefreshJxPriceByVendor [put]
func (c *StoreSkuController) RefreshJxPriceByVendor() {
	var skuBindInfos []*cms.JdStoreSkus
	c.callRefreshJxPriceByVendor(func(params *tStoreSkuRefreshJxPriceByVendorParams) (retVal interface{}, errCode string, err error) {
		if err = jxutils.Strings2Objs(params.Payload, &skuBindInfos); err != nil {
			return retVal, "", err
		}
		retVal, err = cms.RefreshJxPriceByVendor(params.Ctx, skuBindInfos, params.VendorID, params.IgnoreLow, params.IsAsync, params.IsContinueWhenError)
		return retVal, "", err
	})
}

// @Title 根据平台价反算京西价2
// @Description 根据平台价反算京西价2
// @Param	token				header			string	true	"认证token"
// @Param	storeIDs			formData		string	true	"门店列表"
// @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 /RefreshJxPriceByVendor2 [put]
func (c *StoreSkuController) RefreshJxPriceByVendor2() {
	var storeIDs []int
	c.callRefreshJxPriceByVendor2(func(params *tStoreSkuRefreshJxPriceByVendor2Params) (retVal interface{}, errCode string, err error) {
		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err != nil {
			return retVal, "", err
		}
		retVal, err = cms.RefreshJxPriceByVendor2(params.Ctx, storeIDs, params.VendorID, 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 /BackUpStoreSkuBind [post]
func (c *StoreSkuController) BackUpStoreSkuBind() {
	c.callBackUpStoreSkuBind(func(params *tStoreSkuBackUpStoreSkuBindParams) (retVal interface{}, errCode string, err error) {
		retVal, err = cms.BackUpStoreSkuBind(params.Ctx, params.IsAsync, params.IsContinueWhenError)
		return retVal, "", err
	})
}

// @Title 恢复门店商品表
// @Description 恢复门店商品表
// @Param	token				header			string	true	"认证token"
// @Param	snapshotAt			formData		string	true	"日期，格式2020-03-06 00:00:00"
// @Param	storeIDs			formData		string	true	"门店列表"
// @Param	skuIDs				formData		string	false	"商品列表"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /ReturnStoreSkuBind [post]
func (c *StoreSkuController) ReturnStoreSkuBind() {
	c.callReturnStoreSkuBind(func(params *tStoreSkuReturnStoreSkuBindParams) (retVal interface{}, errCode string, err error) {
		var storeIDs, skuIDs []int
		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs); err != nil {
			return retVal, "", err
		}
		err = cms.ReturnStoreSkuBind(params.Ctx, params.SnapshotAt, storeIDs, skuIDs)
		return retVal, "", err
	})
}

// @Title 物料库存刷新（物料店商品上下架）
// @Description 物料库存刷新（物料店商品上下架）
// @Param	token				header			string	false	"认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /RefreshMatterStock [post]
func (c *StoreSkuController) RefreshMatterStock() {
	c.callRefreshMatterStock(func(params *tStoreSkuRefreshMatterStockParams) (retVal interface{}, errCode string, err error) {
		err = cms.RefreshMatterStock(params.Ctx, 0)
		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 /CreateSkusAndFocusFromYb [post]
func (c *StoreSkuController) CreateSkusAndFocusFromYb() {
	c.callCreateSkusAndFocusFromYb(func(params *tStoreSkuCreateSkusAndFocusFromYbParams) (retVal interface{}, errCode string, err error) {
		// retVal, err = cms.CreateSkusAndFocusFromYb(params.Ctx, params.IsAsync, params.IsContinueWhenError)
		return retVal, "", err
	})
}

// @Title 从微信上扫码标品到京西创建或关注
// @Description 从微信上扫码标品到京西创建或关注
// @Param	token				header			string	true	"认证token"
// @Param	payload				formData		string	true	"json数据，ProductInfo对象"
// @Param	storeID				formData		int		true	"门店ID"
// @Param	price				formData		int		true	"商品价格"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /CreateSkusAndFocusFromWx [post]
func (c *StoreSkuController) CreateSkusAndFocusFromWx() {
	var productInfo *jdapi.ProductInfo
	c.callCreateSkusAndFocusFromWx(func(params *tStoreSkuCreateSkusAndFocusFromWxParams) (retVal interface{}, errCode string, err error) {
		if err = jxutils.Strings2Objs(params.Payload, &productInfo); err != nil {
			return retVal, "", err
		}
		err = cms.CreateSkusAndFocusFromWx(params.Ctx, productInfo, params.Price, params.StoreID)
		return retVal, "", err
	})
}

// @Title 同步菜市物料到果园
// @Description 同步菜市物料到果园
// @Param	token				header			string	true	"认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /SyncMatterC4ToGy [post]
func (c *StoreSkuController) SyncMatterC4ToGy() {
	c.callSyncMatterC4ToGy(func(params *tStoreSkuSyncMatterC4ToGyParams) (retVal interface{}, errCode string, err error) {
		retVal, err = cms.SyncMatterC4ToGy(params.Ctx, true, true)
		return retVal, "", err
	})
}

// @Title 查询商品审核信息
// @Description 查询商品审核信息
// @Param	token			header		string	true	"认证token"
// @Param	applyTimeStart	query		string	false	"申请开始时间"
// @Param	applyTimeEnd	query		string	false	"申请结束时间"
// @Param	auditTimeStart	query		string	false	"审核开始时间"
// @Param	auditTimeEnd	query		string	false	"审核结束时间"
// @Param	name			query		string	false	"审核人"
// @Param	remark			query		string	false	"不通过原因"
// @Param	storeIDs		query		string	false	"门店ID列表"
// @Param	nameIDs			query		string	false	"id列表对象，当前指skuname id"
// @Param	statuss			query		string	false	"审核状态"
// @Param	types			query		string	false	"改价类型，1是普通改价，2是关注"
// @Param	keyword			query		string	false	"关键字"
// @Param	marketManPhone	query		string	false	"市场负责人电话"
// @Param	cityName		query		string	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 /GetStoreSkuAudit [get]
func (c *StoreSkuController) GetStoreSkuAudit() {
	c.callGetStoreSkuAudit(func(params *tStoreSkuGetStoreSkuAuditParams) (retVal interface{}, errCode string, err error) {
		var (
			storeIDs, nameIDs, statuss, types []int
		)
		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.NameIDs, &nameIDs, params.Statuss, &statuss, params.Types, &types); err != nil {
			return retVal, "", err
		}
		retVal, err = cms.GetStoreSkuAudit(params.Ctx, storeIDs, nameIDs, nil, statuss, types, params.Name, params.Remark, params.Keyword, params.MarketManPhone, params.CityName, params.ApplyTimeStart, params.ApplyTimeEnd, params.AuditTimeStart, params.AuditTimeEnd, params.PageSize, params.Offset)
		return retVal, "", err
	})
}

// @Title 审核商品
// @Description 审核商品
// @Param	token				header			string	true	"认证token"
// @Param	payload				formData		string	true	"json数据，storeskuaudit对象"
// @Param	status				formData		int		false	"审核标志，1通过，-1 不通过，2 预审核"
// @Param	isAsync				formData		bool	false	"是否异步，缺省是同步"
// @Param	isContinueWhenError	formData		bool	false	"单个同步失败是否继续，缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /StoreSkuPriceAudit [post]
func (c *StoreSkuController) StoreSkuPriceAudit() {
	c.callStoreSkuPriceAudit(func(params *tStoreSkuStoreSkuPriceAuditParams) (retVal interface{}, errCode string, err error) {
		var storeSkuAudits []*model.StoreSkuAudit
		if err = jxutils.Strings2Objs(params.Payload, &storeSkuAudits); err != nil {
			return retVal, "", err
		}
		retVal, hint, err := cms.StoreSkuPriceAudit(params.Ctx, storeSkuAudits, params.Status, params.IsAsync, params.IsContinueWhenError)
		if hint != "" {
			return hint, "", err
		} else {
			return retVal, "", err
		}
	})
}

// @Title 查看美团力荐或京东置顶商品
// @Description 查看美团力荐或京东置顶商品
// @Param	token				header			string	true	"认证token"
// @Param	vendorIDs			formData		string	true	"平台ids"
// @Param	storeIDs			formData		string	true	"门店IDs"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetSpecialtyStoreSkus [post]
func (c *StoreSkuController) GetSpecialtyStoreSkus() {
	c.callGetSpecialtyStoreSkus(func(params *tStoreSkuGetSpecialtyStoreSkusParams) (retVal interface{}, errCode string, err error) {
		var (
			storeIDs, vendorIDs []int
		)
		if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
			return retVal, "", err
		}
		err = cms.GetSpecialtyStoreSkus(params.Ctx, storeIDs, vendorIDs)
		return retVal, "", err
	})
}

// @Title 拉取平台标品
// @Description 拉取平台标品
// @Param	token				header			string	true	"认证token"
// @Param	vendorID			formData		int		true	"平台id"
// @Param	storeID				formData		int		true	"门店ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetVendorStoreSkus [post]
func (c *StoreSkuController) GetVendorStoreSkus() {
	c.callGetVendorStoreSkus(func(params *tStoreSkuGetVendorStoreSkusParams) (retVal interface{}, errCode string, err error) {
		err = cms.GetVendorStoreSkus(params.Ctx, params.StoreID, params.VendorID)
		return retVal, "", err
	})
}

// @Title 得到商家商品信息
// @Description 得到商家商品信息，如下条件之间是与的关系。对于没有认领的商品，按城市限制。但对于已经认领的商品就不限制了，因为已经在平台上可售，可以操作（改价等等）
// @Param	token			header		string	false	"认证token"
// @Param	storeID			query		int		true	"门店ID"
// @Param	isFocus			query		bool	true	"是否已关注（认领）"
// @Param	stock			query		int		false	"库存是否为0[1-全查/2-有库存/3-没库存]"
// @Param	locationCode	query		bool	false	"商品位置是否为空"
// @Param	keyword			query		string	false	"查询关键字（可以为空，为空表示不限制）"
// @Param	categoryID		query		int		false	"商品所属类别ID"
// @Param	status			query		int		false	"查询起始状态（0：不可售，1：可售,-1 全部）"
// @Param	offset			query		int		false	"门店列表起始序号（以0开始，缺省为0）"
// @Param	pageSize		query		int		false	"门店列表页大小（缺省为50，-1表示全部）"
// @Param	isAct			query		bool	false	"是否活动商品（包括正常活动与补贴）"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetStoresSkusForStore [get]
func (c *StoreSkuController) GetStoresSkusForStore() {
	c.callGetStoresSkusForStore(func(params *tStoreSkuGetStoresSkusForStoreParams) (retVal interface{}, errCode string, err error) {
		retVal, err = cms.GetStoresSkusForStore(params.Ctx, params.StoreID, params.IsFocus, params.IsAct, params.Keyword, params.CategoryID, params.Status, params.Offset, params.PageSize, params.Stock, params.LocationCode)
		return retVal, "", err
	})
}

// @Title 复制美团到京东
// @Description 复制美团到京东
// @Param	token				header			string	true	"认证token"
// @Param	mtStoreID			formData		string	true	"美团门店ID"
// @Param	mtOrgCode			formData		string	true	"美团账号"
// @Param	jdStoreID			formData		string	true	"京东门店ID"
// @Param	jdOrgCode			formData		string	true	"京东账号"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /CopyMtToJd [post]
func (c *StoreSkuController) CopyMtToJd() {
	c.callCopyMtToJd(func(params *tStoreSkuCopyMtToJdParams) (retVal interface{}, errCode string, err error) {
		err = cms.CopyMtToJd(params.Ctx, params.MtStoreID, params.MtOrgCode, params.JdStoreID, params.JdOrgCode)
		return retVal, "", err
	})
}

// @Title 美团门店复制到美团(相同平台门店相互复制)
// @Description 美团门店复制到美团(相同平台门店相互复制)
// @Param	token				header			string	true	"认证token"
// @Param	fromStoreID			formData		string	true	"被复制门店id(平台ID)"
// @Param	toStoreID			formData		string	true	"复制到门店id(平台ID)"
// @Param	vendorID			formData		int		true	"平台id[(0京东-京东)(3饿百-饿百)(1美团-美团)(14抖音-抖音)(16淘宝-淘宝)(114美团-抖音)(31饿百-美团)(13美团-饿百)]"
// @Param	offSet				formData		int		false	"跳过页码"
// @Param	syncType			formData		int		true	"同步类型[1-商品/2-活动/3-前两者一起同步]"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /CopyMtToMt [post]
func (c *StoreSkuController) CopyMtToMt() {
	c.callCopyMtToMt(func(params *tStoreSkuCopyMtToMtParams) (retVal interface{}, errCode string, err error) {
		retVal, err = cms.CopyOnStoreSkuToOther(params.Ctx, params.FromStoreID, params.ToStoreID, params.VendorID, false, params.OffSet, params.SyncType)
		return retVal, errCode, err
	})
}
