From 5b83b50d38c757b38dcc87a40a17d34cc2948e10 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 15 三月 2024 09:49:15 +0800
Subject: [PATCH] Merge branch '2.0' of http://120.76.84.145:10101/gitblit/r/java/PlayPai into 2.0

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java |  254 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 208 insertions(+), 46 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 f2ee93a..ac910e3 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
@@ -20,26 +20,48 @@
 import com.dsh.course.feignClient.other.SiteClient;
 import com.dsh.course.feignClient.other.model.Site;
 import com.dsh.course.service.TGameConfigService;
+import com.dsh.course.util.UUIDUtil;
 import com.dsh.guns.config.UserExt;
 import com.dsh.guns.core.base.controller.BaseController;
+import com.dsh.guns.core.util.ToolUtil;
 import com.dsh.guns.modular.system.controller.util.MD5;
 import com.dsh.guns.modular.system.model.*;
 import com.dsh.guns.modular.system.model.dto.*;
 import com.dsh.guns.modular.system.service.*;
-import com.dsh.guns.modular.system.util.DateComparisonExample;
-import com.dsh.guns.modular.system.util.HttpRequestUtil;
-import com.dsh.guns.modular.system.util.ResultUtil;
+import com.dsh.guns.modular.system.util.*;
 import com.dsh.course.entity.SiteLock;
+import com.google.gson.Gson;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.WriterException;
+import com.google.zxing.client.j2se.MatrixToImageWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.QRCodeWriter;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
 import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
 import javax.annotation.Resource;
+import javax.imageio.ImageIO;
 
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
 import java.math.BigDecimal;
 
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
@@ -87,7 +109,6 @@
 
     @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();
@@ -194,7 +215,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());
@@ -212,7 +233,47 @@
         return ResultUtil.success();
     }
 
+//    public static void main(String[] args) {
+//        // 添加sutu编号
+//        HashMap<String, String> map3 = new HashMap<>();
+//        // 添加sutu编号
+//        // 添加门禁 红蓝方
+//        TSite si = siteService.getById(site);
+//        TStore st = storeService.getById(store);
+//        map3.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+//        map3.put("space_id", si.getId() + "");
+//        map3.put("name", ToolUtil.isEmpty(sutuName) ? "" : sutuName);
+//        map3.put("city_code", "");
+//        String s3 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map3);
+//        System.out.println("---------------------------"+s3);
+//        JSONObject jsonObject = new JSONObject(s3);
+//        // 获取 data 字段的值
+//        JSONObject dataObject = jsonObject.getJSONObject("data");
+//        // 获取 sutu_id 字段的值
+//        String sutuIdValue = dataObject.getString("sutu_id");
+//        Integer sutuId = Integer.valueOf(sutuIdValue);
+//        game.setSutuId(sutuId);
+//    }
 
+    public static MultipartFile convert(BufferedImage bufferedImage, String fileName) throws IOException {
+        // 将 BufferedImage 转换为字节数组
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ImageIO.write(bufferedImage, "png", baos);
+        byte[] bytes = baos.toByteArray();
+
+        // 创建 ByteArrayResource
+        ByteArrayResource resource = new ByteArrayResource(bytes);
+
+        // 创建 MockMultipartFile
+        MockMultipartFile multipartFile = new MockMultipartFile(
+                "file",
+                fileName,
+                "image/png",
+                resource.getInputStream()
+        );
+
+        return multipartFile;
+    }
     @RequestMapping("/save")
     @ResponseBody
     public ResultUtil save(Integer id, String operationId, String red, String blue, String province, String city, Integer site, Integer store
@@ -228,12 +289,12 @@
             , String ly, BigDecimal lyCoin, BigDecimal lyCash, String lyImage, BigDecimal lyInt, Integer lyId,Integer lyIId
                            ,String sutuName
 
-    ) {
+    ) throws Exception {
 
         Game game = new Game();
-        game.setRed(red);
+        game.setRedName(red);
         game.setState(0);
-        game.setBlue(blue);
+        game.setBlueName(blue);
 
 
         Integer objectType = UserExt.getUser().getObjectType();
@@ -266,30 +327,59 @@
 
         // 添加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");
-        map3.put("space_id", si.getId() + "");
-        map3.put("name", sutuName);
-        map3.put("city_code", "");
-        String s3 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map3);
+        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);
-        game.setSutuId(sutuId);
+        Integer sutuId1 = Integer.valueOf(sutuIdValue1);
+        game.setBlue(""+sutuId);
+        game.setRed(""+sutuId1);
+
+        // 生成红蓝sutu二维码
+        HashMap<String, String> blueCode = new HashMap<>();
+        blueCode.put("scan_type", "1000");
+        blueCode.put("sutu_id", ""+sutuId);
+        blueCode.put("space_id", st.getId() + "");
+        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);
+        game.setBlueCode(s);
+        game.setRedCode(s1);
         Integer gameId = ballClient.save(game);
