| | |
| | | package com.dsh.activity.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.activity.entity.THuiminAgreement; |
| | |
| | | import com.dsh.activity.util.ResultUtil; |
| | | import com.dsh.activity.util.TokenUtil; |
| | | import com.dsh.activity.util.UUIDUtil; |
| | | import com.dsh.activity.util.wx.WxV3PayConfig; |
| | | import com.wechat.pay.contrib.apache.httpclient.util.AesUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 惠民卡回调 |
| | | * 玩湃惠民卡回调 |
| | | * |
| | | * @author zhibing.pu |
| | | * @date 2023/6/24 11:27 |
| | | */ |
| | |
| | | |
| | | |
| | | /** |
| | | * 惠民卡支付宝支付回调接口 |
| | | * 玩湃惠民卡支付宝支付回调接口 |
| | | */ |
| | | @PostMapping("/aliPayHuiminCallback") |
| | | public void aliPayHuiminCallback(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.err.println("==========回调"); |
| | | System.err.println("支付宝回调"); |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | if (null != map) { |
| | | String out_trade_no = map.get("out_trade_no"); |
| | | String transaction_id = map.get("transaction_id"); |
| | | String transaction_id = map.get("trade_no"); |
| | | TPayHuimin one = payHuiminService.getOne(new LambdaQueryWrapper<TPayHuimin>().eq(TPayHuimin::getCode, out_trade_no)); |
| | | if (one!=null){ |
| | | if (one.getStatus()==2){ |
| | | if (one != null) { |
| | | if (one.getStatus() == 2) { |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | }else{ |
| | | } else if (one.getStatus() == 1) { |
| | | one.setOrderNumber(transaction_id); |
| | | one.setStatus(2); |
| | | one.setPaymentTime(new Date()); |
| | | payHuiminService.updateById(one); |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } else { |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 惠民卡微信支付回调接口 |
| | | * 玩湃惠民卡微信支付回调接口 |
| | | */ |
| | | @PostMapping("/weixinPayHuiminCallback") |
| | | public void weixinPayHuiminCallback(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.err.println("微信回调"); |
| | | Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | | if (null != map) { |
| | | String out_trade_no = map.get("out_trade_no"); |
| | | String transaction_id = map.get("transaction_id"); |
| | | String result = map.get("result"); |
| | | TPayHuimin one = payHuiminService.getOne(new LambdaQueryWrapper<TPayHuimin>().eq(TPayHuimin::getCode, out_trade_no)); |
| | | if (one!=null){ |
| | | if (one.getStatus()==2){ |
| | | if (one != null) { |
| | | if (one.getStatus() == 2) { |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(result); |
| | | out.flush(); |
| | | out.close(); |
| | | }else{ |
| | | } else if (one.getStatus() == 1) { |
| | | one.setOrderNumber(transaction_id); |
| | | one.setStatus(2); |
| | | one.setPaymentTime(new Date()); |
| | | payHuiminService.updateById(one); |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(result); |
| | | out.flush(); |
| | | out.close(); |
| | | } else { |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("SUCCESS"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | @PostMapping("/weixinPayHuiminCallback1") |
| | | public void weixinPayHuiminCallback1(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.err.println("微信回调"); |
| | | System.err.println("请求" + request); |
| | | BufferedReader reader = request.getReader(); |
| | | String string1 = reader.toString(); |
| | | System.err.println("请求reader" + string1); |
| | | StringBuilder requestBody = new StringBuilder(); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | requestBody.append(line); |
| | | } |
| | | System.err.println("全部请求体" + requestBody); |
| | | JSONObject jsonObject = JSONObject.parseObject(requestBody.toString()); |
| | | JSONObject resource = jsonObject.getJSONObject("resource"); |
| | | |
| | | AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8)); |
| | | String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8), |
| | | resource.getString("ciphertext")); |
| | | System.err.println("微信解密的字符串信息" + decryptedData); |
| | | JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData); |
| | | String out_trade_no = jsonInfo.getString("out_trade_no"); |
| | | String transaction_id = jsonInfo.getString("transaction_id"); |
| | | String trade_state = jsonInfo.getString("trade_state"); |
| | | if (trade_state.equals("SUCCESS")) { |
| | | TPayHuimin one = payHuiminService.getOne(new LambdaQueryWrapper<TPayHuimin>().eq(TPayHuimin::getCode, out_trade_no)); |
| | | if (one != null) { |
| | | if (one.getStatus() == 2) { |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("SUCCESS"); |
| | | out.flush(); |
| | | out.close(); |
| | | } else if (one.getStatus() == 1) { |
| | | one.setOrderNumber(transaction_id); |
| | | one.setStatus(2); |
| | | one.setPaymentTime(new Date()); |
| | | payHuiminService.updateById(one); |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("SUCCESS"); |
| | | out.flush(); |
| | | out.close(); |
| | | } else { |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("SUCCESS"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 惠民卡微信退款回调 |
| | | * 玩湃惠民卡微信退款回调 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/wxRefundHuiminCallback") |
| | | public void wxRefundHuiminCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | public void wxRefundHuiminCallback(HttpServletRequest request, HttpServletResponse response) { |
| | | Map<String, String> map = payMoneyUtil.wxRefundCallback(request); |
| | | if(null != map){ |
| | | if (null != map) { |
| | | String refund_id = map.get("refund_id"); |
| | | String out_refund_no = map.get("out_refund_no"); |
| | | String result = map.get("result"); |