From 1eed180f9c2bf73130ddcab66d25e6a641660ff0 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 25 三月 2024 17:13:33 +0800
Subject: [PATCH] 合并代码

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java |  183 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 128 insertions(+), 55 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 ac910e3..5acaff0 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
@@ -1,6 +1,5 @@
 package com.dsh.guns.modular.system.controller.system;
 
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.nacos.common.utils.Md5Utils;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -40,6 +39,7 @@
 import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
 import org.apache.commons.fileupload.FileItem;
 import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
+import org.json.JSONArray;
 import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ByteArrayResource;
@@ -105,7 +105,6 @@
     private CoursePackageClient coursePackageClient;
     @Autowired
     private AppUserClient appUserClient;
-
 
     @RequestMapping("/tolist")
     public String tolist(Model model) {
@@ -190,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);
@@ -287,6 +285,7 @@
             , String zs, BigDecimal zsCoin, BigDecimal zsCash, String zsImage, BigDecimal zsInt, Integer zsId,Integer zsIId
             , String zs2, BigDecimal zs2Coin, BigDecimal zs2Cash, String zs2Image, BigDecimal zs2Int, Integer zs2Id,Integer zs2IId
             , String ly, BigDecimal lyCoin, BigDecimal lyCash, String lyImage, BigDecimal lyInt, Integer lyId,Integer lyIId
+            , String v3, BigDecimal v3Coin, BigDecimal v3Cash, String v3Image, BigDecimal v3Int, Integer v3Id,Integer v3IId
                            ,String sutuName
 
     ) throws Exception {
@@ -318,6 +317,7 @@
         game.setId(id);
 
 
+
         if (!operationId.equals("平台")){
         game.setOperationId(Integer.valueOf(operationId));}
         else {
@@ -325,58 +325,106 @@
         }
         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);
+        HashMap<String, String> map5 = new HashMap<>();
+        map5.put("space_id", store+"");
+        map5.put("area_id", site+"");
+        String s5 = HttpRequestUtil.getRequest("https://try.daowepark.com/v7/user_api/general/get_space_sutu", map5);
+        System.err.println(s5);
+        JSONObject jsonObject5 = new JSONObject(s5);
         // 获取 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);
-
-        // 生成红蓝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);
+        JSONArray data = jsonObject5.getJSONArray("data");
+        Integer temp = null;  // 临时sutuid
+        Integer temp1 = null; // 临时sutuid
+        TSite si = siteService.getById(site);
+        if (data.length() == 0){
+            // 这个场地没有添加过sutu
+            HashMap<String, String> map3 = new HashMap<>();
+            HashMap<String, String> map4 = new HashMap<>();
+            // 添加sutu编号
+            // 调用两次 创建sutu
+            map3.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+            map4.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+            map3.put("space_id", store + "");
+            map3.put("area_id", si.getId() + "");
+            map4.put("space_id", store + "");
+            map4.put("area_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);
+            // 生成红蓝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{
+            Integer sutuid=0;
+            Integer sutuid1=0;
+            JSONObject element = data.getJSONObject(0);
+            if (site==27){
+                sutuid=1036;
+                sutuid1=1037;
+                game.setBlue(sutuid.toString());
+                game.setRed(sutuid1.toString());
+            }else{
+                sutuid = element.getInt("id");
+                game.setBlue(sutuid.toString());
+                JSONObject element1 = data.getJSONObject(1);
+                sutuid1 = element1.getInt("id");
+                game.setRed(sutuid1.toString());
+            }
+            // 生成红蓝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<>();
         //玩湃跨城赛
@@ -503,6 +551,18 @@
         gameConfigly.setIntegral(lyInt);
         gameConfigly.setOtherId(gameId);
         gameConfigList.add(gameConfigly);
+    
+        //激战3V3
+        TGameConfig gameConfigv3 = new TGameConfig();
+        gameConfigv3.setGameId(v3Id);
+        gameConfigv3.setId(v3IId);
+        gameConfigv3.setCash(v3Cash);
+        gameConfigv3.setImg(v3Image);
+        gameConfigv3.setName(v3);
+        gameConfigv3.setPlayCoin(v3Coin);
+        gameConfigv3.setIntegral(v3Int);
+        gameConfigv3.setOtherId(gameId);
+        gameConfigList.add(gameConfigv3);
         HashMap<String, String> map1 = new HashMap<>();
         HashMap<String, String> map2 = new HashMap<>();
 
@@ -526,6 +586,14 @@
         return null;
     }
 
+//    public static void main(String[] args) {
+//        HashMap<String, String> map3 = new HashMap<>();
+//        map3.put("space_id", "1001");
+//        map3.put("area_id", "4352");
+//        String s3 = HttpRequestUtil.getRequest("https://try.daowepark.com/v7/user_api/general/get_space_sutu", map3);
+//
+//        System.err.println(s3);
+//    }
     @RequestMapping("/pre_add")
     public String add(Model model) {
 
@@ -606,6 +674,9 @@
 
         TGameConfig ly = gameConfigService.getOne(new QueryWrapper<TGameConfig>().eq("otherId", id).eq("gameId", 5));
         model.addAttribute("ly",ly);
+    
+        TGameConfig v3 = gameConfigService.getOne(new QueryWrapper<TGameConfig>().eq("otherId", id).eq("gameId", 0));
+        model.addAttribute("v3",v3);
 
 
         Integer objectType = UserExt.getUser().getObjectType();
@@ -675,7 +746,9 @@
 
         TGameConfig ly = gameConfigService.getOne(new QueryWrapper<TGameConfig>().eq("otherId", id).eq("gameId", 5));
         model.addAttribute("ly",ly);
-
+        
+        TGameConfig v3 = gameConfigService.getOne(new QueryWrapper<TGameConfig>().eq("otherId", id).eq("gameId", 0));
+        model.addAttribute("v3",v3);
 
 
         return PREFIX+"ball_pre_info.html";

--
Gitblit v1.7.1