75 lines
3.6 KiB
Go
75 lines
3.6 KiB
Go
package controllers
|
||
|
||
import (
|
||
"git.rosy.net.cn/baseapi/utils"
|
||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||
"github.com/astaxie/beego"
|
||
)
|
||
|
||
type StoreSkuController struct {
|
||
beego.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 skuID query int 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 jdID query int false "商品京东ID"
|
||
// @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)"
|
||
// @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) {
|
||
retVal, err = cms.GetStoreSkus(params.StoreID, params.IsFocus, params.Keyword, params.MapData, params.Offset, params.PageSize)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 修改商家商品绑定
|
||
// @Description 修改商家商品绑定
|
||
// @Param token header string true "认证token"
|
||
// @Param storeID formData int true "需要修改的商品名ID,payload中的相应数据会被忽略"
|
||
// @Param payload formData string true "json数据,StoreSkuBindInfo对象
|
||
// @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 = utils.UnmarshalUseNumber([]byte(params.Payload), &skuBindInfo); err == nil {
|
||
retVal, err = cms.UpdateStoreSku(params.StoreID, &skuBindInfo, GetUserNameFromToken(params.Token))
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 批量修改商家商品绑定
|
||
// @Description 批量修改商家商品绑定
|
||
// @Param token header string true "认证token"
|
||
// @Param storeID formData int true "需要修改的商品名ID,payload中的相应数据会被忽略"
|
||
// @Param payload formData string true "json数据,StoreSkuBindInfo对象数组
|
||
// @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 = utils.UnmarshalUseNumber([]byte(params.Payload), &skuBindInfos); err == nil {
|
||
retVal, err = cms.UpdateStoreSkus(params.StoreID, skuBindInfos, GetUserNameFromToken(params.Token))
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|