diff --git a/pom.xml b/pom.xml
index 9a19233..7cdf3d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -100,6 +100,16 @@
commons-logging
1.2
+
+ com.squareup.okhttp3
+ okhttp
+ 3.14.2
+
+
+ com.alipay.sdk
+ alipay-sdk-java
+ 4.38.61.ALL
+
diff --git a/src/main/java/com/payment/djypaymentplat/config/AliPayConfig.java b/src/main/java/com/payment/djypaymentplat/config/AliPayConfig.java
new file mode 100644
index 0000000..5758a3c
--- /dev/null
+++ b/src/main/java/com/payment/djypaymentplat/config/AliPayConfig.java
@@ -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;
+ }
+}
diff --git a/src/main/java/com/payment/djypaymentplat/config/WeixinPayConfig.java b/src/main/java/com/payment/djypaymentplat/config/WeixinPayConfig.java
index b527e90..cc67f38 100644
--- a/src/main/java/com/payment/djypaymentplat/config/WeixinPayConfig.java
+++ b/src/main/java/com/payment/djypaymentplat/config/WeixinPayConfig.java
@@ -30,6 +30,9 @@ public class WeixinPayConfig {
/** 通知接收地址 **/
public String noticeUrl;
+ /** 大简云回写地址 */
+ public String djyNoticeUrl;
+
/** 商户号 */
public void setMerchantId(String merchantId) {
this.merchantId = merchantId;
@@ -63,6 +66,11 @@ public class WeixinPayConfig {
this.noticeUrl = noticeUrl;
}
+ /** 大简云回写地址 */
+ public void setDjyNoticeUrl(String djyNoticeUrl) {
+ this.djyNoticeUrl = djyNoticeUrl;
+ }
+
/** 商户号 */
public String MerchantId() {
return merchantId;
@@ -93,4 +101,8 @@ public class WeixinPayConfig {
return noticeUrl;
}
+ /** 大简云回写地址 */
+ public String DjyNoticeUrl() {
+ return djyNoticeUrl;
+ }
}
diff --git a/src/main/java/com/payment/djypaymentplat/domain/CompanyChargeOrderMessageMainInfo.java b/src/main/java/com/payment/djypaymentplat/domain/CompanyChargeOrderMessageMainInfo.java
index 371059b..e2ed8f9 100644
--- a/src/main/java/com/payment/djypaymentplat/domain/CompanyChargeOrderMessageMainInfo.java
+++ b/src/main/java/com/payment/djypaymentplat/domain/CompanyChargeOrderMessageMainInfo.java
@@ -37,4 +37,12 @@ public class CompanyChargeOrderMessageMainInfo {
/** 充值企业名称 */
@ApiModelProperty("充值企业名称")
public String companyName;
+
+ /** 充值业务单号 */
+ @ApiModelProperty("充值业务单号")
+ public String businessId;
+
+ /** 支付接口 WEIXIN-微信支付;ALIPAY-支付宝 */
+ @ApiModelProperty("支付接口代码")
+ public String payApiCode;
}
diff --git a/src/main/java/com/payment/djypaymentplat/domain/CompanyChargeResult.java b/src/main/java/com/payment/djypaymentplat/domain/CompanyChargeResult.java
index cc12058..0416e32 100644
--- a/src/main/java/com/payment/djypaymentplat/domain/CompanyChargeResult.java
+++ b/src/main/java/com/payment/djypaymentplat/domain/CompanyChargeResult.java
@@ -17,4 +17,7 @@ public class CompanyChargeResult {
/** 生成200*200的二维码BASE64字符 */
public String imgBase64;
+
+ /** 阿里支付Form展示链接 */
+ public String alipayFormAction;
}
diff --git a/src/main/java/com/payment/djypaymentplat/mapper/PayOrderInfoMapper.java b/src/main/java/com/payment/djypaymentplat/mapper/PayOrderInfoMapper.java
index c6e0983..7466252 100644
--- a/src/main/java/com/payment/djypaymentplat/mapper/PayOrderInfoMapper.java
+++ b/src/main/java/com/payment/djypaymentplat/mapper/PayOrderInfoMapper.java
@@ -1,9 +1,7 @@
package com.payment.djypaymentplat.mapper;
import com.payment.djypaymentplat.model.PayOrderInfo;
-import org.springframework.stereotype.Repository;
-@Repository
public interface PayOrderInfoMapper {
int deleteByPrimaryKey(String pkId);
diff --git a/src/main/java/com/payment/djypaymentplat/mapper/PayOrderQrcodeMapper.java b/src/main/java/com/payment/djypaymentplat/mapper/PayOrderQrcodeMapper.java
index 5b5ec30..57f5ad8 100644
--- a/src/main/java/com/payment/djypaymentplat/mapper/PayOrderQrcodeMapper.java
+++ b/src/main/java/com/payment/djypaymentplat/mapper/PayOrderQrcodeMapper.java
@@ -1,9 +1,7 @@
package com.payment.djypaymentplat.mapper;
import com.payment.djypaymentplat.model.PayOrderQrcode;
-import org.springframework.stereotype.Repository;
-@Repository
public interface PayOrderQrcodeMapper {
int deleteByPrimaryKey(String pkId);
diff --git a/src/main/java/com/payment/djypaymentplat/model/PayOrderInfo.java b/src/main/java/com/payment/djypaymentplat/model/PayOrderInfo.java
index d016910..50a8c21 100644
--- a/src/main/java/com/payment/djypaymentplat/model/PayOrderInfo.java
+++ b/src/main/java/com/payment/djypaymentplat/model/PayOrderInfo.java
@@ -131,6 +131,20 @@ public class PayOrderInfo implements Serializable {
*/
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;
}
+ 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() {
return createdtime;
}
@@ -436,6 +466,8 @@ public class PayOrderInfo implements Serializable {
sb.append(", beforeChargeAmount=").append(beforeChargeAmount);
sb.append(", isComplete=").append(isComplete);
sb.append(", completeType=").append(completeType);
+ sb.append(", senderKey=").append(senderKey);
+ sb.append(", senderPkid=").append(senderPkid);
sb.append(", createdtime=").append(createdtime);
sb.append(", updatedtime=").append(updatedtime);
sb.append(", createduserid=").append(createduserid);
diff --git a/src/main/java/com/payment/djypaymentplat/model/PayOrderQrcode.java b/src/main/java/com/payment/djypaymentplat/model/PayOrderQrcode.java
index 58c36f4..1c463f2 100644
--- a/src/main/java/com/payment/djypaymentplat/model/PayOrderQrcode.java
+++ b/src/main/java/com/payment/djypaymentplat/model/PayOrderQrcode.java
@@ -17,6 +17,13 @@ public class PayOrderQrcode implements Serializable {
*/
private String qrcodeImg;
+ /**
+ * 支付宝FROM的请求链接
+ *
+ * @mbg.generated
+ */
+ private String formActionUrl;
+
private static final long serialVersionUID = 1L;
public String getPkId() {
@@ -35,6 +42,14 @@ public class PayOrderQrcode implements Serializable {
this.qrcodeImg = qrcodeImg;
}
+ public String getFormActionUrl() {
+ return formActionUrl;
+ }
+
+ public void setFormActionUrl(String formActionUrl) {
+ this.formActionUrl = formActionUrl;
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -43,6 +58,7 @@ public class PayOrderQrcode implements Serializable {
sb.append("Hash = ").append(hashCode());
sb.append(", pkId=").append(pkId);
sb.append(", qrcodeImg=").append(qrcodeImg);
+ sb.append(", formActionUrl=").append(formActionUrl);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
diff --git a/src/main/java/com/payment/djypaymentplat/service/ICompanyChargeService.java b/src/main/java/com/payment/djypaymentplat/service/ICompanyChargeService.java
index ec423ae..4653a36 100644
--- a/src/main/java/com/payment/djypaymentplat/service/ICompanyChargeService.java
+++ b/src/main/java/com/payment/djypaymentplat/service/ICompanyChargeService.java
@@ -55,4 +55,7 @@ public interface ICompanyChargeService {
* @date 2023/12/7 15:02
**/
public OutResultInfo PushPaymentNotice(HttpServletRequest request, HttpServletResponse response);
+
+
+ public void TestSendDJY();
}
diff --git a/src/main/java/com/payment/djypaymentplat/service/impl/CompanyChargeServiceImpl.java b/src/main/java/com/payment/djypaymentplat/service/impl/CompanyChargeServiceImpl.java
index 9a8be72..3d5856d 100644
--- a/src/main/java/com/payment/djypaymentplat/service/impl/CompanyChargeServiceImpl.java
+++ b/src/main/java/com/payment/djypaymentplat/service/impl/CompanyChargeServiceImpl.java
@@ -1,10 +1,17 @@
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.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
+import com.payment.djypaymentplat.config.AliPayConfig;
import com.payment.djypaymentplat.config.WeixinPayConfig;
import com.payment.djypaymentplat.domain.*;
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.PayOrderQrcode;
import com.payment.djypaymentplat.service.ICompanyChargeService;
+import com.payment.djypaymentplat.util.AliPayUtil;
import com.payment.djypaymentplat.util.HttpUtils;
import com.payment.djypaymentplat.util.WechatPay2ValidatorForRequest;
import com.payment.djypaymentplat.util.WeixinPayUtil;
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.nativepay.model.*;
+import okhttp3.*;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,6 +39,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.security.GeneralSecurityException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -69,6 +80,11 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
@Autowired
private WeixinPayUtil weixinPayUtil;
+ @Autowired
+ private AliPayUtil aliPayUtil;
+
+ @Autowired
+ private AliPayConfig aliPayConfig;
@PostMapping("/createorder")
@Override
@@ -82,13 +98,24 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
orderInfo.setPkId(UUID.randomUUID().toString().replace("-", ""));
orderInfo.setAmount(model.main.amount);
- orderInfo.setAppId(wexinConfig.Appid());
- orderInfo.setMchId(wexinConfig.MerchantId());
+
+ if(model.main.payApiCode.equals("WEIXIN"))
+ {
+ orderInfo.setAppId(wexinConfig.Appid());
+ orderInfo.setMchId(wexinConfig.MerchantId());
+ }
+ else if(model.main.payApiCode.equals("ALIPAY"))
+ {
+ orderInfo.setAppId(aliPayConfig.AppId());
+ }
+
orderInfo.setDescription(model.main.notes);
orderInfo.setCurrency(model.main.currency);
orderInfo.setCreateduserid(model.main.operatorId);
orderInfo.setCreatedusername(model.main.operatorName);
orderInfo.setStatus("WAIT");
+ orderInfo.setSenderKey(model.head.senderKey);
+ orderInfo.setSenderPkid(model.main.businessId);
Date nowDate = new Date();
try {
@@ -102,71 +129,108 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
payOrderInfoMapper.insert(orderInfo);
PayOrderInfo payOrder = payOrderInfoMapper.selectByPrimaryKey(orderInfo.getPkId());
- /*
- 1、测试充值0.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();
+ String getCodeUrl = "";
+ String alipayFormAct = "";
+
+ if(model.main.payApiCode.equals("WEIXIN")) {
+ PrepayRequest request = new PrepayRequest();
+
+ request.setAppid(wexinConfig.Appid());
+ request.setMchid(wexinConfig.MerchantId());
+ request.setDescription(model.main.notes);
+ request.setOutTradeNo(payOrder.getOrderNo());
+ request.setNotifyUrl(wexinConfig.NoticeUrl());
+
+ Amount amount = new Amount();
+
+ amount.setTotal(model.main.amount.multiply(new BigDecimal(100)).intValue());
+ amount.setCurrency(model.main.currency);
+ request.setAmount(amount);
+
+ // 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
+ // 调用接口
+ PrepayResponse preRlt = weixinPayUtil.getNativePayService().prepay(request);
- service = new NativePayService.Builder().config(config).build();
- */
+ 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());
- PrepayRequest request = new PrepayRequest();
+ aliPayModel.setProductCode("FAST_INSTANT_TRADE_PAY");
+ aliPayModel.setQrPayMode("4");
- request.setAppid(wexinConfig.Appid());
- request.setMchid(wexinConfig.MerchantId());
- request.setDescription(model.main.notes);
- request.setOutTradeNo(payOrder.getOrderNo());
- request.setNotifyUrl(wexinConfig.NoticeUrl());
+ alipayRequest.setBizModel(aliPayModel);
+ alipayRequest.setNotifyUrl(aliPayConfig.DjyNoticeUrl());
- Amount amount = new Amount();
+ CertAlipayRequest certAlipayRequest = new CertAlipayRequest ();
- amount.setTotal(model.main.amount.multiply(new BigDecimal(100)).intValue());
- amount.setCurrency(model.main.currency);
- request.setAmount(amount);
+ try
+ {
+ AlipayClient alipayClient = aliPayUtil.getAlipayClient();
+ AlipayTradePagePayResponse aliPayResult = alipayClient.pageExecute(alipayRequest,"GET");
- // 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
- // 调用接口
- PrepayResponse preRlt = weixinPayUtil.getNativePayService().prepay(request);
+ log.info("请求支付宝下单后返回结果,body={}",aliPayResult.getBody());
+
+ if(aliPayResult.isSuccess())
+ {
+ alipayFormAct = aliPayResult.getBody();
+ }
+ }
+ catch (AlipayApiException e)
+ {
+ e.printStackTrace();
+ }
+ }
CompanyChargeResult chargeRlt = new CompanyChargeResult();
chargeRlt.excuteDate = sdf.format(nowDate);
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();
+ payOrder.setCallbackUrl(getCodeUrl);
+ try {
+ payOrder.setUpdatedtime(sdf.parse(sdf.format(new Date())));
+ }catch (ParseException e)
+ {
+ e.printStackTrace();
+ }
+ }
- chargeRlt.qRCodeUrl = preRlt.getCodeUrl();
- chargeRlt.imgBase64 = GetQRCodeFile(preRlt.getCodeUrl()).getData();
- payOrder.setCallbackUrl(preRlt.getCodeUrl());
+ if(!StringUtils.isEmpty(alipayFormAct)){
+ chargeRlt.alipayFormAction = alipayFormAct;
- try {
- payOrder.setUpdatedtime(sdf.parse(sdf.format(new Date())));
- }catch (ParseException e)
- {
- e.printStackTrace();
}
+
payOrderInfoMapper.updateByPrimaryKey(payOrder);
PayOrderQrcode qrcode = new PayOrderQrcode();
qrcode.setPkId(payOrder.getPkId());
- qrcode.setQrcodeImg(chargeRlt.imgBase64);
+
+ if(!StringUtils.isEmpty(getCodeUrl)) {
+ qrcode.setQrcodeImg(chargeRlt.imgBase64);
+ }
+
+ if(!StringUtils.isEmpty(alipayFormAct)) {
+ qrcode.setFormActionUrl(alipayFormAct);
+ }
payOrderQrcodeMapper.insert(qrcode);
@@ -395,12 +459,30 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
//解密报文
String plainText = decryptFromResource(bodyMap);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
log.info("解密报文 bodyMap={}",plainText);
//将明文转换成map
//Gson gson = new Gson();
HashMap plainTextMap = gson.fromJson(plainText, HashMap.class);
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 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 bodyMap) throws GeneralSecurityException {
log.info("密文解密");
@@ -456,6 +580,13 @@ public class CompanyChargeServiceImpl implements ICompanyChargeService {
return plainText;
}
+ public void TestSendDJY()
+ {
+ //更新本地记录
+ PayOrderInfo chargeOrder = payOrderInfoMapper.selectByOrderNo("PWX202312080002");
+
+ SendNoticeToDaJanYun(chargeOrder.getSenderPkid(),chargeOrder.getAmount());
+ }
/*
public OutResultInfo PushPaymentNotice(HttpServletRequest request, HttpServletResponse response) throws Exception {
diff --git a/src/main/java/com/payment/djypaymentplat/util/AliPayUtil.java b/src/main/java/com/payment/djypaymentplat/util/AliPayUtil.java
new file mode 100644
index 0000000..ce9eed5
--- /dev/null
+++ b/src/main/java/com/payment/djypaymentplat/util/AliPayUtil.java
@@ -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;
+ }
+
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 171c9bb..6c5db5f 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -22,4 +22,16 @@ weixinpay:
merchantSerialNumber: 2816B386EBF44CD4E47CE88304C26420A4F0D523
apiV3Key: DongShengCharge20231204145800V01
appId: wx029d5994ace18575
- noticeUrl: https://wechat.myshipping.net:8860/payment/onlinecharge/pushnotice
\ No newline at end of file
+ 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
diff --git a/src/main/resources/mapper/PayOrderInfoMapper.xml b/src/main/resources/mapper/PayOrderInfoMapper.xml
index df68fa5..d959ebd 100644
--- a/src/main/resources/mapper/PayOrderInfoMapper.xml
+++ b/src/main/resources/mapper/PayOrderInfoMapper.xml
@@ -20,6 +20,8 @@
+
+
@@ -33,8 +35,8 @@
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,
- IS_COMPLETE, COMPLETE_TYPE, CreatedTime, UpdatedTime, CreatedUserId, CreatedUserName,
- UpdatedUserId, UpdatedUserName, IsDeleted, TenantId, TenantName
+ IS_COMPLETE, COMPLETE_TYPE, SENDER_KEY, SENDER_PKID, CreatedTime, UpdatedTime, CreatedUserId,
+ CreatedUserName, UpdatedUserId, UpdatedUserName, IsDeleted, TenantId, TenantName
+
+ delete from pay_order_info
+ where PK_ID = #{pkId,jdbcType=VARCHAR}
+
-
- delete from pay_order_info
- where PK_ID = #{pkId,jdbcType=VARCHAR} and IsDeleted = 0
-
insert into pay_order_info (PK_ID, ORDER_NO, APP_ID,
MCH_ID, DESCRIPTION, TIME_EXPIRE,
@@ -59,20 +61,20 @@
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, UpdatedUserId, UpdatedUserName,
- IsDeleted, TenantId, TenantName
- )
+ SENDER_KEY, SENDER_PKID, CreatedTime,
+ UpdatedTime, CreatedUserId, CreatedUserName,
+ UpdatedUserId, UpdatedUserName, IsDeleted,
+ TenantId, TenantName)
values (#{pkId,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR}, #{appId,jdbcType=VARCHAR},
#{mchId,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{timeExpire,jdbcType=TIMESTAMP},
#{attachData,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{currency,jdbcType=VARCHAR},
#{payerOpenId,jdbcType=VARCHAR}, #{payerClientIp,jdbcType=VARCHAR}, #{payApiCode,jdbcType=VARCHAR},
#{callbackUrl,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{codeUrl,jdbcType=VARCHAR},
#{beforeChargeAmount,jdbcType=DECIMAL}, #{isComplete,jdbcType=BIT}, #{completeType,jdbcType=VARCHAR},
- #{createdtime,jdbcType=TIMESTAMP}, #{updatedtime,jdbcType=TIMESTAMP}, #{createduserid,jdbcType=VARCHAR},
- #{createdusername,jdbcType=VARCHAR}, #{updateduserid,jdbcType=VARCHAR}, #{updatedusername,jdbcType=VARCHAR},
- #{isdeleted,jdbcType=BIT}, #{tenantid,jdbcType=VARCHAR}, #{tenantname,jdbcType=VARCHAR}
- )
+ #{senderKey,jdbcType=VARCHAR}, #{senderPkid,jdbcType=VARCHAR}, #{createdtime,jdbcType=TIMESTAMP},
+ #{updatedtime,jdbcType=TIMESTAMP}, #{createduserid,jdbcType=VARCHAR}, #{createdusername,jdbcType=VARCHAR},
+ #{updateduserid,jdbcType=VARCHAR}, #{updatedusername,jdbcType=VARCHAR}, #{isdeleted,jdbcType=BIT},
+ #{tenantid,jdbcType=VARCHAR}, #{tenantname,jdbcType=VARCHAR})
insert into pay_order_info
@@ -131,6 +133,12 @@
COMPLETE_TYPE,
+
+ SENDER_KEY,
+
+
+ SENDER_PKID,
+
CreatedTime,
@@ -214,6 +222,12 @@
#{completeType,jdbcType=VARCHAR},
+
+ #{senderKey,jdbcType=VARCHAR},
+
+
+ #{senderPkid,jdbcType=VARCHAR},
+
#{createdtime,jdbcType=TIMESTAMP},
@@ -297,6 +311,12 @@
COMPLETE_TYPE = #{completeType,jdbcType=VARCHAR},
+
+ SENDER_KEY = #{senderKey,jdbcType=VARCHAR},
+
+
+ SENDER_PKID = #{senderPkid,jdbcType=VARCHAR},
+
CreatedTime = #{createdtime,jdbcType=TIMESTAMP},
@@ -346,6 +366,8 @@
BEFORE_CHARGE_AMOUNT = #{beforeChargeAmount,jdbcType=DECIMAL},
IS_COMPLETE = #{isComplete,jdbcType=BIT},
COMPLETE_TYPE = #{completeType,jdbcType=VARCHAR},
+ SENDER_KEY = #{senderKey,jdbcType=VARCHAR},
+ SENDER_PKID = #{senderPkid,jdbcType=VARCHAR},
CreatedTime = #{createdtime,jdbcType=TIMESTAMP},
UpdatedTime = #{updatedtime,jdbcType=TIMESTAMP},
CreatedUserId = #{createduserid,jdbcType=VARCHAR},
diff --git a/src/main/resources/mapper/PayOrderQrcodeMapper.xml b/src/main/resources/mapper/PayOrderQrcodeMapper.xml
index 5c9b32f..310826a 100644
--- a/src/main/resources/mapper/PayOrderQrcodeMapper.xml
+++ b/src/main/resources/mapper/PayOrderQrcodeMapper.xml
@@ -6,12 +6,13 @@
+
PK_ID
- QRCODE_IMG
+ QRCODE_IMG, FORM_ACTION_URL