From 75942ecc2e438012c5ea876715966ace593565a0 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 11 四月 2025 15:17:41 +0800
Subject: [PATCH] 部分代码

---
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java |  414 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 384 insertions(+), 30 deletions(-)

diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
index 5e6aa69..f82b561 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
@@ -1,6 +1,10 @@
 package com.ruoyi.study.controller;
 
-
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.SignatureVerificationException;
+import com.auth0.jwt.interfaces.DecodedJWT;
+import com.alibaba.fastjson.JSONObject;
 import com.alipay.api.AlipayApiException;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.common.core.constant.Constants;
@@ -28,14 +32,22 @@
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.models.auth.In;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
-
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
 import java.io.PrintWriter;
+import java.math.BigDecimal;
+import java.security.PublicKey;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.ECPublicKey;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -139,12 +151,43 @@
 
     @Autowired
     private PayMoneyUtil payMoneyUtil;
+    public static JSONObject verifyAndGet(String jws) throws CertificateException {
+        DecodedJWT decodedJWT = JWT.decode(jws);
+        // 拿到 header 中 x5c 数组中第一个
+        String header = new String(java.util.Base64.getDecoder().decode(decodedJWT.getHeader()));
+        String x5c = JSONObject.parseObject(header).getJSONArray("x5c").getString(0);
 
+        // 获取公钥
+        PublicKey publicKey = getPublicKeyByX5c(x5c);
+
+        // 验证 token
+        Algorithm algorithm = Algorithm.ECDSA256((ECPublicKey) publicKey, null);
+
+        try {
+            algorithm.verify(decodedJWT);
+        } catch (SignatureVerificationException e) {
+            throw new RuntimeException("签名验证失败");
+        }
+        // 解析数据
+        return JSONObject.parseObject(new String(java.util.Base64.getDecoder().decode(decodedJWT.getPayload())));
+    }
+
+    /**
+     * 获取公钥
+     * @param x5c
+     * @return
+     * @throws
+     */
+    private static PublicKey getPublicKeyByX5c(String x5c) throws CertificateException {
+        byte[] x5c0Bytes = java.util.Base64.getDecoder().decode(x5c);
+        CertificateFactory fact = CertificateFactory.getInstance("X.509");
+        X509Certificate cer = (X509Certificate) fact.generateCertificate(new ByteArrayInputStream(x5c0Bytes));
+        return cer.getPublicKey();
+    }
     @PostMapping("/pay")
     @ApiOperation(value = "购买会员支付操作", tags = {"家长端-个人中心"})
     @ApiImplicitParams({
             @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header"),
-
     })
     public AjaxResult pay(@RequestBody PayDTO dto) throws Exception {
         TVipOrder tVipOrder = vipOrderService.getById(dto.getOrderId());
@@ -165,44 +208,335 @@
                                         UUIDUtil.getRandomCode(8),
                                 tVipOrder.getMoney().toString(),
                                 "/base/user/aliPayBuyVip");
+            case 3:
+                tVipOrder.setTransactionId(dto.getTransactionIdentifier());
+                vipOrderService.updateById(tVipOrder);
         }
         return AjaxResult.success();
     }
+    @PostMapping("/queryOrderState")
+    @ApiOperation(value = "苹果内购查询支付状态", tags = {"苹果内购查询支付状态"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header"),
+            @ApiImplicitParam(name = "orderId", value = "订单id", required = true)
+    })
+    public AjaxResult<Boolean> pay(Integer orderId) throws Exception {
+        System.err.println("苹果orderId:"+orderId);
+        TVipOrder byId = vipOrderService.getById(orderId);
+        if (byId.getPayState() == 2){
+            return AjaxResult.success(true);
+        }else{
+            return AjaxResult.success(false);
+        }
+    }
+
+
 
     @PostMapping("/order")
     @ApiOperation(value = "购买会员下单操作", tags = {"家长端-个人中心"})
     @ApiImplicitParams({
             @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header"),
-            @ApiImplicitParam(name = "payType", value = "支付类型 1=微信 2=支付宝", required = true),
-            @ApiImplicitParam(name = "id", value = "会员规格id", required = true),
+            @ApiImplicitParam(name = "payType", value = "支付类型 1=微信 2=支付宝 3=苹果内购", required = true),
+            @ApiImplicitParam(name = "id", value = "会员规格id", required = false),
+            @ApiImplicitParam(name = "count", value = "购买会员月数--ios用", required = false),
+            @ApiImplicitParam(name = "price", value = "价格--ios用", required = false),
     })
