From d47bf3e1e3bf56b60ea6a1649ddd618d5ae803f1 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 26 十二月 2025 09:13:14 +0800
Subject: [PATCH] bug修改

---
 cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java |  111 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 104 insertions(+), 7 deletions(-)

diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java
index e5f51b0..ef74165 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java
@@ -1,9 +1,11 @@
 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.*;
@@ -41,6 +43,8 @@
 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;
 
@@ -262,7 +266,8 @@
         }
     }
 
-
+    @Autowired
+    private ITSitePriceService sitePriceService;
     @ResponseBody
     @PostMapping("/base/site/querySiteList")
     @ApiOperation(value = "获取场地列表", tags = {"用户—预约场地"})
@@ -270,6 +275,8 @@
     })
     public ResultUtil<List<QuerySiteListVo>> querySiteList(QuerySiteList querySiteList) {
         try {
+
+
             List<QuerySiteListVo> querySiteListVos = siteService.querySiteList(querySiteList);
             return ResultUtil.success(querySiteListVos);
         } catch (Exception e) {
@@ -304,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();
@@ -366,6 +374,7 @@
             if (null == uid) {
                 return ResultUtil.tokenErr();
             }
+//            Integer uid = 201;
             return siteService.reservationSite(uid, reservationSite);
         } catch (Exception e) {
             e.printStackTrace();
@@ -505,7 +514,10 @@
     @PostMapping("/base/site/aliPaymentSiteCallback")
     public void aliPaymentSiteCallback(HttpServletRequest request, HttpServletResponse response) {
         try {
+            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");
@@ -630,6 +642,7 @@
             HashMap<String, Object> map = new HashMap<>();
             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);
@@ -640,8 +653,15 @@
             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(siteBooking.getSiteId());
@@ -706,6 +726,7 @@
     })
     public ResultUtil cancelMySite(Integer id) {
         try {
+            System.err.println("预约数据id");
             Integer uid = tokenUtil.getUserIdFormRedis();
             if (null == uid) {
                 return ResultUtil.tokenErr();
@@ -753,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")
@@ -885,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);
             }
         }
@@ -904,4 +1000,5 @@
 
     }
 
+
 }

--
Gitblit v1.7.1