微信刷脸:复制自助机模块

This commit is contained in:
2025-08-18 18:37:29 +08:00
parent 9ca5424a28
commit 9a8be43091
10 changed files with 54 additions and 55 deletions

View File

@@ -18,7 +18,6 @@ import com.dpkj.modules.scanface.wx.vo.WxFacePayAuthinfoResp;
import com.dpkj.modules.scanface.wx.vo.WxFacePayReq; import com.dpkj.modules.scanface.wx.vo.WxFacePayReq;
import com.dpkj.modules.scanface.wx.vo.WxFacePayResp; import com.dpkj.modules.scanface.wx.vo.WxFacePayResp;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.binarywang.wxpay.bean.request.WxPayOrderReverseRequest; import com.github.binarywang.wxpay.bean.request.WxPayOrderReverseRequest;
import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult; import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult;
import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult; import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult;
@@ -34,16 +33,9 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.HashMap; import java.math.BigDecimal;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/** /**
* @description: 微信刷脸支付 * @description: 微信刷脸支付
@@ -79,6 +71,10 @@ public class WxFacePayController {
public Result<String> doFacePay(@RequestBody WxFaceOrderVo wxFaceOrderVo) throws Exception { public Result<String> doFacePay(@RequestBody WxFaceOrderVo wxFaceOrderVo) throws Exception {
Result<String> result = new Result<>(); Result<String> result = new Result<>();
try { try {
//元转分
int money = new BigDecimal(wxFaceOrderVo.getTotalAmount()).multiply(new BigDecimal(100)).intValue();
wxFaceOrderVo.setTotalAmount(String.valueOf(money));
//1 初始化 //1 初始化
this.initWxpayface(); this.initWxpayface();
@@ -95,6 +91,7 @@ public class WxFacePayController {
WxPayMicropayResult micropayResult = new WxPayMicropayResult(); WxPayMicropayResult micropayResult = new WxPayMicropayResult();
if (StringUtil.isNotBlank(authinfoResp.getFace_code())) { if (StringUtil.isNotBlank(authinfoResp.getFace_code())) {
//5、调用后台人脸支付API发起支付 //5、调用后台人脸支付API发起支付
System.out.println("---------调用后台人脸支付API发起支付");
wxFaceOrderVo.setOutTradeNo(getOutTradeNo()); wxFaceOrderVo.setOutTradeNo(getOutTradeNo());
micropayResult = this.toCreateWxOrder(authinfoResp, wxFaceOrderVo, wxFacePayResp0); micropayResult = this.toCreateWxOrder(authinfoResp, wxFaceOrderVo, wxFacePayResp0);
@@ -184,6 +181,7 @@ public class WxFacePayController {
public WxFacePayAuthinfoResp getWxpayfaceCode(@RequestBody WxFaceOrderVo wxFaceOrderVo, WxFacePayAuthinfoResp wxFacePayResp0) throws Exception { public WxFacePayAuthinfoResp getWxpayfaceCode(@RequestBody WxFaceOrderVo wxFaceOrderVo, WxFacePayAuthinfoResp wxFacePayResp0) throws Exception {
//4、进行人脸识别getWxpayfaceCode获取支付凭证 //4、进行人脸识别getWxpayfaceCode获取支付凭证
String outTradeNo = getOutTradeNo();//获取流水号 String outTradeNo = getOutTradeNo();//获取流水号
// 构建请求参数的JSON字符串 // 构建请求参数的JSON字符串
WxFacePayReq wxFacePayReq = new WxFacePayReq("getWxpayfaceCode", "1", System.currentTimeMillis() / 1000); WxFacePayReq wxFacePayReq = new WxFacePayReq("getWxpayfaceCode", "1", System.currentTimeMillis() / 1000);
wxFacePayReq.setAuthinfo(wxFacePayResp0.getAuthinfo()) wxFacePayReq.setAuthinfo(wxFacePayResp0.getAuthinfo())

View File

@@ -4,8 +4,6 @@ import com.dpkj.common.vo.Result;
import com.dpkj.modules.scanface.wx.dll.WxpayFaceSDKDll; import com.dpkj.modules.scanface.wx.dll.WxpayFaceSDKDll;
import com.dpkj.modules.scanface.wx.service.CallWxpayFaceService; import com.dpkj.modules.scanface.wx.service.CallWxpayFaceService;
import com.dpkj.modules.scanface.wx.service.WeChatPayFaceService; import com.dpkj.modules.scanface.wx.service.WeChatPayFaceService;
import com.dpkj.modules.scanface.wx.service.impl.CallWxpayFaceServiceImpl;
import com.dpkj.modules.scanface.wx.service.impl.WeChatPayFaceServiceImpl;
import com.dpkj.modules.scanface.wx.vo.WxFacePayAuthinfoResp; import com.dpkj.modules.scanface.wx.vo.WxFacePayAuthinfoResp;
import com.dpkj.modules.scanface.wx.vo.WxFacePayReq; import com.dpkj.modules.scanface.wx.vo.WxFacePayReq;
import com.dpkj.modules.scanface.wx.vo.WxFacePayResp; import com.dpkj.modules.scanface.wx.vo.WxFacePayResp;
@@ -15,15 +13,11 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.thymeleaf.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.security.Provider; import java.security.Provider;
import java.security.Security; import java.security.Security;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet; import java.util.TreeSet;
/** /**

View File

@@ -7,7 +7,6 @@ import com.dpkj.modules.scanface.wx.vo.WxFacePayResp;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Map;
/** /**
* @description: 调用微信刷脸方法 * @description: 调用微信刷脸方法

View File

@@ -56,7 +56,6 @@ public class CallWxpayFaceServiceImpl implements CallWxpayFaceService {
// 调用本地方法 // 调用本地方法
WxpayFaceSDKDll.Dll dll = WxpayFaceSDKDll.instance(); WxpayFaceSDKDll.Dll dll = WxpayFaceSDKDll.instance();
int result = dll.wxpayCallFaceService(reqPointer.getString(0), reqSize, pRespBuf, respSize); int result = dll.wxpayCallFaceService(reqPointer.getString(0), reqSize, pRespBuf, respSize);
//使用C:\Windows\System32目录下 int result = WxpayFaceSDK.INSTANCE.wxpayCallFaceService(reqPointer.getString(0), reqSize, pRespBuf, respSize);
if (result == 0) { if (result == 0) {
Pointer pointer = new Pointer(pRespBuf[0]); Pointer pointer = new Pointer(pRespBuf[0]);

View File

@@ -10,13 +10,10 @@ import com.dpkj.modules.scanface.wx.util.WXPayUtil;
import com.dpkj.modules.scanface.wx.util.WxRandomUtils; import com.dpkj.modules.scanface.wx.util.WxRandomUtils;
import com.dpkj.modules.scanface.wx.util.XmlParserUtil; import com.dpkj.modules.scanface.wx.util.XmlParserUtil;
import com.dpkj.modules.scanface.wx.util.XmlUtils; import com.dpkj.modules.scanface.wx.util.XmlUtils;
import com.dpkj.modules.scanface.wx.vo.WxFacePayAuthinfoResp; import com.dpkj.modules.scanface.wx.vo.*;
import com.dpkj.modules.scanface.wx.vo.WxFacePayMicroPayResp;
import com.dpkj.modules.scanface.wx.vo.WxFacePayOrderResp;
import com.dpkj.modules.scanface.wx.vo.WxFacePayReq;
import com.dpkj.modules.scanface.wx.vo.WxFacePayResp;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.sun.jna.Memory; import com.sun.jna.Memory;
import com.sun.jna.Pointer; import com.sun.jna.Pointer;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -27,16 +24,10 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.*;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
/** /**
* @description: 调用微信刷脸方法 * @description: 调用微信刷脸方法

View File

@@ -3,19 +3,12 @@ package com.dpkj.modules.scanface.wx.util;
import org.jdom2.Content; import org.jdom2.Content;
import org.jdom2.Document; import org.jdom2.Document;
import org.jdom2.Element; import org.jdom2.Element;
import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverter;
import java.io.StringReader; import java.io.StringReader;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.HashMap; import java.util.*;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
/** /**
* @description: 生成签名 * @description: 生成签名

View File

@@ -1,6 +1,8 @@
package com.dpkj.modules.scanface.wx.util; package com.dpkj.modules.scanface.wx.util;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath; import javax.xml.xpath.XPath;

View File

@@ -36,8 +36,10 @@ public class WxFaceOrderVo {
private String outTradeNo; private String outTradeNo;
/** /**
* 用户支付金额 * 用户支付金额 单位元
* 调用微信时需要转为分
*/ */
private String totalAmount; private String totalAmount;
} }

