From e030255c23c7ba3e2cbad1036a810d6d72fa864f Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期四, 26 十月 2023 18:04:58 +0800
Subject: [PATCH] 修改bug

---
 cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java |  271 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 241 insertions(+), 30 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 b0f032d..a04ed24 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,35 +1,42 @@
 package com.dsh.other.controller;
 
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.dsh.other.entity.Site;
-import com.dsh.other.entity.SiteBooking;
-import com.dsh.other.entity.SiteType;
+import com.dsh.other.entity.*;
+import com.dsh.other.feignclient.account.CityManagerClient;
 import com.dsh.other.feignclient.activity.UserCouponClient;
 import com.dsh.other.feignclient.activity.model.QueryUserCouponByIdAndUserId;
 import com.dsh.other.feignclient.activity.model.UserCoupon;
 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.model.*;
-import com.dsh.other.service.ISiteBookingService;
-import com.dsh.other.service.ISiteService;
-import com.dsh.other.service.ISiteTypeService;
+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.PayMoneyUtil;
+import com.dsh.other.util.RedisUtil;
 import com.dsh.other.util.ResultUtil;
 import com.dsh.other.util.TokenUtil;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
+import redis.clients.jedis.Jedis;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author zhibing.pu
@@ -56,10 +63,93 @@
 
     @Resource
     private UserCouponClient userCouponClient;
+    @Autowired
+    private CityManagerClient cityManagerClient;
+
+    /**
+     * 获取所有场地
+     */
+    @RequestMapping("/base/site/getList")
+    @ResponseBody
+    public List<Site> getList(){
+        return siteService.list(new QueryWrapper<Site>().ne("state",3));
+    }
+    /**
+     * 获取场地预约记录
+     */
+    @RequestMapping("/base/site/listAll")
+    public List<SiteBooking> listAll(@RequestBody SiteBookingQuery query){
+        return siteBookingService.listAll(query);
+    }
+    /**
+     * 获取所有场地
+     * @return
+     */
+    @RequestMapping("/base/site/list")
+    public List<TSiteDTO> listAll(@RequestBody SiteSearchVO vo){
+        return siteTypeService.listAll(vo);
+    }
+    /**
+     * 获取场地有效期在两个月内的场地列表
+     * @return
+     */
+    @RequestMapping("/base/site/listExipre")
+    public List<TSiteDTO> listExipre(@RequestBody ExpireSiteSearchVO vo){
+
+        return siteTypeService.listExipre(vo);
+
+    }
+
+    /**
+     * 上/下架、删除常见问题 type=1为上架 2为下架 3为删除
+     */
+    @RequestMapping("/base/site/changeState")
+    public Object changeState(@RequestBody SiteChangeStateVO vo){
+
+        return siteService.changeState(vo);
+    }
+    /**
+     * 添加场地管理
+     * @return
+     */
+    @RequestMapping("/base/site/addSite")
+    public Integer addSite(@RequestBody Site site){
+        if(site.getId()!= null ){
+            siteService.updateById(site);
+            return site.getId();
+        }else {
+            boolean save = siteService.save(site);
+            return site.getId();
+        }
+    }
 
 
+    /**
+     * 添加场地管理
+     * @return
+     */
+    @RequestMapping("/base/site/addSiteBooking")
+    public Object addSiteBooking(@RequestBody SiteBooking siteBooking){
+        if(siteBooking.getId()!= null ){
+
+            return siteBookingService.updateById(siteBooking);
+        }else {
+            return siteBookingService.save(siteBooking);
+        }
+    }
+
+    @RequestMapping("/base/site/listById")
+    public Site listById(@RequestParam("id") Integer id){
+        Site byId = siteService.getById(id);
+        return byId;
+    }
 
 
+    @RequestMapping("/base/site/listBooks")
+    public  List<SiteBooking> listBooks(@RequestParam("id") Integer id){
+        List<SiteBooking> siteId = siteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id));
+        return siteId;
+    }
     @ResponseBody
     @PostMapping("/base/site/querySiteType")
     @ApiOperation(value = "获取场地类型", tags = {"用户—预约场地"})
@@ -93,7 +183,6 @@
 
 
 
-
     @ResponseBody
     @PostMapping("/base/site/querySiteInfo")
     @ApiOperation(value = "获取场地详情", tags = {"用户—预约场地"})
@@ -112,7 +201,8 @@
         }
     }
 
-
+    @Autowired
+    private RedisUtil redisUtil;
 
     @ResponseBody
     @PostMapping("/base/site/querySiteTimes")
@@ -120,16 +210,34 @@
     @ApiImplicitParams({
             @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)
     })
