- 启用新活动初始版本
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
package controllers
|
||||
|
||||
import "github.com/astaxie/beego"
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/act"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
type ActController struct {
|
||||
beego.Controller
|
||||
@@ -15,17 +20,121 @@ type ActController struct {
|
||||
// @Param beginAt formData string true "开始日期"
|
||||
// @Param endAt formData string true "结束日期"
|
||||
// @Param pricePercentage formData int true "活动价格比例"
|
||||
// @Param actStoreSku formData string true "活动门店商品信息"
|
||||
// @Param actStoreSkuList formData string true "活动门店商品信息"
|
||||
// @Param advertising formData string false "广告语"
|
||||
// @Param limitDaily formData int false "是否按日0-不限,>0限购单数(限时抢需填)"
|
||||
// @Param limitUser formData int false "是否用户限购0-不限,1-限购"
|
||||
// @Param limitCount formData int false "限购件数 0-不限,如账号限购、设备限购有一个为1,则限购件数必须大于0的整数"
|
||||
// @Param remark formData string false "备注"
|
||||
// @Param isAsync formData bool false "是否异步,缺省否(暂时只支持同步)"
|
||||
// @Param isContinueWhenError formData bool false "单个广告失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /CreatePromotion [post]
|
||||
// @router /CreateAct [post]
|
||||
func (c *ActController) CreateAct() {
|
||||
|
||||
c.callCreateAct(func(params *tActCreateActParams) (retVal interface{}, errCode string, err error) {
|
||||
var (
|
||||
vendorIDs []int
|
||||
actStoreSkuList []*act.ActStoreSkuParam
|
||||
)
|
||||
timeList, err := jxutils.BatchStr2Time(params.BeginAt, params.EndAt)
|
||||
if err == nil {
|
||||
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs, params.ActStoreSkuList, &actStoreSkuList); err == nil {
|
||||
actObj := &model.Act{
|
||||
Name: params.Name,
|
||||
Type: params.Type,
|
||||
LimitUser: params.LimitUser,
|
||||
LimitDaily: params.LimitDaily,
|
||||
LimitCount: params.LimitCount,
|
||||
// Source:,
|
||||
CreateType: model.ActCreateTypeAPI,
|
||||
PricePercentage: params.PricePercentage,
|
||||
BeginAt: timeList[0],
|
||||
EndAt: timeList[1],
|
||||
Remark: params.Remark,
|
||||
}
|
||||
retVal, err = act.CreateAct(params.Ctx, actObj, vendorIDs, nil, actStoreSkuList, params.IsAsync)
|
||||
}
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 查询活动
|
||||
// @Description 查询活动
|
||||
// @Param token header string true "认证token"
|
||||
// @Param createdAtFrom query string true "创建开始日期"
|
||||
// @Param createdAtTo query string false "创建结束日期"
|
||||
// @Param keyword query string false "关键字"
|
||||
// @Param actID query int false "活动id"
|
||||
// @Param name query string false "活动名,不完全匹配"
|
||||
// @Param cityCode query int false "活动门店所属城市code"
|
||||
// @Param beginAt query string false "开始日期,包括"
|
||||
// @Param endAt query string false "结束日期,包括"
|
||||
// @Param typeList query string false "活动类型列表,3:直降,4:限时抢购"
|
||||
// @Param statusList query string false "活动状态列表"
|
||||
// @Param storeID query int false "包含门店"
|
||||
// @Param skuID query int false "包含sku"
|
||||
// @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 /QueryActs [get]
|
||||
func (c *ActController) QueryActs() {
|
||||
c.callQueryActs(func(params *tActQueryActsParams) (retVal interface{}, errCode string, err error) {
|
||||
timeList, err := jxutils.BatchStr2Time(params.CreatedAtFrom, params.CreatedAtTo, params.BeginAt, params.EndAt)
|
||||
if err == nil {
|
||||
var typeList, statusList []int
|
||||
if err = jxutils.Strings2Objs(params.TypeList, &typeList, params.StatusList, &statusList); err == nil {
|
||||
retVal, err = act.QueryActs(params.Ctx, params.ActID, params.Offset, params.PageSize, params.Keyword, statusList, typeList,
|
||||
params.StoreID, params.SkuID, params.CityCode, timeList[2], timeList[3], timeList[0], timeList[1])
|
||||
}
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 取消活动
|
||||
// @Description 取消活动
|
||||
// @Param token header string true "认证token"
|
||||
// @Param actID formData int true "活动id"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /CancelAct [put]
|
||||
func (c *ActController) CancelAct() {
|
||||
c.callCancelAct(func(params *tActCancelActParams) (retVal interface{}, errCode string, err error) {
|
||||
err = act.CancelAct(params.Ctx, params.ActID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到活动平台信息
|
||||
// @Description 得到活动平台信息
|
||||
// @Param token header string true "认证token"
|
||||
// @Param actID query int false "活动id"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetActVendorInfo [get]
|
||||
func (c *ActController) GetActVendorInfo() {
|
||||
c.callGetActVendorInfo(func(params *tActGetActVendorInfoParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = act.GetActVendorInfo(params.Ctx, params.ActID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到活动门店商品信息
|
||||
// @Description 得到活动门店商品信息
|
||||
// @Param token header string true "认证token"
|
||||
// @Param actID query int true "活动id"
|
||||
// @Param vendorIDs query string false "厂商ID列表"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetActStoreSkuInfo [get]
|
||||
func (c *ActController) GetActStoreSkuInfo() {
|
||||
c.callGetActStoreSkuInfo(func(params *tActGetActStoreSkuInfoParams) (retVal interface{}, errCode string, err error) {
|
||||
var vendorIDs []int
|
||||
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs); err == nil {
|
||||
retVal, err = act.GetActStoreSkuInfo(params.Ctx, params.ActID, vendorIDs)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user