View File

@@ -67,27 +67,27 @@ dpkj:
service-id: pay service-id: pay
#微信模块 #微信模块
wx: wx:
configs: #清研家 configs: #中医院
- app-id: wxe8334dd2140bb0e1 - app-id: wxc12fa4977f66974d
# 公众号的appsecret # 公众号的appsecret
secret: f83420d79cc6ecd1d7fe9684ac9cdfe4 secret: a51dbcac25a73d7e4812a43cf550c5fc
# 接口配置里的Token值 # 接口配置里的Token值
token: dpkjylwjvote token: DPKJYINYITONG
# 接口配置里的EncodingAESKey值 # 接口配置里的EncodingAESKey值
aes-key: go2uM3ASe2rEyeoNsZHoPCiKGgpku0Bi49P5IypdQWT aes-key: yIBgBrHwRGjO2L3CLIE9hmnlf1FrXQQ7qJZVIg4r6Dx
mch-config: #商户信息 清研家关联的商户:驿路万家-扬州清研软件科技 mch-config: #商户信息 中医院
app-id: wxe8334dd2140bb0e1 app-id: wxc12fa4977f66974d
secret: f83420d79cc6ecd1d7fe9684ac9cdfe4 secret: a51dbcac25a73d7e4812a43cf550c5fc
#调用接口所需service_id #调用接口所需service_id
service-id: service_id service-id: service_id
#商户号 #商户号
mch-id: 1557642321 mch-id: 1603658732
#商户秘钥 #商户秘钥
mch-key: yndpkj15288216506YndpkjKsjytZx12 mch-key: lczyywxc12fa4977f66974dyytzz1234
#报文解密 APIv3密钥 #报文解密 APIv3密钥
v3-key: yndpkj15288216506YndpkjKsjytZx12 v3-key: lczyywxc12fa4977f66974dyytzz1234
#微信: 商户APIv2密钥 #微信: 商户APIv2密钥
key-api: yndpkj15288216506YndpkjKsjytZx12 key-api: lczyywxc12fa4977f66974dyytzz1234
#p12证书的位置可以指定绝对路径也可以指定类路径以classpath;开头) #p12证书的位置可以指定绝对路径也可以指定类路径以classpath;开头)
key-path: classpath:test\apiclient_cert.p12 key-path: classpath:test\apiclient_cert.p12
private-key-path: classpath:test\apiclient_key.pem private-key-path: classpath:test\apiclient_key.pem
@@ -105,9 +105,9 @@ dpkj:
url: url:
# 后端接口地址 # 后端接口地址
# server: https://102760424tfyw.vicp.fun/api # server: https://102760424tfyw.vicp.fun/api
server: ${dpkj.server-url} server: ${dpkj.url.server-url}
# h5地址 # h5地址
h5: ${dpkj.h5-url} h5: ${dpkj.url.h5-url}
# 身份证读取等待时间 # 身份证读取等待时间

View File

@@ -1,6 +1,27 @@
spring: spring:
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB
resource:
static-locations: classpath:/static/,classpath:/public/
application: application:
name: yinyitong-zhongyuyuan-dll-hang name: ems-express-bridge
profiles: profiles:
active: '@profile.name@' #active: '@profile.name@'
active: pro
server:
port: 5948 #5946
servlet:
context-path: /api
tomcat:
max-swallow-size: -1
error:
include-exception: true
include-stacktrace: ALWAYS
include-message: ALWAYS
compression:
enabled: true
min-response-size: 1024
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*