puzhibing
2024-01-03 168d852672f8f671a01d6f0f053349d0d321ec7c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
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.*;
import com.dsh.other.feignclient.CourseRecordClient;
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.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.*;
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.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * @author zhibing.pu
 * @date 2023/7/13 16:50
 */
@RestController
@RequestMapping("")
public class SiteController {
 
    @Autowired
    private ISiteService siteService;
 
    @Autowired
    private ISiteTypeService siteTypeService;
 
    @Autowired
    private TokenUtil tokenUtil;
 
    @Autowired
    private PayMoneyUtil payMoneyUtil;
 
    @Autowired
    private ISiteBookingService siteBookingService;
 
    @Resource
    private UserCouponClient userCouponClient;
    @Autowired
    private CityManagerClient cityManagerClient;
 
    /**
     * 通过运营商id查询运营商对应的支付宝商户号
     */
    @RequestMapping("/base/getSMIDByOperatorId")
    @ResponseBody
    public String getSMIDByOperatorId(Integer id) {
        // 获取运营商的管理员
        return siteService.getSMIDByOperatorId(id);
    }
    /**
     * 获取所有场地
     */
    @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/addSite1")
    public Integer addSite1(@RequestBody Site site) {
            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 = {"用户—预约场地"})
    @ApiImplicitParams({
    })
    public ResultUtil<List<BaseVo>> querySiteType() {
        try {
            List<BaseVo> list = siteTypeService.querySiteType();
            return ResultUtil.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    @ResponseBody
    @PostMapping("/base/site/querySiteList")
    @ApiOperation(value = "获取场地列表", tags = {"用户—预约场地"})
    @ApiImplicitParams({
    })
    public ResultUtil<List<QuerySiteListVo>> querySiteList(QuerySiteList querySiteList) {
        try {
            List<QuerySiteListVo> querySiteListVos = siteService.querySiteList(querySiteList);
            return ResultUtil.success(querySiteListVos);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    @ResponseBody
    @PostMapping("/base/site/querySiteInfo")
    @ApiOperation(value = "获取场地详情", tags = {"用户—预约场地"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "场地id", name = "id", dataType = "int", required = true),
            @ApiImplicitParam(value = "经度", name = "lon", dataType = "string", required = false),
            @ApiImplicitParam(value = "纬度", name = "lat", dataType = "string", required = false),
    })
    public ResultUtil<QuerySiteInfoVo> querySiteInfo(Integer id, String lon, String lat) {
        try {
            QuerySiteInfoVo querySiteInfoVo = siteService.querySiteInfo(id, lon, lat);
            return ResultUtil.success(querySiteInfoVo);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    @Autowired
    private RedisUtil redisUtil;
 
    @ResponseBody
    @PostMapping("/base/site/querySiteTimes")
    @ApiOperation(value = "获取场地详情时间段数据", tags = {"用户—预约场地"})
    @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, String halfName, String siteName) {
        try {
            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("系统繁忙,请稍后再试!");
//        }
//
//    }
 
 
    /**
     * 根据id获取数据
     *
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/site/querySiteById")
    public Site querySiteById(@RequestBody Integer id) {
        try {
            return siteService.getById(id);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
 
 
    @ResponseBody
    @PostMapping("/api/site/reservationSite")
    @ApiOperation(value = "预约场地操作", tags = {"用户—预约场地"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    public ResultUtil reservationSite(ReservationSite reservationSite) {
        try {
            Integer uid = tokenUtil.getUserIdFormRedis();
            if (null == uid) {
                return ResultUtil.tokenErr();
            }
            return siteService.reservationSite(uid, reservationSite);
        } 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("系统繁忙,请稍后再试!");
//        }
//
//    }
 
 
    /**
     * 购买课程微信支付回调
     *
     * @param request
     * @param response
     */
    @ResponseBody
    @PostMapping("/base/site/weChatPaymentSiteCallback")
    public void weChatPaymentSiteCallback(HttpServletRequest request, HttpServletResponse response) {
        try {
            Map<String, String> map = payMoneyUtil.weixinpayCallback(request);
            if (null != map) {
                String code = map.get("out_trade_no");
                String transaction_id = map.get("transaction_id");
                String result = map.get("result");
                SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("orderNo", code).eq("state", 1));
                if (siteBooking.getStatus() == 0) {
                    siteBooking.setPayTime(new Date());
                    siteBooking.setStatus(1);
                    siteBooking.setPayOrderNo(transaction_id);
                    siteBookingService.updateById(siteBooking);
                }
                PrintWriter out = response.getWriter();
                out.write(result);
                out.flush();
                out.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    /**
     * 预约场地支付宝回调
     *
     * @param request
     * @param response
     */
    @ResponseBody
    @PostMapping("/base/site/aliPaymentSiteCallback")
    public void aliPaymentSiteCallback(HttpServletRequest request, HttpServletResponse response) {
        try {
            System.out.println("回调回调回调");
            Map<String, String> map = payMoneyUtil.alipayCallback(request);
            if (null != map) {
                String code = map.get("out_trade_no");
                String trade_no = map.get("trade_no");
                SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>()
                        .eq("orderNo", code).eq("state", 1));
                if (siteBooking.getStatus() == 0) {
                    siteBooking.setPayTime(new Date());
                    siteBooking.setStatus(1);
                    siteBooking.setPayOrderNo(trade_no);
                    siteBookingService.updateById(siteBooking);
                }
                PrintWriter out = response.getWriter();
                out.write("success");
                out.flush();
                out.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    @Autowired
    private TGameConfigService gameConfigService;
    @Autowired
    private TGameRecordService gameRecordService;
 
    @Resource
    private CourseRecordClient courseRecordClient;
    /**
     * 启动游戏支付宝回调
     *
     * @param request
     * @param response
     */
    @ResponseBody
    @PostMapping("/base/site/gameCallback")
    public void gameCallback(HttpServletRequest request, HttpServletResponse response) {
        try {
            System.out.println("回调回调回调");
            Map<String, String> map = payMoneyUtil.alipayCallback(request);
            if (null != map) {
 
                String code = map.get("passback_params");
                String trade_no = map.get("trade_no");
                String[] s = code.split("_");
                Integer i = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3]));
                List<TGameRecord> list = gameRecordService.list(new QueryWrapper<TGameRecord>().eq("number", s[4]).eq("payType", 2));
                TGameRecord one = list.get(0);
                TGameConfig config = gameConfigService.getById(s[5]);
                for (TGameRecord coursePackagePayment : list) {
                    coursePackagePayment.setStatus(1);
                    coursePackagePayment.setMoney(config.getCash());
                    coursePackagePayment.setOrderNo(trade_no);
 
                    CourseCounsum courseCounsum = new CourseCounsum();
                    courseCounsum.setChangeType(3);
                    courseCounsum.setInsertTime(new Date());
                    courseCounsum.setReason("智慧球场;" + config.getCash());
                    courseCounsum.setAppUserId(Integer.valueOf(s[0]));
                    courseRecordClient.save(courseCounsum);
                }
                gameRecordService.updateBatchById(list);
 
                System.err.println("===========游戏回调游戏回调=========" + i);
                PrintWriter out = response.getWriter();
                out.write("success");
                out.flush();
                out.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
    private static Integer startGame(Integer uid, Integer gameId, Integer spaceId, Integer sutuId) {
        HashMap<String, String> map = new HashMap<>();
        map.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
        map.put("app_user_id", uid + "");
        map.put("game_id", gameId + "");
        map.put("space_id", spaceId + "");
        map.put("sutu_id", sutuId + "");
 
        String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/gameStart", map);
        JSONObject jsonObject = JSONObject.parseObject(s);
        Object code = jsonObject.get("code");
        if (String.valueOf(code) != null && "200".equals(String.valueOf(code))) {
            System.err.println("启动了一次游戏");
            return 200;
        } else {
            return 500;
        }
    }
 
 
    @ResponseBody
    @PostMapping("/api/site/queryMySite")
    @ApiOperation(value = "获取我的预约场地列表", tags = {"用户—预约场地"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "状态(0=待支付,1=待核销,2=已到店,3=已完成,4=已过期,5=已取消)", name = "status", dataType = "int", required = false),
            @ApiImplicitParam(value = "页码,首页1", name = "pageNo", dataType = "int", required = true),
            @ApiImplicitParam(value = "页条数", name = "pageSize", dataType = "int", required = true),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    public ResultUtil<List<QueryMySiteVo>> queryMySite(Integer status, Integer pageNo, Integer pageSize) {
        try {
            Integer uid = tokenUtil.getUserIdFormRedis();
            if (null == uid) {
                return ResultUtil.tokenErr();
            }
            List<QueryMySiteVo> queryMySiteVos = siteService.queryMySite(uid, status, pageNo, pageSize);
            return ResultUtil.success(queryMySiteVos);
        } catch (Exception e) {
            e.printStackTrace();
            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());
 
            map.put("name", site.getName());
 
 
            List<Integer> ids = getIds(byId.getSiteId());
            byId.setStorePhone(byId1.getPhone());
 
            //拼接开始结束时间
            Date startTime = byId.getStartTime();
            Date endTime = byId.getEndTime();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            String startTimeString = sdf.format(startTime);
            String endTimeString = sdf.format(endTime);
            String result = startTimeString + "-" + endTimeString.substring(11);
            byId.setTimes(result);
 
 
            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());
            Integer siteId = byId.getSiteId();
            ArrayList<Integer> list1 = new ArrayList<>();
            list1.add(siteId);
            byId.setRid(list1);
            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
    @PostMapping("/api/site/cancelMySite")
    @ApiOperation(value = "取消我的预约场地", 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 cancelMySite(Integer id) {
        try {
            Integer uid = tokenUtil.getUserIdFormRedis();
            if (null == uid) {
                return ResultUtil.tokenErr();
            }
 
 
            return siteService.cancelMySite(uid, id);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 微信退款回调
     *
     * @param request
     * @param response
     */
    @ResponseBody
    @PostMapping("/base/site/cancelMySiteCallback")
    public void cancelMySiteCallback(HttpServletRequest request, HttpServletResponse response) {
        try {
            Map<String, String> map = payMoneyUtil.wxRefundCallback(request);
            if (null != map) {
                String code = map.get("out_refund_no");
                String refund_id = map.get("refund_id");
                String result = map.get("result");
 
                SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("orderNo", code).eq("state", 1));
                siteBooking.setStatus(5);
                siteBooking.setCancelTime(new Date());
                siteBooking.setRefundOrderNo(refund_id);
                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(result);
                out.flush();
                out.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
    @ResponseBody
    @PostMapping("/api/site/continuePaymentMySite")
    @ApiOperation(value = "继续支付我预约的场地", tags = {"用户—预约场地"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "预约数据id", name = "id", dataType = "int", required = true),
            @ApiImplicitParam(value = "支付方式(1=微信,2=支付宝,3=玩湃币)", name = "payType", dataType = "int", required = true),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    public ResultUtil continuePaymentMySite(Integer id, Integer payType) {
        try {
            Integer uid = tokenUtil.getUserIdFormRedis();
            if (null == uid) {
                return ResultUtil.tokenErr();
            }
            return siteService.continuePaymentMySite(uid, id, payType);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    @ResponseBody
    @PostMapping("/api/site/queryContinuePaymentMySitePrice")
    @ApiOperation(value = "获取继续支付场地金额", tags = {"用户—预约场地"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "预约数据id", name = "id", dataType = "int", required = true),
    })
    public ResultUtil<Map<String, Double>> queryContinuePaymentMySitePrice(Integer id) {
        try {
            return siteService.queryContinuePaymentMySitePrice(id);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 查询所有现金支付的预约记录
     *
     * @param requestVo
     * @return
     */
    @ResponseBody
    @PostMapping("/base/site/queryPaymentSiteDetail")
    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;
    }
 
    /**
     * 查询所有玩湃币支付的预约记录
     *
     * @param appUserId
     * @return
     */
    @ResponseBody
    @PostMapping("/base/site/queryPlaypaiGoldSiteDetail")
    public List<SiteBooking> wanpaiGoldSiteBookingList(@RequestBody Integer appUserId) {
        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)
                .eq("payType", 3)
                .eq("appUserId", appUserId));
    }
 
 
    @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/counts")
    public Integer counts(@RequestBody Integer stuId) {
        return siteBookingService.count(new QueryWrapper<SiteBooking>().eq("appUserId", stuId));
 
    }
 
    @Autowired
    private  IUserService userService;
 
 
    @ResponseBody
    @PostMapping("/base/site/queryUserName")
    public User queryUserName(@RequestBody Integer coachId){
        User byId = userService.getById(coachId);
 
        return byId;
 
    }
 
    @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(@RequestBody Integer storeId) {
        List<SiteVo> siteVos = new ArrayList<>();
 
        List<Site> list = siteService.list(new QueryWrapper<Site>().eq("state", 1).eq("storeId", storeId)
                .orderByDesc("insertTime"));
        if (list.size() > 0) {
            for (Site site : list) {
                SiteVo vo = new SiteVo();
                vo.setSiteId(site.getId());
                vo.setSiteName(site.getName());
                vo.setSiteTime(site.getAppointmentStartTime() + "-" + site.getAppointmentEndTime());
                SiteType byId = siteTypeService.getById(site.getSiteTypeId());
                vo.setSiteType(byId.getName());
                vo.setPrice(site.getCashPrice());
                siteVos.add(vo);
            }
        }
        return siteVos;
 
    }
 
}