- 重构京东活动API
This commit is contained in:
@@ -29,27 +29,6 @@ const (
|
||||
PromotionStateEnded = 9
|
||||
)
|
||||
|
||||
type PromotionSkuResult struct {
|
||||
LimitDaily int
|
||||
LimitDevice int
|
||||
LimitPin int
|
||||
PlatformRatio int
|
||||
PromotionPrice int
|
||||
SkuId int64
|
||||
StationNo int64
|
||||
StoreRatio int
|
||||
}
|
||||
|
||||
type PromotionInfo struct {
|
||||
BeginTime time.Time
|
||||
EndTime time.Time
|
||||
PromotionInfoId int64
|
||||
PromotionState int
|
||||
PromotionType int
|
||||
Source string
|
||||
SkuResultList []*PromotionSkuResult
|
||||
}
|
||||
|
||||
func getPromotionCmd(inCmd string, promotionType int) (outCmd string) {
|
||||
if promotionType == PromotionTypeDirectDown {
|
||||
outCmd = "singlePromote/" + inCmd
|
||||
@@ -190,39 +169,3 @@ func (a *API) cancelPromotion(promotionType int, infoId int64, outInfoId string)
|
||||
_, err = a.AccessAPINoPage(getPromotionCmd("cancelPromotion", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0"))
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *API) QueryPromotionInfo(promotionInfoId int64) (promotionInfo *PromotionInfo, err error) {
|
||||
jdParams := map[string]interface{}{
|
||||
"promotionInfoId": promotionInfoId,
|
||||
}
|
||||
result, err := a.AccessAPINoPage("singlePromote/queryPromotionInfo", jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0"))
|
||||
if err == nil {
|
||||
data := result.(map[string]interface{})
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(data, false))
|
||||
promotionInfo = &PromotionInfo{
|
||||
BeginTime: utils.Timestamp2Time(utils.MustInterface2Int64(data["beginTime"].(map[string]interface{})["time"]) / 1000),
|
||||
EndTime: utils.Timestamp2Time(utils.MustInterface2Int64(data["endTime"].(map[string]interface{})["time"]) / 1000),
|
||||
PromotionInfoId: utils.MustInterface2Int64(data["promotionInfoId"]),
|
||||
PromotionState: int(utils.MustInterface2Int64(data["promotionState"])),
|
||||
PromotionType: int(utils.MustInterface2Int64(data["promotionType"])),
|
||||
Source: utils.Interface2String(data["source"]),
|
||||
}
|
||||
skuResultList := data["skuResultList"].([]interface{})
|
||||
promotionInfo.SkuResultList = make([]*PromotionSkuResult, len(skuResultList))
|
||||
for k, v := range skuResultList {
|
||||
skuResult := v.(map[string]interface{})
|
||||
promotionInfo.SkuResultList[k] = &PromotionSkuResult{
|
||||
LimitDaily: int(utils.MustInterface2Int64(skuResult["limitDaily"])),
|
||||
LimitDevice: int(utils.MustInterface2Int64(skuResult["limitDevice"])),
|
||||
LimitPin: int(utils.MustInterface2Int64(skuResult["limitPin"])),
|
||||
PlatformRatio: int(utils.MustInterface2Int64(skuResult["platformRatio"])),
|
||||
PromotionPrice: int(utils.MustInterface2Int64(skuResult["promotionPrice"])),
|
||||
SkuId: utils.MustInterface2Int64(skuResult["skuId"]),
|
||||
StationNo: utils.MustInterface2Int64(skuResult["stationNo"]),
|
||||
StoreRatio: int(utils.MustInterface2Int64(skuResult["storeRatio"])),
|
||||
}
|
||||
}
|
||||
return promotionInfo, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user