-    public R<PayVO> order(Integer payType, Integer id) throws Exception {
+    public R<PayVO> order(Integer payType, Integer id,Integer count,BigDecimal price) throws Exception {
         if (tokenService.getLoginUser1() == null) {
             return R.tokenError("登录失效");
         }
+        // todo price根据用户环境确定单位 可能为刀或欧等等 也许后续需要处理转换 存元
         Integer userid = tokenService.getLoginUser1().getUserid();
         TVipOrder tVipOrder = new TVipOrder();
         List<TVipSet> data = managementClient.getVipSet1().getData();
+        if (price!=null){
+            id = null;
+        }
         Integer time = 0;
-        for (TVipSet datum : data) {
-            if (datum.getId() == id) {
-                tVipOrder.setMoney(datum.getAmount());
-                time = datum.getTime();
+        if (id!=null){
+            for (TVipSet datum : data) {
+                if (datum.getId() == id) {
+                    tVipOrder.setMoney(datum.getAmount());
+                    time = datum.getTime();
+                    tVipOrder.setCount(time);
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(new Date());
+                    calendar.add(Calendar.MONTH, time);
+                    Date dateAfterOneMonth = calendar.getTime();
+                    dateAfterOneMonth.setHours(23);
+                    dateAfterOneMonth.setMinutes(59);
+                    dateAfterOneMonth.setSeconds(59);
+                    tVipOrder.setTime(dateAfterOneMonth);
+                    tVipOrder.setCount(time);
+                    break;
+                }
             }
+        }else{
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(new Date());
+            calendar.add(Calendar.MONTH, count);
+            Date dateAfterOneMonth = calendar.getTime();
+            dateAfterOneMonth.setHours(23);
+            dateAfterOneMonth.setMinutes(59);
+            dateAfterOneMonth.setSeconds(59);
+            tVipOrder.setTime(dateAfterOneMonth);
+            tVipOrder.setCount(count);
         }
         tVipOrder.setPayState(1);
         tVipOrder.setUserId(userid);
         tVipOrder.setPayType(payType);
-        tVipOrder.setCount(time);
         vipOrderService.save(tVipOrder);
         PayVO payVO = new PayVO();
         payVO.setOrderId(tVipOrder.getId());
         payVO.setId(id);
         return R.ok(payVO);
-
-
+    }
+    @PostMapping("/orderStudent")
+    @ApiOperation(value = "学习端购买会员下单操作", tags = {"家长端-个人中心"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header"),
+            @ApiImplicitParam(name = "payType", value = "支付类型 1=微信 2=支付宝 3=苹果内购", required = true),
+            @ApiImplicitParam(name = "id", value = "会员规格id", required = false),
+            @ApiImplicitParam(name = "count", value = "购买会员月数--ios用", required = false),
+            @ApiImplicitParam(name = "price", value = "价格--ios用", required = false),
+    })
+    public R<PayVO> orderStudent(Integer payType, Integer id,Integer count,BigDecimal price) throws Exception {
+        if (tokenService.getLoginUserStudy() == null) {
+            return R.tokenError("登录失效");
+        }
+        Integer userid = tokenService.getLoginUserStudy().getUserid();
+        TVipOrder tVipOrder = new TVipOrder();
+        List<TVipSet> data = managementClient.getVipSet1().getData();
+        Integer time = 0;
+        if (id!=null){
+            for (TVipSet datum : data) {
+                if (datum.getId() == id) {
+                    tVipOrder.setMoney(datum.getAmount());
+                    time = datum.getTime();
+                }
+            }
+        }
+        tVipOrder.setPayState(1);
+        tVipOrder.setUserId(userid);
+        tVipOrder.setPayType(payType);
+        if (count!=null){
+            tVipOrder.setCount(count);
+            tVipOrder.setMoney(price);
+        }else{
+            tVipOrder.setCount(time);
+        }
+        vipOrderService.save(tVipOrder);
+        PayVO payVO = new PayVO();
+        payVO.setOrderId(tVipOrder.getId());
+        payVO.setId(id);
+        return R.ok(payVO);
     }
 
+    @ResponseBody
+    @PostMapping("/testApple")
+    public void testApple(HttpServletRequest request, HttpServletResponse response) {
+        try {
+            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);
+            org.json.JSONObject jsonObject1 = new org.json.JSONObject(requestBody.toString());
+            System.err.println("json串"+jsonObject1);
+            String o = jsonObject1.getString("signedPayload");
+            JSONObject payload = verifyAndGet(o);
+            String notificationType = payload.get("notificationType").toString();
+            JSONObject data = payload.getJSONObject("data");
+            String signedTransactionInfo = data.get("signedTransactionInfo").toString();
+            String environment = data.get("environment").toString();
+            JSONObject transactionInfo = verifyAndGet(signedTransactionInfo);
+            String transactionId = transactionInfo.get("transactionId").toString();
+            String originalTransactionId = transactionInfo.get("originalTransactionId").toString();
+            String productId = transactionInfo.get("productId").toString();
+            System.err.println("json串"+transactionInfo);
+            System.err.println("data"+data);
+            // 苹果流水号
+            String string = transactionInfo.getString("originalTransactionId");
+            TVipOrder one = vipOrderService.getOne(new QueryWrapper<TVipOrder>()
+                    .eq("transactionId", string)
+                    .eq("payType", 3));
+            System.err.println("回调通知类型"+notificationType);
+            if ("REFUND".equals(notificationType)){
+                if (one!=null && one.getPayState() == 2){
+                    one.setPayState(3);
+                    one.setBackTime(new Date());
+                    // 用户的vip剩余时间减少
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(new Date());
+                    calendar.add(Calendar.MONTH, -one.getCount());
+                    Integer userId = one.getUserId();
+                    TUser byId1 = userService.getById(userId);
+                    // 判断用户是不是第一次充值
+                    List<TVipOrder> list = vipOrderService.list(new QueryWrapper<TVipOrder>()
+                            .eq("userId", userId)
+                                    .ne("id",one.getId())
+                            .eq("payState", 2)
+                            .orderByDesc("createTime"));
+                    int size = list.size();
+                    if (size == 0) {
+                        System.err.println("证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空");
+                        // 证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空
+                        byId1.setVipEndTime(null);
+                        byId1.setVipPayTime(null);
+                        userService.updateById(byId1);
+                        userService.updateOne(byId1.getId(), null, null);
+                    } else {
+                        System.err.println("最近的一次充值会员时间  将会员到期时间回退到上一次");
+                        // 最近的一次充值会员时间
+                        TVipOrder tVipOrder = list.get(0);
+                        // 将会员到期时间回退到上一次
+                        byId1.setVipEndTime(tVipOrder.getTime());
+                        byId1.setVipPayTime(tVipOrder.getPayTime());
+                        userService.updateById(byId1);
+                    }
+                }
+                vipOrderService.updateById(one);
+            }else{
+                if (one!=null){
+                    one.setPayState(2);
+                    one.setPayTime(new Date());
+
+                    TUser byId1 = userService.getById(one.getUserId());
+                    if (byId1.getVipPayTime() == null) {
+                        // 是否是首次充值会员
+                        byId1.setVipPayTime(new Date());
+                        Calendar calendar = Calendar.getInstance();
+                        calendar.setTime(new Date());
+                        calendar.add(Calendar.MONTH, one.getCount());
+                        Date dateAfterOneMonth = calendar.getTime();
+                        dateAfterOneMonth.setHours(23);
+                        dateAfterOneMonth.setMinutes(59);
+                        dateAfterOneMonth.setSeconds(59);
+                        byId1.setVipEndTime(dateAfterOneMonth);
+                        one.setTime(dateAfterOneMonth);
+                        userService.updateById(byId1);
+                    } else {
+                        // 不是首次 判断vipEndTime 是否到期 如果没有 加指定月份时间 如果到期了 将会员到期时间从当前增加指定月份
+                        if (byId1.getVipEndTime().getTime() < new Date().getTime()) {
+                            Calendar calendar = Calendar.getInstance();
+                            calendar.setTime(new Date());
+                            calendar.add(Calendar.MONTH, one.getCount());
+                            Date dateAfterOneMonth = calendar.getTime();
+                            dateAfterOneMonth.setHours(23);
+                            dateAfterOneMonth.setMinutes(59);
+                            dateAfterOneMonth.setSeconds(59);
+                            one.setTime(dateAfterOneMonth);
+                            byId1.setVipEndTime(dateAfterOneMonth);
+                            userService.updateById(byId1);
+                        } else {
+                            Calendar calendar = Calendar.getInstance();
+                            calendar.setTime(byId1.getVipEndTime());
+                            calendar.add(Calendar.MONTH, one.getCount());
+                            Date dateAfterOneMonth = calendar.getTime();
+                            dateAfterOneMonth.setHours(23);
+                            dateAfterOneMonth.setMinutes(59);
+                            dateAfterOneMonth.setSeconds(59);
+                            one.setTime(dateAfterOneMonth);
+                            byId1.setVipEndTime(dateAfterOneMonth);
+                            userService.updateById(byId1);
+                        }
+                    }
+                }
+            }
+
+            vipOrderService.updateById(one);
+            System.err.println("苹果流水号"+string);
+            PrintWriter out = response.getWriter();
+            out.write("success");
+            out.flush();
+            out.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 处理苹果退款 回调通知
+     * @param request
+     * @param response
+     */
+    @ResponseBody
+    @PostMapping("/refundApple")
+    public void refundApple(HttpServletRequest request, HttpServletResponse response) {
+        try {
+            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);
+            org.json.JSONObject jsonObject1 = new org.json.JSONObject(requestBody.toString());
+            System.err.println("json串"+jsonObject1);
+            String o = jsonObject1.getString("signedPayload");
+            JSONObject payload = verifyAndGet(o);
+            String notificationType = payload.get("notificationType").toString();
+
+            JSONObject data = payload.getJSONObject("data");
+            String signedTransactionInfo = data.get("signedTransactionInfo").toString();
+            JSONObject transactionInfo = verifyAndGet(signedTransactionInfo);
+            System.err.println("解签后的json串"+transactionInfo);
+            System.err.println("data"+data);
+            // 苹果流水号
+            String string = transactionInfo.getString("originalTransactionId");
+            TVipOrder one = vipOrderService.getOne(new QueryWrapper<TVipOrder>()
+                    .eq("transactionId", string)
+                    .eq("payType", 3));
+            if (one!=null && one.getPayState() == 2){
+                one.setPayState(3);
+                one.setBackTime(new Date());
+                // 用户的vip剩余时间减少
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(new Date());
+                calendar.add(Calendar.MONTH, -one.getCount());
+                Integer userId = one.getUserId();
+                TUser byId1 = userService.getById(userId);
+                // 判断用户是不是第一次充值
+                List<TVipOrder> list = vipOrderService.list(new QueryWrapper<TVipOrder>()
+                        .eq("userId", userId)
+                        .eq("payState", 2)
+                        .orderByDesc("createTime"));
+                int size = list.size();
+                if (size == 0) {
+                    System.err.println("证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空");
+                    // 证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空
+                    byId1.setVipEndTime(null);
+                    byId1.setVipPayTime(null);
+                    userService.updateById(byId1);
+                    userService.updateOne(byId1.getId(), null, null);
+                } else {
+                    System.err.println("最近的一次充值会员时间  将会员到期时间回退到上一次");
+                    // 最近的一次充值会员时间
+                    TVipOrder tVipOrder = list.get(0);
+                    // 将会员到期时间回退到上一次
+                    byId1.setVipEndTime(tVipOrder.getTime());
+                    byId1.setVipPayTime(tVipOrder.getPayTime());
+                    userService.updateById(byId1);
+                }
+            }
+            vipOrderService.updateById(one);
+            System.err.println("苹果流水号"+string);
+            PrintWriter out = response.getWriter();
+            out.write("success");
+            out.flush();
+            out.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
     @ResponseBody
     @PostMapping("/aliPayBuyVip")
     public void addVipPaymentAliCallback(HttpServletRequest request, HttpServletResponse response) {
@@ -211,6 +545,10 @@
             Map<String, String> map = payMoneyUtil.alipayCallback(request);
             System.err.println("返回参数" + map);
             if (null != map) {
+                PrintWriter out = response.getWriter();
+                out.write("success");
+                out.flush();
+                out.close();
                 String out_trade_no = map.get("out_trade_no");
                 String trade_no = map.get("trade_no");
                 // 会员规格id
@@ -247,7 +585,6 @@
                     dateAfterOneMonth.setSeconds(59);
                     byId1.setVipEndTime(dateAfterOneMonth);
                     byId.setTime(dateAfterOneMonth);
-
                 } else {
                     // 不是首次 判断vipEndTime 是否到期 如果没有 加指定月份时间 如果到期了 将会员到期时间从当前增加指定月份
                     if (byId1.getVipEndTime().getTime() < new Date().getTime()) {
@@ -278,10 +615,7 @@
 
                 // 修改用户会员续期信息
                 userService.updateById(byId1);
-                PrintWriter out = response.getWriter();
-                out.write("success");
-                out.flush();
-                out.close();
+
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -294,11 +628,16 @@
         try {
             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");
+                PrintWriter out = response.getWriter();
+                out.write(result);
+                out.flush();
+                out.close();
                 // 会员规格id
                 String s = out_trade_no.split("_")[0];
                 Integer integer = Integer.valueOf(s);
@@ -359,10 +698,7 @@
                 vipOrderService.updateById(byId);
                 // 修改用户会员续期信息
                 userService.updateById(byId1);
-                PrintWriter out = response.getWriter();
-                out.write(result);
-                out.flush();
-                out.close();
+
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -500,6 +836,7 @@
                 return R.freeze("登录失败,您的账号已被冻结!");
             }
         } else {
+            tUser1 = new TUser();
             // 手机验证码校验
             if (!phoneCode.equals("123456")) {
                 Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone);
@@ -512,8 +849,8 @@
                     if (!rCode.equalsIgnoreCase(phoneCode)) {
                         return R.errorCode("登录失败,手机验证码无效!");
                     } else {
-                        tUser1.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg");
                         tUser1 = getUser(phone);
+                        tUser1.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg");
                         String upperCase = UUIDUtil.getRandomCode(6).toUpperCase();
                         tUser1.setAccount("用户"+upperCase);
                         tUser1.setName("用户"+upperCase);
@@ -708,7 +1045,7 @@
 
             userShareService.save(record);
             TIntegralRecord tIntegralRecord = new TIntegralRecord();
-            tIntegralRecord.setIntegral(data.getIntegral());
+            tIntegralRecord.setIntegral(data.getIntegralShare());
             tIntegralRecord.setMethod("每日分享");
             tIntegralRecord.setUserId(userid);
             integralRecordService.save(tIntegralRecord);
@@ -742,7 +1079,7 @@
             record.setUserId(userid);
             userShareService.save(record);
             TIntegralRecord tIntegralRecord = new TIntegralRecord();
-            tIntegralRecord.setIntegral(data.getIntegral());
+            tIntegralRecord.setIntegral(data.getIntegralShare());
             tIntegralRecord.setMethod("每日分享");
             tIntegralRecord.setUserId(userid);
             integralRecordService.save(tIntegralRecord);
@@ -844,7 +1181,22 @@
         userService.removeById(tUser);
         return R.ok("注销成功");
     }
-
+    @PostMapping("/deleteUserStudy")
+    @ApiOperation(value = "注销当前帐号", tags = {"学习端-个人中心"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header"),
+    })
+    public R<String> deleteUserStudy() {
+        if (tokenService.getLoginUserStudy() == null) {
+            return R.tokenError("登录失效");
+        }
+        Integer userid = tokenService.getLoginUserStudy().getUserid();
+        TUser tUser = userService.getById(userid);
+        tUser.setState(3);
+        userService.updateById(tUser);
+        userService.removeById(tUser);
+        return R.ok("注销成功");
+    }
     @PostMapping("/logout")
     @ApiOperation(value = "退出登录", tags = {"家长端-个人中心"})
     @ApiImplicitParams({
@@ -923,9 +1275,14 @@
         try {
             Map<String, String> map = payMoneyUtil.wxRefundCallback(request);
             if (null != map) {
+
                 String code = map.get("out_refund_no");
                 String refund_id = map.get("refund_id");
                 String result = map.get("result");
+                PrintWriter out = response.getWriter();
+                out.write(result);
+                out.flush();
+                out.close();
                 TVipOrder one = vipOrderService.getOne(new QueryWrapper<TVipOrder>()
                         .eq("outTradeNo", code)
                         .eq("payState", 3));
@@ -952,10 +1309,7 @@
                     userService.updateById(byId1);
                 }
 
-                PrintWriter out = response.getWriter();
-                out.write(result);
-                out.flush();
-                out.close();
+
             }
         } catch (Exception e) {
             e.printStackTrace();

--
Gitblit v1.7.1