- 京东活动API重构
This commit is contained in:
@@ -29,6 +29,16 @@ const (
|
||||
PromotionStateEnded = 9
|
||||
)
|
||||
|
||||
type PromotionSku struct {
|
||||
SkuID int64 `json:"skuId,omitempty"`
|
||||
OutSkuID string `json:"outSkuId,omitempty"`
|
||||
StationNo int64 `json:"stationNo,omitempty"`
|
||||
OutStationNo string `json:"outStationNo,omitempty"`
|
||||
PromotionPrice int64 `json:"promotionPrice"`
|
||||
LimitSkuCount int `json:"limitSkuCount,omitempty"`
|
||||
FailReason string `json:"failReason,omitempty"`
|
||||
}
|
||||
|
||||
func getPromotionCmd(inCmd string, promotionType int) (outCmd string) {
|
||||
if promotionType == PromotionTypeDirectDown {
|
||||
outCmd = "singlePromote/" + inCmd
|
||||
@@ -49,7 +59,7 @@ func (a *API) CreatePromotionInfosSingle(name string, beginDate, endDate time.Ti
|
||||
// 单品直降添加活动商品信息接口
|
||||
// 最多200条
|
||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=178&apiid=0ad0715e0aaa42489cbeac36398e916d
|
||||
func (a *API) CreatePromotionSkuSingle(infoId int64, outInfoId string, skus []map[string]interface{}) (skusResult []map[string]interface{}, err error) {
|
||||
func (a *API) CreatePromotionSkuSingle(infoId int64, outInfoId string, skus []*PromotionSku) (skusResult []*PromotionSku, err error) {
|
||||
return a.createPromotionSku(PromotionTypeDirectDown, infoId, outInfoId, skus)
|
||||
}
|
||||
|
||||
@@ -93,7 +103,7 @@ func (a *API) CreatePromotionRules(infoId int64, outInfoId string, limitDevice,
|
||||
// 限时抢添加活动商品信息接口
|
||||
// 最多200条
|
||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=184&apiid=65fecef4883c40c6b23bbdb6123f5d80
|
||||
func (a *API) CreatePromotionSkuLimitTime(infoId int64, outInfoId string, skus []map[string]interface{}) (skusResult []map[string]interface{}, err error) {
|
||||
func (a *API) CreatePromotionSkuLimitTime(infoId int64, outInfoId string, skus []*PromotionSku) (skusResult []*PromotionSku, err error) {
|
||||
return a.createPromotionSku(PromotionTypeLimitedTime, infoId, outInfoId, skus)
|
||||
}
|
||||
|
||||
@@ -130,7 +140,7 @@ func (a *API) createPromotionInfos(promotionType int, name string, beginDate, en
|
||||
}
|
||||
|
||||
// todo skusResult 返回值没有意义,为了兼容暂时保留
|
||||
func (a *API) createPromotionSku(promotionType int, infoId int64, outInfoId string, skus []map[string]interface{}) (skusResult []map[string]interface{}, err error) {
|
||||
func (a *API) createPromotionSku(promotionType int, infoId int64, outInfoId string, skus []*PromotionSku) (skusResult []*PromotionSku, err error) {
|
||||
jdParams := map[string]interface{}{
|
||||
"skus": skus,
|
||||
"timeStamp": utils.GetCurTimeStr(),
|
||||
@@ -140,8 +150,11 @@ func (a *API) createPromotionSku(promotionType int, infoId int64, outInfoId stri
|
||||
} else {
|
||||
jdParams[KeyOutInfoId] = outInfoId
|
||||
}
|
||||
_, err = a.AccessAPINoPage(getPromotionCmd("createPromotionSku", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "data", "", "0"))
|
||||
return nil, err
|
||||
result, err := a.AccessAPINoPage(getPromotionCmd("createPromotionSku", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0"))
|
||||
if err == nil {
|
||||
err = utils.Map2StructByJson(result, &skusResult, false)
|
||||
}
|
||||
return skusResult, err
|
||||
}
|
||||
|
||||
func (a *API) confirmPromotion(promotionType int, infoId int64, outInfoId string) (err error) {
|
||||
|
||||
Reference in New Issue
Block a user