diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbCallTableController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbCallTableController.java index 14b1039..e357078 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbCallTableController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbCallTableController.java @@ -1,5 +1,7 @@ package com.chaozhanggui.system.cashierservice.controller; +import com.chaozhanggui.system.cashierservice.entity.dto.BaseCallTableDTO; +import com.chaozhanggui.system.cashierservice.entity.dto.CancelCallQueueDTO; import com.chaozhanggui.system.cashierservice.entity.dto.TakeNumberDTO; import com.chaozhanggui.system.cashierservice.service.TbCallService; import com.chaozhanggui.system.cashierservice.sign.Result; @@ -46,4 +48,11 @@ public class TbCallTableController { return Result.successWithData(tbCallService.getAllInfo(shopId)); } + @PutMapping("/cancel") + public Result cancel( + @Validated @RequestParam CancelCallQueueDTO cancelCallQueueDTO + ) { + return Result.successWithData(tbCallService.cancel(cancelCallQueueDTO)); + } + } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CancelCallQueueDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CancelCallQueueDTO.java new file mode 100644 index 0000000..e0dd55a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CancelCallQueueDTO.java @@ -0,0 +1,13 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class CancelCallQueueDTO { + @NotNull + private Integer queueId; + @NotNull + private Integer shopId; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallService.java index 3a2dd59..d81ff43 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallService.java @@ -1,5 +1,6 @@ package com.chaozhanggui.system.cashierservice.service; +import com.chaozhanggui.system.cashierservice.entity.dto.CancelCallQueueDTO; import com.chaozhanggui.system.cashierservice.entity.dto.TakeNumberDTO; public interface TbCallService { @@ -8,4 +9,6 @@ public interface TbCallService { Object getList(Integer shopId, String openId); Object getAllInfo(Integer shopId); + + Object cancel(CancelCallQueueDTO cancelCallQueueDTO); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallServiceImpl.java index 43db758..8995f12 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallServiceImpl.java @@ -7,6 +7,7 @@ import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper; import com.chaozhanggui.system.cashierservice.entity.TbCallQueue; import com.chaozhanggui.system.cashierservice.entity.TbCallTable; import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; +import com.chaozhanggui.system.cashierservice.entity.dto.CancelCallQueueDTO; import com.chaozhanggui.system.cashierservice.entity.dto.TakeNumberDTO; import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.mapper.TbCallQueueMapper; @@ -77,6 +78,7 @@ public class TbCallServiceImpl implements TbCallService { TbCallQueue callQueue = callQueueService.lambdaQuery() .eq(TbCallQueue::getPhone, takeNumberDTO.getPhone()) .eq(TbCallQueue::getShopId, takeNumberDTO.getShopId()) + .in(TbCallQueue::getState, 0, 1) .eq(TbCallQueue::getCallTableId, takeNumberDTO.getCallTableId()).one(); if (callQueue != null) { throw new MsgException("您已取号,请勿重复取号"); @@ -100,4 +102,13 @@ public class TbCallServiceImpl implements TbCallService { public Object getAllInfo(Integer shopId) { return callTableService.lambdaQuery().eq(TbCallTable::getShopId, shopId).eq(TbCallTable::getState, 1).list(); } + + @Override + public Object cancel(CancelCallQueueDTO cancelCallQueueDTO) { + return callQueueService.lambdaUpdate() + .eq(TbCallQueue::getShopId, cancelCallQueueDTO.getShopId()) + .eq(TbCallQueue::getId, cancelCallQueueDTO.getQueueId()) + .set(TbCallQueue::getCallTime, DateUtil.date()) + .set(TbCallQueue::getState, -1).update(); + } }