-List<TGameConfig> gameConfigList = new ArrayList<>();
-
-
-
-//玩湃跨城赛
-
+        List<TGameConfig> gameConfigList = new ArrayList<>();
+        //玩湃跨城赛
         TGameConfig gameConfigkuacheng = new TGameConfig();
         gameConfigkuacheng.setId(kcId);
         gameConfigkuacheng.setGameId(kuachengId);
@@ -301,10 +391,8 @@
         gameConfigkuacheng.setOtherId(gameId);
         System.out.println("========gameConfig======"+gameConfigkuacheng);
         gameConfigList.add(gameConfigkuacheng);
-System.out.println("======gameConfigList======="+gameConfigList);
-
+        System.out.println("======gameConfigList======="+gameConfigList);
         //社区冠军赛
-
         TGameConfig gameConfigshequ = new TGameConfig();
         gameConfigshequ.setId(shequIId);
         gameConfigshequ.setGameId(shequId);
@@ -419,18 +507,18 @@
         HashMap<String, String> map2 = new HashMap<>();
 
 
-        map1.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
-        map1.put("space_id", si.getId() + "");
-        map1.put("device_id", red);
-        map1.put("region_id", st.getId() + "");
-        // 添加门禁
-        String s1 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map1);
-        map2.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
-        map2.put("space_id", si.getId() + "");
-        map2.put("device_id", blue);
-        map2.put("region_id", st.getId() + "");
-        // 添加门禁
-        String s2 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map2);
+//        map1.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+//        map1.put("space_id", si.getId() + "");
+//        map1.put("device_id", red);
+//        map1.put("region_id", st.getId() + "");
+//        // 添加门禁
+//        String s1 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map1);
+//        map2.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+//        map2.put("space_id", si.getId() + "");
+//        map2.put("device_id", blue);
+//        map2.put("region_id", st.getId() + "");
+//        // 添加门禁
+//        String s2 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map2);
 
 
 
@@ -869,7 +957,6 @@
     @RequestMapping("/getStudentTotal")
     @ResponseBody
     public List<Map<String, Object>>getStudentTotal(@RequestBody StudentQeryDto studentQeryDto) {
-System.out.println("========ballQueryDto======"+studentQeryDto);
         if (studentQeryDto.getTimes()!=null&& studentQeryDto.getTimes()!=""){
             String[] split = studentQeryDto.getTimes().split(",");
             studentQeryDto.setStart(split[0]);
@@ -890,9 +977,6 @@
             studentQeryDto.setCoursePackageIds(coursePackageByStoreIds);
         }
         List<Map<String, Object>>  pays = coursePackageClient.getStudentTotal(studentQeryDto);
-
-        System.out.println("=========getStudentTotal======="+pays);
-
         return pays;
     }
 
