Commit 163c6c25 authored by 李灿灿's avatar 李灿灿

订单唯一性校验

parent 93f0abb8
......@@ -38,6 +38,14 @@ public class OrderConstants {
* 订单编号不能为空
*/
public static final String ORDER_NO_IS_EMPTY = "订单编号不能为空";
/**
* 订单不存在
*/
public static final String ORDER_NO_NOT_EXIST = "订单不存在";
/**
* 订单已存在
*/
public static final String ORDER_NO_IS_EXIST = "订单已存在";
/**
* 下单人不能为空
*/
......
......@@ -191,6 +191,14 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
if (Common.isEmpty(orderNo)){
return R.failed(OrderConstants.ORDER_NO_IS_EMPTY);
}
TOrder one = this.getOne(Wrappers.<TOrder>query().lambda()
.eq(TOrder::getOrderNo, orderNo)
.eq(TOrder::getDeleteFlag,CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(one).isPresent()){
return R.failed(OrderConstants.ORDER_NO_NOT_EXIST);
}
if (Common.isEmpty(replyContent) && ArrayUtils.isEmpty(file)){
return R.failed(OrderConstants.REPLY_CONTENT_AND_ENCLOSURE_IS_EMPTY);
}
......@@ -299,6 +307,14 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
if (Common.isEmpty(vo.getOrderNo())){
return R.failed(OrderConstants.ORDER_NO_IS_EMPTY);
}
TOrder one = this.getOne(Wrappers.<TOrder>query().lambda()
.eq(TOrder::getOrderNo, vo.getOrderNo())
.eq(TOrder::getDeleteFlag,CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (Optional.ofNullable(one).isPresent()){
return R.failed(OrderConstants.ORDER_NO_IS_EXIST);
}
if (Common.isEmpty(vo.getCreateName())){
return R.failed(OrderConstants.ORDER_NAME_IS_EMPTY);
}
......@@ -383,6 +399,14 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
if (Common.isEmpty(vo.getOrderNo())){
return R.failed(OrderConstants.ORDER_NO_IS_EMPTY);
}
TOrder one = this.getOne(Wrappers.<TOrder>query().lambda()
.eq(TOrder::getOrderNo, vo.getOrderNo())
.eq(TOrder::getDeleteFlag,CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(one).isPresent()){
return R.failed(OrderConstants.ORDER_NO_NOT_EXIST);
}
if (Common.isEmpty(vo.getCreateName())){
return R.failed(OrderConstants.REPLY_NAME_IS_EMPTY);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment