微信刷脸模块
This commit is contained in:
parent
ab05bf79ce
commit
9c09e8f004
|
@ -76,45 +76,57 @@ public class WxFacePayController {
|
|||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/doFacePay", method = RequestMethod.POST)
|
||||
public Result<WxFacePayAuthinfoResp> doFacePay(@RequestBody WxFaceOrderVo wxFaceOrderVo) throws Exception {
|
||||
//1 初始化
|
||||
this.initWxpayface();
|
||||
public Result<String> doFacePay(@RequestBody WxFaceOrderVo wxFaceOrderVo) throws Exception {
|
||||
Result<String> result = new Result<>();
|
||||
try {
|
||||
//1 初始化
|
||||
this.initWxpayface();
|
||||
|
||||
//2 获取数据getWxpayfaceRawdata
|
||||
WxFacePayResp wxFacePayResp = this.getWxpayfaceRawdata();
|
||||
//String rawdata = wxFacePayResp.getRawdata();
|
||||
//2 获取数据getWxpayfaceRawdata
|
||||
WxFacePayResp wxFacePayResp = this.getWxpayfaceRawdata();
|
||||
//String rawdata = wxFacePayResp.getRawdata();
|
||||
|
||||
//3、获取调用凭证get_wxpayface_authinfo(rawdata)(获取调用凭证)
|
||||
WxFacePayAuthinfoResp wxFacePayResp0 = this.getWxpayfaceAuthinfo(wxFacePayResp.getRawdata());
|
||||
//3、获取调用凭证get_wxpayface_authinfo(rawdata)(获取调用凭证)
|
||||
WxFacePayAuthinfoResp wxFacePayResp0 = this.getWxpayfaceAuthinfo(wxFacePayResp.getRawdata());
|
||||
|
||||
//4、进行人脸识别getWxpayfaceCode(获取支付凭证)
|
||||
WxFacePayAuthinfoResp authinfoResp = this.getWxpayfaceCode(wxFaceOrderVo, wxFacePayResp0);
|
||||
//4、进行人脸识别getWxpayfaceCode(获取支付凭证)
|
||||
WxFacePayAuthinfoResp authinfoResp = this.getWxpayfaceCode(wxFaceOrderVo, wxFacePayResp0);
|
||||
|
||||
WxPayMicropayResult micropayResult = new WxPayMicropayResult();
|
||||
if (StringUtil.isNotBlank(authinfoResp.getFace_code())) {
|
||||
//5、调用后台人脸支付API发起支付
|
||||
wxFaceOrderVo.setOutTradeNo(getOutTradeNo());
|
||||
micropayResult = this.toCreateWxOrder(authinfoResp, wxFaceOrderVo, wxFacePayResp0);
|
||||
WxPayMicropayResult micropayResult = new WxPayMicropayResult();
|
||||
if (StringUtil.isNotBlank(authinfoResp.getFace_code())) {
|
||||
//5、调用后台人脸支付API发起支付
|
||||
wxFaceOrderVo.setOutTradeNo(getOutTradeNo());
|
||||
micropayResult = this.toCreateWxOrder(authinfoResp, wxFaceOrderVo, wxFacePayResp0);
|
||||
|
||||
//6、向后端查询订单状态 WxPayOrderQueryResult queryResult = queryOrderByNo(micropayResult);
|
||||
boolean isSuccess = pollOrderStatus(micropayResult);
|
||||
if (isSuccess) {
|
||||
//8、更新支付结果updateWxpayfacePayResult
|
||||
WxFacePayResp updFacePayResp = this.updateWxpayfacePayResult(wxFacePayResp0);
|
||||
//6、向后端查询订单状态 WxPayOrderQueryResult queryResult = queryOrderByNo(micropayResult);
|
||||
boolean isSuccess = pollOrderStatus(micropayResult);
|
||||
if (isSuccess) {
|
||||
//8、更新支付结果updateWxpayfacePayResult
|
||||
WxFacePayResp updFacePayResp = this.updateWxpayfacePayResult(wxFacePayResp0);
|
||||
|
||||
if (ObjUtil.isNotEmpty(updFacePayResp) && WxConstant.STATE_SUCCESS.equals(updFacePayResp.getReturn_code())) {
|
||||
//向后端发起更新订单,进行相应的操作、
|
||||
this.updatePayResult(micropayResult);
|
||||
if (ObjUtil.isNotEmpty(updFacePayResp) && WxConstant.STATE_SUCCESS.equals(updFacePayResp.getReturn_code())) {
|
||||
//11、向后端发起更新订单,进行相应的操作、
|
||||
this.updatePayResult(micropayResult);
|
||||
|
||||
result = Result.ok("微信刷脸成功!", micropayResult.getOutTradeNo());
|
||||
}
|
||||
} else { //查询失败或者长时间未有结果
|
||||
//7、撤销交易reverse
|
||||
WxPayOrderReverseRequest reverseRequest = new WxPayOrderReverseRequest();
|
||||
reverseRequest.setTransactionId(micropayResult.getTransactionId());
|
||||
reverseRequest.setOutTradeNo(micropayResult.getOutTradeNo());
|
||||
WxPayOrderReverseResult reverseResult = this.toReverseOrder(reverseRequest);
|
||||
result = Result.error("微信刷脸失败后已经撤销订单!");
|
||||
}
|
||||
} else { //查询失败或者长时间未有结果
|
||||
//7、撤销交易reverse
|
||||
WxPayOrderReverseRequest reverseRequest = new WxPayOrderReverseRequest();
|
||||
reverseRequest.setTransactionId(micropayResult.getTransactionId());
|
||||
reverseRequest.setOutTradeNo(micropayResult.getOutTradeNo());
|
||||
WxPayOrderReverseResult reverseResult = this.toReverseOrder(reverseRequest);
|
||||
} else {
|
||||
result = Result.error("获取人脸识别支付凭证为空值");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info("[WxFacePayController][doFacePay][84][微信刷脸完成流程出错] :{}", e.getMessage());
|
||||
result = Result.error("微信刷脸完成流程出错:" + e.getMessage());
|
||||
}
|
||||
return Result.ok(authinfoResp);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -255,6 +267,7 @@ public class WxFacePayController {
|
|||
* 查询微信刷脸订单状态
|
||||
* 30秒
|
||||
* 调用步骤6
|
||||
*
|
||||
* @param micropayResult
|
||||
* @return
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue