淘宝客获取促销价格API的示例

因为淘宝客商品获取接口中的价格是正常价格 ,但很多商品实际是按促销价销售的 ,下面是如何获取促销价格的代码(需要事先通过淘宝客推广商品接口查到商品 ID后,以商品ID作为查询参数 ):

public static String getPromotionPrice(String url,String appkey,String secret,long proId,String channel,HttpServletRequest request) throws ApiException, HttpException, IOException
{
String promPrice = "";
url = ServiceLocator.getSysConfigService().getStringValueByParmName("tbkUrl");
appkey = ServiceLocator.getSysConfigService().getStringValueByParmName("tbkAppkey");
secret = ServiceLocator.getSysConfigService().getStringValueByParmName("tbkSecret");
//taobao.ump.promotion.get
UmpPromotionGetRequest req=new UmpPromotionGetRequest();
req.setItemId(proId);
if(channel!=null&&channel.trim().length()>0)
{
req.setChannelKey(channel);
}
TaobaoClient client=new DefaultTaobaoClient(url, appkey, secret);

//获取折扣可以不使用sessionKey
UmpPromotionGetResponse response = client.execute(req , null);
PromotionDisplayTop top = response.getPromotions();
//商品优惠详情查询,可查询商品设置的详细优惠。包括限时折扣,满就送等官方优惠以及第三方优惠。
//下面是从列表查一个符合当前日期范围的促销价格

List<PromotionInItem> list = top.getPromotionInItem();
for(int i=0;i<list.size();i++)
{
PromotionInItem item = list.get(i);
Date startDt = item.getStartTime();
Date endDt = item.getEndTime();
Date currentDate = new Date(System.currentTimeMillis());
if(currentDate.after(startDt)&&currentDate.before(endDt))
{
promPrice = item.getItemPromoPrice();
//System.out.print(item.getItemPromoPrice());
break;
}
}
return promPrice;
}

本人最近上线了淘宝导购网站-托众导购网,地址http://www.tuozhong.com ,欢迎 大家到网站购物(直连淘宝天猫商城 ),注册后认领订单可以换取集分宝,推荐的会员购物后也可返集分宝 。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值