加入购物车修改

This commit is contained in:
2024-09-28 09:41:17 +08:00
parent 492fa159b9
commit 70291911a6

View File

@@ -1284,19 +1284,22 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
}
LambdaUpdateWrapper<TbShopTable> wrapper = new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getShopId, createOrderDTO.getShopId())
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
.set(TbShopTable::getProductNum, cashierCarts.size())
.set(TbShopTable::getTotalAmount, orderInfo.getOrderAmount())
.set(TbShopTable::getRealAmount, orderInfo.getOrderAmount())
.set(TbShopTable::getUseNum, mealNum)
.set(TbShopTable::getStatus, TableStateEnum.USING.getState());
if (isFirst) {
wrapper.set(TbShopTable::getUseTime, DateUtil.date());
if (!shopEatTypeInfoDTO.isTakeout()) {
LambdaUpdateWrapper<TbShopTable> wrapper = new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getShopId, createOrderDTO.getShopId())
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
.set(TbShopTable::getProductNum, cashierCarts.size())
.set(TbShopTable::getTotalAmount, orderInfo.getOrderAmount())
.set(TbShopTable::getRealAmount, orderInfo.getOrderAmount())
.set(TbShopTable::getUseNum, mealNum)
.set(TbShopTable::getStatus, TableStateEnum.USING.getState());
if (isFirst) {
wrapper.set(TbShopTable::getUseTime, DateUtil.date());
}
// 设置台桌信息
mpShopTableMapper.update(null, wrapper);
}
// 设置台桌信息
mpShopTableMapper.update(null, wrapper);
String tableCartKey = RedisConstant.getTableCartKey(createOrderDTO.getTableId(), createOrderDTO.getShopId().toString());
redisTemplate.delete(tableCartKey);
@@ -1461,6 +1464,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
throw new BadRequestException("未知支付方式");
}
TbOrderInfo orderInfo = orderInfoMapper.selectById(payDTO.getOrderId());
if (ObjectUtil.isEmpty(orderInfo)) {
@@ -1471,6 +1475,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
throw new BadRequestException("订单非未支付状态");
}
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(payDTO.getShopId(), orderInfo.getTableId());
if (payDTO.getDiscount() == null) {
payDTO.setDiscount((double) 1);
}
@@ -1534,23 +1540,26 @@ public class TbShopTableServiceImpl implements TbShopTableService {
rabbitTemplate.convertAndSend(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, mqData.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
// 修改台桌状态
TbShopTable tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getShopId, payDTO.getShopId())
.eq(TbShopTable::getQrcode, orderInfo.getTableId()));
if (tbShopTable.getAutoClear().equals(1)) {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getEndTime, DateUtil.date())
.set(TbShopTable::getUseNum, 0)
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
} else {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getEndTime, DateUtil.date())
.set(TbShopTable::getStatus, TableStateEnum.CLEANING.getState()));
if (!shopEatTypeInfoDTO.isTakeout()) {
TbShopTable tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getShopId, payDTO.getShopId())
.eq(TbShopTable::getQrcode, orderInfo.getTableId()));
if (tbShopTable.getAutoClear().equals(1)) {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getEndTime, DateUtil.date())
.set(TbShopTable::getUseNum, 0)
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
} else {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getEndTime, DateUtil.date())
.set(TbShopTable::getStatus, TableStateEnum.CLEANING.getState()));
}
}
if ("postPay".equals(orderInfo.getUseType())) {
if (!shopEatTypeInfoDTO.isTakeout()) {
String day = DateUtils.getDay();
String key = "SHOP:CODE:USER:pc" + ":" + payDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
redisTemplate.delete(key);