说明:
本帖是利用支付宝正式环境测试账号测试活动下架接口接口,请求中根据文档传入了必传参数,大家可以配置自己的环境,根据自己的需求严格按照文档要求添加相关的可选参数,此demo仅供参考
测试环境:Eclipse+JDK1.6及以上+Tomcat6.0及以上
通过活动下架接口下架需要提前停止的活动
koubei.marketing.campaign.activity.offline(活动下架接口)接口示例代码
package com.alipay.demo; import java.text.SimpleDateFormat;import java.util.Date;import java.util.Random;import com.alipay.api.AlipayApiException;import com.alipay.api.AlipayClient;import com.alipay.api.DefaultAlipayClient;import com.alipay.api.domain.KoubeiMarketingCampaignActivityOfflineModel;import com.alipay.api.request.KoubeiMarketingCampaignActivityOfflineRequest;import com.alipay.api.response.KoubeiMarketingCampaignActivityOfflineResponse;import com.alipay.config.AlipayConfig; public class koubeiMarketingCampaignActivityOffline { /** * koubei.marketing.campaign.activity.offline 活动下架接口 * * @param args * @throws AlipayApiException */ public static void main(String[] args) throws AlipayApiException { AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, AlipayConfig.format, AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type); KoubeiMarketingCampaignActivityOfflineRequest request = new KoubeiMarketingCampaignActivityOfflineRequest(); KoubeiMarketingCampaignActivityOfflineModel model = new KoubeiMarketingCampaignActivityOfflineModel(); model.setOutBizNo(getOutBizNo()); model.setCampId("20180314000000002575287000151333"); model.setReason("尾货下架"); // model.setExtInfo(extInfo); model.setOperatorId("2088501624560335"); model.setOperatorType("MER"); request.setBizModel(model); KoubeiMarketingCampaignActivityOfflineResponse response = alipayClient.execute(request); if (response.isSuccess()) { System.out.println("调用成功"); } else { System.out.println("调用失败"); } System.out.println(response.getBody()); } /** * 外部批次ID * * @return */ private static String getOutBizNo() { SimpleDateFormat simpleDateFormat; simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); Date date = new Date(); String str = simpleDateFormat.format(date); Random random = new Random(); int rannum = (int) (random.nextDouble() * (999 - 100 + 1)) + 100;// 获取5位随机数 return str + rannum;// 当前时间 } }
请求参数注意事项:
1.app_auth_token:ISV/开发者可以通过“第三方应用授权:[url]https://openclub.alipay.com/read.php?tid=1649[/url]得到商家授权令牌(app_auth_token)作为请求参数传入,实现代商家发起请求的能力;
2.camp_id(活动id)通过koubei.marketing.campaign.activity.create (活动创建接口):[url]https://openclub.alipay.com/read.php?tid=2638&fid=74[/url]调用成功同步返回
3.out_biz_no 外部批次ID,每次需传入不同的值
调用成功返回信息:
{"koubei_marketing_campaign_activity_offline_response":{"code":"10000","msg":"Success","camp_status":"CLOSING"},"sign":"pmhM2zu+mbht93dRbDfu+EqmNkkZCqHNJkIVU/Kl67mPttYmkzHMozK2f0hgkVIkA5Xk52SSNWSd8xSv6Yn5m4EtzzOkfMpsxLvS+OA5LH/V1752JGmEjQeVRH8f285VChdZtjmPrc46zMFpmNYkNJMwNLHd8s55Jq0mTs9GPkM="}
如有疑问欢迎跟帖提问,不足之处欢迎多多吐槽!!!