无关风月
2025-12-26 d47bf3e1e3bf56b60ea6a1649ddd618d5ae803f1
cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java
@@ -1,12 +1,15 @@
package com.dsh.other.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.other.entity.*;
import com.dsh.other.feignclient.CourseRecordClient;
import com.dsh.other.feignclient.account.CityManagerClient;
import com.dsh.other.feignclient.activity.UserCouponClient;
import com.dsh.other.feignclient.activity.model.QueryUserCouponByIdAndUserId;
@@ -14,15 +17,19 @@
import com.dsh.other.feignclient.model.BillingDataRequestVo;
import com.dsh.other.feignclient.model.SiteChangeStateVO;
import com.dsh.other.feignclient.model.SiteVo;
import com.dsh.other.mapper.TOperatorUserMapper;
import com.dsh.other.model.*;
import com.dsh.other.model.dto.siteDto.TSiteDTO;
import com.dsh.other.model.vo.siteVo.ExpireSiteSearchVO;
import com.dsh.other.model.vo.siteVo.SiteSearchVO;
import com.dsh.other.service.*;
import com.dsh.other.util.*;
import com.dsh.other.util.wx.WxV3PayConfig;
import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
@@ -31,8 +38,13 @@
import javax.annotation.Resource;
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.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@@ -61,9 +73,82 @@
    @Resource
    private UserCouponClient userCouponClient;
    @Autowired
    private CityManagerClient cityManagerClient;
    @Resource
    private CityManagerClient cityManagerClient;
    @Autowired
    private IOperatorUserService operatorUserService;
    @Autowired
    private TGameConfigService gameConfigService;
    @Autowired
    private TGameRecordService gameRecordService;
    @Resource
    private CourseRecordClient courseRecordClient;
@Resource
private StoreService storeService;
    @Autowired
    private RedisUtil redisUtil;
    /**
     * 通过运营商id查询运营商对应的支付宝商户号
     */
    @RequestMapping("/base/getSMIDByOperatorId")
    @ResponseBody
    public String getSMIDByOperatorId(Integer id) {
        return siteService.getSMIDByOperatorId(id);
    }
    /**
     * 通过运营商id查询运营商对应的微信商户号
     */
    @RequestMapping("/base/getmerchantNumberByOperatorId/{id}")
    @ResponseBody
    public String getmerchantNumberByOperatorId(@PathVariable("id")Integer id) {
        return siteService.getmerchantNumberByOperatorId(id);
    }
    /**
     * 通过运营商id 获取支付宝商户号
     * @param id
     * @return
     */
    @RequestMapping("/base/getmerchantNumberAliByOperatorId/{id}")
    @ResponseBody
    public String getmerchantNumberAliByOperatorId(@PathVariable("id")Integer id) {
        return siteService.getmerchantNumberAliByOperatorId(id);
    }
    /**
     * 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例
     */
    @RequestMapping("/base/getProportionByOperatorId/{id}")
    @ResponseBody
    public String getProportionByOperatorId(@PathVariable("id")Integer id) {
        OperatorUser operatorId = operatorUserService.getOne(
                new QueryWrapper<OperatorUser>().eq("operatorId",id)
        );
        if (operatorId.getWechatProportion() == null){
            operatorId.setWechatProportion("0");
        }
        if (operatorId.getAlipayProportion() == null){
            operatorId.setAlipayProportion("0");
        }
        System.err.println("查询分账比例"+operatorId);
        return operatorId.getWechatProportion()+","+operatorId.getAlipayProportion();
    }
    /**
     * 获取所有场地
     */
