企业在线充值新增支付宝充值

master
jianghaiqing 12 months ago
parent c9c0962dba
commit eee6fca395

@ -100,6 +100,16 @@
<artifactId>commons-logging</artifactId> <artifactId>commons-logging</artifactId>
<version>1.2</version> <version>1.2</version>
</dependency> </dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.14.2</version>
</dependency>
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.38.61.ALL</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -0,0 +1,154 @@
package com.payment.djypaymentplat.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @Description TODO
* @Author JHQ
* @Date 2023/12/12 15:37
*/
@Component
@ConfigurationProperties(prefix = "alipay",ignoreUnknownFields = false)
public class AliPayConfig {
/** 支付宝网关 */
public String gatewayUrl;
/** 商家APPID */
public String appId;
/** 商户私钥 */
public String merchantPrivateKeyPath;
/** 字符编码格式 */
public String charset;
/** 签名方式 */
public String signType;
/** 服务器异步通知 */
public String noticeUrl;
/** 大简云回写地址 */
public String djyNoticeUrl;
/** 应用公钥证书路径 */
public String appCertPath;
/** 支付宝公钥证书路径 */
public String alipayCertPath;
/** 支付宝根证书路径 */
public String alipayRootCertPath;
/** 支付宝网关 */
public void setGatewayUrl(String gatewayUrl) {
this.gatewayUrl = gatewayUrl;
}
/** 商家APPID */
public void setAppId(String appId) {
this.appId = appId;
}
/** 商户私钥 */
public void setMerchantPrivateKeyPath(String merchantPrivateKeyPath) {
this.merchantPrivateKeyPath = merchantPrivateKeyPath;
}
/** 字符编码格式 */
public void setCharset(String charset) {
this.charset = charset;
}
/** 签名方式 */
public void setSignType(String signType) {
this.signType = signType;
}
/** 服务器异步通知 */
public void setNoticeUrl(String noticeUrl) {
this.noticeUrl = noticeUrl;
}
/** 大简云回写地址 */
public void setDjyNoticeUrl(String djyNoticeUrl) {
this.djyNoticeUrl = djyNoticeUrl;
}
/** 应用公钥证书路径 */
public void setAppCertPath(String appCertPath) {
this.appCertPath = appCertPath;
}
/** 支付宝公钥证书路径 */
public void setAlipayCertPath(String alipayCertPath) {
this.alipayCertPath = alipayCertPath;
}
/** 支付宝根证书路径 */
public void setAlipayRootCertPath(String alipayRootCertPath) {
this.alipayRootCertPath = alipayRootCertPath;
}
/** 支付宝网关 */
public String GatewayUrl() {
return gatewayUrl;
}
/** 商家APPID */
public String AppId() {
return appId;
}
/** 商户私钥 */
public String MerchantPrivateKeyPath() {
return merchantPrivateKeyPath;
}
/** 字符编码格式 */
public String CharSet() {
return charset;
}
/** 签名方式 */
public String SignType() {
return signType;
}
/** 服务器异步通知 */
public String NoticeUrl() {
return noticeUrl;
}
/** 大简云回写地址 */
public String DjyNoticeUrl() {
return djyNoticeUrl;
}
/** 应用公钥证书路径 */
public String AppCertPath() {
return appCertPath;
}
/** 支付宝公钥证书路径 */
public String AlipayCertPath() {
return alipayCertPath;
}
/** 支付宝根证书路径 */
public String AlipayRootCertPath() {
return alipayRootCertPath;
}
}

@ -30,6 +30,9 @@ public class WeixinPayConfig {
/** 通知接收地址 **/ /** 通知接收地址 **/
public String noticeUrl; public String noticeUrl;
/** 大简云回写地址 */
public String djyNoticeUrl;
/** 商户号 */ /** 商户号 */
public void setMerchantId(String merchantId) { public void setMerchantId(String merchantId) {
this.merchantId = merchantId; this.merchantId = merchantId;
@ -63,6 +66,11 @@ public class WeixinPayConfig {
this.noticeUrl = noticeUrl; this.noticeUrl = noticeUrl;
} }
/** 大简云回写地址 */
public void setDjyNoticeUrl(String djyNoticeUrl) {
this.djyNoticeUrl = djyNoticeUrl;
}
/** 商户号 */ /** 商户号 */
public String MerchantId() { public String MerchantId() {
return merchantId; return merchantId;
@ -93,4 +101,8 @@ public class WeixinPayConfig {
return noticeUrl; return noticeUrl;
} }
/** 大简云回写地址 */
public String DjyNoticeUrl() {
return djyNoticeUrl;
}
} }

@ -37,4 +37,12 @@ public class CompanyChargeOrderMessageMainInfo {
/** 充值企业名称 */ /** 充值企业名称 */
@ApiModelProperty("充值企业名称") @ApiModelProperty("充值企业名称")
public String companyName; public String companyName;
/** 充值业务单号 */
@ApiModelProperty("充值业务单号")
public String businessId;
/** 支付接口 WEIXIN-微信支付ALIPAY-支付宝 */
@ApiModelProperty("支付接口代码")
public String payApiCode;
} }

