This commit is contained in:
cjw 2024-10-15 15:47:17 +08:00
parent b5caf5fb15
commit 81bc8da7b9
1 changed files with 10 additions and 5 deletions

View File

@ -42,7 +42,7 @@ public class ReservationRefundServiceImpl implements IReservationRefundService {
* @return 预约退款
*/
@Override
public ReservationRefundVo queryById(Long id){
public ReservationRefundVo queryById(Long id) {
return baseMapper.selectVoById(id);
}
@ -111,28 +111,33 @@ public class ReservationRefundServiceImpl implements IReservationRefundService {
@Override
public Boolean updateByBo(ReservationRefundBo bo) {
ReservationRefund update = MapstructUtils.convert(bo, ReservationRefund.class);
validEntityBeforeSave(update);
//validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(ReservationRefund entity){
private void validEntityBeforeSave(ReservationRefund entity) {
Long orderId = entity.getOrderId();
Long userId = entity.getUserId();
ReservationOrder order = orderMapper.selectById(orderId);
if(order == null){
if (order == null) {
throw new ServiceException("查无订单,请确认后重试");
}
Long createBy = order.getCreateBy();
if(!createBy.equals(userId)){
if (!createBy.equals(userId)) {
throw new ServiceException("订单数据异常,请确认后重试");
}
Integer orderStatus = order.getOrderStatus();
if (orderStatus != 1) {
throw new ServiceException("订单数据异常,请确认后重试");
}
boolean exists = baseMapper.exists(new LambdaQueryWrapper<ReservationRefund>()
.eq(ReservationRefund::getOrderId, orderId));
if (exists) {
throw new ServiceException("此订单已提交退款申请,请勿重复提交");
}
}
}