@@ -128,7 +213,16 @@
        }
    }
    /**
     * 添加场地管理
     *
     * @return
     */
    @RequestMapping("/base/site/addSite1")
    public Integer addSite1(@RequestBody Site site) {
            boolean save = siteService.save(site);
            return site.getId();
    }
    /**
     * 添加场地管理
     *
@@ -145,14 +239,14 @@
    }
    @RequestMapping("/base/site/listById")
    public Site listById(@RequestParam("id") Integer id) {
    public Site listById(@RequestBody Integer id) {
        Site byId = siteService.getById(id);
        return byId;
    }
    @RequestMapping("/base/site/listBooks")
    public List<SiteBooking> listBooks(@RequestParam("id") Integer id) {
    public List<SiteBooking> listBooks(@RequestBody Integer id) {
        List<SiteBooking> siteId = siteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id));
        return siteId;
    }
@@ -172,7 +266,8 @@
        }
    }
    @Autowired
    private ITSitePriceService sitePriceService;
    @ResponseBody
    @PostMapping("/base/site/querySiteList")
    @ApiOperation(value = "获取场地列表", tags = {"用户—预约场地"})
@@ -180,6 +275,8 @@
    })
    public ResultUtil<List<QuerySiteListVo>> querySiteList(QuerySiteList querySiteList) {
        try {
            List<QuerySiteListVo> querySiteListVos = siteService.querySiteList(querySiteList);
            return ResultUtil.success(querySiteListVos);
        } catch (Exception e) {
@@ -207,9 +304,6 @@
        }
    }
    @Autowired
    private RedisUtil redisUtil;
    @ResponseBody
    @PostMapping("/base/site/querySiteTimes")
    @ApiOperation(value = "获取场地详情时间段数据", tags = {"用户—预约场地"})
@@ -217,11 +311,12 @@
            @ApiImplicitParam(value = "场地id", name = "id", dataType = "int", required = true),
            @ApiImplicitParam(value = "日期(2023-01-01)", name = "day", dataType = "string", required = true),
            @ApiImplicitParam(value = "半场名称", name = "halfName", dataType = "string", required = false),
            @ApiImplicitParam(value = "选择场地的名称", name = "siteName", dataType = "string", required = false)
            @ApiImplicitParam(value = "选择场地的名称", name = "siteName", dataType = "string", required = false),
            @ApiImplicitParam(value = "入场方式 1订场 2散客", name = "targetAudience",defaultValue = "1",dataType = "string", required = true),
    })
    public ResultUtil<List<QuerySiteTimes>> querySiteTimes(Integer id, String day, String halfName, String siteName) {
    public ResultUtil<List<QuerySiteTimes>> querySiteTimes(Integer id, String day, String halfName, String siteName,Integer targetAudience) {
        try {
            List<QuerySiteTimes> list = siteService.querySiteTimes(id, day, halfName, siteName);
            List<QuerySiteTimes> list = siteService.querySiteTimes(id, day, halfName, siteName,targetAudience);
            return ResultUtil.success(list);
        } catch (Exception e) {
            e.printStackTrace();
@@ -229,20 +324,8 @@
        }
    }
//    public ResultUtil<List<QuerySiteTimes>> querySiteTimes(Integer id, String day, String halfName, String siteName) throws Exception {
//
//        if (redisUtil.acquireLock(day,day)) {
//            try {
//                List<QuerySiteTimes> list = siteService.querySiteTimes(id, day,halfName,siteName);
//            return ResultUtil.success(list);
//            } finally {
//                redisUtil.releaseLock(day);
//            }
//        } else {
//            return ResultUtil.error("系统繁忙,请稍后再试!");
//        }
//
//    }
    /**
@@ -256,6 +339,22 @@
    public Site querySiteById(@RequestBody Integer id) {
        try {
            return siteService.getById(id);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 根据id获取数据
     *
     * @param ids
     * @return
     */
    @ResponseBody
    @PostMapping("/site/querySiteByStoreIds")
    public List<Site> querySiteByStoreIds(@RequestBody String ids) {
        try {
            return siteService.lambdaQuery().in(Site::getStoreId,Arrays.asList(ids.split(","))).list();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
@@ -275,6 +374,7 @@
            if (null == uid) {
                return ResultUtil.tokenErr();
            }
//            Integer uid = 201;
            return siteService.reservationSite(uid, reservationSite);
        } catch (Exception e) {
            e.printStackTrace();
@@ -282,22 +382,58 @@
        }
    }
