| | |
| | | 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; |
| | |
| | | @RestController |
| | | @Api(tags = "硬件方调用 存储玩湃惠民卡使用记录") |
| | | @RequestMapping("/base/code") |
| | | @Slf4j |
| | | public class CodeCallBackController { |
| | | @Autowired |
| | | private ISiteBookingService siteBookingService; |
| | |
| | | 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); |
| | |
| | | siteBooking.setStatus(3); |
| | | siteBookingService.updateById(siteBooking); |
| | | } |
| | | return ResultUtil.success(); |
| | | 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){ |
| | | // 判断是否能入场 远程调用将门票设置为已使用 |
| | | LocalDate now = LocalDate.now(); |
| | | Date date1 = new Date(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String day = simpleDateFormat.format(now); |
| | | String day = simpleDateFormat.format(date1); |
| | | |
| | | List<QuerySiteTimes> querySiteTimes = siteService.querySiteTimes(rid, day, null, null, 2); |
| | | Integer flag =0; |
| | |
| | | return ResultUtil.error("该时间段已无空位"); |
| | | }else{ |
| | | // 远程调用 将门票设置为已使用 |
| | | userCouponClient.changeTicketStatus(dataId); |
| | | return ResultUtil.success(); |
| | | 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){ |
| | | // 判断是否能入场 远程调用将门票设置为已使用 |
| | | LocalDate now = LocalDate.now(); |
| | | // 判断是否能入场 |
| | | Date date1 = new Date(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String day = simpleDateFormat.format(now); |
| | | String day = simpleDateFormat.format(date1); |
| | | List<QuerySiteTimes> querySiteTimes = siteService.querySiteTimes(rid, day, null, null, 2); |
| | | Integer flag =0; |
| | | for (QuerySiteTimes querySiteTime : querySiteTimes) { |
| | |
| | | } |
| | | } |
| | | if (flag==0){ |
| | | log.info("该时间段已无空位"); |
| | | return ResultUtil.error("该时间段已无空位"); |
| | | }else{ |
| | | return ResultUtil.success(); |
| | |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | } |