feat: 新增等叫接口

This commit is contained in:
张松
2024-11-28 15:23:19 +08:00
parent 7693850127
commit f82b521b00
8 changed files with 122 additions and 4 deletions

View File

@@ -206,6 +206,11 @@ public class TbPlaceController {
return ResponseEntity.ok(tbShopTableService.pay(payDTO));
}
@PutMapping("/waitCall")
public ResponseEntity<?> waitCall(@Valid @RequestBody WaitCallDTO waitCallDTO) {
return ResponseEntity.ok(tbShopTableService.waitCall(waitCallDTO));
}
@PostMapping("/returnOrder")
public ResponseEntity<?> returnOrder(@RequestBody ReturnOrderDTO returnOrderDTO) {
return ResponseEntity.ok(tbShopTableService.returnOrder(returnOrderDTO));

View File

@@ -0,0 +1,20 @@
package cn.ysk.cashier.dto.shoptable;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
public class WaitCallDTO {
@NotNull
private Integer shopId;
@NotNull
private Integer isWaitCall;
private Integer orderId;
@NotBlank
private String masterId;
@NotBlank
private String useType;
private String tableId;
}

View File

@@ -4,8 +4,10 @@ import cn.ysk.cashier.cons.TableConstant;
import cn.ysk.cashier.dto.shoptable.ShopEatTypeInfoDTO;
import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.ArrayList;
import java.util.List;
/**
@@ -66,6 +68,9 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
*/
List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, TableConstant.OrderInfo.Status... statuses);
List<TbCashierCart> selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, TableConstant.OrderInfo.Status... statuses);
/**
* 根据订单id和状态获取购物车数据
* @param orderId 订单id
@@ -99,5 +104,7 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
* @param statuses 状态
*/
List<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, TableConstant.OrderInfo.Status... statuses);
boolean updateFieldValByIds(Integer shopId, ArrayList<Integer> cartIds, SFunction<TbCashierCart, ?> column, Object val);
}

View File

@@ -4,6 +4,7 @@ import cn.ysk.cashier.cons.TableConstant;
import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.pojo.order.TbOrderDetail;
import cn.ysk.cashier.pojo.order.TbOrderInfo;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.IService;
import java.math.BigDecimal;
@@ -42,5 +43,10 @@ public interface MpOrderInfoService extends IService<TbOrderInfo> {
TbOrderInfo selectOrderByIdAndState(Integer orderId, TableConstant.OrderInfo.Status status);
boolean incrAmount(Integer orderId, BigDecimal subtract);
boolean updateFieldVal(Integer shopId, Integer orderId, SFunction<TbOrderInfo, ?> column, Object val);
}

View File

@@ -17,6 +17,7 @@ import cn.ysk.cashier.pojo.shop.TbShopInfo;
import cn.ysk.cashier.pojo.shop.TbShopTable;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@@ -118,7 +119,7 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
if (statuses.length == 0) {
queryWrapper.in(TbCashierCart::getStatus, "create", "return");
}else {
} else {
queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
}
@@ -137,6 +138,40 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
return list(queryWrapper);
}
@Override
public List<TbCashierCart> selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, TableConstant.OrderInfo.Status... statuses) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId())
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
.and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId));
if (statuses.length == 0) {
queryWrapper.in(TbCashierCart::getStatus, "create", "return");
} else {
queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
}
if (orderId != null) {
queryWrapper.and(q -> q.eq(TbCashierCart::getOrderId, orderId)
.or().isNull(TbCashierCart::getOrderId));
}
// 非堂食校验台桌状态
if (shopEatTypeInfoDTO.isTakeout()) {
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
} else {
if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) {
queryWrapper.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId());
} else {
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""));
}
}
return list(queryWrapper);
}
@Override
public List<TbCashierCart> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status... status) {
LambdaQueryChainWrapper<TbCashierCart> queryChainWrapper = lambdaQuery().eq(TbCashierCart::getOrderId, orderId);
@@ -158,7 +193,7 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
.and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId));
if (isTemp) {
query.isNull(TbCashierCart::getProductId).isNull(TbCashierCart::getSkuId).eq(TbCashierCart::getIsTemporary, 1);
}else {
} else {
query.eq(TbCashierCart::getProductId, productId)
.eq(TbCashierCart::getSkuId, skuId);
}
@@ -196,5 +231,13 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
}
return list(queryWrapper);
}
@Override
public boolean updateFieldValByIds(Integer shopId, ArrayList<Integer> cartIds, SFunction<TbCashierCart, ?> column, Object val) {
return update(new LambdaUpdateWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.in(TbCashierCart::getId, cartIds)
.set(column, val));
}
}