-    public ResultUtil<List<QuerySiteTimes>> querySiteTimes(Integer id, String day){
+    public ResultUtil<List<QuerySiteTimes>> querySiteTimes(Integer id, String day,String halfName,String siteName){
         try {
-            List<QuerySiteTimes> list = siteService.querySiteTimes(id, day);
+            List<QuerySiteTimes> list = siteService.querySiteTimes(id, day,halfName,siteName);
             return ResultUtil.success(list);
         }catch (Exception e){
             e.printStackTrace();
             return ResultUtil.runErr();
         }
     }
+
+//    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("系统繁忙,请稍后再试!");
+//        }
+//
+//    }
+
 
 
     /**
@@ -169,8 +277,20 @@
         }
     }
 
-
-
+//        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("系统繁忙,请稍后再试!");
+//        }
+//
+//    }
 
 
     /**
@@ -260,6 +380,63 @@
             return ResultUtil.runErr();
         }
     }
+    @ResponseBody
+    @PostMapping("/api/site/queryMySiteById")
+    @ApiOperation(value = "获取我的预约场地列表详情2.0", 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....."),
+    })
+    public ResultUtil<Map<String,Object>> queryMySiteById(Integer id){
+        try {
+            HashMap<String, Object> map = new HashMap<>();
+            SiteBooking byId = siteBookingService.getById(id);
+            Integer storeId = byId.getStoreId();
+            Store byId1 = service.getById(storeId);
+            Site site = siteService.getById(byId.getSiteId());
+
+            map.put("siteName",byId1.getName());
+            SiteType siteType = siteTypeService.getById(site.getSiteTypeId());
+            map.put("siteType",siteType.getName());
+            map.put("shopName",byId1.getName());
+            map.put("shopAddress",byId1.getAddress());
+
+
+            List<Integer> ids = getIds(byId.getSiteId());
+            byId.setStorePhone(byId1.getPhone());
+
+            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);
+
+
+            map.put("ids",ids);
+            return ResultUtil.success(map);
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultUtil.runErr();
+        }
+    }
+
+    public List<Integer>  getIds(Integer siteId) {
+        HttpRequest httpRequest = HttpRequest.get("https://try.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);
+        Object data = jsonObject.get("data");
+        JSONArray array = JSONArray.parseArray(data.toString());
+        List<Integer> ids =new ArrayList<>();
+        for (Object o : array) {
+            JSONObject jsonObject1 = JSONObject.parseObject(o.toString());
+            Object id = jsonObject1.get("id");
+            Integer integer = Integer.valueOf(id.toString());
+            ids.add(integer);
+        }
+        return ids;
+
+    }
 
 
     @ResponseBody
@@ -275,6 +452,8 @@
             if(null == uid){
                 return ResultUtil.tokenErr();
             }
+
+
             return siteService.cancelMySite(uid, id);
         }catch (Exception e){
             e.printStackTrace();
@@ -363,19 +542,15 @@
      * @param requestVo
      * @return
      */
+    @ResponseBody
     @PostMapping("/base/site/queryPaymentSiteDetail")
-    public List<SiteBooking> getAllSiteBookingList(@RequestBody BillingDataRequestVo requestVo){
-        ArrayList<Integer> integers = new ArrayList<>();
-        integers.add(1);
-        integers.add(2);
-        integers.add(3);
-        integers.add(4);
-        integers.add(5);
-        return siteBookingService.list(new QueryWrapper<SiteBooking>()
-                .in("status",integers)
-                .ne("payType",3)
-                .eq("appUserId",requestVo.getAppUserId())
-                .between("payTime",requestVo.getMonthStart(),requestVo.getMonthEnd()));
+    public RequestOfTypeVo getAllSiteBookingList(@RequestBody BillingDataRequestVo requestVo){
+        RequestOfTypeVo typeVo = new RequestOfTypeVo();
+        List<BillingRequestOfType> billingRequestOfTypes = siteBookingService.queryDatas(requestVo.getAppUserId(), requestVo.getMonthStart(), requestVo.getMonthEnd());
+        if (billingRequestOfTypes.size() > 0 ){
+            typeVo.setRequest(billingRequestOfTypes);
+        }
+        return typeVo;
     }
 
     /**
@@ -383,6 +558,7 @@
      * @param appUserId
      * @return
      */
+    @ResponseBody
     @PostMapping("/base/site/queryPlaypaiGoldSiteDetail")
     public List<SiteBooking> wanpaiGoldSiteBookingList(@RequestBody Integer appUserId){
         ArrayList<Integer> integers = new ArrayList<>();
@@ -398,11 +574,46 @@
     }
 
 
+    @ResponseBody
+    @PostMapping("/base/site/queryByCode")
+    public Integer queryByCode(@RequestBody String code){
+
+        return siteBookingService.queryByCode(code);
+    }
+
+
+    @Autowired
+   private StoreService service;
+
+    @Autowired
+    private IOperatorUserService operatorUserService;
+
+
+    @ResponseBody
+    @PostMapping("/base/site/game")
+    public List<Map<String, Object>> game(@RequestBody Integer appUserId){
+        return service.game(appUserId);
+
+    }
+
+    @ResponseBody
+    @PostMapping("/base/site/queryOperator")
+    public OperatorUser queryOperator(@RequestBody List<Integer> stores){
+
+        Store one = service.getOne(new QueryWrapper<Store>().in("id", stores));
+        OperatorUser o = operatorUserService.getById(one.getOperatorId());
+
+        return o;
+    }
+
+
+
+    @ResponseBody
     @PostMapping("/base/site/getNewAddSiteList")
-    public List<SiteVo> getAppUserSiteList(){
+    public List<SiteVo> getAppUserSiteList(@RequestBody Integer storeId){
         List<SiteVo> siteVos = new ArrayList<>();
 
-        List<Site> list = siteService.list(new QueryWrapper<Site>()
+        List<Site> list = siteService.list(new QueryWrapper<Site>().eq("state",1).eq("storeId",storeId)
                 .orderByDesc("insertTime"));
         if (list.size() > 0 ){
             for (Site site : list) {

--
Gitblit v1.7.1