From bf86176207eb0dabae3889109beb2c57d6bf0d59 Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期日, 24 十二月 2023 19:08:22 +0800 Subject: [PATCH] 11.27,9 --- cloud-server-management/src/main/java/com/dsh/guns/modular/system/util/PayMoneyUtil.java | 87 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 87 insertions(+), 0 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..e1874a2 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,84 @@ 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() { + 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); + } + } + }); + } /** * 支付宝支付 */ -- Gitblit v1.7.1