View File

@@ -10,6 +10,7 @@ import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.pojo.order.TbOrderInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@@ -56,5 +57,13 @@ public class MpOrderInfoServiceImpl extends ServiceImpl<TbOrderInfoMapper, TbOrd
.setSql(StrUtil.format("origin_amount=origin_amount+{}", subtract))
);
}
@Override
public boolean updateFieldVal(Integer shopId, Integer orderId, SFunction<TbOrderInfo, ?> column, Object val) {
return update(new LambdaUpdateWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getShopId, shopId)
.eq(TbOrderInfo::getId, orderId)
.set(column, val));
}
}

View File

@@ -595,7 +595,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() != null ? 1 : 0);
tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1);
tbCashierCart.setMemberPrice(productSku.getMemberPrice());
cashierCartRepository.save(tbCashierCart);
mpCashierCartService.save(tbCashierCart);
} else {
tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1);
@@ -1569,7 +1569,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
});
for (TbCashierCart cashierCart : fullCashierCarts) {
cashierCart.setIsWaitCall(isWaitCall);
if (isWaitCall != null) {
cashierCart.setIsWaitCall(isWaitCall);
}
if (orderInfo != null && shopEatTypeInfoDTO != null) {
cashierCart.setIsMember(StrUtil.isBlank(orderInfo.getMemberId()) ? 0 : shopEatTypeInfoDTO.isMemberPrice() ? 1 : 0);
}
@@ -3235,4 +3237,28 @@ public class TbShopTableServiceImpl implements TbShopTableService {
thirdPartyCouponRecordService.save(record);
return true;
}
@Override
public Object waitCall(WaitCallDTO waitCallDTO) {
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(waitCallDTO.getShopId(), waitCallDTO.getTableId(), waitCallDTO.getUseType());
List<TbCashierCart> cashierCarts = mpCashierCartService.selectByShopEatTypeAndOrderId(shopEatTypeInfoDTO,
waitCallDTO.getMasterId(), waitCallDTO.getOrderId(), TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN, TableConstant.OrderInfo.Status.CLOSED);
if (cashierCarts.isEmpty()) {
throw new BadRequestException("购物车为空");
}
ArrayList<Integer> cartIds = new ArrayList<>();
cashierCarts.forEach(item -> {
if (waitCallDTO.getOrderId() != null && item.getOrderId() != null && !item.getOrderId().equals(waitCallDTO.getOrderId())) {
throw new BadRequestException("订单id有误");
}
cartIds.add(item.getId());
});
if (waitCallDTO.getOrderId() != null) {
mpOrderInfoService.updateFieldVal(waitCallDTO.getShopId(), waitCallDTO.getOrderId(), TbOrderInfo::getIsWaitCall, waitCallDTO.getIsWaitCall());
}
mpCashierCartService.updateFieldValByIds(waitCallDTO.getShopId(), cartIds, TbCashierCart::getIsWaitCall, waitCallDTO.getIsWaitCall());
return mpOrderDetailService.updateFieldByCartId(TbOrderDetail::getIsWaitCall, waitCallDTO.getIsWaitCall(), cartIds);
}
}

View File

@@ -167,4 +167,6 @@ public interface TbShopTableService {
* 团购券核销
*/
Object checkCoupon(ThirdCouponCheckDTO checkDTO);
Object waitCall(WaitCallDTO waitCallDTO);
}