//        public ResultUtil<List<QuerySiteTimes>> querySiteTimes(Integer id, String day, String halfName, String siteName) throws Exception {
//
//        if (redisUtil.acquireLock(day,day)) {
//            try {
//                List<QuerySiteTimes> list = siteService.querySiteTimes(id, day,halfName,siteName);
//            return ResultUtil.success(list);
//            } finally {
//                redisUtil.releaseLock(day);
//            }
//        } else {
//            return ResultUtil.error("系统繁忙,请稍后再试!");
//        }
//
//    }
    /**
     * 购买课程微信支付回调
     *
     * @param request
     * @param response
     */
    @ResponseBody
    @PostMapping("/base/site/weChatPaymentSiteCallback1")
    public void weChatPaymentSiteCallback1(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");
            if (trade_state.equals("SUCCESS")) {
                SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("orderNo", code).eq("state", 1));
                if (siteBooking.getStatus() == 0) {
                    siteBooking.setPayTime(new Date());
                    siteBooking.setStatus(1);
                    siteBooking.setPayOrderNo(transaction_id);
                    siteBookingService.updateById(siteBooking);
                    PrintWriter out = response.getWriter();
                    out.write("SUCCESS");
                    out.flush();
                    out.close();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 购买课程微信支付回调
     *
@@ -308,6 +444,7 @@
    @PostMapping("/base/site/weChatPaymentSiteCallback")
    public void weChatPaymentSiteCallback(HttpServletRequest request, HttpServletResponse response) {
        try {
            System.err.println("预约场地回调");
            Map<String, String> map = payMoneyUtil.weixinpayCallback(request);
            if (null != map) {
                String code = map.get("out_trade_no");
@@ -319,18 +456,54 @@
                    siteBooking.setStatus(1);
                    siteBooking.setPayOrderNo(transaction_id);
                    siteBookingService.updateById(siteBooking);
                    Store byId = service.getById(siteBooking.getStoreId());
//                    if (byId.getOperatorId()!=null && byId.getOperatorId()!=0){
//                        System.err.println("预约场地分账");
//                        // 休眠两分钟后再调用分账接口 避免提示订单正在处理中
//                        Thread.sleep(120000);
//                        // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例
//                        OperatorUser operatorId = operatorUserService.getOne(
//                                new QueryWrapper<OperatorUser>().eq("operatorId",byId.getOperatorId())
//                        );
//                        if (operatorId.getWechatProportion() == null){
//                            operatorId.setWechatProportion("0");
//                        }
//                        if (operatorId.getAlipayProportion() == null){
//                            operatorId.setAlipayProportion("0");
//                        }
//                        String proportion=  operatorId.getWechatProportion()+","+operatorId.getAlipayProportion();
//                        String[] split = proportion.split(",");
//                        String s1 = split[0];
//                        if (!s1.equals("未设置")){
//                            BigDecimal bigDecimal = new BigDecimal(s1);
//                            // 分账比例
//                            BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2);
//                            // 微信商户号
//                            String s2 =siteService.getmerchantNumberByOperatorId(byId.getOperatorId());
//                            String nonce_str = UUIDUtil.getRandomCode(16);
//                            BigDecimal bigDecimal2 = new BigDecimal(siteBooking.getPayMoney());
//                            ResultUtil fenzhang = payMoneyUtil.fenzhang(transaction_id, bigDecimal2.multiply(bigDecimal1), s2,nonce_str,"预约场地分账");
//                            if (!fenzhang.getCode().equals(200)){
//                                System.err.println("分账失败 原因是:"+fenzhang.getMsg());
//                            }else{
//                                siteBooking.setFenzhangNo(fenzhang.getData().toString());
//                                siteBooking.setFenzhangOrderNo(nonce_str);
//                                siteBooking.setFenzhangAmount(bigDecimal2.multiply(bigDecimal1));
//                                siteBookingService.updateById(siteBooking);
//                            }
//                        }
//                    }
                    PrintWriter out = response.getWriter();
                    out.write(result);
                    out.flush();
                    out.close();
                }
                PrintWriter out = response.getWriter();
                out.write(result);
                out.flush();
                out.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 预约场地支付宝回调
     *
@@ -341,27 +514,33 @@
    @PostMapping("/base/site/aliPaymentSiteCallback")
    public void aliPaymentSiteCallback(HttpServletRequest request, HttpServletResponse response) {
        try {
            System.out.println("回调回调回调");
            System.err.println("预约场地回调");
            Map<String, String> map = payMoneyUtil.alipayCallback(request);
            System.err.println("map");
            System.err.println(map);
            if (null != map) {
                String code = map.get("out_trade_no");
                String trade_no = map.get("trade_no");
                SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("orderNo", code).eq("state", 1));
                SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>()
                        .eq("orderNo", code).eq("state", 1));
                if (siteBooking.getStatus() == 0) {
                    siteBooking.setPayTime(new Date());
                    siteBooking.setStatus(1);
                    siteBooking.setPayOrderNo(trade_no);
                    siteBookingService.updateById(siteBooking);
                    PrintWriter out = response.getWriter();
                    out.write("success");
                    out.flush();
                    out.close();
                }
                PrintWriter out = response.getWriter();
                out.write("success");
                out.flush();
                out.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
@@ -374,23 +553,29 @@
    @PostMapping("/base/site/gameCallback")
    public void gameCallback(HttpServletRequest request, HttpServletResponse response) {
        try {
            System.out.println("回调回调回调");
            Map<String, String> map = payMoneyUtil.alipayCallback(request);
            if (null != map) {
                String code = map.get("passback_params");
//                String trade_no = map.get("trade_no");
//                SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("orderNo", code).eq("state", 1));
//                if(siteBooking.getStatus() == 0){
//                    siteBooking.setPayTime(new Date());
//                    siteBooking.setStatus(1);
//                    siteBooking.setPayOrderNo(trade_no);
//                    siteBookingService.updateById(siteBooking);
//                }
                String trade_no = map.get("trade_no");
                String[] s = code.split("_");
                Integer i = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3]));
                System.err.println("===========游戏回调游戏回调=========" + i);
                List<TGameRecord> list = gameRecordService.list(new QueryWrapper<TGameRecord>().eq("number", s[4]).eq("payType", 2));
                TGameRecord one = list.get(0);
                TGameConfig config = gameConfigService.getById(s[5]);
                for (TGameRecord coursePackagePayment : list) {
                    coursePackagePayment.setStatus(1);
                    coursePackagePayment.setMoney(config.getCash());
                    coursePackagePayment.setOrderNo(trade_no);
                    CourseCounsum courseCounsum = new CourseCounsum();
                    courseCounsum.setChangeType(3);
                    courseCounsum.setInsertTime(new Date());
                    courseCounsum.setReason("智慧球场;" + config.getCash());
                    courseCounsum.setAppUserId(Integer.valueOf(s[0]));
                    courseRecordClient.save(courseCounsum);
                }
                gameRecordService.updateBatchById(list);
                PrintWriter out = response.getWriter();
                out.write("success");
                out.flush();
@@ -410,10 +595,11 @@
        map.put("space_id", spaceId + "");
        map.put("sutu_id", sutuId + "");
        String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/gameStart", map);
        String s = HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/gameStart", map);
        JSONObject jsonObject = JSONObject.parseObject(s);
        Object code = jsonObject.get("code");
        if (String.valueOf(code) != null && "200".equals(String.valueOf(code))) {
            System.err.println("启动了一次游戏");
            return 200;
        } else {
            return 500;
@@ -446,7 +632,7 @@
    @ResponseBody
    @PostMapping("/api/site/queryMySiteById")
    @ApiOperation(value = "获取我的预约场地列表详情2.0", tags = {"用户—预约场地"})
    @ApiOperation(value = "获取我的预约场地列表详情", tags = {"用户—预约场地"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "id", name = "id", dataType = "int", required = true),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
@@ -454,41 +640,56 @@
    public ResultUtil<Map<String, Object>> queryMySiteById(Integer id) {
        try {
            HashMap<String, Object> map = new HashMap<>();
            SiteBooking byId = siteBookingService.getById(id);
            Integer storeId = byId.getStoreId();
            System.err.println("预约id"+id);
            SiteBooking siteBooking = siteBookingService.getById(id);
            Integer targetAudience = siteBooking.getTargetAudience();
            System.err.println("预约"+siteBooking);
            Integer storeId = siteBooking.getStoreId();
            Store byId1 = service.getById(storeId);
            Site site = siteService.getById(byId.getSiteId());
            Site site = siteService.getById(siteBooking.getSiteId());
            map.put("siteName", byId1.getName());
            SiteType siteType = siteTypeService.getById(site.getSiteTypeId());
            System.err.println("预约类型"+siteType);
            map.put("siteType", siteType.getName());
            map.put("shopName", byId1.getName());
            map.put("shopAddress", byId1.getAddress());
            // 进场二维码新增参数codeType 1=订场 2=散客,3=门票,玩湃惠民卡codeType=4
            map.put("codeType", targetAudience);
            map.put("dataId", siteBooking.getId());
//            map.put("siteName", siteBooking.getNextName()==null?"":siteBooking.getNextName());
//            map.put("halfName", siteBooking.getHalfName()==null?"":siteBooking.getHalfName());
            System.err.println("订场类型:"+targetAudience);
            map.put("name", site.getName());
            map.put("targetAudience", targetAudience);
            List<Integer> ids = getIds(byId.getSiteId());
            byId.setStorePhone(byId1.getPhone());
            List<Integer> ids = getIds(siteBooking.getSiteId());
            siteBooking.setStorePhone(byId1.getPhone());
            //拼接开始结束时间
            Date startTime = byId.getStartTime();
            Date endTime = byId.getEndTime();
            Date startTime = siteBooking.getStartTime();
            Date endTime = siteBooking.getEndTime();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            String startTimeString = sdf.format(startTime);
            String endTimeString = sdf.format(endTime);
            String result = startTimeString + "-" + endTimeString.substring(11);
            byId.setTimes(result);
            siteBooking.setTimes(result);
            byId.setSid(Arrays.asList(storeId));
            List<Site> list = siteService.list(new LambdaQueryWrapper<Site>().eq(Site::getStoreId, storeId).eq(Site::getSign, 1));
            List<Integer> collect = list.stream().map(Site::getId).collect(Collectors.toList());
            byId.setRid(collect);
            map.put("data", byId);
            siteBooking.setSid(Arrays.asList(storeId));
            Integer siteId = siteBooking.getSiteId();
            ArrayList<Integer> list1 = new ArrayList<>();
            list1.add(siteId);
            siteBooking.setRid(list1);
            SiteBookingVo siteBookingVo = new SiteBookingVo();
            BeanUtils.copyProperties(siteBooking, siteBookingVo);
            siteBookingVo.setStartTime(siteBooking.getStartTime().getTime());
            siteBookingVo.setEndTime(siteBooking.getEndTime().getTime());
            if (siteBooking.getPayTime()!=null){
                siteBookingVo.setPayTime(siteBooking.getPayTime().getTime());
            }
            map.put("data", siteBookingVo);
            map.put("ids", ids);
            return ResultUtil.success(map);
        } catch (Exception e) {
@@ -498,7 +699,7 @@
    }
    public List<Integer> getIds(Integer siteId) {
        HttpRequest httpRequest = HttpRequest.get("https://try.daowepark.com/v7/user_api/general/get_space_area?space_id=" + siteId);
        HttpRequest httpRequest = HttpRequest.get("https://port.daowepark.com/v7/user_api/general/get_space_area?space_id=" + siteId);
        HttpResponse execute = httpRequest.execute();
        String body = execute.body();
        JSONObject jsonObject = JSONObject.parseObject(body);
@@ -525,12 +726,11 @@
    })
    public ResultUtil cancelMySite(Integer id) {
        try {
            System.err.println("预约数据id");
            Integer uid = tokenUtil.getUserIdFormRedis();
            if (null == uid) {
                return ResultUtil.tokenErr();
            }
            return siteService.cancelMySite(uid, id);
        } catch (Exception e) {
            e.printStackTrace();
@@ -574,7 +774,59 @@
            e.printStackTrace();
        }
    }
    /**
     * 微信退款回调V3服务商版本
     *
     * @param request
     * @param response
     */
    @ResponseBody
    @PostMapping("/base/site/cancelMySiteCallback1")
    public void cancelMySiteCallback1(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 refund_status = jsonInfo.getString("refund_status");
            String out_refund_no = jsonInfo.getString("out_refund_no");
            if (refund_status.equals("SUCCESS")) {
                SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("orderNo", code).eq("state", 1));
                siteBooking.setStatus(5);
                siteBooking.setCancelTime(new Date());
                siteBooking.setRefundOrderNo(out_refund_no);
                siteBookingService.updateById(siteBooking);
                if (null != siteBooking.getUserCouponId()) {
                    UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(), siteBooking.getAppUserId()));
                    userCoupon.setStatus(1);
                    userCouponClient.updateUserCoupon(userCoupon);
                }
                    PrintWriter out = response.getWriter();
                    out.write("SUCCESS");
                    out.flush();
                    out.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ResponseBody
    @PostMapping("/api/site/continuePaymentMySite")
@@ -663,10 +915,6 @@
    @Autowired
    private StoreService service;
    @Autowired
    private IOperatorUserService operatorUserService;
    @ResponseBody
    @PostMapping("/base/site/game")
    public List<Map<String, Object>> game(@RequestBody Integer appUserId) {
@@ -679,6 +927,19 @@
    @PostMapping("/base/site/counts")
    public Integer counts(@RequestBody Integer stuId) {
        return siteBookingService.count(new QueryWrapper<SiteBooking>().eq("appUserId", stuId));
    }
    @Autowired
    private  IUserService userService;
    @ResponseBody
    @PostMapping("/base/site/queryUserName")
    public User queryUserName(@RequestBody Integer coachId){
        User byId = userService.getById(coachId);
        return byId;
    }
@@ -697,18 +958,41 @@
    @PostMapping("/base/site/getNewAddSiteList")
    public List<SiteVo> getAppUserSiteList(@RequestBody Integer storeId) {
        List<SiteVo> siteVos = new ArrayList<>();
        DayOfWeek dayOfWeek = LocalDate.now().getDayOfWeek();
        Map<Integer, List<TSitePrice>> priceMap = sitePriceService.lambdaQuery().eq(TSitePrice::getDayOfWeek, dayOfWeek.getValue())
                .list()
                .stream().collect(Collectors.groupingBy(TSitePrice::getSiteId));
        List<Site> list = siteService.list(new QueryWrapper<Site>().eq("state", 1).eq("storeId", storeId)
                .orderByDesc("insertTime"));
        String now = DateUtil.now().substring(11, 19);
        if (list.size() > 0) {
            for (Site site : list) {
                List<TSitePrice> tSitePrices = priceMap.get(site.getId());
                SiteVo vo = new SiteVo();
                vo.setIsCanBeBooked(site.getIsCanBeBooked());
                vo.setSiteId(site.getId());
                vo.setSiteName(site.getName());
                vo.setSiteTime(site.getAppointmentStartTime() + "-" + site.getAppointmentEndTime());
                vo.setSiteTime("");
                vo.setPrice(0.0);
                if (tSitePrices!=null&& !tSitePrices.isEmpty()){
                    BigDecimal bigDecimal = BigDecimal.ZERO;
                    // 遍历 查询最小的价格
                    for (TSitePrice tSitePrice : tSitePrices) {
                        // 当前时间再范围之内
                        if (tSitePrice.getStartTime().compareTo(now) <= 0 && tSitePrice.getEndTime().compareTo(now) >= 0) {
                            if (tSitePrice.getCashPrice().compareTo(bigDecimal) > 0) {
                                bigDecimal = tSitePrice.getCashPrice();
                            }
                        }
                    }
                    vo.setPrice(bigDecimal.doubleValue());
                    vo.setSiteTime(tSitePrices.get(0).getStartTime() + "-" + tSitePrices.get(tSitePrices.size()-1).getEndTime());
                }
                SiteType byId = siteTypeService.getById(site.getSiteTypeId());
                vo.setSiteType(byId.getName());
                vo.setPrice(site.getCashPrice());
                siteVos.add(vo);
            }
        }
@@ -716,4 +1000,5 @@
    }
}