com.alipay.api.response.AlipayMobilePublicMessageCustomSendResponse Java Examples

The following examples show how to use com.alipay.api.response.AlipayMobilePublicMessageCustomSendResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlipayCoreService.java    From jeewx with Apache License 2.0 6 votes vote down vote up
public String sendMsg(final String responseMsg,String fromUserId){
	//update-begin--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
	// 1. 首先同步构建ACK响应
	String syncResponseMsg = AlipayMsgBuildUtil.buildBaseAckMsg(fromUserId,alipayAccountService.getAlipayConfig());
	//update-end--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
	// 2. 异步发送消息
	executors.execute(new Runnable() {
		@Override
		public void run() {
			try {
				//update-begin--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
				AlipayMobilePublicMessageCustomSendResponse response =JwSendMessageAPI.messageCustomSend(null, responseMsg,alipayAccountService.getAlipayConfig());
				//update-end--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
				if (null != response && response.isSuccess()) {
					System.out.println("异步发送成功,结果为:" + response.getBody());
				} else {
					System.out.println("异步发送失败 code=" + response.getCode() + "msg:" + response.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				System.out.println("异步发送失败");
			}
		}
	});
	return syncResponseMsg;
}
 
Example #2
Source File: JwSendMessageAPI.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
/**
 * 异步单发消息(文本)
 * 
 * @param appAuthToken
 *            商户授权后获取的app_auth_token
 * @param model
 * @return
 * @throws AlipayApiException
 */
@Deprecated
public static AlipayMobilePublicMessageCustomSendResponse messageCustomSendText(String appAuthToken, SendMessage model,AlipayConfig config) throws AlipayApiException {
	AlipayMobilePublicMessageCustomSendRequest request = new AlipayMobilePublicMessageCustomSendRequest();
	request.putOtherTextParam("app_auth_token", appAuthToken);
	String json = "";
	json = JSONObject.toJSONString(model);
	request.setBizContent(json);
	return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
 
Example #3
Source File: JwSendMessageAPI.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
/**
 * 异步单发消息(图文消息,支持6条)
 * 
 * @param appAuthToken
 *            商户授权后获取的app_auth_token
 * @param model
 * @return
 * @throws AlipayApiException
 */
@Deprecated
public static AlipayMobilePublicMessageCustomSendResponse messageCustomSendImageText(String appAuthToken, SendMessageImageText model,AlipayConfig config) throws AlipayApiException {
	AlipayMobilePublicMessageCustomSendRequest request = new AlipayMobilePublicMessageCustomSendRequest();
	request.putOtherTextParam("app_auth_token", appAuthToken);
	String json = "";
	json = JSONObject.toJSONString(model);
	request.setBizContent(json);
	return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}
 
Example #4
Source File: AlipayCoreService.java    From jeewx with Apache License 2.0 5 votes vote down vote up
/**
 * 消息发送方法
 * @param requestMsg
 * @param bizContent
 * @param requestMsg 收到的消息
 * @param type 消息类型:菜单点击,文本消息,用户关注等
 * @return
 */
private String sendMsg(final String responseMsg,JSONObject bizContent,final String requestMsg,String type){
	
	 // 取得发起请求的支付宝账号id
	final String fromUserId = bizContent.getString("FromUserId");
	// 1. 首先同步构建ACK响应
	String syncResponseMsg = AlipayMsgBuildUtil.buildBaseAckMsg(fromUserId,alipayAccountService.getAlipayConfig());
	// 2. 异步发送消息
	executors.execute(new Runnable() {
		@Override
		public void run() {
			try {
				AlipayMobilePublicMessageCustomSendResponse response =JwSendMessageAPI.messageCustomSend(null, responseMsg,alipayAccountService.getAlipayConfig());
				// 2.3 商户根据响应结果处理结果
				// 这里只是简单的打印,请商户根据实际情况自行进行处理
				AlipayReceivetext rt = new AlipayReceivetext();
		    	String randomSeed = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
		    	rt.setId(randomSeed);
				rt.setAccountid(SystemUtil.getOnlieAlipayAccountId());
				rt.setContent(requestMsg);
				rt.setCreatetime(new Date());
				rt.setFromusername(fromUserId);
				rt.setTousername(alipayAccountService.getAccount().getAccontName());
				rt.setMsgtype("文本消息");
				if (null != response && response.isSuccess()) {
					rt.setResponse("回复成功");
					System.out.println("异步发送成功,结果为:" + response.getBody());
				} else {
					rt.setResponse("回复失败");
					System.out.println("异步发送失败 code=" + response.getCode() + "msg:" + response.getMsg());
				}
				alipayReceivetextDao.insert(rt);
			} catch (Exception e) {
				e.printStackTrace();
				System.out.println("异步发送失败");
			}
		}
	});
	return syncResponseMsg;
}
 
Example #5
Source File: AlipayMobilePublicMessageCustomSendRequest.java    From alipay-sdk-java-all with Apache License 2.0 4 votes vote down vote up
public Class<AlipayMobilePublicMessageCustomSendResponse> getResponseClass() {
	return AlipayMobilePublicMessageCustomSendResponse.class;
}
 
Example #6
Source File: AlipayMobilePublicMessageCustomSendRequest.java    From alipay-sdk with Apache License 2.0 4 votes vote down vote up
public Class<AlipayMobilePublicMessageCustomSendResponse> getResponseClass() {
	return AlipayMobilePublicMessageCustomSendResponse.class;
}
 
Example #7
Source File: AlipayMobilePublicMessageCustomSendRequest.java    From pay with Apache License 2.0 4 votes vote down vote up
public Class<AlipayMobilePublicMessageCustomSendResponse> getResponseClass() {
	return AlipayMobilePublicMessageCustomSendResponse.class;
}
 
Example #8
Source File: InAlipayChatTextExecutor.java    From jeewx with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @see com.alipay.executor.ActionExecutor#execute()
 */
@Override
public String execute() throws MyException {

    //取得发起请求的支付宝账号id
    final String fromUserId = bizContent.getString("FromUserId");
  //update-begin--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
    //1. 首先同步构建ACK响应
    String syncResponseMsg = AlipayMsgBuildUtil.buildBaseAckMsg(fromUserId,alipayAccountService.getAlipayConfig());
  //update-end--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
    //2. 异步发送消息
    executors.execute(new Runnable() {
        @Override
        public void run() {
            try {
            	String content = bizContent.getJSONObject("Text").getString("Content");
            	AlipayReceivetext receiveText = new AlipayReceivetext();
            	receiveText.setContent(content);
            	String randomSeed = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
            	receiveText.setId(randomSeed);
            	receiveText.setAccountid(SystemUtil.getOnlieAlipayAccountId());
            	receiveText.setCreatetime(new Date());
            	receiveText.setCreateDate(new Date());
            	receiveText.setFromusername(fromUserId);
            	receiveText.setMsgtype(AlipayUtil.REQ_MESSAGE_TYPE_TEXT);
            	receiveText.setResponse("0");
            	receiveText.setNickname("");
            	//update-begin--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
                AlipayClient alipayClient = AlipayClientFactory.getAlipayClientInstance(alipayAccountService.getAlipayConfig());
              //update-end--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
                AlipayMobilePublicMessageCustomSendRequest request = new AlipayMobilePublicMessageCustomSendRequest();
                String requestMsg = alipayKeyWordDealInterfaceService.dealKeyMessage(content, alipayAccountService.getAccount().getId(),fromUserId);
                request.setBizContent(requestMsg);
                // 2.2 使用SDK接口类发送响应
                AlipayMobilePublicMessageCustomSendResponse response = alipayClient.execute(request);

                // 2.3 商户根据响应结果处理结果
                //这里只是简单的打印,请商户根据实际情况自行进行处理
                if (null != response && response.isSuccess()) {
                    System.out.println("异步发送成功,结果为:" + response.getBody());
                } else {
                    System.out.println("异步发送失败 code=" + response.getCode() + "msg:"
                                       + response.getMsg());
                }
            } catch (Exception e) {
            	e.printStackTrace();
                System.out.println("异步发送失败");
            }
        }
    });

    // 3.返回同步的ACK响应
    return syncResponseMsg;
}
 
Example #9
Source File: InAlipayDIYQRCodeEnterExecutor.java    From jeewx with Apache License 2.0 4 votes vote down vote up
/** 
 * @see com.alipay.executor.ActionExecutor#executor(java.util.Map)
 */
@Override
public String execute() throws MyException {
    //自身业务处理
    //理论上,自定义二维码会有sceneId设置,通过该id,开发者开始知道是哪个自定义二维码进入

    String syncResponseMsg = "";
    try {
        JSONObject actionParam = JSONObject.fromObject(bizContent.getString("ActionParam"));
        JSONObject scene = JSONObject.fromObject(actionParam.get("scene"));
        String sceneId = scene.getString("sceneId");
        System.out.println(sceneId);

        //取得发起请求的支付宝账号id
        final String fromUserId = bizContent.getString("FromUserId");
      //update-begin--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
        //1. 首先同步构建ACK响应
        syncResponseMsg = AlipayMsgBuildUtil.buildBaseAckMsg(fromUserId,alipayAccountService.getAlipayConfig());
      //update-end--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
        //2. 异步发送消息
        executors.execute(new Runnable() {
            @Override
            public void run() {
                try {

                    // 2.1 构建一个业务响应消息,开发者根据自行业务构建,这里只是一个简单的样例
                    String requestMsg = AlipayMsgBuildUtil.buildSingleImgTextMsg(fromUserId);
                  //update-begin--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
                    AlipayClient alipayClient = AlipayClientFactory.getAlipayClientInstance(alipayAccountService.getAlipayConfig());
                  //update-end--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
                    AlipayMobilePublicMessageCustomSendRequest request = new AlipayMobilePublicMessageCustomSendRequest();
                    request.setBizContent(requestMsg);

                    // 2.2 使用SDK接口类发送响应
                    AlipayMobilePublicMessageCustomSendResponse response = alipayClient
                        .execute(request);

                    // 2.3 开发者根据响应结果处理结果
                    //这里只是简单的打印,请开发者根据实际情况自行进行处理
                    if (null != response && response.isSuccess()) {
                        System.out.println("异步发送成功,结果为:" + response.getBody());
                    } else {
                        System.out.println("异步发送失败 code=" + response.getCode() + "msg:"
                                           + response.getMsg());
                    }
                } catch (Exception e) {
                    System.out.println("异步发送失败");
                }
            }
        });

    } catch (Exception exception) {
        throw new MyException("转换json错误,检查数据格式");
    }

    // 同步返回ACK响应
    return syncResponseMsg;
}
 
Example #10
Source File: InAlipayAsyncMsgSendExecutor.java    From jeewx with Apache License 2.0 4 votes vote down vote up
@Override
public String execute() {
    //取得发起请求的支付宝账号id
    final String fromUserId = bizContent.getString("FromUserId");
    
  //update-begin--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
    //1. 首先同步响应一个消息
    String syncResponseMsg = AlipayMsgBuildUtil.buildBaseAckMsg(fromUserId,alipayAccountService.getAlipayConfig());
  //update-end--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
    final String content = bizContent.getJSONObject("Text").getString("Content");
    //2. 异步发送消息
    executors.execute(new Runnable() {
        @Override
        public void run() {
            try {
            	AlipayReceivetext receiveText = new AlipayReceivetext();
            	receiveText.setContent(content);
            	String randomSeed = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
            	receiveText.setId(randomSeed);
            	receiveText.setAccountid(SystemUtil.getOnlieAlipayAccountId());
            	receiveText.setCreatetime(new Date());
            	receiveText.setCreateDate(new Date());
            	receiveText.setFromusername(fromUserId);
            	receiveText.setMsgtype(AlipayUtil.REQ_MESSAGE_TYPE_TEXT);
            	receiveText.setResponse("0");
            	receiveText.setNickname("");
            	//保存消息
            	textDealInterfaceService.dealTextMessage(receiveText);
            	//遍历关键字列表
                String requestMsg = AlipayMsgBuildUtil.buildSingleImgTextMsg(fromUserId);
              //update-begin--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
                AlipayClient alipayClient = AlipayClientFactory.getAlipayClientInstance(alipayAccountService.getAlipayConfig());
              //update-end--author:zhangjiaqiang Date:20161108 for:#1487 【开源项目】开源支付窗服务窗单公众号项目
                AlipayMobilePublicMessageCustomSendRequest request = new AlipayMobilePublicMessageCustomSendRequest();
                request.setBizContent(requestMsg);

                // 2.2 使用SDK接口类发送响应
                AlipayMobilePublicMessageCustomSendResponse response = alipayClient.execute(request);

                // 2.3 开发者根据响应结果处理结果
                //这里只是简单的打印,请开发者根据实际情况自行进行处理
                if (null != response && response.isSuccess()) {
                    System.out.println("异步发送成功,结果为:" + response.getBody());
                } else {
                    System.out.println("异步发送失败 code=" + response.getCode() + "msg:"
                                       + response.getMsg());
                }
            } catch (Exception e) {
                System.out.println("异步发送失败");
            }
        }
    });

    return syncResponseMsg;
}
 
Example #11
Source File: JwSendMessageAPI.java    From jeewx-api with Apache License 2.0 3 votes vote down vote up
/**
 * 异步单发消息(文本)
 * 
 * @param appAuthToken
 *            商户授权后获取的app_auth_token
 * @param model
 * @return
 * @throws AlipayApiException
 */
public static AlipayMobilePublicMessageCustomSendResponse messageCustomSend(String appAuthToken, String content,AlipayConfig config) throws AlipayApiException {
	AlipayMobilePublicMessageCustomSendRequest request = new AlipayMobilePublicMessageCustomSendRequest();
	request.putOtherTextParam("app_auth_token", appAuthToken);
	request.setBizContent(content);
	return AlipayClientFactory.getAlipayClientInstance(config).execute(request);
}