Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
Tankaikai
2024-10-12 10:44:17 +08:00
16 changed files with 128 additions and 90 deletions

View File

@@ -1,5 +1,6 @@
package cn.ysk.cashier.service.impl.order;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil;
import cn.ysk.cashier.cons.TableConstant;
@@ -257,7 +258,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
@Override
@Transactional
public TbOrderInfoDto findById(Integer id) {
public Map<String, Object> findById(Integer id) {
TbOrderInfo tbOrderInfo = tbOrderInfoRepository.findById(id).orElseGet(TbOrderInfo::new);
ValidationUtil.isNull(tbOrderInfo.getId(), "TbOrderInfo", "id", id);
TbOrderInfoDto dto = tbOrderInfoMapper.toDto(tbOrderInfo);
@@ -294,9 +295,14 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
dto.setRefundAmount(tbOrderInfos.stream().map(TbOrderInfo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
}
dto.setDetailList(details);
TbCashierCart cashierCart = tbCashierCartMapper.selectOne(new LambdaQueryWrapper<TbCashierCart>().eq(TbCashierCart::getOrderId, id).eq(TbCashierCart::getProductId, TableConstant.CART_SEAT_ID));
TbCashierCart cashierCart = tbCashierCartMapper.selectOne(new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getOrderId, id)
.eq(TbCashierCart::getUseType, tbOrderInfo.getUseType())
.eq(TbCashierCart::getProductId, TableConstant.CART_SEAT_ID));
dto.setSeatInfo(cashierCart);
return dto;
Map<String, Object> data = BeanUtil.beanToMap(tbOrderInfo, false, false);
data.putAll(BeanUtil.beanToMap(dto, false, false));
return data;
}
@Override
@@ -612,6 +618,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
return;
}
orderInfo.setStatus("refund");
orderInfo.setPaidTime(cn.hutool.core.date.DateUtil.current());
orderInfoMapper.updateById(orderInfo);
}
}

View File

@@ -241,7 +241,12 @@ public class TbProductServiceImpl implements TbProductService {
}
@Override
public Map<String, Object> queryAllV2(TbProductQueryV2Criteria criteria,Pageable pageable) {
public Map<String, Object> queryAllV2(TbProductQueryV2Criteria criteria) {
String[] sortParams = criteria.getSort().split(",");
String sortField = sortParams[0];
Sort.Direction sortDirection = Sort.Direction.fromString(sortParams[1]);
Sort sort = Sort.by(sortDirection, sortField);
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
//查询商品数据
Page<TbProduct> page = tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
Integer warnLine = 0;

View File

@@ -176,6 +176,7 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
stockDetail.setUnitName(tbShopUnit==null?"":tbShopUnit.getName());
stockDetail.setCreatedAt(System.currentTimeMillis());
stockDetail.setUpdatedAt(System.currentTimeMillis());
stockDetail.setOperator(SecurityUtils.getCurrentUsername());
tbProductStockDetailRepository.save(stockDetail);
product.setStockNumber(product.getStockNumber()-stockDetail.getStockNumber().intValue());
tbProductRepository.save(product);

View File

@@ -629,6 +629,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
// 餐位费直接删除
TbOrderDetail orderDetail = orderDetailMapper.selectOne(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getCartId, cashierCart.getId()));
if (cashierCart.getId() == -999) {
cashierCartMapper.deleteById(cashierCart.getId());
if (cashierCart.getOrderId() != null) {
@@ -656,6 +659,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
if (cashierCart.getOrderId() != null) {
// 减少订单金额
orderInfoMapper.updateOrderAmount(cashierCart.getOrderId(), orderDetail.getPriceAmount(), orderDetail.getPackAmount());
}
}
@Override
@@ -1205,7 +1214,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
String orderNo = generateOrderNumber(null);
orderInfo = new TbOrderInfo();
orderInfo.setOrderNo(orderNo);
orderInfo.setUseType(createOrderDTO.isPostPay() ? "postPay" : "afterPay");
orderInfo.setAmount(totalAmount);
orderInfo.setPayAmount(BigDecimal.ZERO);
orderInfo.setPackFee(packAMount);
@@ -1286,6 +1294,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
if (cashierCart.getPlaceNum() == null) {
cashierCart.setPlaceNum(placeNum);
}
// 先付费模式,结束购物车状态
if (shopEatTypeInfoDTO.isDineInBefore()) {
cashierCart.setStatus("final");
}
cashierCartMapper.updateById(cashierCart);
}
@@ -1305,19 +1318,32 @@ public class TbShopTableServiceImpl implements TbShopTableService {
pushConsMsg(orderInfo, cashierCarts);
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());
// 清空台桌信息
if (shopEatTypeInfoDTO.isDineInBefore()) {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getShopId, createOrderDTO.getShopId())
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
.set(TbShopTable::getProductNum, 0)
.set(TbShopTable::getTotalAmount, 0)
.set(TbShopTable::getRealAmount, 0)
.set(TbShopTable::getUseNum, 0)
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
// 设置台桌信息
}else {
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);
}
@@ -1531,6 +1557,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
if (!isOnline) {
orderInfo.setPaidTime(DateUtil.current());
orderInfo.setPayAmount(finalAmount);
orderInfo.setStatus("closed");
orderInfo.setDiscountRatio(BigDecimal.valueOf(payDTO.getDiscount()));

View File

@@ -62,7 +62,7 @@ public interface TbOrderInfoService {
* @param id ID
* @return TbOrderInfoDto
*/
TbOrderInfoDto findById(Integer id);
Map<String, Object> findById(Integer id);
/**
* 创建

View File

@@ -31,7 +31,7 @@ public interface TbProductService {
Map<String, Object> queryAll(TbProductQueryCriteria criteria, boolean isAdmin);
Map<String, Object> queryAllV2(TbProductQueryV2Criteria criteria, Pageable pageable);
Map<String, Object> queryAllV2(TbProductQueryV2Criteria criteria);
/**