From 8195f171e3c854e1606964d341a29a4e71648998 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 5 Nov 2018 14:58:19 +0800 Subject: [PATCH] - jd cancel promotion --- platformapi/jdapi/promotion.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/platformapi/jdapi/promotion.go b/platformapi/jdapi/promotion.go index ecbd5f44..7f32674c 100644 --- a/platformapi/jdapi/promotion.go +++ b/platformapi/jdapi/promotion.go @@ -41,6 +41,12 @@ func (a *API) ConfirmPromotionSingle(infoId int64, outInfoId string) (err error) return a.confirmPromotion(PromotionTypeDirectDown, infoId, outInfoId) } +// 单品直降整个活动取消接口 +// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=178&apiid=3d02c2acad714bea86d20d498a1aa074 +func (a *API) CancelPromotionSingle(infoId int64, outInfoId string) (err error) { + return a.cancelPromotion(PromotionTypeDirectDown, infoId, outInfoId) +} + // 限时抢添加活动主信息接口 // https://opendj.jd.com/staticnew/widgets/resources.html?groupid=184&apiid=7d8b7ff86c9e457bb8a46963cb575769 func (a *API) CreatePromotionInfosLimitTime(name string, beginDate, endDate time.Time, outInfoId, advertising string) (infoId int64, err error) { @@ -79,6 +85,12 @@ func (a *API) ConfirmPromotionLimitTime(infoId int64, outInfoId string) (err err return a.confirmPromotion(PromotionTypeLimitedTime, infoId, outInfoId) } +// 限时抢整个活动取消接口 +// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=184&apiid=97b6678d30624f73bc13cb68987e6a6d +func (a *API) CancelPromotionLimitTime(infoId int64, outInfoId string) (err error) { + return a.cancelPromotion(PromotionTypeLimitedTime, infoId, outInfoId) +} + func (a *API) createPromotionInfos(promotionType int, name string, beginDate, endDate time.Time, outInfoId, advertising string) (infoId int64, err error) { if outInfoId == "" { outInfoId = fmt.Sprintf("%X", md5.Sum([]byte(name))) @@ -155,3 +167,24 @@ func (a *API) confirmPromotion(promotionType int, infoId int64, outInfoId string _, err = a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0")) return err } + +func (a *API) cancelPromotion(promotionType int, infoId int64, outInfoId string) (err error) { + jdParams := map[string]interface{}{ + "timeStamp": utils.GetCurTimeStr(), + } + if infoId != 0 { + jdParams[KeyInfoId] = infoId + } else { + jdParams[KeyOutInfoId] = outInfoId + } + cmd := "" + if promotionType == PromotionTypeDirectDown { + cmd = "singlePromote/cancelPromotion" + } else if promotionType == PromotionTypeLimitedTime { + cmd = "limitTime/cancelPromotion" + } else { + panic("unknow promotionType!") + } + _, err = a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0")) + return err +}