@@ -901,19 +985,37 @@
     @RequestMapping("/bypac")
     @ResponseBody
     public List<Map<String, Object>>bypac(@RequestBody PacQueryDto pacQueryDto) {
-        System.out.println("========ballQueryDto======"+pacQueryDto);
         if (pacQueryDto.getTimes()!=null&& pacQueryDto.getTimes()!=""){
             String[] split = pacQueryDto.getTimes().split(",");
             pacQueryDto.setStart(split[0]);
             pacQueryDto.setEnd(split[1]);
         }
         if (UserExt.getUser().getObjectType() == 2){
-            List<Integer> storeIds = storeService.list(new QueryWrapper<TStore>().eq("operatorId", UserExt.getUser().getObjectId()))
+            QueryWrapper<TStore> queryWrapper = new QueryWrapper<TStore>().eq("operatorId", UserExt.getUser().getObjectId()).eq("state", 1);
+            if(ToolUtil.isNotEmpty(pacQueryDto.getCityCode())){
+                queryWrapper.eq("cityCode", pacQueryDto.getCityCode());
+            }
+            if(ToolUtil.isNotEmpty(pacQueryDto.getName())){
+                queryWrapper.like("name", pacQueryDto.getName());
+            }
+            List<Integer> storeIds = storeService.list(queryWrapper)
                     .stream().map(TStore::getId).collect(Collectors.toList());
+            storeIds.add(-1);
+            pacQueryDto.setStoreIds(storeIds);
+        }else{
+            QueryWrapper<TStore> queryWrapper = new QueryWrapper<TStore>().eq("state", 1);
+            if(ToolUtil.isNotEmpty(pacQueryDto.getCityCode())){
+                queryWrapper.eq("cityCode", pacQueryDto.getCityCode());
+            }
+            if(ToolUtil.isNotEmpty(pacQueryDto.getName())){
+                queryWrapper.like("name", pacQueryDto.getName());
+            }
+            List<Integer> storeIds = storeService.list(queryWrapper)
+                    .stream().map(TStore::getId).collect(Collectors.toList());
+            storeIds.add(-1);
             pacQueryDto.setStoreIds(storeIds);
         }
         List<Map<String, Object>>  pays = coursePackageClient.bypac(pacQueryDto);
-        System.out.println("=========getStudentTotal======="+pays);
         return pays;
     }
 
@@ -977,6 +1079,23 @@
                     }
                 }
             }
+
+            if (Integer.parseInt(vo.get("status").toString())==1 ){
+                String dateTimeStr = vo.get("times").toString();
+                String formattedDateTimeStr = dateTimeStr.substring(0, 11) + dateTimeStr.substring(17);
+
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+                try {
+                    Date date = sdf.parse(formattedDateTimeStr);
+                    if (new Date().after(date)){
+                        vo.put("status",4);
+                    }
+
+                    System.out.println(date);
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+            }
         }
         return orders;
     }
@@ -1007,7 +1126,7 @@
         System.out.println("=====stie====="+site);
         System.out.println("=====type====="+type);
 
-        if (type == 0 ){
+        if (type == 1 ){
             doubles.add(site.getCashPrice());
             doubles.add(Double.valueOf(site.getPlayPaiCoin()));
             return  doubles;
@@ -1029,7 +1148,7 @@
 
     @RequestMapping("/yuyuetimes/{id}")
     @ResponseBody
-    public List<OrderDto> yuyuetimes(@PathVariable("id") Integer id,String date,String siteName,String halfName) {
+    public List<OrderDto> yuyuetimes(@PathVariable("id") Integer id,String date,String siteName,String halfName) throws ParseException {
 //        System.out.println("=======date======"+date);
 //
 //        List<String> strings = new ArrayList<>();
@@ -1089,7 +1208,8 @@
 //        return timeRanges;
 
 
-
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        Date now = new Date();
 
         System.out.println("=======date======" + date);
         List<String> strings = new ArrayList<>();
@@ -1168,6 +1288,10 @@
 
                 String stime = date + " " + currentTime;
                 String etime = date + " " + nextTime;
+                Date isPass = format.parse(etime);
+
+
+
                 orderDto.setState(1);
                 // 查出lock
                 List<SiteLock> list = siteLockService.list(new LambdaQueryWrapper<SiteLock>().eq(SiteLock::getSiteId, id));
@@ -1184,7 +1308,9 @@
                     }
 
                 }
-
+                if (isPass.before(now)){
+                    orderDto.setState(0);
+                }
 
             }
 
@@ -1251,6 +1377,17 @@
         return split;
     }
 
+    @RequestMapping("/nextName/{id}")
+    @ResponseBody
+    public String[] nextName(@PathVariable("id") Integer id) {
+        TSite byId =   siteService.getById(id);
+        String[] split = byId.getNextName().split(",");
+        System.out.println("=-============"+split);
+
+        return split;
+    }
+
+
     @RequestMapping("/yuyue_add")
     public String yuyueadd(Model model) {
         Integer objectType = UserExt.getUser().getObjectType();
@@ -1305,6 +1442,31 @@
         siteBooking.setState(1);
         siteBooking.setStatus(0);
         siteBooking.setAddType(1);
+        
+        //存开始和结束时间
+        String times = siteBooking.getTimes();
+        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);
+
+            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();
+        }
+        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