| | |
| | | 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.*; |
| | |
| | | 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); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | /** |
| | | * 支付宝支付 |
| | | */ |
| | |
| | | |
| | | |
| | | |
| | | // 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); |
| | | // } |
| | | |
| | | |
| | | |
| | | /** |