perf: 台桌接口增加状态查询 选择台桌支持清空原有购物车
This commit is contained in:
parent
56d8195450
commit
35ad186a9d
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package cn.ysk.cashier.dto.shop;
|
package cn.ysk.cashier.dto.shop;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.enums.TableStateEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import cn.ysk.cashier.annotation.Query;
|
import cn.ysk.cashier.annotation.Query;
|
||||||
|
|
||||||
|
|
@ -42,6 +43,7 @@ public class TbShopTableQueryCriteria{
|
||||||
|
|
||||||
@Query
|
@Query
|
||||||
private Long qrcode;
|
private Long qrcode;
|
||||||
|
private String state;
|
||||||
|
|
||||||
private Integer page = 1;
|
private Integer page = 1;
|
||||||
private Integer size = 99999;
|
private Integer size = 99999;
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,7 @@ public class ChoseTableDTO {
|
||||||
private String masterId;
|
private String masterId;
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String tableId;
|
private String tableId;
|
||||||
|
@NotNull
|
||||||
|
private Boolean isClear;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package cn.ysk.cashier.mybatis.service;
|
||||||
|
|
||||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
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 com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -31,5 +30,14 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
|
||||||
* @return 购物车数量
|
* @return 购物车数量
|
||||||
*/
|
*/
|
||||||
long countByTableId(Integer shopId, String tableId, OrderStatusEnums... statusEnums);
|
long countByTableId(Integer shopId, String tableId, OrderStatusEnums... statusEnums);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据tableIdId和用餐类型清空购物车
|
||||||
|
*
|
||||||
|
* @param tableId 台桌id
|
||||||
|
* @param useType 用餐类型
|
||||||
|
* @param shopId 店铺id
|
||||||
|
*/
|
||||||
|
boolean clearCartByTableIdAndUseType(String tableId, String useType, Integer shopId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,13 @@ import cn.hutool.core.date.DateUtil;
|
||||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
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.service.MpCashierCartService;
|
import cn.ysk.cashier.mybatis.service.MpCashierCartService;
|
||||||
import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
|
|
||||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -49,5 +45,15 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
|
||||||
}
|
}
|
||||||
return count(queryWrapper);
|
return count(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean clearCartByTableIdAndUseType(String tableId, String useType, Integer shopId) {
|
||||||
|
return remove(new LambdaQueryWrapper<TbCashierCart>()
|
||||||
|
.in(TbCashierCart::getStatus, OrderStatusEnums.CREATE.getValue(), OrderStatusEnums.RETURN.getValue())
|
||||||
|
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
||||||
|
.eq(TbCashierCart::getShopId, shopId)
|
||||||
|
.eq(TbCashierCart::getTableId, tableId)
|
||||||
|
.eq(TbCashierCart::getUseType, useType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
query.eq(TbShopTable::getQrcode, criteria.getQrcode());
|
query.eq(TbShopTable::getQrcode, criteria.getQrcode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(criteria.getState())) {
|
||||||
|
query.eq(TbShopTable::getStatus, criteria.getState());
|
||||||
|
}
|
||||||
|
|
||||||
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbShopTable> shopTablePage =
|
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbShopTable> shopTablePage =
|
||||||
mpShopTableService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()), query);
|
mpShopTableService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()), query);
|
||||||
List<TbShopTable> tbShopTableList = shopTablePage.getRecords();
|
List<TbShopTable> tbShopTableList = shopTablePage.getRecords();
|
||||||
|
|
@ -281,10 +285,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
itemMap.put("masterId", orderInfo == null ? null : orderInfo.getMasterId());
|
itemMap.put("masterId", orderInfo == null ? null : orderInfo.getMasterId());
|
||||||
infoList.add(itemMap);
|
infoList.add(itemMap);
|
||||||
}
|
}
|
||||||
int i = tbShopTableRepository.countAllByShopId(criteria.getShopId());
|
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put("content", infoList);
|
map.put("content", infoList);
|
||||||
map.put("total", i);
|
map.put("total", shopTablePage.getTotal());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1786,6 +1789,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
|
|
||||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(choseTableDTO.getShopId(), choseTableDTO.getTableId());
|
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(choseTableDTO.getShopId(), choseTableDTO.getTableId());
|
||||||
|
|
||||||
|
// 清空原有桌台商品
|
||||||
|
if (choseTableDTO.getIsClear()) {
|
||||||
|
mpCashierCartService.clearCartByTableIdAndUseType(choseTableDTO.getTableId(), shopEatTypeInfoDTO.getUseType(), choseTableDTO.getShopId());
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<Integer> cartIds = new ArrayList<>();
|
ArrayList<Integer> cartIds = new ArrayList<>();
|
||||||
Integer orderId = null;
|
Integer orderId = null;
|
||||||
for (TbCashierCart item : tbCashierCarts) {
|
for (TbCashierCart item : tbCashierCarts) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue