|
|
|
@@ -549,6 +549,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
public CzgResult<Object> mergeOrder(MergeOrderDTO param) {
|
|
|
|
public CzgResult<Object> mergeOrder(MergeOrderDTO param) {
|
|
|
|
if (param.getTargetOrderId() == null && StrUtil.isBlank(param.getTargetTableCode())) {
|
|
|
|
if (param.getTargetOrderId() == null && StrUtil.isBlank(param.getTargetTableCode())) {
|
|
|
|
throw new CzgException("转台失败,请选择目标台桌后转台");
|
|
|
|
throw new CzgException("转台失败,请选择目标台桌后转台");
|
|
|
|
@@ -560,11 +561,21 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|
|
|
if (sourceOrder == null || !sourceOrder.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
|
|
|
if (sourceOrder == null || !sourceOrder.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
|
|
|
throw new CzgException("转台失败,无可转订单");
|
|
|
|
throw new CzgException("转台失败,无可转订单");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String sourceTableCode = sourceOrder.getTableCode();
|
|
|
|
OrderInfo targetOrder = orderInfoService.getOne(QueryWrapper.create().eq(OrderInfo::getId, param.getTargetOrderId())
|
|
|
|
OrderInfo targetOrder = orderInfoService.getOne(QueryWrapper.create().eq(OrderInfo::getId, param.getTargetOrderId())
|
|
|
|
.eq(OrderInfo::getTableCode, param.getTargetTableCode())
|
|
|
|
.eq(OrderInfo::getTableCode, param.getTargetTableCode())
|
|
|
|
.eq(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode()));
|
|
|
|
.eq(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode()));
|
|
|
|
if (targetOrder == null) {
|
|
|
|
if (targetOrder == null) {
|
|
|
|
ShopTable shopTable = shopTableService.getOneByTableCode(sourceOrder.getShopId(), param.getTargetTableCode());
|
|
|
|
ShopTable shopTable = shopTableService.getOneByTableCode(sourceOrder.getShopId(), param.getTargetTableCode());
|
|
|
|
|
|
|
|
sourceOrder.setTableCode(shopTable.getTableCode());
|
|
|
|
|
|
|
|
sourceOrder.setTableName(shopTable.getName());
|
|
|
|
|
|
|
|
if(param.getAllMerge()==1){
|
|
|
|
|
|
|
|
OrderInfo upOrder = new OrderInfo();
|
|
|
|
|
|
|
|
upOrder.setTableCode(shopTable.getTableCode());
|
|
|
|
|
|
|
|
upOrder.setTableName(shopTable.getName());
|
|
|
|
|
|
|
|
orderInfoService.update(upOrder, new QueryWrapper().eq(OrderInfo::getId, sourceOrder.getId()));
|
|
|
|
|
|
|
|
targetOrder=sourceOrder;
|
|
|
|
|
|
|
|
}else {
|
|
|
|
OrderInfoAddDTO addDTO = new OrderInfoAddDTO();
|
|
|
|
OrderInfoAddDTO addDTO = new OrderInfoAddDTO();
|
|
|
|
addDTO.setShopId(sourceOrder.getShopId());
|
|
|
|
addDTO.setShopId(sourceOrder.getShopId());
|
|
|
|
addDTO.setStaffId(sourceOrder.getStaffId());
|
|
|
|
addDTO.setStaffId(sourceOrder.getStaffId());
|
|
|
|
@@ -578,14 +589,20 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|
|
|
addDTO.setVipPrice(false);
|
|
|
|
addDTO.setVipPrice(false);
|
|
|
|
ShopInfo shopInfo = shopInfoService.getById(sourceOrder.getShopId());
|
|
|
|
ShopInfo shopInfo = shopInfoService.getById(sourceOrder.getShopId());
|
|
|
|
targetOrder = initOrderInfo(addDTO, shopInfo, shopTable);
|
|
|
|
targetOrder = initOrderInfo(addDTO, shopInfo, shopTable);
|
|
|
|
|
|
|
|
OrderDetail orderDetailUp = new OrderDetail();
|
|
|
|
|
|
|
|
orderDetailUp.setOrderId(targetOrder.getId());
|
|
|
|
|
|
|
|
orderDetailUp.setPlaceNum(1);
|
|
|
|
|
|
|
|
orderDetailService.update(orderDetailUp,
|
|
|
|
|
|
|
|
new QueryWrapper().eq(OrderDetail::getOrderId, sourceOrder.getId()).in(OrderDetail::getId, param.getDetailIds()));
|
|
|
|
|
|
|
|
redisService.set(RedisCst.classKeyExpired.EXPIRED_ORDER + targetOrder.getId(), "", 60 * 15);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
targetOrder.setPlaceNum(targetOrder.getPlaceNum() + 1);
|
|
|
|
targetOrder.setPlaceNum(targetOrder.getPlaceNum() + 1);
|
|
|
|
//下单次数+1
|
|
|
|
//下单次数+1
|
|
|
|
OrderInfo updateTargetOrder = new OrderInfo();
|
|
|
|
OrderInfo updateTargetOrder = new OrderInfo();
|
|
|
|
updateTargetOrder.setId(targetOrder.getId());
|
|
|
|
|
|
|
|
updateTargetOrder.setPlaceNum(targetOrder.getPlaceNum() + 1);
|
|
|
|
updateTargetOrder.setPlaceNum(targetOrder.getPlaceNum() + 1);
|
|
|
|
orderInfoService.updateById(updateTargetOrder);
|
|
|
|
orderInfoService.update(updateTargetOrder, new QueryWrapper().eq(OrderInfo::getId, targetOrder.getId()));
|
|
|
|
}
|
|
|
|
|
|
|
|
OrderDetail orderDetailUp = new OrderDetail();
|
|
|
|
OrderDetail orderDetailUp = new OrderDetail();
|
|
|
|
orderDetailUp.setOrderId(targetOrder.getId());
|
|
|
|
orderDetailUp.setOrderId(targetOrder.getId());
|
|
|
|
orderDetailUp.setPlaceNum(targetOrder.getPlaceNum());
|
|
|
|
orderDetailUp.setPlaceNum(targetOrder.getPlaceNum());
|
|
|
|
@@ -600,7 +617,11 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|
|
|
new QueryWrapper().eq(OrderDetail::getOrderId, sourceOrder.getId()).in(OrderDetail::getId, param.getDetailIds()));
|
|
|
|
new QueryWrapper().eq(OrderDetail::getOrderId, sourceOrder.getId()).in(OrderDetail::getId, param.getDetailIds()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(param.getAllMerge()==1){
|
|
|
|
if(param.getAllMerge()==1){
|
|
|
|
shopTableService.updateStatus(sourceOrder.getShopId(), null, sourceOrder.getTableCode(), ShopTableStatusEnum.IDLE.getValue());
|
|
|
|
orderInfoService.remove(new QueryWrapper().eq(OrderInfo::getId, sourceOrder.getId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(param.getAllMerge()==1){
|
|
|
|
|
|
|
|
shopTableService.updateStatus(sourceOrder.getShopId(), null, sourceTableCode, ShopTableStatusEnum.IDLE.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
shopTableService.updateStatus(sourceOrder.getShopId(), null, targetOrder.getTableCode(), ShopTableStatusEnum.UNSETTLED.getValue());
|
|
|
|
shopTableService.updateStatus(sourceOrder.getShopId(), null, targetOrder.getTableCode(), ShopTableStatusEnum.UNSETTLED.getValue());
|
|
|
|
return CzgResult.success();
|
|
|
|
return CzgResult.success();
|
|
|
|
@@ -1330,6 +1351,10 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public void expired(Long orderId) {
|
|
|
|
public void expired(Long orderId) {
|
|
|
|
OrderInfo orderInfo = orderInfoService.getById(orderId);
|
|
|
|
OrderInfo orderInfo = orderInfoService.getById(orderId);
|
|
|
|
|
|
|
|
if(orderInfo == null){
|
|
|
|
|
|
|
|
log.info("订单取消失败,订单Id:{} 为空", orderId);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
|
|
|
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
|
|
|
orderInfoService.updateById(new OrderInfo().setId(orderId).setStatus(OrderStatusEnums.CANCELLED.getCode()));
|
|
|
|
orderInfoService.updateById(new OrderInfo().setId(orderId).setStatus(OrderStatusEnums.CANCELLED.getCode()));
|
|
|
|
if (StrUtil.isNotBlank(orderInfo.getTableCode())) {
|
|
|
|
if (StrUtil.isNotBlank(orderInfo.getTableCode())) {
|
|
|
|
|