微信公眾號開發===訊息推送_NotifyPushFlower程式碼(2)
阿新 • • 發佈:2019-01-17
package com.igoxin.template; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; import javax.servlet.http.HttpServletRequest; import net.sf.json.JSONObject; /* * * * {{first.DATA}} 支付金額:{{orderMoneySum.DATA}} 商品資訊:{{orderProductName.DATA}} {{Remark.DATA}} {{first.DATA}} 訂單編號:{{keyword1.DATA}} 物流公司:{{keyword2.DATA}} 物流單號:{{keyword3.DATA}} {{remark.DATA}} */ public class NotifyPushFlower { private static final String JUMPURL = "http://packsale.gocent.net/index.html#/tab/index?"; // groupBuyingId=' + $scope.groupBuyingId + '&sharerId=' + // $scope.shareData.groupBuyingVO.templateId + '&ctrl=4&openid=authOpenid"; /** * 支付成功通知 * * @param request * @return */ public static JSONObject paySuccess(Map<String, Object> map) { String openid = (String) map.get("openid"); String title = (String) map.get("title"); String money = (String) map.get("money"); String productName = (String) map.get("productName"); String packedSaleId = (String) map.get("packedSaleId"); //鮮花 String template_id = "1fPU9z0qE8kqoT48uk12evBkleRCwnEsyFRPlPE_VWg"; System.out.println("NotifyPushFlower==========openid="+openid); StringBuffer buffer = new StringBuffer(); buffer.append(JUMPURL).append("packedSaleId").append("=").append(packedSaleId).append("&").append("ctrl").append("=").append("2").append("&") .append("openid").append("=").append("authOpenid"); String url = buffer.toString(); JSONObject jsonObject = new JSONObject(); jsonObject.put("touser", openid); jsonObject.put("template_id", template_id); jsonObject.put("url", url); JSONObject subJson = new JSONObject(); JSONObject first = new JSONObject(); first.put("value", title); first.put("color", "#173177"); subJson.put("first", first); //支付金額 JSONObject keynote1 = new JSONObject(); keynote1.put("value", money); keynote1.put("color", "#173177"); subJson.put("orderMoneySum", keynote1); //商品資訊 JSONObject keynote2 = new JSONObject(); keynote2.put("value",productName); //productName keynote2.put("color", "#173177"); subJson.put("orderProductName", keynote2); jsonObject.put("data", subJson); System.out.println("flower - pushTemplateMsg=====================" + jsonObject.toString()); return jsonObject; } /** * 發貨通知 * * @param request * @return */ public static JSONObject deliverGoods(Map<String, Object> request) { String openid = (String) request.get("openid"); String title = (String) request.get("title"); String orderNum = (String) request.get("orderNum"); String expressName = (String) request.get("expressName"); String expressNum = (String) request.get("expressNum"); String packedSaleId = (String) request.get("packedSaleId"); String forwardId = (String) request.get("forwardId"); // String template_id = "P4uUvOSAwHJ_kwfuSYirhlTTjOC4i3Tk-o5uDUHmorM"; String template_id = "lDa-F-7rgS51W3RxzcIEFp5c03KsF3yJ7FZojhUUBj8"; StringBuffer buffer = new StringBuffer(); buffer.append(JUMPURL).append("packedSaleId").append("=").append(packedSaleId).append("&").append("sharerId") .append("=").append("0").append("&").append("ctrl").append("=").append("5").append("&") .append("openid").append("=").append("authOpenid").append("&").append("forwardId").append("=").append(forwardId); String url = buffer.toString(); JSONObject jsonObject = new JSONObject(); jsonObject.put("touser", openid); jsonObject.put("template_id", template_id); jsonObject.put("url", url); JSONObject subJson = new JSONObject(); JSONObject first = new JSONObject(); first.put("value", title); first.put("color", "#173177"); subJson.put("first", first); JSONObject keynote1 = new JSONObject(); keynote1.put("value", orderNum); keynote1.put("color", "#173177"); subJson.put("keyword1", keynote1); JSONObject keynote2 = new JSONObject(); keynote2.put("value", expressName); keynote2.put("color", "#173177"); subJson.put("keyword2", keynote2); JSONObject keynote3 = new JSONObject(); keynote3.put("value", expressNum); keynote3.put("color", "#173177"); subJson.put("keyword3", keynote3); jsonObject.put("data", subJson); return jsonObject; } /** * 訂單支付成功 * * @param request * @return */ public static JSONObject orderPay(HttpServletRequest request) { return null; } /** * 組團失敗 * * @param request * @return */ public static JSONObject groupFail(HttpServletRequest request) { return null; } /** * 拼團失敗退款 * * @param request * @return */ public static JSONObject refund(HttpServletRequest request) { return null; } /** * 組團 - 成功 */ public static JSONObject paySuccessTest(Map<String, Object> map) { String openid = (String) map.get("openid"); String titleTip = (String) map.get("titleTip"); String joinNum = (String) map.get("joinNum"); String productName = (String) map.get("productName"); String groupTime = (String) map.get("groupTime"); String tip = (String) map.get("remark"); String groupBuyingId = (String) map.get("groupBuyingId"); String sharerId = (String) map.get("sharerId"); //鮮花 String template_id = "1fPU9z0qE8kqoT48uk12evBkleRCwnEsyFRPlPE_VWg"; // String template_id = "WzDO7PABr2hlx7eFaLX4-HdCs1r55sNi1rG3zBaS-h8"; StringBuffer buffer = new StringBuffer(); buffer.append(JUMPURL).append("groupBuyingId").append("=").append(groupBuyingId).append("&").append("sharerId") .append("=").append(sharerId).append("&").append("ctrl").append("=").append("1").append("&") .append("openid").append("=").append("authOpenid"); String url = buffer.toString(); JSONObject jsonObject = new JSONObject(); jsonObject.put("touser", openid); jsonObject.put("template_id", template_id); jsonObject.put("url", url); JSONObject subJson = new JSONObject(); JSONObject first = new JSONObject(); first.put("value", titleTip); first.put("color", "#173177"); subJson.put("first", first); JSONObject keynote1 = new JSONObject(); keynote1.put("value", productName); keynote1.put("color", "#173177"); subJson.put("keyword1", keynote1); JSONObject keynote2 = new JSONObject(); keynote2.put("value", joinNum); keynote2.put("color", "#173177"); subJson.put("keyword2", keynote2); JSONObject keynote3 = new JSONObject(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); keynote3.put("value", format.format(new Date(Long.parseLong(groupTime)))); keynote3.put("color", "#173177"); subJson.put("keyword3", keynote3); JSONObject remark = new JSONObject(); remark.put("value", tip); remark.put("color", "#173177"); subJson.put("remark", remark == null ? "" : remark); jsonObject.put("data", subJson); System.out.println("pushTemplateMsg=====================" + jsonObject.toString()); return jsonObject; } }