From 537ed054fe1d9b40b4908cf41ce8c9a6a82d0df9 Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期一, 18 三月 2024 16:04:04 +0800
Subject: [PATCH] 部分bug修改

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java |  213 ++++++++++++++++++++++++++++++-----------------------
 1 files changed, 121 insertions(+), 92 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java
index d071b09..eac9e98 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java
@@ -106,10 +106,8 @@
     @Autowired
     private AppUserClient appUserClient;
 
-
     @RequestMapping("/tolist")
     public String tolist(Model model) {
-
         List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
         model.addAttribute("list",list);
         String roleid = UserExt.getUser().getRoleid();
@@ -191,7 +189,6 @@
 
         SiteBooking byId = iSiteBookingService.getById(id);
         String money = byId.getMoney();
-        // todo 这里手动支付 默认按照现金当作支付金额 后续可能要问下产品
         String[] split = money.split(",");
         Double aDouble = Double.valueOf(split[0]);
         System.out.println("============"+id);
@@ -216,7 +213,7 @@
     @RequestMapping("/list")
     @ResponseBody
     public List<Game> changelist(BallQueryDto ballQueryDto) {
-System.out.println("=======ballQueryDto=========="+ballQueryDto);
+        System.out.println("=======ballQueryDto=========="+ballQueryDto);
         User user = UserExt.getUser();
         ballQueryDto.setType(user.getObjectType());
         ballQueryDto.setId(user.getObjectId());
@@ -326,67 +323,118 @@
         }
         System.out.println("============"+game);
 
-        // 添加sutu编号
-        HashMap<String, String> map3 = new HashMap<>();
-        HashMap<String, String> map4 = new HashMap<>();
-        // 添加sutu编号
-        // 调用两次 创建sutu
-        TSite si = siteService.getById(site);
-        TStore st = storeService.getById(store);
-        map3.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
-        map4.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
-        map3.put("space_id", st.getId() + "");
-        map4.put("space_id", st.getId() + "");
-        map3.put("name", blue);
-        map4.put("name", red);
-        map3.put("city_code", city);
-        map4.put("city_code", city);
-        String s3 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpaceSutu", map3);
-        String s4 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpaceSutu", map4);
-        System.out.println("---------------------------"+s3);
-        JSONObject jsonObject = new JSONObject(s3);
-        JSONObject jsonObject1 = new JSONObject(s4);
-        // 获取 data 字段的值
-        JSONObject dataObject = jsonObject.getJSONObject("data");
-        JSONObject dataObject1 = jsonObject1.getJSONObject("data");
-        // 获取 sutu_id 字段的值
-        String sutuIdValue = dataObject.getString("sutu_id");
-        String sutuIdValue1 = dataObject1.getString("sutu_id");
-        Integer sutuId = Integer.valueOf(sutuIdValue);
-        Integer sutuId1 = Integer.valueOf(sutuIdValue1);
-        game.setBlue(""+sutuId);
-        game.setRed(""+sutuId1);
+        // 判断一下新增还是修改
+        // 如果是修改的话判断 有没有修改场地id 有的话需要重新生成二维码 和sutuid
+        if(id!=null){
+            Game game1 = ballClient.queryGame(id);
+            // 如果场地id不相同那么要重新生成sutu二维码
+            if (!game1.getSiteId().equals(site)){
+                // 添加sutu编号
+                HashMap<String, String> map3 = new HashMap<>();
+                HashMap<String, String> map4 = new HashMap<>();
+                // 添加sutu编号
+                // 调用两次 创建sutu
+                TSite si = siteService.getById(site);
+                map3.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+                map4.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+                map3.put("space_id", si.getId() + "");
+                map4.put("space_id", si.getId() + "");
+                map3.put("name", blue);
+                map4.put("name", red);
+                map3.put("city_code", city);
+                map4.put("city_code", city);
+                String s3 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpaceSutu", map3);
+                String s4 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpaceSutu", map4);
+                JSONObject jsonObject = new JSONObject(s3);
+                JSONObject jsonObject1 = new JSONObject(s4);
+                // 获取 data 字段的值
+                JSONObject dataObject = jsonObject.getJSONObject("data");
+                JSONObject dataObject1 = jsonObject1.getJSONObject("data");
+                // 获取 sutu_id 字段的值
+                String sutuIdValue = dataObject.getString("sutu_id");
+                String sutuIdValue1 = dataObject1.getString("sutu_id");
+                Integer sutuId = Integer.valueOf(sutuIdValue);
+                Integer sutuId1 = Integer.valueOf(sutuIdValue1);
+                game.setBlue(""+sutuId);
+                game.setRed(""+sutuId1);
 
-        // 生成设备二维码
-        HashMap<String, String> blueCode = new HashMap<>();
-        blueCode.put("scan_type", "1000");
-        blueCode.put("sutu_id", ""+sutuId);
-        blueCode.put("space_id", st.getId() + "");
+                // 生成红蓝sutu二维码
+                HashMap<String, String> blueCode = new HashMap<>();
+                blueCode.put("scan_type", "1000");
+                blueCode.put("sutu_id", ""+sutuId);
+                blueCode.put("space_id", si.getId() + "");
+                HashMap<String, String> redCode = new HashMap<>();
+                redCode.put("scan_type", "1000");
+                redCode.put("sutu_id", sutuId1+"");
+                redCode.put("space_id", si.getId() + "");
+                String blueS= "{\"scan_type\": 1000, \"space_id\": "+si.getId()+", \"sutu_id\": "+sutuId+"}";
+                String redS= "{\"scan_type\": 1000, \"space_id\": "+si.getId()+", \"sutu_id\": "+sutuId1+"}";
+                MyQrCodeUtil.createCodeToFile(blueS);
+                MyQrCodeUtil.createCodeToFile(redS);
+                BufferedImage blueImage = QRCodeUtil.createImage(blueS);
+                BufferedImage redImage = QRCodeUtil.createImage(redS);
+                MultipartFile blueFile = convert(blueImage, new Date().getTime()+UUIDUtil.getRandomCode(3)+".PNG");
+                MultipartFile redFile = convert(redImage, new Date().getTime()+UUIDUtil.getRandomCode(3)+".PNG");
+                String s = OssUploadUtil.ossUpload("img/", blueFile);
+                String s1 = OssUploadUtil.ossUpload("img/", redFile);
+                game.setBlueCode(s);
+                game.setRedCode(s1);
+            }
+        }else{
+            // 添加sutu编号
+            HashMap<String, String> map3 = new HashMap<>();
+            HashMap<String, String> map4 = new HashMap<>();
+            // 添加sutu编号
+            // 调用两次 创建sutu
+            TSite si = siteService.getById(site);
+            map3.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+            map4.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+            map3.put("space_id", si.getId() + "");
+            map4.put("space_id", si.getId() + "");
+            map3.put("name", blue);
+            map4.put("name", red);
+            map3.put("city_code", city);
+            map4.put("city_code", city);
+            String s3 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpaceSutu", map3);
+            String s4 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpaceSutu", map4);
+            System.out.println("---------------------------"+s3);
+            JSONObject jsonObject = new JSONObject(s3);
+            JSONObject jsonObject1 = new JSONObject(s4);
+            // 获取 data 字段的值
+            JSONObject dataObject = jsonObject.getJSONObject("data");
+            JSONObject dataObject1 = jsonObject1.getJSONObject("data");
+            // 获取 sutu_id 字段的值
+            String sutuIdValue = dataObject.getString("sutu_id");
+            String sutuIdValue1 = dataObject1.getString("sutu_id");
+            Integer sutuId = Integer.valueOf(sutuIdValue);
+            Integer sutuId1 = Integer.valueOf(sutuIdValue1);
+            game.setBlue(""+sutuId);
+            game.setRed(""+sutuId1);
 
-        HashMap<String, String> redCode = new HashMap<>();
-        redCode.put("scan_type", "1000");
-        redCode.put("sutu_id", sutuId1+"");
-        redCode.put("space_id", st.getId() + "");
-        String blueS= "{\"scan_type\": 1000, \"space_id\": "+st.getId()+", \"sutu_id\": "+sutuId+"}";
-        String redS= "{\"scan_type\": 1000, \"space_id\": "+st.getId()+", \"sutu_id\": "+sutuId1+"}";
-        MyQrCodeUtil.createCodeToFile(blueS);
-        MyQrCodeUtil.createCodeToFile(redS);
-        BufferedImage blueImage = QRCodeUtil.createImage(blueS);
-        BufferedImage redImage = QRCodeUtil.createImage(redS);
-        MultipartFile blueFile = convert(blueImage, new Date().getTime()+UUIDUtil.getRandomCode(3)+".PNG");
-        MultipartFile redFile = convert(redImage, new Date().getTime()+UUIDUtil.getRandomCode(3)+".PNG");
-        String s = OssUploadUtil.ossUpload("img/", blueFile);
-        String s1 = OssUploadUtil.ossUpload("img/", redFile);
-//        MultipartFile multipartFile = convert(blueImage);
-//        MultipartFile multipartFile1 = convert(redImage);
-//
-//        String s = OssUploadUtil.ossUpload("img/", multipartFile);
-//        String s1 = OssUploadUtil.ossUpload("img/", multipartFile1);
-        game.setBlueCode(s);
-        game.setRedCode(s1);
+            // 生成红蓝sutu二维码
+            HashMap<String, String> blueCode = new HashMap<>();
+            blueCode.put("scan_type", "1000");
+            blueCode.put("sutu_id", ""+sutuId);
+            blueCode.put("space_id", si.getId() + "");
+            HashMap<String, String> redCode = new HashMap<>();
+            redCode.put("scan_type", "1000");
+            redCode.put("sutu_id", sutuId1+"");
+            redCode.put("space_id", si.getId() + "");
+            String blueS= "{\"scan_type\": 1000, \"space_id\": "+si.getId()+", \"sutu_id\": "+sutuId+"}";
+            String redS= "{\"scan_type\": 1000, \"space_id\": "+si.getId()+", \"sutu_id\": "+sutuId1+"}";
+            MyQrCodeUtil.createCodeToFile(blueS);
+            MyQrCodeUtil.createCodeToFile(redS);
+            BufferedImage blueImage = QRCodeUtil.createImage(blueS);
+            BufferedImage redImage = QRCodeUtil.createImage(redS);
+            MultipartFile blueFile = convert(blueImage, new Date().getTime()+UUIDUtil.getRandomCode(3)+".PNG");
+            MultipartFile redFile = convert(redImage, new Date().getTime()+UUIDUtil.getRandomCode(3)+".PNG");
+            String s = OssUploadUtil.ossUpload("img/", blueFile);
+            String s1 = OssUploadUtil.ossUpload("img/", redFile);
+            game.setBlueCode(s);
+            game.setRedCode(s1);
+        }
         Integer gameId = ballClient.save(game);
         List<TGameConfig> gameConfigList = new ArrayList<>();
-
         //玩湃跨城赛
         TGameConfig gameConfigkuacheng = new TGameConfig();
         gameConfigkuacheng.setId(kcId);
@@ -400,9 +448,7 @@
         System.out.println("========gameConfig======"+gameConfigkuacheng);
         gameConfigList.add(gameConfigkuacheng);
         System.out.println("======gameConfigList======="+gameConfigList);
-
         //社区冠军赛
-
         TGameConfig gameConfigshequ = new TGameConfig();
         gameConfigshequ.setId(shequIId);
         gameConfigshequ.setGameId(shequId);
@@ -1458,42 +1504,25 @@
         String[] dates = times.split(";");
 
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        try {
+            String start = dates[0];
+            String startDateStr = start.substring(0, start.lastIndexOf("-"));
+            Date startDate = format.parse(startDateStr);
 
-        Date minDate = null;
-        Date maxDate = null;
-
-        for (String dateStr : dates) {
-            String[] dateRange = dateStr.split("-");
-            String startDateStr = dateRange[0].trim();
-            String endDateStr = dateRange[1].trim();
-
-            try {
-                Date startDate = format.parse(startDateStr);
-                Date endDate = format.parse(endDateStr);
-
-                if (minDate == null || startDate.before(minDate)) {
-                    minDate = startDate;
-                }
-                if (maxDate == null || endDate.after(maxDate)) {
-                    maxDate = endDate;
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
+            String end = dates[dates.length - 1];
+            String[] str = end.split(" ");
+            String endDateStr = str[0] + " " + str[1].substring(str[1].indexOf("-") + 1);
+            Date endDate = format.parse(endDateStr);
+            siteBooking.setStartTime(startDate);
+            siteBooking.setEndTime(endDate);
+        } catch (Exception e) {
+            e.printStackTrace();
         }
-
-        System.out.println("最小日期:" + minDate);
-        System.out.println("最大日期:" + maxDate);
-        siteBooking.setStartTime(minDate);
-        siteBooking.setEndTime(maxDate);
         siteBooking.setPayType(2);
-
         //存多少钱
         String money = siteBooking.getMoney();
         String[] moneys = money.split(",");
         siteBooking.setPayMoney(Double.valueOf(moneys[0]));
-
-
         // 查询当前预约人是否是会员
         String phone = siteBooking.getPhone();
         String booker = siteBooking.getBooker();

--
Gitblit v1.7.1