@ -17,4 +17,7 @@ public class CompanyChargeResult {
/** 生成200*200的二维码BASE64字符 */ /** 生成200*200的二维码BASE64字符 */
public String imgBase64; public String imgBase64;
/** 阿里支付Form展示链接 */
public String alipayFormAction;
} }

@ -1,9 +1,7 @@
package com.payment.djypaymentplat.mapper; package com.payment.djypaymentplat.mapper;
import com.payment.djypaymentplat.model.PayOrderInfo; import com.payment.djypaymentplat.model.PayOrderInfo;
import org.springframework.stereotype.Repository;
@Repository
public interface PayOrderInfoMapper { public interface PayOrderInfoMapper {
int deleteByPrimaryKey(String pkId); int deleteByPrimaryKey(String pkId);

@ -1,9 +1,7 @@
package com.payment.djypaymentplat.mapper; package com.payment.djypaymentplat.mapper;
import com.payment.djypaymentplat.model.PayOrderQrcode; import com.payment.djypaymentplat.model.PayOrderQrcode;
import org.springframework.stereotype.Repository;
@Repository
public interface PayOrderQrcodeMapper { public interface PayOrderQrcodeMapper {
int deleteByPrimaryKey(String pkId); int deleteByPrimaryKey(String pkId);

@ -131,6 +131,20 @@ public class PayOrderInfo implements Serializable {
*/ */
private String completeType; private String completeType;
/**
*
*
* @mbg.generated
*/
private String senderKey;
/**
* ID
*
* @mbg.generated
*/
private String senderPkid;
/** /**
* *
* *
@ -340,6 +354,22 @@ public class PayOrderInfo implements Serializable {
this.completeType = completeType; this.completeType = completeType;
} }
public String getSenderKey() {
return senderKey;
}
public void setSenderKey(String senderKey) {
this.senderKey = senderKey;
}
public String getSenderPkid() {
return senderPkid;
}
public void setSenderPkid(String senderPkid) {
this.senderPkid = senderPkid;
}
public Date getCreatedtime() { public Date getCreatedtime() {
return createdtime; return createdtime;
} }
@ -436,6 +466,8 @@ public class PayOrderInfo implements Serializable {
sb.append(", beforeChargeAmount=").append(beforeChargeAmount); sb.append(", beforeChargeAmount=").append(beforeChargeAmount);
sb.append(", isComplete=").append(isComplete); sb.append(", isComplete=").append(isComplete);
sb.append(", completeType=").append(completeType); sb.append(", completeType=").append(completeType);
sb.append(", senderKey=").append(senderKey);
sb.append(", senderPkid=").append(senderPkid);
sb.append(", createdtime=").append(createdtime); sb.append(", createdtime=").append(createdtime);
sb.append(", updatedtime=").append(updatedtime); sb.append(", updatedtime=").append(updatedtime);
sb.append(", createduserid=").append(createduserid); sb.append(", createduserid=").append(createduserid);

@ -17,6 +17,13 @@ public class PayOrderQrcode implements Serializable {
*/ */
private String qrcodeImg; private String qrcodeImg;
/**
* FROM
*
* @mbg.generated
*/
private String formActionUrl;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public String getPkId() { public String getPkId() {
@ -35,6 +42,14 @@ public class PayOrderQrcode implements Serializable {
this.qrcodeImg = qrcodeImg; this.qrcodeImg = qrcodeImg;
} }
public String getFormActionUrl() {
return formActionUrl;
}
public void setFormActionUrl(String formActionUrl) {
this.formActionUrl = formActionUrl;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -43,6 +58,7 @@ public class PayOrderQrcode implements Serializable {
sb.append("Hash = ").append(hashCode()); sb.append("Hash = ").append(hashCode());
sb.append(", pkId=").append(pkId); sb.append(", pkId=").append(pkId);
sb.append(", qrcodeImg=").append(qrcodeImg); sb.append(", qrcodeImg=").append(qrcodeImg);
sb.append(", formActionUrl=").append(formActionUrl);
sb.append(", serialVersionUID=").append(serialVersionUID); sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();

@ -55,4 +55,7 @@ public interface ICompanyChargeService {
* @date 2023/12/7 15:02 * @date 2023/12/7 15:02
**/ **/
public OutResultInfo PushPaymentNotice(HttpServletRequest request, HttpServletResponse response); public OutResultInfo PushPaymentNotice(HttpServletRequest request, HttpServletResponse response);
public void TestSendDJY();
} }

@ -1,10 +1,17 @@
package com.payment.djypaymentplat.service.impl; package com.payment.djypaymentplat.service.impl;
import com.alipay.api.*;
import com.alipay.api.domain.AlipayTradeAppPayModel;
import com.alipay.api.domain.AlipayTradePagePayModel;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.response.AlipayTradePagePayResponse;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.QRCodeWriter;
import com.payment.djypaymentplat.config.AliPayConfig;
import com.payment.djypaymentplat.config.WeixinPayConfig; import com.payment.djypaymentplat.config.WeixinPayConfig;
import com.payment.djypaymentplat.domain.*; import com.payment.djypaymentplat.domain.*;
import com.payment.djypaymentplat.mapper.PayOrderInfoMapper; import com.payment.djypaymentplat.mapper.PayOrderInfoMapper;
@ -12,12 +19,14 @@ import com.payment.djypaymentplat.mapper.PayOrderQrcodeMapper;
import com.payment.djypaymentplat.model.PayOrderInfo; import com.payment.djypaymentplat.model.PayOrderInfo;
import com.payment.djypaymentplat.model.PayOrderQrcode; import com.payment.djypaymentplat.model.PayOrderQrcode;
import com.payment.djypaymentplat.service.ICompanyChargeService; import com.payment.djypaymentplat.service.ICompanyChargeService;
import com.payment.djypaymentplat.util.AliPayUtil;
import com.payment.djypaymentplat.util.HttpUtils; import com.payment.djypaymentplat.util.HttpUtils;
import com.payment.djypaymentplat.util.WechatPay2ValidatorForRequest; import com.payment.djypaymentplat.util.WechatPay2ValidatorForRequest;
import com.payment.djypaymentplat.util.WeixinPayUtil; import com.payment.djypaymentplat.util.WeixinPayUtil;
import com.wechat.pay.contrib.apache.httpclient.util.AesUtil; import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
import com.wechat.pay.java.service.payments.model.Transaction; import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.payments.nativepay.model.*; import com.wechat.pay.java.service.payments.nativepay.model.*;
import okhttp3.*;
import org.apache.catalina.servlet4preview.http.HttpServletRequest; import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -30,6 +39,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.GeneralSecurityException; import java.security.GeneralSecurityException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -69,6 +80,11 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
@Autowired @Autowired
private WeixinPayUtil weixinPayUtil; private WeixinPayUtil weixinPayUtil;
@Autowired
private AliPayUtil aliPayUtil;
@Autowired
private AliPayConfig aliPayConfig;
@PostMapping("/createorder") @PostMapping("/createorder")
@Override @Override
@ -82,13 +98,24 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
orderInfo.setPkId(UUID.randomUUID().toString().replace("-", "")); orderInfo.setPkId(UUID.randomUUID().toString().replace("-", ""));
orderInfo.setAmount(model.main.amount); orderInfo.setAmount(model.main.amount);
if(model.main.payApiCode.equals("WEIXIN"))
{
orderInfo.setAppId(wexinConfig.Appid()); orderInfo.setAppId(wexinConfig.Appid());
orderInfo.setMchId(wexinConfig.MerchantId()); orderInfo.setMchId(wexinConfig.MerchantId());
}
else if(model.main.payApiCode.equals("ALIPAY"))
{
orderInfo.setAppId(aliPayConfig.AppId());
}
orderInfo.setDescription(model.main.notes); orderInfo.setDescription(model.main.notes);
orderInfo.setCurrency(model.main.currency); orderInfo.setCurrency(model.main.currency);
orderInfo.setCreateduserid(model.main.operatorId); orderInfo.setCreateduserid(model.main.operatorId);
orderInfo.setCreatedusername(model.main.operatorName); orderInfo.setCreatedusername(model.main.operatorName);
orderInfo.setStatus("WAIT"); orderInfo.setStatus("WAIT");
orderInfo.setSenderKey(model.head.senderKey);
orderInfo.setSenderPkid(model.main.businessId);
Date nowDate = new Date(); Date nowDate = new Date();
try { try {
@ -102,28 +129,11 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
payOrderInfoMapper.insert(orderInfo); payOrderInfoMapper.insert(orderInfo);
PayOrderInfo payOrder = payOrderInfoMapper.selectByPrimaryKey(orderInfo.getPkId()); PayOrderInfo payOrder = payOrderInfoMapper.selectByPrimaryKey(orderInfo.getPkId());
/*
10.1
2
3
*/
// 初始化商户配置
/*
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(wexinConfig.MerchantId())
// 使用 com.wechat.pay.java.core.util 中的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
.privateKeyFromPath(wexinConfig.PrivateKeyPath())
.merchantSerialNumber(wexinConfig.MerchantSerialNumber())
.apiV3Key(wexinConfig.ApiV3Key())
.build();
service = new NativePayService.Builder().config(config).build();
*/
String getCodeUrl = "";
String alipayFormAct = "";
if(model.main.payApiCode.equals("WEIXIN")) {
PrepayRequest request = new PrepayRequest(); PrepayRequest request = new PrepayRequest();
request.setAppid(wexinConfig.Appid()); request.setAppid(wexinConfig.Appid());
@ -142,19 +152,59 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
// 调用接口 // 调用接口
PrepayResponse preRlt = weixinPayUtil.getNativePayService().prepay(request); PrepayResponse preRlt = weixinPayUtil.getNativePayService().prepay(request);
log.info("支付返回={}", gson.toJson(preRlt));
if (preRlt != null && preRlt.getCodeUrl() != "") {
getCodeUrl = preRlt.getCodeUrl();
}
}else if(model.main.payApiCode.equals("ALIPAY")){
AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
AlipayTradePagePayModel aliPayModel = new AlipayTradePagePayModel();
//aliPayModel.setBody("我是测试数据");
aliPayModel.setSubject(model.main.notes);
aliPayModel.setOutTradeNo(payOrder.getOrderNo());
aliPayModel.setTimeoutExpress("60m");
aliPayModel.setTotalAmount(model.main.amount.setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
aliPayModel.setProductCode("FAST_INSTANT_TRADE_PAY");
aliPayModel.setQrPayMode("4");
alipayRequest.setBizModel(aliPayModel);
alipayRequest.setNotifyUrl(aliPayConfig.DjyNoticeUrl());
CertAlipayRequest certAlipayRequest = new CertAlipayRequest ();
try
{
AlipayClient alipayClient = aliPayUtil.getAlipayClient();
AlipayTradePagePayResponse aliPayResult = alipayClient.pageExecute(alipayRequest,"GET");
log.info("请求支付宝下单后返回结果body={}",aliPayResult.getBody());
if(aliPayResult.isSuccess())
{
alipayFormAct = aliPayResult.getBody();
}
}
catch (AlipayApiException e)
{
e.printStackTrace();
}
}
CompanyChargeResult chargeRlt = new CompanyChargeResult(); CompanyChargeResult chargeRlt = new CompanyChargeResult();
chargeRlt.excuteDate = sdf.format(nowDate); chargeRlt.excuteDate = sdf.format(nowDate);
chargeRlt.orderNo = payOrder.getOrderNo(); chargeRlt.orderNo = payOrder.getOrderNo();
log.info("支付返回={}", gson.toJson(preRlt)); if(!StringUtils.isEmpty(getCodeUrl) || !StringUtils.isEmpty(alipayFormAct)){
if(preRlt != null && preRlt.getCodeUrl() != ""){ if(!StringUtils.isEmpty(getCodeUrl)){
chargeRlt.qRCodeUrl = getCodeUrl;
chargeRlt.imgBase64 = GetQRCodeFile(getCodeUrl).getData();
chargeRlt.qRCodeUrl = preRlt.getCodeUrl(); payOrder.setCallbackUrl(getCodeUrl);
chargeRlt.imgBase64 = GetQRCodeFile(preRlt.getCodeUrl()).getData();
payOrder.setCallbackUrl(preRlt.getCodeUrl());
try { try {
payOrder.setUpdatedtime(sdf.parse(sdf.format(new Date()))); payOrder.setUpdatedtime(sdf.parse(sdf.format(new Date())));
@ -162,11 +212,25 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
{ {
e.printStackTrace(); e.printStackTrace();
} }
}
if(!StringUtils.isEmpty(alipayFormAct)){
chargeRlt.alipayFormAction = alipayFormAct;
}
payOrderInfoMapper.updateByPrimaryKey(payOrder); payOrderInfoMapper.updateByPrimaryKey(payOrder);
PayOrderQrcode qrcode = new PayOrderQrcode(); PayOrderQrcode qrcode = new PayOrderQrcode();
qrcode.setPkId(payOrder.getPkId()); qrcode.setPkId(payOrder.getPkId());
if(!StringUtils.isEmpty(getCodeUrl)) {
qrcode.setQrcodeImg(chargeRlt.imgBase64); qrcode.setQrcodeImg(chargeRlt.imgBase64);
}
if(!StringUtils.isEmpty(alipayFormAct)) {
qrcode.setFormActionUrl(alipayFormAct);
}
payOrderQrcodeMapper.insert(qrcode); payOrderQrcodeMapper.insert(qrcode);
@ -395,12 +459,30 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
//解密报文 //解密报文
String plainText = decryptFromResource(bodyMap); String plainText = decryptFromResource(bodyMap);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
log.info("解密报文 bodyMap={}",plainText); log.info("解密报文 bodyMap={}",plainText);
//将明文转换成map //将明文转换成map
//Gson gson = new Gson(); //Gson gson = new Gson();
HashMap plainTextMap = gson.fromJson(plainText, HashMap.class); HashMap plainTextMap = gson.fromJson(plainText, HashMap.class);
String orderNo = (String) plainTextMap.get("out_trade_no"); String orderNo = (String) plainTextMap.get("out_trade_no");
//更新本地记录
PayOrderInfo chargeOrder = payOrderInfoMapper.selectByOrderNo(orderNo);
if(chargeOrder != null)
{
//PAY_SUCC-支付成功
chargeOrder.setStatus("PAY_SUCC");
chargeOrder.setIsComplete(true);
chargeOrder.setCompleteType("WEIXIN_NOTICE");
chargeOrder.setUpdatedtime(new Date());
payOrderInfoMapper.updateByPrimaryKey(chargeOrder);
}
//触发大简云回写
SendNoticeToDaJanYun(chargeOrder.getSenderPkid(),chargeOrder.getAmount());
/* /*
@ -434,6 +516,48 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
}*/ }*/
} }
private void SendNoticeToDaJanYun(String senderPkId,BigDecimal amount){
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Gson gson = new Gson();
log.info("充值成功回写大简云 act={} uid={} amount={}","charge",senderPkId,amount.setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
MultipartBody formBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("act", "charge")
.addFormDataPart("uid", senderPkId)
.addFormDataPart("amount", amount.setScale(2, BigDecimal.ROUND_HALF_DOWN).toString())
.build();
//MediaType mediaType = MediaType.parse("application/json");
//RequestBody body = RequestBody.create(mediaType, json);
Request request = new Request.Builder()
.url(wexinConfig.DjyNoticeUrl())
.method("POST", formBody)
.addHeader("Content-Type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
if(response.isSuccessful())
{
String msg = response.body().string();
log.info("发送大简云完成,返回结果={}",msg);
R<String> djyRlt = gson.fromJson(msg,R.class);
if(djyRlt.getCode() == Constants.SUCCESS){
log.info("充值成功发送大简云回写成功,消息={}",djyRlt.getMsg());
}else {
log.info("充值成功发送大简云回写失败,消息={}",djyRlt.getMsg());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
private String decryptFromResource(Map<String, Object> bodyMap) throws GeneralSecurityException { private String decryptFromResource(Map<String, Object> bodyMap) throws GeneralSecurityException {
log.info("密文解密"); log.info("密文解密");
@ -456,6 +580,13 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
return plainText; return plainText;
} }
public void TestSendDJY()
{
//更新本地记录
PayOrderInfo chargeOrder = payOrderInfoMapper.selectByOrderNo("PWX202312080002");
SendNoticeToDaJanYun(chargeOrder.getSenderPkid(),chargeOrder.getAmount());
}
/* /*
public OutResultInfo PushPaymentNotice(HttpServletRequest request, HttpServletResponse response) throws Exception { public OutResultInfo PushPaymentNotice(HttpServletRequest request, HttpServletResponse response) throws Exception {

@ -0,0 +1,79 @@
package com.payment.djypaymentplat.util;
import com.alipay.api.*;
import com.payment.djypaymentplat.config.AliPayConfig;
import com.payment.djypaymentplat.config.WeixinPayConfig;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.service.payments.nativepay.NativePayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
/**
* @Description TODO
* @Author JHQ
* @Date 2023/12/12 16:44
*/
@Configuration
public class AliPayUtil {
@Autowired
private AliPayConfig aliPayConfig;
@Autowired
private AlipayClient alipayClient;
/** 获取Native支付服务 **/
@Bean
public AlipayClient getAlipayClient(){
if(alipayClient != null)
return alipayClient;
CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
certAlipayRequest.setServerUrl(aliPayConfig.GatewayUrl()); //设置网关地址
certAlipayRequest.setAppId(aliPayConfig.AppId()); //设置应用Id
certAlipayRequest.setFormat("json"); //设置请求格式固定值json
certAlipayRequest.setCharset(aliPayConfig.CharSet()); //设置字符集
certAlipayRequest.setSignType(aliPayConfig.SignType()); //设置签名类型
//设置应用公钥证书路径
certAlipayRequest.setCertPath(aliPayConfig.AppCertPath());
//设置支付宝公钥证书路径
certAlipayRequest.setAlipayPublicCertPath(aliPayConfig.AlipayCertPath());
//设置支付宝根证书路径
certAlipayRequest.setRootCertPath(aliPayConfig.AlipayRootCertPath());
try {
String privateKey = new String(Files.readAllBytes(Paths.get(aliPayConfig.MerchantPrivateKeyPath())));
certAlipayRequest.setPrivateKey(privateKey); //应用私钥-自己创建
}
catch (Exception e)
{
e.printStackTrace();
}
try {
alipayClient = new DefaultAlipayClient(certAlipayRequest);
}catch (AlipayApiException e) {
e.printStackTrace();
}
/*
alipayClient = new DefaultAlipayClient(aliPayConfig.GatewayUrl(),
aliPayConfig.AppId(),
aliPayConfig.MerchantPrivateKey(), "json",
aliPayConfig.CharSet(),
aliPayConfig.AlipayPublicKey(),
aliPayConfig.SignType());
*/
return alipayClient;
}
}

@ -23,3 +23,15 @@ weixinpay:
apiV3Key: DongShengCharge20231204145800V01 apiV3Key: DongShengCharge20231204145800V01
appId: wx029d5994ace18575 appId: wx029d5994ace18575
noticeUrl: https://wechat.myshipping.net:8860/payment/onlinecharge/pushnotice noticeUrl: https://wechat.myshipping.net:8860/payment/onlinecharge/pushnotice
djyNoticeUrl: http://60.209.125.238:30801/Interface/CompChargeCallBack.ashx
alipay:
gatewayUrl: https://openapi.alipay.com/gateway.do
appId: 2021002159639156
merchantPrivateKeyPath: D:/DjyPaymentPlat/alipaykey/alipay_pv_key.txt
charset: utf-8
appCertPath: D:/DjyPaymentPlat/alipaykey/appCertPublicKey_2021002159639156.crt
alipayCertPath: D:/DjyPaymentPlat/alipaykey/alipayCertPublicKey_RSA2.crt
alipayRootCertPath: D:/DjyPaymentPlat/alipaykey/alipayRootCert.crt
signType: RSA2
noticeUrl: https://wechat.myshipping.net:8860/payment/onlinecharge/pushalinotice
djyNoticeUrl: http://60.209.125.238:30801/Interface/CompChargeCallBack.ashx

@ -20,6 +20,8 @@
<result column="BEFORE_CHARGE_AMOUNT" jdbcType="DECIMAL" property="beforeChargeAmount" /> <result column="BEFORE_CHARGE_AMOUNT" jdbcType="DECIMAL" property="beforeChargeAmount" />
<result column="IS_COMPLETE" jdbcType="BIT" property="isComplete" /> <result column="IS_COMPLETE" jdbcType="BIT" property="isComplete" />
<result column="COMPLETE_TYPE" jdbcType="VARCHAR" property="completeType" /> <result column="COMPLETE_TYPE" jdbcType="VARCHAR" property="completeType" />
<result column="SENDER_KEY" jdbcType="VARCHAR" property="senderKey" />
<result column="SENDER_PKID" jdbcType="VARCHAR" property="senderPkid" />
<result column="CreatedTime" jdbcType="TIMESTAMP" property="createdtime" /> <result column="CreatedTime" jdbcType="TIMESTAMP" property="createdtime" />
<result column="UpdatedTime" jdbcType="TIMESTAMP" property="updatedtime" /> <result column="UpdatedTime" jdbcType="TIMESTAMP" property="updatedtime" />
<result column="CreatedUserId" jdbcType="VARCHAR" property="createduserid" /> <result column="CreatedUserId" jdbcType="VARCHAR" property="createduserid" />
@ -33,8 +35,8 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
PK_ID, ORDER_NO, APP_ID, MCH_ID, DESCRIPTION, TIME_EXPIRE, ATTACH_DATA, AMOUNT, CURRENCY, PK_ID, ORDER_NO, APP_ID, MCH_ID, DESCRIPTION, TIME_EXPIRE, ATTACH_DATA, AMOUNT, CURRENCY,
PAYER_OPEN_ID, PAYER_CLIENT_IP, PAY_API_CODE, CALLBACK_URL, STATUS, CODE_URL, BEFORE_CHARGE_AMOUNT, PAYER_OPEN_ID, PAYER_CLIENT_IP, PAY_API_CODE, CALLBACK_URL, STATUS, CODE_URL, BEFORE_CHARGE_AMOUNT,
IS_COMPLETE, COMPLETE_TYPE, CreatedTime, UpdatedTime, CreatedUserId, CreatedUserName, IS_COMPLETE, COMPLETE_TYPE, SENDER_KEY, SENDER_PKID, CreatedTime, UpdatedTime, CreatedUserId,
UpdatedUserId, UpdatedUserName, IsDeleted, TenantId, TenantName CreatedUserName, UpdatedUserId, UpdatedUserName, IsDeleted, TenantId, TenantName
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select select
@ -42,16 +44,16 @@
from pay_order_info from pay_order_info
where PK_ID = #{pkId,jdbcType=VARCHAR} where PK_ID = #{pkId,jdbcType=VARCHAR}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from pay_order_info
where PK_ID = #{pkId,jdbcType=VARCHAR}
</delete>
<select id="selectByOrderNo" parameterType="java.lang.String" resultMap="BaseResultMap"> <select id="selectByOrderNo" parameterType="java.lang.String" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from pay_order_info from pay_order_info
where ORDER_NO = #{orderNo,jdbcType=VARCHAR} where ORDER_NO = #{orderNo,jdbcType=VARCHAR}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from pay_order_info
where PK_ID = #{pkId,jdbcType=VARCHAR} and IsDeleted = 0
</delete>
<insert id="insert" parameterType="com.payment.djypaymentplat.model.PayOrderInfo"> <insert id="insert" parameterType="com.payment.djypaymentplat.model.PayOrderInfo">
insert into pay_order_info (PK_ID, ORDER_NO, APP_ID, insert into pay_order_info (PK_ID, ORDER_NO, APP_ID,
MCH_ID, DESCRIPTION, TIME_EXPIRE, MCH_ID, DESCRIPTION, TIME_EXPIRE,
@ -59,20 +61,20 @@
PAYER_OPEN_ID, PAYER_CLIENT_IP, PAY_API_CODE, PAYER_OPEN_ID, PAYER_CLIENT_IP, PAY_API_CODE,
CALLBACK_URL, STATUS, CODE_URL, CALLBACK_URL, STATUS, CODE_URL,
BEFORE_CHARGE_AMOUNT, IS_COMPLETE, COMPLETE_TYPE, BEFORE_CHARGE_AMOUNT, IS_COMPLETE, COMPLETE_TYPE,
CreatedTime, UpdatedTime, CreatedUserId, SENDER_KEY, SENDER_PKID, CreatedTime,
CreatedUserName, UpdatedUserId, UpdatedUserName, UpdatedTime, CreatedUserId, CreatedUserName,
IsDeleted, TenantId, TenantName UpdatedUserId, UpdatedUserName, IsDeleted,
) TenantId, TenantName)
values (#{pkId,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR}, #{appId,jdbcType=VARCHAR}, values (#{pkId,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR}, #{appId,jdbcType=VARCHAR},
#{mchId,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{timeExpire,jdbcType=TIMESTAMP}, #{mchId,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{timeExpire,jdbcType=TIMESTAMP},
#{attachData,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{currency,jdbcType=VARCHAR}, #{attachData,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{currency,jdbcType=VARCHAR},
#{payerOpenId,jdbcType=VARCHAR}, #{payerClientIp,jdbcType=VARCHAR}, #{payApiCode,jdbcType=VARCHAR}, #{payerOpenId,jdbcType=VARCHAR}, #{payerClientIp,jdbcType=VARCHAR}, #{payApiCode,jdbcType=VARCHAR},
#{callbackUrl,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{codeUrl,jdbcType=VARCHAR}, #{callbackUrl,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{codeUrl,jdbcType=VARCHAR},
#{beforeChargeAmount,jdbcType=DECIMAL}, #{isComplete,jdbcType=BIT}, #{completeType,jdbcType=VARCHAR}, #{beforeChargeAmount,jdbcType=DECIMAL}, #{isComplete,jdbcType=BIT}, #{completeType,jdbcType=VARCHAR},
#{createdtime,jdbcType=TIMESTAMP}, #{updatedtime,jdbcType=TIMESTAMP}, #{createduserid,jdbcType=VARCHAR}, #{senderKey,jdbcType=VARCHAR}, #{senderPkid,jdbcType=VARCHAR}, #{createdtime,jdbcType=TIMESTAMP},
#{createdusername,jdbcType=VARCHAR}, #{updateduserid,jdbcType=VARCHAR}, #{updatedusername,jdbcType=VARCHAR}, #{updatedtime,jdbcType=TIMESTAMP}, #{createduserid,jdbcType=VARCHAR}, #{createdusername,jdbcType=VARCHAR},
#{isdeleted,jdbcType=BIT}, #{tenantid,jdbcType=VARCHAR}, #{tenantname,jdbcType=VARCHAR} #{updateduserid,jdbcType=VARCHAR}, #{updatedusername,jdbcType=VARCHAR}, #{isdeleted,jdbcType=BIT},
) #{tenantid,jdbcType=VARCHAR}, #{tenantname,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.payment.djypaymentplat.model.PayOrderInfo"> <insert id="insertSelective" parameterType="com.payment.djypaymentplat.model.PayOrderInfo">
insert into pay_order_info insert into pay_order_info
@ -131,6 +133,12 @@
<if test="completeType != null"> <if test="completeType != null">
COMPLETE_TYPE, COMPLETE_TYPE,
</if> </if>
<if test="senderKey != null">
SENDER_KEY,
</if>
<if test="senderPkid != null">
SENDER_PKID,
</if>
<if test="createdtime != null"> <if test="createdtime != null">
CreatedTime, CreatedTime,
</if> </if>
@ -214,6 +222,12 @@
<if test="completeType != null"> <if test="completeType != null">
#{completeType,jdbcType=VARCHAR}, #{completeType,jdbcType=VARCHAR},
</if> </if>
<if test="senderKey != null">
#{senderKey,jdbcType=VARCHAR},
</if>
<if test="senderPkid != null">
#{senderPkid,jdbcType=VARCHAR},
</if>
<if test="createdtime != null"> <if test="createdtime != null">
#{createdtime,jdbcType=TIMESTAMP}, #{createdtime,jdbcType=TIMESTAMP},
</if> </if>
@ -297,6 +311,12 @@
<if test="completeType != null"> <if test="completeType != null">
COMPLETE_TYPE = #{completeType,jdbcType=VARCHAR}, COMPLETE_TYPE = #{completeType,jdbcType=VARCHAR},
</if> </if>
<if test="senderKey != null">
SENDER_KEY = #{senderKey,jdbcType=VARCHAR},
</if>
<if test="senderPkid != null">
SENDER_PKID = #{senderPkid,jdbcType=VARCHAR},
</if>
<if test="createdtime != null"> <if test="createdtime != null">
CreatedTime = #{createdtime,jdbcType=TIMESTAMP}, CreatedTime = #{createdtime,jdbcType=TIMESTAMP},
</if> </if>
@ -346,6 +366,8 @@
BEFORE_CHARGE_AMOUNT = #{beforeChargeAmount,jdbcType=DECIMAL}, BEFORE_CHARGE_AMOUNT = #{beforeChargeAmount,jdbcType=DECIMAL},
IS_COMPLETE = #{isComplete,jdbcType=BIT}, IS_COMPLETE = #{isComplete,jdbcType=BIT},
COMPLETE_TYPE = #{completeType,jdbcType=VARCHAR}, COMPLETE_TYPE = #{completeType,jdbcType=VARCHAR},
SENDER_KEY = #{senderKey,jdbcType=VARCHAR},
SENDER_PKID = #{senderPkid,jdbcType=VARCHAR},
CreatedTime = #{createdtime,jdbcType=TIMESTAMP}, CreatedTime = #{createdtime,jdbcType=TIMESTAMP},
UpdatedTime = #{updatedtime,jdbcType=TIMESTAMP}, UpdatedTime = #{updatedtime,jdbcType=TIMESTAMP},
CreatedUserId = #{createduserid,jdbcType=VARCHAR}, CreatedUserId = #{createduserid,jdbcType=VARCHAR},

@ -6,12 +6,13 @@
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.payment.djypaymentplat.model.PayOrderQrcode"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.payment.djypaymentplat.model.PayOrderQrcode">
<result column="QRCODE_IMG" jdbcType="LONGVARCHAR" property="qrcodeImg" /> <result column="QRCODE_IMG" jdbcType="LONGVARCHAR" property="qrcodeImg" />
<result column="FORM_ACTION_URL" jdbcType="LONGVARCHAR" property="formActionUrl" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
PK_ID PK_ID
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
QRCODE_IMG QRCODE_IMG, FORM_ACTION_URL
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs"> <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select select
@ -26,8 +27,10 @@
where PK_ID = #{pkId,jdbcType=VARCHAR} where PK_ID = #{pkId,jdbcType=VARCHAR}
</delete> </delete>
<insert id="insert" parameterType="com.payment.djypaymentplat.model.PayOrderQrcode"> <insert id="insert" parameterType="com.payment.djypaymentplat.model.PayOrderQrcode">
insert into pay_order_qrcode (PK_ID, QRCODE_IMG) insert into pay_order_qrcode (PK_ID, QRCODE_IMG, FORM_ACTION_URL
values (#{pkId,jdbcType=VARCHAR}, #{qrcodeImg,jdbcType=LONGVARCHAR}) )
values (#{pkId,jdbcType=VARCHAR}, #{qrcodeImg,jdbcType=LONGVARCHAR}, #{formActionUrl,jdbcType=LONGVARCHAR}
)
</insert> </insert>
<insert id="insertSelective" parameterType="com.payment.djypaymentplat.model.PayOrderQrcode"> <insert id="insertSelective" parameterType="com.payment.djypaymentplat.model.PayOrderQrcode">
insert into pay_order_qrcode insert into pay_order_qrcode
@ -38,6 +41,9 @@
<if test="qrcodeImg != null"> <if test="qrcodeImg != null">
QRCODE_IMG, QRCODE_IMG,
</if> </if>
<if test="formActionUrl != null">
FORM_ACTION_URL,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="pkId != null"> <if test="pkId != null">
@ -46,6 +52,9 @@
<if test="qrcodeImg != null"> <if test="qrcodeImg != null">
#{qrcodeImg,jdbcType=LONGVARCHAR}, #{qrcodeImg,jdbcType=LONGVARCHAR},
</if> </if>
<if test="formActionUrl != null">
#{formActionUrl,jdbcType=LONGVARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<update id="updateByPrimaryKeySelective" parameterType="com.payment.djypaymentplat.model.PayOrderQrcode"> <update id="updateByPrimaryKeySelective" parameterType="com.payment.djypaymentplat.model.PayOrderQrcode">
@ -54,12 +63,16 @@
<if test="qrcodeImg != null"> <if test="qrcodeImg != null">
QRCODE_IMG = #{qrcodeImg,jdbcType=LONGVARCHAR}, QRCODE_IMG = #{qrcodeImg,jdbcType=LONGVARCHAR},
</if> </if>
<if test="formActionUrl != null">
FORM_ACTION_URL = #{formActionUrl,jdbcType=LONGVARCHAR},
</if>
</set> </set>
where PK_ID = #{pkId,jdbcType=VARCHAR} where PK_ID = #{pkId,jdbcType=VARCHAR}
</update> </update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.payment.djypaymentplat.model.PayOrderQrcode"> <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.payment.djypaymentplat.model.PayOrderQrcode">
update pay_order_qrcode update pay_order_qrcode
set QRCODE_IMG = #{qrcodeImg,jdbcType=LONGVARCHAR} set QRCODE_IMG = #{qrcodeImg,jdbcType=LONGVARCHAR},
FORM_ACTION_URL = #{formActionUrl,jdbcType=LONGVARCHAR}
where PK_ID = #{pkId,jdbcType=VARCHAR} where PK_ID = #{pkId,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>
Loading…
Cancel
Save