刘帅
2026-09-22 bc68f4393cafe39c4fce614c8128936067ea25f7
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
package com.dsh.other.controller;
 
import com.dsh.other.entity.SiteBooking;
import com.dsh.other.entity.TSiteBookingUse;
import com.dsh.other.feignclient.activity.UserCouponClient;
import com.dsh.other.model.QuerySiteTimes;
import com.dsh.other.service.ISiteBookingService;
import com.dsh.other.service.ISiteBookingUseService;
import com.dsh.other.service.ISiteService;
import com.dsh.other.util.ResultUtil;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
 
/**
 * 硬件方调用 存储玩湃惠民卡使用记录
 * @author zhibing.pu
 * @date 2023/6/24 11:27
 */
@RestController
@Api(tags = "硬件方调用 存储玩湃惠民卡使用记录")
@RequestMapping("/base/code")
@Slf4j
public class CodeCallBackController {
    @Autowired
    private ISiteBookingService siteBookingService;
    @Autowired
    private ISiteService siteService;
    @Autowired
    private UserCouponClient userCouponClient;
    @Autowired
    private ISiteBookingUseService siteBookingUseService;
    // 进场二维码新增参数codeType 1=订场 2=散客,3=门票,玩湃惠民卡codeType=4
    /**
     * 硬件开门后回调 是否可进场检查接口 sid门店id rid场地id
     */
    @GetMapping("/verify")
    public ResultUtil verify(Integer codeType,String dataId, Integer rid, Integer sid) throws Exception {
        log.info("硬件开门后回调 校验是否可入场");
        System.err.println("硬件开门后回调 校验是否可入场");
        System.err.println("codeType:"+codeType);
        System.err.println("dataId:"+dataId);
        System.err.println("rid:"+rid);
        System.err.println("sid:"+sid);
        if (rid==32){
            rid= 27;
        }
        Date date = new Date();
 
        // codeType二维码类型1=订场 2=散客,3=门票,玩湃惠民卡codeType=4 234需要校验能否进场
        if (codeType==1 || codeType==2){
            // 将订单设置为已使用
            SiteBooking siteBooking = siteBookingService.getById(Integer.valueOf(dataId));
            if (siteBooking==null){
                System.err.println("未查询到订场记录"+dataId);
                System.err.println("codeType"+codeType);
                return ResultUtil.error("未查询到订场记录");
            }else{
                siteBooking.setStatus(3);
                siteBookingService.updateById(siteBooking);
            }
            if (siteBooking.getStoreId()==9939 && codeType==2){
                TSiteBookingUse siteBookingUse = siteBookingUseService.lambdaQuery()
                        .eq(TSiteBookingUse::getDataId, dataId)
                        .eq(TSiteBookingUse::getType, 1)
                        .last("limit 1")
                        .one();
                if (siteBookingUse!=null){
                    // 已经使用过了 不开门
                    return ResultUtil.error("已使用");
                }
                TSiteBookingUse siteBookingUse1 = new TSiteBookingUse();
                siteBookingUse1.setDataId(dataId);
                siteBookingUse1.setType(1);
                siteBookingUse1.setInsertTime(date);
                siteBookingUseService.save(siteBookingUse1);
                return ResultUtil.success();
            }
 
        }
        if (codeType==3){
            //  判断是否能入场 远程调用将门票设置为已使用
            Date date1 = new Date();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            String day = simpleDateFormat.format(date1);
 
            List<QuerySiteTimes> querySiteTimes = siteService.querySiteTimes(rid, day, null, null, 2);
            Integer flag =0;
            for (QuerySiteTimes querySiteTime : querySiteTimes) {
                if (querySiteTime.getSelectable()==1){
                    flag = 1;
                    break;
                }
            }
            if (flag==0){
                return ResultUtil.error("该时间段已无空位");
            }else{
                // 远程调用 将门票设置为已使用
                userCouponClient.changeTicketStatus(dataId,sid,rid);
                if (sid==9939){
                    TSiteBookingUse siteBookingUse = siteBookingUseService.lambdaQuery()
                            .eq(TSiteBookingUse::getDataId, dataId)
                            .eq(TSiteBookingUse::getType, 2)
                            .last("limit 1")
                            .one();
                    if (siteBookingUse!=null){
                        // 已经使用过了 不开门
                        return ResultUtil.error("已使用");
                    }
                    TSiteBookingUse siteBookingUse2 = new TSiteBookingUse();
                    siteBookingUse2.setDataId(dataId);
                    siteBookingUse2.setType(2);
                    siteBookingUse2.setInsertTime(date);
                    siteBookingUseService.save(siteBookingUse2);
                    return ResultUtil.success();
                }
 
            }
        }
        if (codeType==4){
            //  判断是否能入场
            Date date1 = new Date();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            String day = simpleDateFormat.format(date1);
            List<QuerySiteTimes> querySiteTimes = siteService.querySiteTimes(rid, day, null, null, 2);
            Integer flag =0;
            for (QuerySiteTimes querySiteTime : querySiteTimes) {
                if (querySiteTime.getSelectable()==1){
                    flag = 1;
                    break;
                }
            }
            if (flag==0){
                log.info("该时间段已无空位");
                return ResultUtil.error("该时间段已无空位");
            }else{
                return ResultUtil.success();
            }
        }
 
        return ResultUtil.success();
    }
 
 
}