- 调整了一些与活动相关的API,三个平台都有

This commit is contained in:
gazebo
2019-06-04 17:42:02 +08:00
parent edc1bb42ff
commit d472c9f449
4 changed files with 99 additions and 37 deletions

View File

@@ -42,7 +42,11 @@ type PromotionSku struct {
func getPromotionCmd(inCmd string, promotionType int) (outCmd string) {
if promotionType == PromotionTypeDirectDown {
outCmd = "singlePromote/" + inCmd
if inCmd == "adjustPromotionSku" || inCmd == "adjustPromotionTime" {
outCmd = "promotesku/" + inCmd
} else {
outCmd = "singlePromote/" + inCmd
}
} else if promotionType == PromotionTypeLimitedTime {
outCmd = "limitTime/" + inCmd
} else {
@@ -88,6 +92,18 @@ func (a *API) CancelPromotionSingle(infoId int64, outInfoId, traceId string) (er
return a.cancelPromotion(PromotionTypeDirectDown, infoId, outInfoId, traceId)
}
// 单品实时促销活动结束时间调整接口
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=178&apiid=0abab0c4b81d45e5bc555cc7dfbeb1ad
func (a *API) AdjustPromotionTimeSingle(infoId int64, outInfoId string, endDate time.Time, traceId string) (err error) {
return a.adjustPromotionTime(PromotionTypeDirectDown, infoId, outInfoId, endDate, traceId)
}
// 单品实时促销商品促销数量调整接口
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=178&apiid=82964e5e0f9c448db072a54ed20e00c4
func (a *API) AdjustPromotionSkuSingle(infoId int64, outInfoId string, skus []*PromotionSku, traceId string) (skusResult []*PromotionSku, err error) {
return a.adjustPromotionSku(PromotionTypeDirectDown, infoId, outInfoId, skus, traceId)
}
// 以下为限时抢
// 限时抢添加活动主信息接口
@@ -127,6 +143,18 @@ func (a *API) CancelPromotionLimitTime(infoId int64, outInfoId, traceId string)
return a.cancelPromotion(PromotionTypeLimitedTime, infoId, outInfoId, traceId)
}
// 限时抢活动结束时间调整接口
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=184&apiid=f91035295cd54a9bbd2db9dfc800484c
func (a *API) AdjustPromotionTimeLimitTime(infoId int64, outInfoId string, endDate time.Time, traceId string) (err error) {
return a.adjustPromotionTime(PromotionTypeLimitedTime, infoId, outInfoId, endDate, traceId)
}
// 限时抢商品促销数量调整接口
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=184&apiid=aa878a000dfb4a248634ee755af1f1d3
func (a *API) AdjustPromotionSkuLimitTime(infoId int64, outInfoId string, skus []*PromotionSku, traceId string) (skusResult []*PromotionSku, err error) {
return a.adjustPromotionSku(PromotionTypeLimitedTime, infoId, outInfoId, skus, traceId)
}
func (a *API) createPromotionInfos(promotionType int, name string, beginDate, endDate time.Time, outInfoId, advertising, traceId string) (infoId int64, err error) {
if outInfoId == "" {
outInfoId = fmt.Sprintf("%X", md5.Sum([]byte(name)))
@@ -186,6 +214,22 @@ func (a *API) cancelPromotion(promotionType int, infoId int64, outInfoId, traceI
return err
}
func (a *API) adjustPromotionTime(promotionType int, infoId int64, outInfoId string, endDate time.Time, traceId string) (err error) {
jdParams := getCommonSkuPromotionParams(infoId, outInfoId, traceId)
_, err = a.AccessAPINoPage(getPromotionCmd("adjustPromotionTime", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0"))
return err
}
func (a *API) adjustPromotionSku(promotionType int, infoId int64, outInfoId string, skus []*PromotionSku, traceId string) (skusResult []*PromotionSku, err error) {
jdParams := getCommonSkuPromotionParams(infoId, outInfoId, traceId)
jdParams["skus"] = skus
result, err := a.AccessAPINoPage(getPromotionCmd("adjustPromotionSku", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "data", "", "0"))
if err == nil && result != nil {
err = utils.Map2StructByJson(result, &skusResult, false)
}
return skusResult, err
}
func getCommonSkuPromotionParams(infoId int64, outInfoId, traceId string) map[string]interface{} {
jdParams := map[string]interface{}{
"timeStamp": utils.GetCurTimeStr(),