params = unionPayService.getParameter2Map(request.getParameterMap(), request.getInputStream());
- if (null == params) {
- return unionPayService.getPayOutMessage("fail", "失败").toMessage();
- }
-
- //校验
- if (unionPayService.verify(params)) {
- //这里处理业务逻辑
- //......业务逻辑处理块........
- return unionPayService.successPayOutMessage(null).toMessage();
- }
-
- return unionPayService.getPayOutMessage("fail", "失败").toMessage();
- }
- /**
- * 支付回调地址
- *
- * @param request 请求
- *
- * @return 是否成功
- *
- * 业务处理在对应的PayMessageHandler里面处理,在哪里设置PayMessageHandler,详情查看{@link com.egzosn.pay.common.api.PayService#setPayMessageHandler(com.egzosn.pay.common.api.PayMessageHandler)}
- *
- * 如果未设置 {@link com.egzosn.pay.common.api.PayMessageHandler} 那么会使用默认的 {@link com.egzosn.pay.common.api.DefaultPayMessageHandler}
- * @throws IOException IOException
- */
- @RequestMapping(value = "payBackOld.json")
- public String payBackOld(HttpServletRequest request) throws IOException {
- //业务处理在对应的PayMessageHandler里面处理,在哪里设置PayMessageHandler,详情查看com.egzosn.pay.common.api.PayService.setPayMessageHandler()
- return unionPayService.payBack(request.getParameterMap(), request.getInputStream()).toMessage();
- }
- /**
- * 支付回调地址
- *
- * @param request 请求
- * @return 是否成功
- *
- * 业务处理在对应的PayMessageHandler里面处理,在哪里设置PayMessageHandler,详情查看{@link com.egzosn.pay.common.api.PayService#setPayMessageHandler(com.egzosn.pay.common.api.PayMessageHandler)}
- *
- * 如果未设置 {@link com.egzosn.pay.common.api.PayMessageHandler} 那么会使用默认的 {@link com.egzosn.pay.common.api.DefaultPayMessageHandler}
- * @throws IOException IOException
- */
- @RequestMapping(value = "payBack.json")
- public String payBack(HttpServletRequest request) {
- //业务处理在对应的PayMessageHandler里面处理,在哪里设置PayMessageHandler,详情查看com.egzosn.pay.common.api.PayService.setPayMessageHandler()
- return unionPayService.payBack(new HttpRequestNoticeParams(request)).toMessage();
- }
-
-
- /**
- * 查询
- *
- * @param order 订单的请求体
- * @return 返回查询回来的结果集,支付方原值返回
- */
- @RequestMapping("query")
- public Map query(QueryOrder order) {
- return unionPayService.query(new AssistOrder(order.getTradeNo(), order.getOutTradeNo()));
- }
-
-
- /**
- * 申请退款接口
- *
- * @param order 订单的请求体
- * @return 返回支付方申请退款后的结果
- */
- @RequestMapping("refund")
- public UnionRefundResult refund(RefundOrder order) {
- return unionPayService.refund(order);
- }
-
-
- /**
- * 下载对账单
- *
- * @param order 订单的请求体
- * @return 返回支付方下载对账单的结果
- */
- @RequestMapping("downloadBill")
- public Object downloadBill(QueryOrder order) {
- return unionPayService.downloadBill(order.getBillDate(), order.getBillType());
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/model/ApyAccount.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/model/ApyAccount.java
deleted file mode 100644
index 950947d..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/model/ApyAccount.java
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-package org.wfc.payment.unionpay.model;
-
-
-/**
- * 支付账户
- *
- */
-//@Table(name = "apy_account")
-//@Entity
-public class ApyAccount {
- // 支付账号id
-// @Id
-// @GeneratedValue
-// @Column(name = "pay_id")
- private Integer payId;
- // 支付合作id,商户id,差不多是支付平台的账号或id
-// @Column(name = "partner")
- private String partner;
- // 应用id
-// @Column(name = "appid")
- private String appId;
- // 支付平台公钥(签名校验使用),sign_type只有单一key时public_key与private_key相等,比如sign_type=MD5的情况
- private String publicKey;
- // 应用私钥(生成签名)
-// @Column(name = "private_key")
- private String privateKey;
- // 异步回调地址
-// @Column(name = "notify_url")
- private String notifyUrl;
- // 同步回调地址
-// @Column(name = "return_url")
- private String returnUrl;
- // 收款账号
-// @Column(name = "seller")
- private String seller;
-
- //请求证书地址,请使用绝对路径
-// @Column(name = "keystore_path")
- private String keystorePath;
- //证书对应的密码
-// @Column(name = "store_password")
- private String storePassword;
-
-
- // 签名类型
-// @Column(name = "sign_type")
- private String signType;
- // 编码类型 枚举值,字符编码 utf-8,gbk等等
-// @Column(name = "input_charset")
- private String inputCharset;
- //支付类型,aliPay:支付宝,wxPay:微信, youdianPay: 友店微信,此处开发者自定义对应com.egzosn.pay.demo.entity.PayType枚举值
-// @Enumerated(EnumType.STRING)
-// @Column(name = "pay_type")
- private PayType payType;
- //是否为测试环境
- private boolean isTest = false;
-
- public Integer getPayId() {
- return payId;
- }
-
- public void setPayId(Integer payId) {
- this.payId = payId;
- }
-
- public String getPartner() {
- return partner;
- }
-
- public void setPartner(String partner) {
- this.partner = partner;
- }
-
- public String getAppId() {
- return appId;
- }
-
- public void setAppId(String appId) {
- this.appId = appId;
- }
-
- public String getPublicKey() {
- return publicKey;
- }
-
- public void setPublicKey(String publicKey) {
- this.publicKey = publicKey;
- }
-
- public String getPrivateKey() {
- return privateKey;
- }
-
- public void setPrivateKey(String privateKey) {
- this.privateKey = privateKey;
- }
-
- public String getNotifyUrl() {
- return notifyUrl;
- }
-
- public void setNotifyUrl(String notifyUrl) {
- this.notifyUrl = notifyUrl;
- }
-
- public String getReturnUrl() {
- return returnUrl;
- }
-
- public void setReturnUrl(String returnUrl) {
- this.returnUrl = returnUrl;
- }
-
- public String getSeller() {
- return seller;
- }
-
- public void setSeller(String seller) {
- this.seller = seller;
- }
-
- public String getSignType() {
- return signType;
- }
-
- public void setSignType(String signType) {
- this.signType = signType;
- }
-
- public PayType getPayType() {
- return payType;
- }
-
- public void setPayType(PayType payType) {
- this.payType = payType;
- }
-
- public String getInputCharset() {
- return inputCharset;
- }
-
- public void setInputCharset(String inputCharset) {
- this.inputCharset = inputCharset;
- }
-
- public boolean isTest() {
- return isTest;
- }
-
- public String getKeystorePath() {
- return keystorePath;
- }
-
- public void setKeystorePath(String keystorePath) {
- this.keystorePath = keystorePath;
- }
-
- public String getStorePassword() {
- return storePassword;
- }
-
- public void setStorePassword(String storePassword) {
- this.storePassword = storePassword;
- }
-
- public void setTest(boolean test) {
- isTest = test;
- }
-
- @Override
- public String toString() {
- return "ApyAccount{" +
- "payId=" + payId +
- ", partner='" + partner + '\'' +
- ", appId='" + appId + '\'' +
- ", publicKey='" + publicKey + '\'' +
- ", privateKey='" + privateKey + '\'' +
- ", notifyUrl='" + notifyUrl + '\'' +
- ", returnUrl='" + returnUrl + '\'' +
- ", seller='" + seller + '\'' +
- ", signType='" + signType + '\'' +
- ", inputCharset='" + inputCharset + '\'' +
- ", payType=" + payType +
- '}';
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/model/PayType.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/model/PayType.java
deleted file mode 100644
index 997e95c..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/model/PayType.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.wfc.payment.unionpay.model;
-
-import org.wfc.payment.unionpay.service.impl.UnionPayMessageImpl;
-
-import com.egzosn.pay.common.api.PayService;
-import com.egzosn.pay.common.bean.BasePayType;
-import com.egzosn.pay.common.bean.CertStoreType;
-import com.egzosn.pay.common.bean.TransactionType;
-import com.egzosn.pay.union.api.UnionPayConfigStorage;
-import com.egzosn.pay.union.api.UnionPayService;
-import com.egzosn.pay.union.bean.UnionTransactionType;
-
-/**
- * 支付类型
- *
- */
-public enum PayType implements BasePayType {
- UNION_PAY {
- @Override
- public PayService getPayService(ApyAccount apyAccount) {
- UnionPayConfigStorage unionPayConfigStorage = new UnionPayConfigStorage();
- unionPayConfigStorage.setMerId(apyAccount.getPartner());
- unionPayConfigStorage.setCertSign(true);
-
- //中级证书路径
- unionPayConfigStorage.setAcpMiddleCert("D:/certs/acp_test_middle.cer");
- //根证书路径
- unionPayConfigStorage.setAcpRootCert("D:/certs/acp_test_root.cer");
- // 私钥证书路径
- unionPayConfigStorage.setKeyPrivateCert("D:/certs/acp_test_sign.pfx");
- //私钥证书对应的密码
- unionPayConfigStorage.setKeyPrivateCertPwd("000000");
- //设置证书对应的存储方式,这里默认为文件地址
- unionPayConfigStorage.setCertStoreType(CertStoreType.PATH);
-
- unionPayConfigStorage.setNotifyUrl(apyAccount.getNotifyUrl());
- unionPayConfigStorage.setReturnUrl(apyAccount.getReturnUrl());
- unionPayConfigStorage.setSignType(apyAccount.getSignType());
- unionPayConfigStorage.setPayType(apyAccount.getPayType().toString());
- unionPayConfigStorage.setInputCharset(apyAccount.getInputCharset());
- unionPayConfigStorage.setTest(apyAccount.isTest());
- final UnionPayService unionPayService = new UnionPayService(unionPayConfigStorage);
- unionPayService.setPayMessageHandler(new UnionPayMessageImpl(apyAccount.getPayId()));
- return unionPayService;
- }
-
- @Override
- public TransactionType getTransactionType(String transactionType) {
- return UnionTransactionType.valueOf(transactionType);
- }
-
-
- };
-
- public abstract PayService getPayService(ApyAccount apyAccount);
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/model/QueryOrder.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/model/QueryOrder.java
deleted file mode 100644
index 8720bb1..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/model/QueryOrder.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.wfc.payment.unionpay.model;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * 订单辅助接口
- * @author egan
- * email egzosn@gmail.com
- * date 2017/3/12 14:50
- */
-public class QueryOrder {
-
- private Integer payId;
-// 支付平台订单号
- private String tradeNo;
-
-// 商户单号
- private String outTradeNo;
-// 退款金额
- private BigDecimal refundAmount;
-// 总金额
- private BigDecimal totalAmount;
-// 账单时间:具体请查看对应支付平台
- private Date billDate;
-// 账单时间:具体请查看对应支付平台
- private String billType;
- // 支付平台订单号或者账单日期
- private Object tradeNoOrBillDate;
- // 商户单号或者 账单类型
- private String outTradeNoBillType;
- // 交易类型
- private String transactionType;
-
- public Integer getPayId() {
- return payId;
- }
-
- public void setPayId(Integer payId) {
- this.payId = payId;
- }
-
- public String getTradeNo() {
- return tradeNo;
- }
-
- public void setTradeNo(String tradeNo) {
- this.tradeNo = tradeNo;
- }
-
- public String getOutTradeNo() {
- return outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public BigDecimal getRefundAmount() {
- return refundAmount;
- }
-
- public void setRefundAmount(BigDecimal refundAmount) {
- this.refundAmount = refundAmount;
- }
-
- public BigDecimal getTotalAmount() {
- return totalAmount;
- }
-
- public void setTotalAmount(BigDecimal totalAmount) {
- this.totalAmount = totalAmount;
- }
-
- public Date getBillDate() {
- return billDate;
- }
-
- public void setBillDate(Date billDate) {
- this.billDate = billDate;
- }
-
- public String getBillType() {
- return billType;
- }
-
- public void setBillType(String billType) {
- this.billType = billType;
- }
-
- public Object getTradeNoOrBillDate() {
- return tradeNoOrBillDate;
- }
-
- public void setTradeNoOrBillDate(Object tradeNoOrBillDate) {
- this.tradeNoOrBillDate = tradeNoOrBillDate;
- }
-
- public String getOutTradeNoBillType() {
- return outTradeNoBillType;
- }
-
- public void setOutTradeNoBillType(String outTradeNoBillType) {
- this.outTradeNoBillType = outTradeNoBillType;
- }
-
- public String getTransactionType() {
- return transactionType;
- }
-
- public void setTransactionType(String transactionType) {
- this.transactionType = transactionType;
- }
-
- @Override
- public String toString() {
- return "QueryOrder{" +
- "payId=" + payId +
- ", tradeNo='" + tradeNo + '\'' +
- ", outTradeNo='" + outTradeNo + '\'' +
- ", refundAmount=" + refundAmount +
- ", totalAmount=" + totalAmount +
- ", billDate=" + billDate +
- ", billType='" + billType + '\'' +
- ", tradeNoOrBillDate=" + tradeNoOrBillDate +
- ", outTradeNoBillType='" + outTradeNoBillType + '\'' +
- ", transactionType='" + transactionType + '\'' +
- '}';
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/repository/ApyAccountRepository.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/repository/ApyAccountRepository.java
deleted file mode 100644
index 8111010..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/repository/ApyAccountRepository.java
+++ /dev/null
@@ -1,69 +0,0 @@
-
-package org.wfc.payment.unionpay.repository;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.wfc.payment.unionpay.model.ApyAccount;
-import org.wfc.payment.unionpay.model.PayType;
-
-import com.egzosn.pay.common.util.sign.SignUtils;
-
-/**
- * 账户
- *
- * @author egan
- * email egzosn@gmail.com
- * date 2016/11/18 1:21
- */
-//@Repository
-public class ApyAccountRepository {
-
- // 这里简单模拟,引入orm等框架之后可自行删除
- protected static final Map apyAccounts = new HashMap<>();
-
- /**
- * 这里简单初始化,引入orm等框架之后可自行删除
- */
- static {
-
- ApyAccount apyAccount4 = new ApyAccount();
- apyAccount4.setPayId(4);
- apyAccount4.setPartner("700000000000001");
- //公钥,验签证书链格式: 中级证书路径;根证书路径
- apyAccount4.setPublicKey("D:/certs/acp_test_middle.cer;D:/certs/acp_test_root.cer");
- //私钥, 私钥证书格式: 私钥证书路径;私钥证书对应的密码
- apyAccount4.setPrivateKey("D:/certs/acp_test_sign.pfx;000000");
- apyAccount4.setNotifyUrl("http://127.0.0.1/payBack4.json");
- // 无需同步回调可不填 app填这个就可以
- apyAccount4.setReturnUrl("http://127.0.0.1/payBack4.json");
- apyAccount4.setSeller("");
- apyAccount4.setInputCharset("UTF-8");
- apyAccount4.setSignType(SignUtils.RSA2.name());
- apyAccount4.setPayType(PayType.UNION_PAY);
- apyAccount4.setTest(true);
- apyAccounts.put(apyAccount4.getPayId(), apyAccount4);
- }
- //_____________________________________________________________
-
- /**
- * Provides access to the apyAccounts map.
- *
- * @return the apyAccounts map
- */
- public static Map getApyAccounts() {
- return apyAccounts;
- }
-
-
- /**
- * 根据id获取对应的账户信息
- *
- * @param payId 账户id
- * @return 账户信息
- */
- public ApyAccount findByPayId(Integer payId) {
- // Retrieve the ApyAccount from the map using the payId
- return apyAccounts.get(payId);
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/ApyAccountService.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/ApyAccountService.java
deleted file mode 100644
index 51d9780..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/ApyAccountService.java
+++ /dev/null
@@ -1,55 +0,0 @@
-
-package org.wfc.payment.unionpay.service;
-
-import org.wfc.payment.unionpay.model.ApyAccount;
-import org.wfc.payment.unionpay.repository.ApyAccountRepository;
-import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
-import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.Map;
-
-@Service
-public class ApyAccountService {
-
-// @Resource
- private ApyAccountRepository dao;
-
- @Resource
- private AutowireCapableBeanFactory spring;
-
- /**
- * 缓存
- */
- private static final Map payResponses = new HashMap<>();
-
- /**
- * 这里简单初始化,引入orm等框架之后可自行删除
- */
- public ApyAccountService() {
- dao = new ApyAccountRepository();
- }
-
-
- /**
- * 获取支付响应
- * @param id 账户id
- * @return 支付响应
- */
- public PayResponse getPayResponse(Integer id) {
-
- PayResponse payResponse = payResponses.get(id);
- if (payResponse == null) {
- ApyAccount apyAccount = dao.findByPayId(id);
- if (apyAccount == null) {
- throw new IllegalArgumentException ("无法查询");
- }
- payResponse = new PayResponse();
- spring.autowireBean(payResponse);
- payResponse.init(apyAccount);
- payResponses.put(id, payResponse);
- // 查询
- }
- return payResponse;
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/PayResponse.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/PayResponse.java
deleted file mode 100644
index 37ed40c..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/PayResponse.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.wfc.payment.unionpay.service;
-
-import javax.annotation.Resource;
-
-import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
-import org.wfc.payment.unionpay.model.ApyAccount;
-
-import com.egzosn.pay.common.api.PayConfigStorage;
-import com.egzosn.pay.common.api.PayService;
-import com.egzosn.pay.common.http.HttpConfigStorage;
-
-/**
- * 支付响应对象
- *
- */
-public class PayResponse {
-
- @Resource
- private AutowireCapableBeanFactory spring;
-
- private PayConfigStorage storage;
-
- private PayService extends PayConfigStorage> service;
-
-
- public PayResponse() {
- // This constructor is intentionally empty. Nothing special is needed here.
- }
-
- /**
- * 初始化支付配置
- *
- * @param apyAccount 账户信息
- * @see ApyAccount 对应表结构详情--》 /pay-java-demo/resources/apy_account.sql
- */
- public void init(ApyAccount apyAccount) {
- //根据不同的账户类型 初始化支付配置
- this.service = apyAccount.getPayType().getPayService(apyAccount);
- this.storage = service.getPayConfigStorage();
-
-
- //这里设置http请求配置
- // buildRouter(apyAccount.getPayId()); // Deprecated method call removed
- }
-
- /**
- * 获取http配置,如果配置为null则为默认配置,无代理,无证书的请求方式。
- * 此处非必需
- *
- * @param apyAccount 账户信息
- * @return 请求配置
- */
- public HttpConfigStorage getHttpConfigStorage(ApyAccount apyAccount) {
- HttpConfigStorage httpConfigStorage = new HttpConfigStorage();
- /* 网路代理配置 根据需求进行设置*/
- // //http代理地址
- // httpConfigStorage.setHttpProxyHost("192.168.1.69");
- // //代理端口
- // httpConfigStorage.setHttpProxyPort(3308);
- // //代理用户名
- // httpConfigStorage.setHttpProxyUsername("user");
- // //代理密码
- // httpConfigStorage.setHttpProxyPassword("password");
- // 设置ssl证书路径 https证书设置 方式二
- httpConfigStorage.setKeystore(apyAccount.getKeystorePath());
- //设置ssl证书对应的密码
- httpConfigStorage.setStorePassword(apyAccount.getStorePassword());
- return httpConfigStorage;
- }
-
- public PayConfigStorage getStorage() {
- return storage;
- }
-
- public PayService extends PayConfigStorage> getService() {
- return service;
- }
-
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/impl/BasePayMessageImpl.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/impl/BasePayMessageImpl.java
deleted file mode 100644
index aa4b8d7..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/impl/BasePayMessageImpl.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.wfc.payment.unionpay.service.impl;
-
-import com.egzosn.pay.common.api.PayMessageHandler;
-import com.egzosn.pay.common.api.PayService;
-import com.egzosn.pay.common.bean.PayMessage;
-
-public abstract class BasePayMessageImpl> implements PayMessageHandler {
- //支付账户id
- private Integer payId;
-
- protected BasePayMessageImpl(Integer payId) {
- this.payId = payId;
- }
-
- public Integer getPayId() {
- return payId;
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/impl/UnionPayMessageImpl.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/impl/UnionPayMessageImpl.java
deleted file mode 100644
index 8a38123..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/unionpay/service/impl/UnionPayMessageImpl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.wfc.payment.unionpay.service.impl;
-
-import com.egzosn.pay.common.bean.PayOutMessage;
-import com.egzosn.pay.common.exception.PayErrorException;
-import com.egzosn.pay.union.api.UnionPayService;
-import com.egzosn.pay.union.bean.SDKConstants;
-import com.egzosn.pay.union.bean.UnionPayMessage;
-
-import java.util.Map;
-
-public class UnionPayMessageImpl extends BasePayMessageImpl {
-
- public UnionPayMessageImpl(Integer payId) {
- super(payId);
- }
-
- @Override
- public PayOutMessage handle(UnionPayMessage payMessage, Map context, UnionPayService payService) throws PayErrorException {
- //交易状态
- if (SDKConstants.OK_RESP_CODE.equals(payMessage.getPayMessage().get(SDKConstants.param_respCode))) {
- /////这里进行成功的处理
-
- return payService.successPayOutMessage(payMessage);
- }
-
- return payService.getPayOutMessage("fail", "失败");
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/utils/StringUtils.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/utils/StringUtils.java
new file mode 100644
index 0000000..86fb3ec
--- /dev/null
+++ b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/utils/StringUtils.java
@@ -0,0 +1,150 @@
+package org.wfc.payment.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Random;
+import java.util.UUID;
+
+/**
+ * 字符串工具类,继承lang3字符串工具类
+ *
+ * @author L.com
+ */
+public final class StringUtils extends org.apache.commons.lang3.StringUtils {
+
+ public static String encode(String str) {
+ String encode = null;
+ try {
+ encode = URLEncoder.encode(str, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return encode;
+ }
+
+ /**
+ * 获取UUID,去掉`-`的
+ *
+ * @return {String}
+ */
+ public static String generateStr() {
+ return UUID.randomUUID().toString().replace("-", "");
+ }
+
+
+ /**
+ * 要求外部订单号必须唯一。
+ *
+ * @return {String}
+ */
+ public static String getOutTradeNo() {
+ SimpleDateFormat format = new SimpleDateFormat("MMddHHmmss", Locale.getDefault());
+ Date date = new Date();
+ String key = format.format(date);
+ key = key + System.currentTimeMillis();
+ key = key.substring(0, 15);
+ return key;
+ }
+
+ /**
+ * 字符串格式化
+ *
+ * use: format("my name is {0}, and i like {1}!", "L.cm", "java")
+ *
+ * int long use {0,number,#}
+ *
+ * @param s
+ * @param args
+ * @return {String}转换后的字符串
+ */
+ public static String format(String s, Object... args) {
+ return MessageFormat.format(s, args);
+ }
+
+ /**
+ * 替换某个字符
+ *
+ * @param str
+ * @param regex
+ * @param args
+ * @return {String}
+ */
+ public static String replace(String str, String regex, String... args) {
+ int length = args.length;
+ for (int i = 0; i < length; i++) {
+ str = str.replaceFirst(regex, args[i]);
+ }
+ return str;
+ }
+
+ /**
+ * 清理字符串,清理出某些不可见字符
+ *
+ * @param txt
+ * @return {String}
+ */
+ public static String cleanChars(String txt) {
+ return txt.replaceAll("[ `·•�\\f\\t\\v]", "");
+ }
+
+ /**
+ * 随机字符串
+ */
+ private static final String INT_TEMP = "0123456789";
+ private static final String STR_TEMP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ private static final String ALL_TEMP = INT_TEMP + STR_TEMP;
+
+ private static final Random RANDOM = new Random();
+
+ /**
+ * 生成的随机数类型
+ */
+ public enum RandomType {
+ /**
+ * 整数
+ */
+ INT,
+ /**
+ * 字符串
+ */
+ STRING,
+ /**
+ * 所有类型
+ */
+ ALL
+ }
+
+ /**
+ * 随机数生成
+ *
+ * @param count
+ * @return {String}
+ */
+ public static String random(int count, RandomType randomType) {
+ if (count == 0) {
+ return "";
+ }
+ if (count < 0) {
+ throw new IllegalArgumentException("Requested random string length " + count + " is less than 0.");
+ }
+ char[] buffer = new char[count];
+ for (int i = 0; i < count; i++) {
+ if (randomType.equals(RandomType.INT)) {
+ buffer[i] = INT_TEMP.charAt(RANDOM.nextInt(INT_TEMP.length()));
+ } else if (randomType.equals(RandomType.STRING)) {
+ buffer[i] = STR_TEMP.charAt(RANDOM.nextInt(STR_TEMP.length()));
+ } else {
+ buffer[i] = ALL_TEMP.charAt(RANDOM.nextInt(ALL_TEMP.length()));
+ }
+ }
+ return new String(buffer);
+ }
+
+ public static void main(String[] args) {
+ System.out.println(random(32, RandomType.ALL));
+ }
+}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/config/WWxPayConfig.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/config/WWxPayConfig.java
deleted file mode 100644
index e1f74fd..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/config/WWxPayConfig.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.wfc.payment.wxpay.config;
-
-import com.github.binarywang.wxpay.config.WxPayConfig;
-import com.github.binarywang.wxpay.service.WxPayService;
-import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
-import lombok.AllArgsConstructor;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-@ConditionalOnClass(WxPayService.class)
-@EnableConfigurationProperties(WxPayProperties.class)
-@AllArgsConstructor
-public class WWxPayConfig {
- private WxPayProperties properties;
-
- @Bean
- @ConditionalOnMissingBean
- public WxPayService wxService() {
- WxPayConfig payConfig = new WxPayConfig();
- payConfig.setAppId(StringUtils.trimToNull(this.properties.getAppId()));
- payConfig.setMchId(StringUtils.trimToNull(this.properties.getMchId()));
- payConfig.setMchKey(StringUtils.trimToNull(this.properties.getMchKey()));
- payConfig.setSubAppId(StringUtils.trimToNull(this.properties.getSubAppId()));
- payConfig.setSubMchId(StringUtils.trimToNull(this.properties.getSubMchId()));
- payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));
-
- // 可以指定是否使用沙箱环境
- payConfig.setUseSandboxEnv(this.properties.getUseSandboxEnv());
-
- WxPayService wxPayService = new WxPayServiceImpl();
- wxPayService.setConfig(payConfig);
- return wxPayService;
- }
-}
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/config/WxPayProperties.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/config/WxPayProperties.java
deleted file mode 100644
index 6a14190..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/config/WxPayProperties.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.wfc.payment.wxpay.config;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * wxpay pay properties.
- *
- */
-@Data
-@ConfigurationProperties(prefix = "wxpay")
-public class WxPayProperties {
- /**
- * 设置微信公众号或者小程序等的appid
- */
- private String appId;
-
- /**
- * 微信支付商户号
- */
- private String mchId;
-
- /**
- * 微信支付商户密钥
- */
- private String mchKey;
-
- /**
- * 服务商模式下的子商户公众账号ID,普通模式请不要配置,请在配置文件中将对应项删除
- */
- private String subAppId;
-
- /**
- * 服务商模式下的子商户号,普通模式请不要配置,最好是请在配置文件中将对应项删除
- */
- private String subMchId;
-
- /**
- * apiclient_cert.p12文件的绝对路径,或者如果放在项目中,请以classpath:开头指定
- */
- private String keyPath;
-
- /**
- * 可以指定是否使用沙箱环境
- */
- private Boolean useSandboxEnv;
-
-}
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/controller/WxPayController.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/controller/WxPayController.java
deleted file mode 100644
index 502b6fe..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/controller/WxPayController.java
+++ /dev/null
@@ -1,431 +0,0 @@
-package org.wfc.payment.wxpay.controller;
-
-import com.alipay.api.AlipayApiException;
-import com.github.binarywang.wxpay.bean.coupon.*;
-import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
-import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
-import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
-import com.github.binarywang.wxpay.bean.notify.WxScanPayNotifyResult;
-import com.github.binarywang.wxpay.bean.request.*;
-import com.github.binarywang.wxpay.bean.result.*;
-import com.github.binarywang.wxpay.exception.WxPayException;
-import com.github.binarywang.wxpay.service.WxPayService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.AllArgsConstructor;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-import org.wfc.payment.wxpay.service.IWxPayNotifyOrderService;
-import org.wfc.payment.wxpay.service.IWxPayNotifyRefundService;
-import org.wfc.payment.wxpay.service.IWxPayNotifyScanpayService;
-
-import java.io.File;
-import java.util.Date;
-import java.util.Map;
-
-@Tag(name = "WeChat Pay")
-@RestController
-@RequestMapping("/wxpay")
-@AllArgsConstructor
-public class WxPayController {
-
- private final WxPayService wxService;
-
- // @Autowired
- // public WxPayController(WxPayService wxService) {
- // this.wxService = wxService;
- // }
-
- /**
- *
- * 查询订单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2)
- * 该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。
- * 需要调用查询接口的情况:
- * ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
- * ◆ 调用支付接口后,返回系统错误或未知交易状态情况;
- * ◆ 调用被扫支付API,返回USERPAYING的状态;
- * ◆ 调用关单或撤销接口API之前,需确认支付状态;
- * 接口地址:https://api.mch.weixin.qq.com/pay/orderquery
- *
- *
- * @param transactionId 微信订单号
- * @param outTradeNo 商户系统内部的订单号,当没提供transactionId时需要传这个。
- */
- @Operation(summary = "Query order")
- @GetMapping("/queryOrder")
- public WxPayOrderQueryResult queryOrder(@RequestParam(required = false) String transactionId,
- @RequestParam(required = false) String outTradeNo)
- throws WxPayException {
- return this.wxService.queryOrder(transactionId, outTradeNo);
- }
-
- @Operation(summary = "Query order")
- @PostMapping("/queryOrder")
- public WxPayOrderQueryResult queryOrder(@RequestBody WxPayOrderQueryRequest wxPayOrderQueryRequest)
- throws WxPayException {
- return this.wxService.queryOrder(wxPayOrderQueryRequest);
- }
-
- /**
- *
- * 关闭订单
- * 应用场景
- * 以下情况需要调用关单接口:
- * 1. 商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
- * 2. 系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
- * 注意:订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。
- * 接口地址:https://api.mch.weixin.qq.com/pay/closeorder
- * 是否需要证书: 不需要。
- *
- *
- * @param outTradeNo 商户系统内部的订单号
- */
- @Operation(summary = "Close order")
- @GetMapping("/closeOrder/{outTradeNo}")
- public WxPayOrderCloseResult closeOrder(@PathVariable String outTradeNo) throws WxPayException {
- return this.wxService.closeOrder(outTradeNo);
- }
-
- @Operation(summary = "Close order")
- @PostMapping("/closeOrder")
- public WxPayOrderCloseResult closeOrder(@RequestBody WxPayOrderCloseRequest wxPayOrderCloseRequest)
- throws WxPayException {
- return this.wxService.closeOrder(wxPayOrderCloseRequest);
- }
-
- /**
- * 调用统一下单接口,并组装生成支付所需参数对象.
- *
- * @param request 统一下单请求参数
- * @param 请使用{@link com.github.binarywang.wxpay.bean.order}包下的类
- * @return 返回 {@link com.github.binarywang.wxpay.bean.order}包下的类对象
- */
- @Operation(summary = "统一下单,并组装所需支付参数")
- @PostMapping("/createOrder")
- public T createOrder(@RequestBody WxPayUnifiedOrderRequest request) throws WxPayException {
- return this.wxService.createOrder(request);
- }
-
- /**
- * 统一下单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
- * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
- * 接口地址:https://api.mch.weixin.qq.com/pay/unifiedorder
- *
- * @param request 请求对象,注意一些参数如appid、mchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置)
- */
- @Operation(summary = "原生的统一下单接口")
- @PostMapping("/unifiedOrder")
- public WxPayUnifiedOrderResult unifiedOrder(@RequestBody WxPayUnifiedOrderRequest request) throws WxPayException {
- return this.wxService.unifiedOrder(request);
- }
-
- /**
- *
- * 微信支付-申请退款
- * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
- * 接口链接:https://api.mch.weixin.qq.com/secapi/pay/refund
- *
- *
- * @param request 请求对象
- * @return 退款操作结果
- */
- @Operation(summary = "Refund")
- @PostMapping("/refund")
- public WxPayRefundResult refund(@RequestBody WxPayRefundRequest request) throws WxPayException {
- return this.wxService.refund(request);
- }
-
- /**
- *
- * 微信支付-查询退款
- * 应用场景:
- * 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,
- * 银行卡支付的退款3个工作日后重新查询退款状态。
- * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5
- * 接口链接:https://api.mch.weixin.qq.com/pay/refundquery
- *
- *
- * 以下四个参数四选一
- *
- * @param transactionId 微信订单号
- * @param outTradeNo 商户订单号
- * @param outRefundNo 商户退款单号
- * @param refundId 微信退款单号
- * @return 退款信息
- */
- @Operation(summary = "退款查询")
- @GetMapping("/refundQuery")
- public WxPayRefundQueryResult refundQuery(@RequestParam(required = false) String transactionId,
- @RequestParam(required = false) String outTradeNo,
- @RequestParam(required = false) String outRefundNo,
- @RequestParam(required = false) String refundId)
- throws WxPayException {
- return this.wxService.refundQuery(transactionId, outTradeNo, outRefundNo, refundId);
- }
-
- @Operation(summary = "退款查询")
- @PostMapping("/refundQuery")
- public WxPayRefundQueryResult refundQuery(@RequestBody WxPayRefundQueryRequest wxPayRefundQueryRequest)
- throws WxPayException {
- return this.wxService.refundQuery(wxPayRefundQueryRequest);
- }
-
- private final IWxPayNotifyOrderService wxPayNotifyOrderService;
- private static final String MSG_SUCCESS = "success";
- private static final String MSG_FAILURE = "failure";
-
- @Operation(summary = "支付回调通知处理")
- @PostMapping("/notify/order")
- public String parseOrderNotifyResult(@RequestBody String xmlData) throws WxPayException {
- final WxPayOrderNotifyResult notifyResult = this.wxService.parseOrderNotifyResult(xmlData);
- // 根据自己业务场景需要构造返回对象
- try {
- Map notifyResultMap = notifyResult.toMap();
- boolean result = wxPayNotifyOrderService.handleWxPayNotifyOrder(notifyResultMap);
- return result ? MSG_SUCCESS : MSG_FAILURE;
- } catch (Exception e) {
- e.printStackTrace();
- return MSG_FAILURE;
- }
- }
-
- private final IWxPayNotifyRefundService wxPayNotifyRefundService;
- @Operation(summary = "退款回调通知处理")
- @PostMapping("/notify/refund")
- public String parseRefundNotifyResult(@RequestBody String xmlData) throws WxPayException {
- final WxPayRefundNotifyResult notifyResult = this.wxService.parseRefundNotifyResult(xmlData);
- // 根据自己业务场景需要构造返回对象
- try {
- Map notifyResultMap = notifyResult.toMap();
- boolean result = wxPayNotifyRefundService.handleWxPayNotifyRefund(notifyResultMap);
- return result ? MSG_SUCCESS : MSG_FAILURE;
- } catch (Exception e) {
- e.printStackTrace();
- return MSG_FAILURE;
- }
- }
-
- private final IWxPayNotifyScanpayService wxPayNotifyScanpayService;
- @Operation(summary = "扫码支付回调通知处理")
- @PostMapping("/notify/scanpay")
- public String parseScanPayNotifyResult(String xmlData) throws WxPayException {
- final WxScanPayNotifyResult notifyResult = this.wxService.parseScanPayNotifyResult(xmlData);
- // 根据自己业务场景需要构造返回对象
- try {
- Map notifyResultMap = notifyResult.toMap();
- boolean result = wxPayNotifyScanpayService.handleWxPayNotifyScanpay(notifyResultMap);
- return result ? MSG_SUCCESS : MSG_FAILURE;
- } catch (Exception e) {
- e.printStackTrace();
- return MSG_FAILURE;
- }
- }
-
- /**
- * 发送微信红包给个人用户
- *
- *
- * 文档详见:
- * 发送普通红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3
- * 接口地址:https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack
- * 发送裂变红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4
- * 接口地址:https://api.mch.weixin.qq.com/mmpaymkttransfers/sendgroupredpack
- *
- *
- * @param request 请求对象
- */
- @Operation(summary = "发送红包")
- @PostMapping("/sendRedpack")
- public WxPaySendRedpackResult sendRedpack(@RequestBody WxPaySendRedpackRequest request) throws WxPayException {
- return this.wxService.getRedpackService().sendRedpack(request);
- }
-
- /**
- *
- * 查询红包记录
- * 用于商户对已发放的红包进行查询红包的具体信息,可支持普通红包和裂变包。
- * 请求Url https://api.mch.weixin.qq.com/mmpaymkttransfers/gethbinfo
- * 是否需要证书 是(证书及使用说明详见商户证书)
- * 请求方式 POST
- *
- *
- * @param mchBillNo 商户发放红包的商户订单号,比如10000098201411111234567890
- */
- @Operation(summary = "查询红包")
- @GetMapping("/queryRedpack/{mchBillNo}")
- public WxPayRedpackQueryResult queryRedpack(@PathVariable String mchBillNo) throws WxPayException {
- return this.wxService.getRedpackService().queryRedpack(mchBillNo);
- }
-
- /**
- *
- * 扫码支付模式一生成二维码的方法
- * 二维码中的内容为链接,形式为:
- * weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX
- * 其中XXXXX为商户需要填写的内容,商户将该链接生成二维码,如需要打印发布二维码,需要采用此格式。商户可调用第三方库生成二维码图片。
- * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4
- *
- *
- * @param productId 产品Id
- * @param logoFile 商户logo图片的文件对象,可以为空
- * @param sideLength 要生成的二维码的边长,如果为空,则取默认值400
- * @return 生成的二维码的字节数组
- */
- public byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength) throws Exception {
- return this.wxService.createScanPayQrcodeMode1(productId, logoFile, sideLength);
- }
-
- /**
- *
- * 扫码支付模式一生成二维码的方法
- * 二维码中的内容为链接,形式为:
- * weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX
- * 其中XXXXX为商户需要填写的内容,商户将该链接生成二维码,如需要打印发布二维码,需要采用此格式。商户可调用第三方库生成二维码图片。
- * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4
- *
- *
- * @param productId 产品Id
- * @return 生成的二维码URL连接
- */
- public String createScanPayQrcodeMode1(String productId) {
- return this.wxService.createScanPayQrcodeMode1(productId);
- }
-
- /**
- *
- * 扫码支付模式二生成二维码的方法
- * 对应链接格式:weixin://wxpay/bizpayurl?sr=XXXXX。请商户调用第三方库将code_url生成二维码图片。
- * 该模式链接较短,生成的二维码打印到结账小票上的识别率较高。
- * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5
- *
- *
- * @param codeUrl 微信返回的交易会话的二维码链接
- * @param logoFile 商户logo图片的文件对象,可以为空
- * @param sideLength 要生成的二维码的边长,如果为空,则取默认值400
- * @return 生成的二维码的字节数组
- */
- public byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) throws Exception {
- return this.wxService.createScanPayQrcodeMode2(codeUrl, logoFile, sideLength);
- }
-
- /**
- *
- * 交易保障
- * 应用场景:
- * 商户在调用微信支付提供的相关接口时,会得到微信支付返回的相关信息以及获得整个接口的响应时间。
- * 为提高整体的服务水平,协助商户一起提高服务质量,微信支付提供了相关接口调用耗时和返回信息的主动上报接口,
- * 微信支付可以根据商户侧上报的数据进一步优化网络部署,完善服务监控,和商户更好的协作为用户提供更好的业务体验。
- * 接口地址: https://api.mch.weixin.qq.com/payitil/report
- * 是否需要证书:不需要
- *
- */
- @Operation(summary = "提交交易保障数据")
- @PostMapping("/report")
- public void report(@RequestBody WxPayReportRequest request) throws WxPayException {
- this.wxService.report(request);
- }
-
- /**
- *
- * 下载对账单
- * 商户可以通过该接口下载历史交易清单。比如掉单、系统错误等导致商户侧和微信侧数据不一致,通过对账单核对后可校正支付状态。
- * 注意:
- * 1、微信侧未成功下单的交易不会出现在对账单中。支付成功后撤销的交易会出现在对账单中,跟原支付单订单号一致,bill_type为REVOKED;
- * 2、微信在次日9点启动生成前一天的对账单,建议商户10点后再获取;
- * 3、对账单中涉及金额的字段单位为“元”。
- * 4、对账单接口只能下载三个月以内的账单。
- * 接口链接:https://api.mch.weixin.qq.com/pay/downloadbill
- * 详情请见: 下载对账单
- *
- *
- * @param billDate 对账单日期 bill_date 下载对账单的日期,格式:20140603
- * @param billType 账单类型 bill_type
- * ALL,返回当日所有订单信息,默认值,SUCCESS,返回当日成功支付的订单,REFUND,返回当日退款订单
- * @param tarType 压缩账单 tar_type 非必传参数,固定值:GZIP,返回格式为.gzip的压缩包账单。不传则默认为数据流形式。
- * @param deviceInfo 设备号 device_info 非必传参数,终端设备号
- * @return 保存到本地的临时文件
- */
- @Operation(summary = "下载对账单")
- @GetMapping("/downloadBill/{billDate}/{billType}/{tarType}/{deviceInfo}")
- public WxPayBillResult downloadBill(@PathVariable String billDate, @PathVariable String billType,
- @PathVariable String tarType, @PathVariable String deviceInfo) throws WxPayException {
- return this.wxService.downloadBill(billDate, billType, tarType, deviceInfo);
- }
-
- @Operation(summary = "下载对账单")
- @PostMapping("/downloadBill")
- public WxPayBillResult downloadBill(WxPayDownloadBillRequest wxPayDownloadBillRequest) throws WxPayException {
- return this.wxService.downloadBill(wxPayDownloadBillRequest);
- }
-
- /**
- *
- * 提交刷卡支付
- * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1
- * 应用场景:
- * 收银员使用扫码设备读取微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台,由商户收银台或者商户后台调用该接口发起支付。
- * 提醒1:提交支付请求后微信会同步返回支付结果。当返回结果为“系统错误”时,商户系统等待5秒后调用【查询订单API】,查询支付实际交易结果;当返回结果为“USERPAYING”时,商户系统可设置间隔时间(建议10秒)重新查询支付结果,直到支付成功或超时(建议30秒);
- * 提醒2:在调用查询接口返回后,如果交易状况不明晰,请调用【撤销订单API】,此时如果交易失败则关闭订单,该单不能再支付成功;如果交易成功,则将扣款退回到用户账户。当撤销无返回或错误时,请再次调用。注意:请勿扣款后立即调用【撤销订单API】,建议至少15秒后再调用。撤销订单API需要双向证书。
- * 接口地址: https://api.mch.weixin.qq.com/pay/micropay
- * 是否需要证书:不需要。
- *
- */
- @Operation(summary = "提交刷卡支付")
- @PostMapping("/micropay")
- public WxPayMicropayResult micropay(@RequestBody WxPayMicropayRequest request) throws WxPayException {
- return this.wxService.micropay(request);
- }
-
- /**
- *
- * 撤销订单API
- * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_11&index=3
- * 应用场景:
- * 支付交易返回失败或支付系统超时,调用该接口撤销交易。如果此订单用户支付失败,微信支付系统会将此订单关闭;如果用户支付成功,微信支付系统会将此订单资金退还给用户。
- * 注意:7天以内的交易单可调用撤销,其他正常支付的单如需实现相同功能请调用申请退款API。提交支付交易后调用【查询订单API】,没有明确的支付结果再调用【撤销订单API】。
- * 调用支付接口后请勿立即调用撤销订单API,建议支付后至少15s后再调用撤销订单接口。
- * 接口链接 :https://api.mch.weixin.qq.com/secapi/pay/reverse
- * 是否需要证书:请求需要双向证书。
- *
- */
- @Operation(summary = "撤销订单")
- @PostMapping("/reverseOrder")
- public WxPayOrderReverseResult reverseOrder(@RequestBody WxPayOrderReverseRequest request) throws WxPayException {
- return this.wxService.reverseOrder(request);
- }
-
- @Operation(summary = "获取沙箱环境签名key")
- @GetMapping("/getSandboxSignKey")
- public String getSandboxSignKey() throws WxPayException {
- return this.wxService.getSandboxSignKey();
- }
-
- @Operation(summary = "发放代金券")
- @PostMapping("/sendCoupon")
- public WxPayCouponSendResult sendCoupon(@RequestBody WxPayCouponSendRequest request) throws WxPayException {
- return this.wxService.sendCoupon(request);
- }
-
- @Operation(summary = "查询代金券批次")
- @PostMapping("/queryCouponStock")
- public WxPayCouponStockQueryResult queryCouponStock(@RequestBody WxPayCouponStockQueryRequest request)
- throws WxPayException {
- return this.wxService.queryCouponStock(request);
- }
-
- @Operation(summary = "查询代金券信息")
- @PostMapping("/queryCouponInfo")
- public WxPayCouponInfoQueryResult queryCouponInfo(@RequestBody WxPayCouponInfoQueryRequest request)
- throws WxPayException {
- return this.wxService.queryCouponInfo(request);
- }
-
- @Operation(summary = "拉取订单评价数据")
- @PostMapping("/queryComment")
- public String queryComment(Date beginDate, Date endDate, Integer offset, Integer limit) throws WxPayException {
- return this.wxService.queryComment(beginDate, endDate, offset, limit);
- }
-
-}
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/error/ErrorController.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/error/ErrorController.java
deleted file mode 100644
index a26dcc5..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/error/ErrorController.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.wfc.payment.wxpay.error;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-@Controller
-@RequestMapping("/error")
-public class ErrorController {
-
- @GetMapping(value = "/404")
- public String error404() {
- return "error";
- }
-
- @GetMapping(value = "/500")
- public String error500() {
- return "error";
- }
-
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/error/ErrorPageConfiguration.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/error/ErrorPageConfiguration.java
deleted file mode 100644
index a91306f..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/error/ErrorPageConfiguration.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.wfc.payment.wxpay.error;
-
-import org.springframework.boot.web.server.ErrorPage;
-import org.springframework.boot.web.server.ErrorPageRegistrar;
-import org.springframework.boot.web.server.ErrorPageRegistry;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ErrorPageConfiguration implements ErrorPageRegistrar {
- @Override
- public void registerErrorPages(ErrorPageRegistry errorPageRegistry) {
- errorPageRegistry.addErrorPages(
- new ErrorPage(HttpStatus.NOT_FOUND, "/error/404"),
- new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500")
- );
- }
-
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/mapper/UWxPayOrderMapper.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/mapper/UWxPayOrderMapper.java
deleted file mode 100644
index a984d13..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/mapper/UWxPayOrderMapper.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.wfc.payment.wxpay.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-import org.wfc.payment.wxpay.model.UWxPayOrderModel;
-
-@Mapper
-public interface UWxPayOrderMapper {
-
- void insertOrder(UWxPayOrderModel uWxPayOrder);
-
- void updateOrder(UWxPayOrderModel uWxPayOrder);
-
- UWxPayOrderModel selectOrderByOutTradeNo(@Param("outTradeNo") String outTradeNo);
-
- UWxPayOrderModel selectOrderById(@Param("id") Long id);
-}
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/model/UWxPayOrderModel.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/model/UWxPayOrderModel.java
deleted file mode 100644
index 6cdb1d4..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/model/UWxPayOrderModel.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.wfc.payment.wxpay.model;
-
-import javax.persistence.*;
-import java.util.Date;
-import lombok.Data;
-
-@Data
-@Entity
-public class UWxPayOrderModel {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
- private Long userId;
- private String outTradeNo;
- private String trancationId;
- private String tradeStatus;
- private Long totalAmount;
- private String subject;
- private String body;
- private String createBy;
- private Date createTime;
- private String updateBy;
- private Date updateTime;
-
- // Getters and Setters
-}
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/IWxPayNotifyOrderService.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/IWxPayNotifyOrderService.java
deleted file mode 100644
index 0ac17f9..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/IWxPayNotifyOrderService.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.wfc.payment.wxpay.service;
-
-import java.util.Map;
-
-public interface IWxPayNotifyOrderService {
- boolean handleWxPayNotifyOrder(Map params);
-}
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/IWxPayNotifyRefundService.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/IWxPayNotifyRefundService.java
deleted file mode 100644
index 1fd98f9..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/IWxPayNotifyRefundService.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.wfc.payment.wxpay.service;
-
-import java.util.Map;
-
-public interface IWxPayNotifyRefundService {
- boolean handleWxPayNotifyRefund(Map params);
-}
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/IWxPayNotifyScanpayService.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/IWxPayNotifyScanpayService.java
deleted file mode 100644
index f8d49d7..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/IWxPayNotifyScanpayService.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.wfc.payment.wxpay.service;
-
-import java.util.Map;
-
-public interface IWxPayNotifyScanpayService {
- boolean handleWxPayNotifyScanpay(Map params);
-}
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/impl/WxPayNotifyOrderServiceImpl.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/impl/WxPayNotifyOrderServiceImpl.java
deleted file mode 100644
index c17f523..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/impl/WxPayNotifyOrderServiceImpl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.wfc.payment.wxpay.service.impl;
-
-import java.util.Map;
-import org.springframework.stereotype.Service;
-import org.wfc.payment.wxpay.mapper.UWxPayOrderMapper;
-import org.wfc.payment.wxpay.model.UWxPayOrderModel;
-import lombok.AllArgsConstructor;
-import java.util.Date;
-import org.wfc.payment.wxpay.utils.VerifySignUtils;
-import org.wfc.payment.wxpay.service.IWxPayNotifyOrderService;
-
-@AllArgsConstructor
-@Service
-public class WxPayNotifyOrderServiceImpl implements IWxPayNotifyOrderService {
-
- private final UWxPayOrderMapper wxpayOrderMapper;
- private final VerifySignUtils verifySignUtils;
-
- public boolean handleWxPayNotifyOrder(Map params) {
- // 验证签名
- boolean signVerified = verifySignUtils.verifySignature(params);
- if (signVerified) {
- // 处理业务逻辑,例如更新订单状态
- String outTradeNo = params.get("out_trade_no");
- String tradeStatus = params.get("trade_state");
- Long totalAmount = new Long(params.get("total_fee")); // 微信支付金额单位为分
- String subject = params.get("subject");
- String body = params.get("body");
-
- UWxPayOrderModel order = wxpayOrderMapper.selectOrderByOutTradeNo(outTradeNo);
- if (order == null) {
- order = new UWxPayOrderModel();
- order.setOutTradeNo(outTradeNo);
- order.setCreateTime(new Date());
- wxpayOrderMapper.insertOrder(order);
- }
- order.setTradeStatus(tradeStatus);
- order.setTotalAmount(totalAmount);
- order.setSubject(subject);
- order.setBody(body);
- order.setUpdateTime(new Date());
-
- wxpayOrderMapper.updateOrder(order);
-
- return "SUCCESS".equals(tradeStatus);
- }
- return false;
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/impl/WxPayNotifyRefundServiceImpl.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/impl/WxPayNotifyRefundServiceImpl.java
deleted file mode 100644
index e2dcf74..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/impl/WxPayNotifyRefundServiceImpl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.wfc.payment.wxpay.service.impl;
-
-import java.util.Map;
-
-import org.springframework.stereotype.Service;
-import org.wfc.payment.wxpay.mapper.UWxPayOrderMapper;
-import org.wfc.payment.wxpay.model.UWxPayOrderModel;
-import lombok.AllArgsConstructor;
-import java.util.Date;
-import org.wfc.payment.wxpay.utils.VerifySignUtils;
-import org.wfc.payment.wxpay.service.IWxPayNotifyRefundService;
-
-@AllArgsConstructor
-@Service
-public class WxPayNotifyRefundServiceImpl implements IWxPayNotifyRefundService {
- private final UWxPayOrderMapper wxpayOrderMapper;
- private final VerifySignUtils verifySignUtils;
-
- public boolean handleWxPayNotifyRefund(Map params) {
- // 验证签名
- boolean signVerified = verifySignUtils.verifySignature(params);
- if (signVerified) {
- // 处理业务逻辑,例如更新订单状态
- String outTradeNo = params.get("out_trade_no");
- String tradeStatus = params.get("trade_status");
- Long totalAmount = new Long(params.get("total_fee")); // 微信支付金额单位为分
- String subject = params.get("subject");
- String body = params.get("body");
-
- UWxPayOrderModel order = wxpayOrderMapper.selectOrderByOutTradeNo(outTradeNo);
- if (order == null) {
- order = new UWxPayOrderModel();
- order.setOutTradeNo(outTradeNo);
- order.setCreateTime(new Date());
- wxpayOrderMapper.insertOrder(order);
- }
- order.setTradeStatus(tradeStatus);
- order.setTotalAmount(totalAmount);
- order.setSubject(subject);
- order.setBody(body);
- order.setUpdateTime(new Date());
-
- wxpayOrderMapper.updateOrder(order);
-
- return "SUCCESS".equals(tradeStatus);
- }
- return false;
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/impl/WxPayNotifyScanpayServiceImpl.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/impl/WxPayNotifyScanpayServiceImpl.java
deleted file mode 100644
index 5ef4485..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/service/impl/WxPayNotifyScanpayServiceImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.wfc.payment.wxpay.service.impl;
-
-import java.util.Map;
-
-import org.springframework.stereotype.Service;
-import org.wfc.payment.wxpay.mapper.UWxPayOrderMapper;
-import org.wfc.payment.wxpay.model.UWxPayOrderModel;
-import org.wfc.payment.wxpay.service.IWxPayNotifyScanpayService;
-
-import lombok.AllArgsConstructor;
-import java.util.Date;
-import org.wfc.payment.wxpay.utils.VerifySignUtils;
-
-@AllArgsConstructor
-@Service
-public class WxPayNotifyScanpayServiceImpl implements IWxPayNotifyScanpayService {
- private final UWxPayOrderMapper wxpayOrderMapper;
- private final VerifySignUtils verifySignUtils;
-
- public boolean handleWxPayNotifyScanpay(Map params) {
- // 验证签名
- boolean signVerified = verifySignUtils.verifySignature(params);
- if (signVerified) {
- // 处理业务逻辑,例如更新订单状态
- String outTradeNo = params.get("out_trade_no");
- String tradeStatus = params.get("trade_status");
- Long totalAmount = new Long(params.get("total_fee")); // 微信支付金额单位为分
- String subject = params.get("subject");
- String body = params.get("body");
-
- UWxPayOrderModel order = wxpayOrderMapper.selectOrderByOutTradeNo(outTradeNo);
- if (order == null) {
- order = new UWxPayOrderModel();
- order.setOutTradeNo(outTradeNo);
- order.setCreateTime(new Date());
- wxpayOrderMapper.insertOrder(order);
- }
- order.setTradeStatus(tradeStatus);
- order.setTotalAmount(totalAmount);
- order.setSubject(subject);
- order.setBody(body);
- order.setUpdateTime(new Date());
-
- wxpayOrderMapper.updateOrder(order);
-
- return "SUCCESS".equals(tradeStatus);
- }
- return false;
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/utils/VerifySignUtils.java b/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/utils/VerifySignUtils.java
deleted file mode 100644
index 5ef2f35..0000000
--- a/wfc-modules/wfc-payment/src/main/java/org/wfc/payment/wxpay/utils/VerifySignUtils.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.wfc.payment.wxpay.utils;
-
-import java.security.KeyFactory;
-import java.security.PrivateKey;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.ArrayList;
-import java.nio.charset.StandardCharsets;
-import java.util.Base64;
-import java.util.Map;
-import java.util.Collections;
-import java.util.List;
-import java.security.PublicKey;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.wfc.payment.wxpay.config.WxPayProperties;
-
-@Component
-public class VerifySignUtils {
-
- private final WxPayProperties wxpayProperties;
-
- @Autowired
- public VerifySignUtils(WxPayProperties wxpayProperties) {
- this.wxpayProperties = wxpayProperties;
- }
-
- public static String sign(String data, PrivateKey privateKey) throws SignatureException {
- if (data == null || privateKey == null) {
- throw new IllegalArgumentException("Data and private key cannot be null");
- }
- try {
- Signature signature = Signature.getInstance("SHA256withRSA");
- signature.initSign(privateKey);
- signature.update(data.getBytes(StandardCharsets.UTF_8));
- byte[] signBytes = signature.sign();
- return Base64.getEncoder().encodeToString(signBytes);
- } catch (Exception e) {
- throw new SignatureException("Failed to sign data", e);
- }
- }
-
- public static boolean verify(String data, String sign, PublicKey publicKey) throws SignatureException {
- if (data == null || sign == null || publicKey == null) {
- throw new IllegalArgumentException("Data, sign and public key cannot be null");
- }
- try {
- Signature signature = Signature.getInstance("SHA256withRSA");
- signature.initVerify(publicKey);
- signature.update(data.getBytes(StandardCharsets.UTF_8));
- byte[] signBytes = Base64.getDecoder().decode(sign);
- return signature.verify(signBytes);
- } catch (Exception e) {
- throw new SignatureException("Failed to verify signature", e);
- }
- }
-
- public boolean verifySignature(Map params) {
- if (params == null || params.isEmpty()) {
- return false;
- }
-
- // Extract signature parameter
- String sign = params.remove("sign");
- if (sign == null) {
- return false;
- }
-
- // Sort parameters
- List keys = new ArrayList<>(params.keySet());
- Collections.sort(keys);
-
- // Build parameter string
- StringBuilder data = new StringBuilder();
- for (String key : keys) {
- String value = params.get(key);
- if (value != null) {
- data.append(key)
- .append("=")
- .append(value)
- .append("&");
- }
- }
-
- // Remove last '&'
- if (data.length() > 0) {
- data.setLength(data.length() - 1);
- }
-
- try {
- byte[] keyBytes = Base64.getDecoder().decode(wxpayProperties.getMchKey());
- X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
- KeyFactory keyFactory = KeyFactory.getInstance("RSA");
- PublicKey publicKey = keyFactory.generatePublic(keySpec);
- return verify(data.toString(), sign, publicKey);
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-}
diff --git a/wfc-modules/wfc-payment/src/main/resources/application.yml b/wfc-modules/wfc-payment/src/main/resources/application.yml
index ef29c56..6d420e5 100644
--- a/wfc-modules/wfc-payment/src/main/resources/application.yml
+++ b/wfc-modules/wfc-payment/src/main/resources/application.yml
@@ -1,6 +1,5 @@
# spring配置
spring:
-
redis:
host: wfc-redis
port: 6379
@@ -55,76 +54,13 @@ mybatis-plus:
logic-delete-value: 1
logic-not-delete-value: 0
-wxpay:
- appId: 121412414112
- mchId: 1131412414
- mchKey: 1525342aa
- subAppId: #服务商模式下的子商户公众账号ID
- subMchId: #服务商模式下的子商户号
- keyPath: /opt/wfc/conf/wxpay/wxpay_key.pem
- useSandboxEnv: false
-
alipay:
- appId: 121412414112
- privateKey: 1131412414
- publicKey: 1525342aa
- notifyUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/alipay/notify
- returnUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/alipay/return
- signType: RSA2
- charset: utf-8
- gatewayUrl: https://openapi.alipaydev.com/gateway.do
- logPath: /opt/wfc/logs/alipay/alipay.log
- maxQueryRetry: 5
- queryDuration: 5
- maxCancelRetry: 3
- cancelDuration: 2
- heartbeatDelay: 5
- heartbeatDuration: 5
- storeId:
- storeName:
- supportEmail:
- supportPhone:
-
-ccpay:
- paymentUrl: https://api.paymentgateway.com/v1/payment
- tokenUrl: https://api.paymentgateway.com/v1/token
- queryUrl: https://api.paymentgateway.com/v1/query
- refundUrl: https://api.paymentgateway.com/v1/refund
- apiKey: api-key
- merchantId: merchant-id
- currency: USD
- timeout: 30
- callbackUrl: https://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/payment/callback
-
-unionpay:
- merId: 700000000000001
- keyPrivateCert: /opt/wfc/conf/cert/unionpay/wfc-union.pfx
- keyPrivateCertPwd: 123456
- signCertType: PKCS12
- encryptCertPath: /opt/wfc/conf/cert/unionpay/wfc-union.cer
- acpMiddleCert: /opt/wfc/conf/cert/unionpay/wfc-middle.cer
- acpRootCert: /opt/wfc/conf/cert/unionpay/wfc-root.cer
- frontUrl: https://gateway.test.95516.com/gateway/api/frontTransReq.do
- backUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/notify
- signMethod: 01
- version: 5.1.0
- channelType: 07
- accessType: 0
- currencyCode: 156
- bizType: 000201
- txnType: 01
- txnSubType: 01
- payTimeout: 30
- queryTimeout: 30
- refundTimeout: 30
- frontFailUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/fail
- frontSuccessUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/success
- frontBackUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/front
- backBackUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/back
- frontNotifyUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/front/notify
- backNotifyUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/back/notify
- refundNotifyUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/refund/notify
- queryNotifyUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/query/notify
- refundSuccessUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/refund/success
- refundFailUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/unionpay/refund/fail
- querySuccessUrl:
\ No newline at end of file
+ appId: 9021000122699258
+ privateKey: MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC7YAcIXV5GJlTWBOoBcrVG1zKxHunznSjYXwTS2DM3YgloxzKye4apfcmBDVnoL93m4QrJTtbiHYvu4yJjJfJsQEY+Wo44IczhDypyu+Il6JpQOwylTs94/+3aaQ1wThsDaGs8edaFGteuw+1pUVl4nxF00fS1VoIR30riqAGFAXrPhcSA6Y9c8HK1htxCelICnPzjpqC4s8ZjrjS7FoyHP2ZAay5fx1VEtah30E4RvycFfV/i2+k3JGFOSeevdCx6Ufu+9Y/RaG4Sh84QuYRQUhAHUswlFDHpRrAnxHzt0zDkOkg3BrCT7vMtBbSOP9BdIhpVTaZm4diQdNbLSl4hAgMBAAECggEAKb1Xc7aQ1KGfTlmj4xSxawlvImOXjAwbWC+6fFlq91BgdjXBhl7b/Y+mvpfBymY3UUIaTAPC/HXGgT2ZoGqImTKsMyGrArgM0qm1M//EfdtV3L96rqxirTqduoSiWL0daWHuWXduoRH8r9K3ZTmY67TLh7FpiKevq9mI7fqs8/qgq5QAN4UPFb3Cq9hDNTU4l6+Bywdg1KkwJ2Jc98SlrIdVl+1eCMAgueLR0aNHTobyPBZ/KfwGRV0OQ3QqjLVgL3zlbzuylYhaZqPgxxd46vgWwkyMiiv7u2OyCetq4LFd+tcNDz0Yqk6rK9/S0oxbN8NM5DLkpwFh/433BoPS3QKBgQD/dsxNr2PYdPLp6pOvw7H2AFMH8CkwTlRg+2f/0fgQF14rJwZgEU6fL5A2JvQeRRC5mCff2m5tDqrS321JNyH/JIKJ+4J8I34GEo/kSCHL3RmyvJGQOQ/EpEyxvP8BV3ob6UO3LR58DOGlJr8eTsr3Y8o9cAMuknCNxvsd2LvybwKBgQC7xKkx4KIPBny6sCOtChOkgIrY3hOCi+ZsHQVESXKzeku0NkH/qrAG+S9pb1XCzXdM2HrzkMeuz6tqi+2TY8nORyY2DZHNW7FqzkAiZ/NO2AgGIlALq1ZfJZke2MxgtBnxSsQ03gfXP9opu/FsLH9a+s6edfHPvKD4kHxlLBfAbwKBgQDYvr6QmuKn4HHJLZGoau0uvw+ziHwp1AubTTLrxgYmAO2Qx0eNcqG2RfChQWOV2xtZnFMYhodyWCNvTsm2eOSLSTrIP3ByStq95DnZganLAgivsXX/W6qZOJ0poCTryoB79enSHKHktjksmjdFS6zBQRVyEvtgJDcC03Rz2lN8WQKBgQCCoJE4otb7bv7s/ccEBeOeaNKvhue5xUwbYKEeXZ6PYAA0sh5+GCf34flq90qJiFl7u4rl0Y4pfk35hLlV9XEasYLSzePmIuktrakOhpTNABus8MgRJjSjYsvAmwCsMf9uTx5qzSBVThWfPSH6qIY9LAj8Un9UjxzJb/Mqi19GvwKBgQC0/KB+3robTqy9KOV4iEKJ4kmnXDRu7ecpMyc8k5HzpolIHcXLZHkBK9pMCXBQ9Kwy6BjRGNnUZOahS+tvnMcjHpwdhu90r7D51GXW/+PeFtphYTscFhHv1yuWbbojzhKf69pZnsVmyllIBqRgtbkS2WNHxWo/peCg47TcLaQNMA==
+ publicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhBZoE6p1TKpd/WsAJRTA2D6yUTzqLmZ73scxbPxxKwPIg2ys2Ap21u/lVmqBWO9Wf2Z7wUwr/6BP1PQqVpg0GAqU3yjjZ0LGfBitzMBMbGrlOLqJQ3PKgnUNmnOdLR4FlHCAjKtuyxjHkxBTHg/L4punk4lkFJQD8YvzFrYalS6WYw5j1/oq080NbcjPirPCRlsU7MRraQuUqSTdPwm2iHkroKwCEbGv+RtNJCfOkKNQVtRFFgPGMhU4nQ620gdfzsGJsNFKVJnD5SjeDWniBAbaGaVF4rEfKJPe6+XrcMg3h+9Fz+A2IU1KCCoth2neEZEaU1t0KBGxXIuo4efi/QIDAQAB
+ appCertPath: \u5E94\u7528\u516C\u94A5\u8BC1\u4E66
+ aliPayCertPath: \u652F\u4ED8\u5B9D\u516C\u94A5\u8BC1\u4E66
+ aliPayRootCertPath: \u652F\u4ED8\u5B9D\u6839\u8BC1\u4E66
+ serverUrl: https://openapi-sandbox.dl.alipaydev.com/gateway.do
+ domain: http://localhost:8085
+ testDomain: http://129.204.171.210:8085
diff --git a/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UAlipayOrderMapper.xml b/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UAlipayOrderMapper.xml
deleted file mode 100644
index 189bde9..0000000
--- a/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UAlipayOrderMapper.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- INSERT INTO u_alipay_order (out_trade_no, trade_status, total_amount, subject, body, create_time, update_time)
- VALUES (#{outTradeNo}, #{tradeStatus}, #{totalAmount}, #{subject}, #{body}, #{createTime}, #{updateTime})
-
-
-
- UPDATE u_alipay_order
- SET trade_status = #{tradeStatus}, total_amount = #{totalAmount}, subject = #{subject}, body = #{body}, update_time = #{updateTime}
- WHERE out_trade_no = #{outTradeNo}
-
-
-
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UCreditCardOrderMapper.xml b/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UCreditCardOrderMapper.xml
deleted file mode 100644
index 3608095..0000000
--- a/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UCreditCardOrderMapper.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
- INSERT INTO u_credit_card_order (transaction_id, user_id, order_id, amount, currency, status, payment_time, card_type, card_holder_name, billing_address, card_last_four, gateway_response)
- VALUES (#{transactionId}, #{userId}, #{orderId}, #{amount}, #{currency}, #{status}, #{paymentTime}, #{cardType}, #{cardHolderName}, #{billingAddress}, #{cardLastFour}, #{gatewayResponse})
-
-
-
-
-
-
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UCreditCardTokenMapper.xml b/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UCreditCardTokenMapper.xml
deleted file mode 100644
index 85b9996..0000000
--- a/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UCreditCardTokenMapper.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- INSERT INTO u_credit_card_token (user_id, token, card_last_four, card_type, created_at)
- VALUES (#{userId}, #{token}, #{cardLastFour}, #{cardType}, #{createdAt})
-
-
-
-
-
\ No newline at end of file
diff --git a/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UWxPayOrderMapper.xml b/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UWxPayOrderMapper.xml
deleted file mode 100644
index 9490700..0000000
--- a/wfc-modules/wfc-payment/src/main/resources/mapper/payment/UWxPayOrderMapper.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- out_trade_no,
- INSERT INTO u_wxpay_order (out_trade_no, trancation_id, trade_status, total_amount, subject, body, create_time, update_time)
- VALUES (#{outTradeNo}, #{trancationId}, #{tradeStatus}, #{totalAmount}, #{subject}, #{body}, #{createTime}, #{updateTime})
-
-
-
- UPDATE u_wxpay_order
- SET trade_status = #{tradeStatus}, total_amount = #{totalAmount}, subject = #{subject}, body = #{body}, update_time = #{updateTime}
- WHERE out_trade_no = #{outTradeNo}
-
-
-
\ No newline at end of file
diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java
index afa8485..7c93c35 100644
--- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java
+++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java
@@ -13,9 +13,11 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.domain.LoginUser;
+import org.wfc.common.core.domain.R;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.core.web.page.TableDataInfo;
+import org.wfc.common.security.annotation.InnerAuth;
import org.wfc.common.security.utils.SecurityUtils;
import org.wfc.user.domain.UOrder;
import org.wfc.user.domain.UPackage;
@@ -96,8 +98,8 @@ public class UOrderController extends BaseController {
}
@PostMapping
- public AjaxResult add(@RequestBody UOrder uOrder) {
- return toAjax(uOrderService.saveOrder(uOrder));
+ public R add(@RequestBody UOrder uOrder) {
+ return R.ok(uOrderService.saveOrder(uOrder));
}
@PutMapping
@@ -110,4 +112,9 @@ public class UOrderController extends BaseController {
return toAjax(uOrderService.removeByIds(CollUtil.newArrayList(ids)));
}
+ @InnerAuth
+ @PostMapping("paySuccess/{id}")
+ public AjaxResult paySuccess(@PathVariable("id") Long id) {
+ return toAjax(uOrderService.paySuccess(id));
+ }
}
diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUOrderService.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUOrderService.java
index beaab53..79f5102 100644
--- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUOrderService.java
+++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUOrderService.java
@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IUOrderService extends IService {
- boolean saveOrder(UOrder order);
+ Long saveOrder(UOrder order);
+ boolean paySuccess(Long orderId);
}
diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java
index 6db857b..0e778c1 100644
--- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java
+++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java
@@ -15,6 +15,7 @@ import org.wfc.user.api.IWifiApi;
import org.wfc.user.api.omada.domain.convert.OmadaConvert;
import org.wfc.user.api.omada.domain.dto.ClientRateLimitSettingDto;
import org.wfc.user.domain.UAccount;
+import org.wfc.user.domain.UBillRule;
import org.wfc.user.domain.UClient;
import org.wfc.user.domain.UOrder;
import org.wfc.user.domain.UPackage;
@@ -22,6 +23,7 @@ import org.wfc.user.domain.URateLimit;
import org.wfc.user.domain.constant.OrderStatusEnum;
import org.wfc.user.domain.constant.OrderTypeEnum;
import org.wfc.user.domain.constant.PeriodTypeEnum;
+import org.wfc.user.mapper.UBillRuleMapper;
import org.wfc.user.mapper.UOrderMapper;
import org.wfc.user.service.IUAccountService;
import org.wfc.user.service.IUClientService;
@@ -58,14 +60,21 @@ public class UOrderServiceImpl extends ServiceImpl impleme
@Autowired
private IUClientService clientService;
+ @Autowired
+ private UBillRuleMapper billRuleMapper;
+
@Autowired
private IWifiApi wifiApi;
- public void paySuccess(Long orderId) {
+ @Override
+ public boolean paySuccess(Long orderId) {
// 支付成功回调(预留)
// 更新当前订单状态为已支付
UOrder order = this.getById(orderId);
+ if (OrderStatusEnum.PAID.getCode().equals(order.getStatus())) {
+ return false;
+ }
order.setStatus(OrderStatusEnum.PAID.getCode());
this.updateById(order);
@@ -109,7 +118,7 @@ public class UOrderServiceImpl extends ServiceImpl impleme
wifiApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting);
}
}
-
+ return true;
}
private void callbackPackage(UOrder order, UAccount account) {
@@ -156,14 +165,20 @@ public class UOrderServiceImpl extends ServiceImpl impleme
}
@Override
- public boolean saveOrder(UOrder order) {
+ public Long saveOrder(UOrder order) {
order.setUserId(SecurityUtils.getUserId());
order.setStatus(OrderStatusEnum.UNPAID.getCode());
order.setOrderNo(System.currentTimeMillis() + StrUtil.EMPTY);
this.save(order);
- // 支付成功回调
- paySuccess(order.getId());
+ List billRules = billRuleMapper.selectList(Wrappers.lambdaQuery());
+ billRules.stream().findFirst().ifPresent(billRule -> {
+ // 测试
+ if (billRule.getTraffic() == 1) {
+ // 支付成功回调
+ paySuccess(order.getId());
+ }
+ });
- return true;
+ return order.getId();
}
}