新增台桌状态接口

This commit is contained in:
2024-10-24 15:20:14 +08:00
parent 743f59d4a3
commit d15b17729c
7 changed files with 70 additions and 1 deletions

View File

@@ -98,6 +98,12 @@ public class TbShopTableController {
return new ResponseEntity<>(tbShopTableService.generate(generateDTO),HttpStatus.OK); return new ResponseEntity<>(tbShopTableService.generate(generateDTO),HttpStatus.OK);
} }
/**
* 台桌状态获取
*/
@GetMapping("/state")
public ResponseEntity<Object> getShopState(@RequestParam Integer shopId, @RequestParam String tableId) {
return new ResponseEntity<>(tbShopTableService.getShopState(shopId, tableId),HttpStatus.OK);
}
} }

View File

@@ -1,5 +1,6 @@
package cn.ysk.cashier.mybatis.service; package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.pojo.order.TbOrderDetail; import cn.ysk.cashier.pojo.order.TbOrderDetail;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
@@ -21,5 +22,14 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
* @return 购物车信息 * @return 购物车信息
*/ */
List<TbCashierCart> selectTakeoutCart(String masterId, Integer shopId); List<TbCashierCart> selectTakeoutCart(String masterId, Integer shopId);
/**
* 统计当前台桌购物车数量
* @param shopId 店铺id
* @param tableId 台桌id
* @param statusEnums 状态,可不传查询所有
* @return 购物车数量
*/
long countByTableId(Integer shopId, String tableId, OrderStatusEnums... statusEnums);
} }

View File

@@ -20,4 +20,12 @@ public interface MpShopTableService extends IService<TbShopTable> {
* @return 台桌信息 * @return 台桌信息
*/ */
TbShopTable selectByStateAndTableId(TableStateEnum tableStateEnum, String tableId, Integer shopId); TbShopTable selectByStateAndTableId(TableStateEnum tableStateEnum, String tableId, Integer shopId);
/**
* 查询台桌信息
* @param tableId 台桌id
* @param shopId 店铺id
* @return 台桌信息
*/
TbShopTable selectByTableId(String tableId, Integer shopId);
} }

View File

@@ -1,6 +1,7 @@
package cn.ysk.cashier.mybatis.service.impl; package cn.ysk.cashier.mybatis.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.enums.OrderUseTypeEnum; import cn.ysk.cashier.enums.OrderUseTypeEnum;
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper; import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper; import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
@@ -12,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -31,5 +33,21 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
.eq(TbCashierCart::getUseType, OrderUseTypeEnum.TAKEOUT.getValue()) .eq(TbCashierCart::getUseType, OrderUseTypeEnum.TAKEOUT.getValue())
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())); .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()));
} }
@Override
public long countByTableId(Integer shopId, String tableId, OrderStatusEnums... statusEnums) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
.eq(TbCashierCart::getTableId, tableId);
if (statusEnums.length > 0) {
ArrayList<String> stateList = new ArrayList<>();
for (OrderStatusEnums statusEnum : statusEnums) {
stateList.add(statusEnum.getValue());
}
queryWrapper.in(TbCashierCart::getStatus, stateList);
}
return count(queryWrapper);
}
} }

View File

@@ -30,4 +30,11 @@ public class MpShopTableServiceImpl extends ServiceImpl<MpShopTableMapper, TbSho
.eq(TbShopTable::getStatus, tableStateEnum.getState()) .eq(TbShopTable::getStatus, tableStateEnum.getState())
.eq(TbShopTable::getQrcode, tableId)); .eq(TbShopTable::getQrcode, tableId));
} }
@Override
public TbShopTable selectByTableId(String tableId, Integer shopId) {
return getOne(new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getShopId, shopId)
.eq(TbShopTable::getQrcode, tableId));
}
} }

View File

@@ -2191,4 +2191,16 @@ public class TbShopTableServiceImpl implements TbShopTableService {
rabbitMsgUtils.updateCons(jsonObject1); rabbitMsgUtils.updateCons(jsonObject1);
return true; return true;
} }
@Override
public Object getShopState(Integer shopId, String tableId) {
TbShopTable tbShopTable = mpShopTableService.selectByTableId(tableId, shopId);
if (tbShopTable != null) {
long cartCount = mpCashierCartService.countByTableId(shopId, tableId);
Map<String, Object> map = BeanUtil.beanToMap(tbShopTable, false, false);
map.put("cartCount", cartCount);
return map;
}
return null;
}
} }

View File

@@ -139,4 +139,12 @@ public interface TbShopTableService {
Object choseModel(ChoseModelDTO choseModelDTO); Object choseModel(ChoseModelDTO choseModelDTO);
Object returnOrder(ReturnOrderDTO returnOrderDTO); Object returnOrder(ReturnOrderDTO returnOrderDTO);
/**
* 获取台桌状态
* @param shopId 电偶id
* @param tableId qrcode
* @return
*/
Object getShopState(Integer shopId, String tableId);
} }