| | |
| | | |
| | | |
| | | import cn.mb.cloud.common.data.controller.BaseController; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.dsh.course.model.vo.TQueryBenefitsVideosVO; |
| | | import com.dsh.course.service.*; |
| | | import com.dsh.course.util.*; |
| | | import com.dsh.course.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.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.BufferedReader; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/course/weChatPaymentCourseCallback1") |
| | | public void weChatPaymentCourseCallback1(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 code = jsonInfo.getString("out_trade_no"); |
| | | String transaction_id = jsonInfo.getString("transaction_id"); |
| | | String trade_state = jsonInfo.getString("trade_state"); |
| | | String attach = jsonInfo.getString("attach"); |
| | | if (trade_state.equals("SUCCESS")) { |
| | | |
| | | ResultUtil resultUtil = coursePackageService.paymentCourseCallback(code, transaction_id, attach); |
| | | if (resultUtil.getCode() == 200) { |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("SUCCESS"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/base/course/weChatPaymentCourseCallback") |
| | | public void weChatPaymentCourseCallback(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 购买课程支付宝回调 |