官方接口文档:https://docs.open.alipay.com/199/105250/
接口描述:对于已经创建的模板,如果需要修改模板内容,可通过该接口修改,适用于修改模板内容。对于已经发布的模板,如果需要修改内容并同步到用户端,则应使用更新卡券接口 调用这个接口前,你肯定是先创建模板了的,
创建模板接口参考该帖:https://openclub.alipay.com/read.php?tid=2135&fid=8
下面我们主要讲更新模板接口,其核心代码
//alipay.pass.template.update 更新模板
public static void passtemplateupdate(){
AlipayClient alipayClient=alipayclient();
AlipayPassTemplateUpdateRequest request = new AlipayPassTemplateUpdateRequest();
request.setBizContent(
"{\"tpl_id\":\"2017082810350676154413356\","
+ "\"tpl_content\":"
+ "{\"logo\":\"https://alipass.alipay.com//temps/free/logo.png\","
+ "\"strip\":\"https://alipass.alipay.com//temps/free/strip.png\","
+"\"icon\":\"http://alipassprod.test.alipay.net/temps/free/icon.png\","
+ "\"content\":"
+ "{\"evoucherInfo\":"
+ "{\"title\":\"九月一号更新卡券模板优惠券\",\"type\":\"coupon\",\"product\":\"free\",\"startDate\":\"$validStartDate$\",\"endDate\":\"$validEndDate$\",\"operation\":"
+ "[{\"format\":\"barcode\",\"message\":\"45612346579465\",\"messageEncoding\":\"UTF-8\",\"altText\":\"45612346579465\"}],"
+ "\"einfo\":{"
+ "\"logoText\":\"$logoText$\","
+ "\"headFields\":"
+ "[{\"key\":\"status\",\"label\":\"状态\",\"value\":\"$useStateDesc$\",\"type\":\"text\"}],"
+ "\"primaryFields\":"
+ "[{\"key\":\"strip\",\"label\":\"\",\"value\":\"$discountInfo$\",\"type\":\"text\"}],"
+ "\"secondaryFields\":"
+ "[{\"key\":\"validDate\",\"label\":\"有效期至:\",\"value\":\"$validEndDate$\",\"type\":\"text\"}],"
+ "\"auxiliaryFields\":[],"
+ "\"backFields\":"
+ "[{\"key\":\"description\",\"label\":\"详情描述\",\"value\":\"1.该优惠有效期:截止至2024年06月18日;\
2.凭此券可以享受以下优惠:\
享门市价优惠\
不与其他优惠同享。详询商家。\",\"type\":\"text\"},"
+ "{\"key\":\"shops\",\"label\":\"可用门店\",\"value\":\"\",\"type\":\"text\"},"
+ "{\"key\":\"disclaimer\",\"label\":\"负责声明\",\"value\":\"除特殊注明外,本优惠不能与其他优惠同时享受;本优惠最终解释权归商家所有,如有疑问请与商家联系。提示:为了使您得到更好的服务,请在进店时出示本券。\",\"type\":\"text\"}"
+ "]},"
+ "\"remindInfo\":"
+ "{\"offset\":\"2\"}},"
+ "\"merchant\":{\"mname\":\"hodewu\",\"mtel\":\"\",\"minfo\":\"\"},"
+ "\"platform\":{\"channelID\":\"$channelID$\",\"webServiceUrl\":\"\"},"
+ "\"style\":{\"backgroundColor\":\"RGB(255,126,0)\"},"
+ "\"fileInfo\":{\"formatVersion\":\"2\",\"canShare\":true,\"canBuy\":false,\"canPresent\":true,\"serialNumber\":\"$serialNumber$\",\"supportTaxi\":\"true\",\"taxiSchemaUrl\":\"alipays://platformapi/startapp?appId=20000130&sourceId=20000030&showTitleBar=YES&showToolBar=NO&showLoading=NO&safePayEnabled=YES&readTitle=YES&backBehavior=back&url=/www/index.html\"},"
+ "\"appInfo\":{\"app\":{},\"label\":\"\",\"message\":\"\"},"
+ "\"source\":\"alipassprod\","
+ "\"alipayVerify\":[]"
+ "}}}");
AlipayPassTemplateUpdateResponse response=null;
try {
response = alipayClient.execute(request);
System.out.println(response.getBody());
} catch (AlipayApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(response.isSuccess()){
System.out.println("调用成功");
} else {
System.out.println("调用失败");
}
}
然后接口同步返回信息如下:
{"alipay_pass_template_update_response":{"code":"10000","msg":"Success","result":"{\"errorCode\":\"KP.AE_SUCCESS\",\"errorMsg\":\"处理成功\",\"tpl_id\":\"2017082810350676154413356\",\"tpl_params\":[\"useStateDesc\",\"logoText\",\"discountInfo\",\"validEndDate\",\"validStartDate\",\"serialNumber\",\"channelID\"]}","success":true},"sign":"p/YPQDKLmJJy2l8Qa2F1eqqvFu8R1oHh/HspfHY4n2uOYThmhJ/p8MjCS+H8B6XiY09pCtfCI5uPBGEwU5xVdsibWJw2D03+3B+lQ/UIvo9hbhUck+f0QmY0IvHzQAWZIwo1ktSyWiG2BeCucMvZK+lv99kndDSEmr8ZRSUQKHw="}
注意点:
1.tpl_id即为需要修改的模板id,从创建模板接口中调用成功之后获取
2.tpl_content即为创建模板是的json内容,该字段的全部内容可复制之前创建接口的内容过来并修改其中你要的参数即可