From 7e7f901b2172281dc294dfbc67e6ad00625f09f4 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期一, 04 三月 2024 10:11:21 +0800 Subject: [PATCH] 合并代码 --- cloud-server-management/src/main/java/com/dsh/guns/modular/system/util/PayMoneyUtil.java | 102 +++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 90 insertions(+), 12 deletions(-) diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/util/PayMoneyUtil.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/util/PayMoneyUtil.java index b9f7be4..d122afc 100644 --- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/util/PayMoneyUtil.java +++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/util/PayMoneyUtil.java @@ -7,13 +7,23 @@ import com.alipay.api.CertAlipayRequest; import com.alipay.api.DefaultAlipayClient; import com.alipay.api.domain.AlipayTradeAppPayModel; +import com.alipay.api.msg.AlipayMsgClient; +import com.alipay.api.msg.MsgHandler; import com.alipay.api.request.*; import com.alipay.api.response.*; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.dsh.guns.modular.system.model.OperatorAuthAlipay; +import com.dsh.guns.modular.system.model.OperatorUser; +import com.dsh.guns.modular.system.service.IOperatorAuthService; +import com.dsh.guns.modular.system.service.IOperatorUserService; +import org.apache.commons.lang3.StringUtils; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; + import javax.servlet.http.HttpServletRequest; import java.io.*; import java.util.*; @@ -47,7 +57,86 @@ private String alipay_root_cert_path = "C:/cert/alipay/user/alipay_root_cert_path.crt";//支付宝CA根证书文件路径 private String certPath = "C:\\cert\\1523106371_20211206_cert\\apiclient_cert.p12";//微信证书 + String signType = "RSA2" ; + String serverHost = "openchannel.alipay.com" ; + @Autowired + private IOperatorAuthService operatorAuthService; + @Autowired + private IOperatorUserService operatorUserService; + + /** + * 处理直付通审核通过和拒绝消息 + */ + public void getMessage() { + System.err.println("进入"); + final AlipayMsgClient alipayMsgClient = AlipayMsgClient.getInstance(aliAppid); + try { + alipayMsgClient.setConnector(serverHost); + } catch (Exception e) { + e.printStackTrace(); + } + alipayMsgClient.setSecurityConfig(signType, appPrivateKey, alipay_public_key); + try { + alipayMsgClient.connect(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + alipayMsgClient.setMessageHandler( new MsgHandler() { + /** + * 客户端接收到消息后回调此方法 + * @param msgApi 接收到的消息的消息api名 + * @param msgId 接收到的消息的消息id + * @param bizContent 接收到的消息的内容,json格式 + */ + public void onMessage (String msgApi, String msgId, String bizContent) { + // 直付通进件审核通过 + if (StringUtils.equals(msgApi,"ant.merchant.expand.indirect.zft.passed")){ + // 修改运营商状态 将返回的商户号填入运营商 + System.out.println( "receive message. msgApi:" + msgApi + " msgId:" + msgId + " bizContent:" + bizContent); + JSONObject json = JSONObject.parseObject(bizContent); + // 商户号 + String smid = json.getString("smid"); + // 审核备注信息 + String memo = json.getString("memo"); + // 订单id + String orderId = json.getString("order_id"); + // 通过订单id查询 + OperatorAuthAlipay auth = operatorAuthService.getOne(new QueryWrapper<OperatorAuthAlipay>() + .eq("orderNo",orderId)); + auth.setSmid(smid); + auth.setAuditState(2); + auth.setRefuseReason(memo); + operatorAuthService.updateById(auth); + Integer operatorId = auth.getOperatorId(); + OperatorUser operatorId1 = operatorUserService.getOne(new QueryWrapper<OperatorUser>() + .eq("operatorId", operatorId)); + operatorId1.setAlipayNum(smid); + operatorId1.setAlipayAudit(2); + operatorUserService.updateById(operatorId1); + } + // 直付通进件审核失败 + if (StringUtils.equals(msgApi,"ant.merchant.expand.indirect.zft.rejected")){ + JSONObject json = JSONObject.parseObject(bizContent); + // 商户号 + String orderId = json.getString("order_id"); + // 官方拒绝理由 + String reason = json.getString("reason"); + // 通过订单id查询 + OperatorAuthAlipay auth = operatorAuthService.getOne(new QueryWrapper<OperatorAuthAlipay>() + .eq("orderNo",orderId)); + auth.setAuditState(3); + auth.setRefuseReason(reason); + operatorAuthService.updateById(auth); + Integer operatorId = auth.getOperatorId(); + OperatorUser operatorId1 = operatorUserService.getOne(new QueryWrapper<OperatorUser>() + .eq("operatorId", operatorId)); + operatorId1.setAlipayAudit(3); + operatorUserService.updateById(operatorId1); + } + } + }); + } /** * 支付宝支付 */ @@ -242,18 +331,7 @@ -// public static void main(String[] ages){ -// PayMoneyUtil payMoneyUtil = new PayMoneyUtil(); -// ResultUtil ce = payMoneyUtil.alipay("测试", "测试", "", "121456457", "10", "http://123.com"); -// System.err.println(ce); -// ResultUtil resultUtil = null; -// try { -// resultUtil = payMoneyUtil.queryALIOrder("121456457"); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// System.err.println(resultUtil); -// } + /** -- Gitblit v1.7.1