|
@@ -92,7 +92,7 @@ public class OrderRefundController {
|
|
|
public ResponseEntity<Boolean> getIsDistribution( String orderNumber){
|
|
|
Order order = orderService.getOrderByOrderNumber(orderNumber);
|
|
|
if(ObjectUtil.isEmpty(order)){
|
|
|
- throw new YamiShopBindException("订单编号不存在,订单编号是否正确");
|
|
|
+ throw new GlobalException("订单编号不存在,订单编号是否正确");
|
|
|
}
|
|
|
// 已支付订单取消订单,已付款后需要相应处理物流状态
|
|
|
OrderDetailRequest orderDetailRequest = new OrderDetailRequest();
|
|
@@ -118,20 +118,20 @@ public class OrderRefundController {
|
|
|
Order order = orderService.getOrderByOrderNumberAndUserId(orderRefundParam.getOrderNumber(), userId, true);
|
|
|
|
|
|
if (!Objects.equals(order.getIsPayed(), 1)) {
|
|
|
- throw new YamiShopBindException("当前订单还未付款,无法申请");
|
|
|
+ throw new GlobalException("当前订单还未付款,无法申请");
|
|
|
}
|
|
|
|
|
|
if (Objects.equals(order.getStatus(), OrderStatus.CLOSE.value())) {
|
|
|
- throw new YamiShopBindException("当前订单已失败,不允许退款");
|
|
|
+ throw new GlobalException("当前订单已失败,不允许退款");
|
|
|
}
|
|
|
|
|
|
if (Objects.equals(order.getStatus(), OrderStatus.WAIT_GROUP.value())) {
|
|
|
- throw new YamiShopBindException("当前订单正在等待成团状态,需等待成团才能进行下一步操作");
|
|
|
+ throw new GlobalException("当前订单正在等待成团状态,需等待成团才能进行下一步操作");
|
|
|
}
|
|
|
|
|
|
|
|
|
// if (!Objects.equals(orderRefundParam.getRefundType(),RefundType.ALL.value()) && Objects.equals(order.getStatus(),OrderStatus.PADYED.value())) {
|
|
|
-// throw new YamiShopBindException("未发货订单仅支持整单退款");
|
|
|
+// throw new GlobalException("未发货订单仅支持整单退款");
|
|
|
// }
|
|
|
// // 代发货整单退款不可以输入金额,为固定全额退款
|
|
|
// if (Objects.equals(orderRefundParam.getRefundType(),RefundType.ALL.value()) && Objects.equals(order.getStatus(),OrderStatus.PADYED.value())) {
|
|
@@ -139,25 +139,25 @@ public class OrderRefundController {
|
|
|
// }
|
|
|
|
|
|
if (orderRefundParam.getRefundAmount() > (order.getActualTotal())) {
|
|
|
- throw new YamiShopBindException("退款金额已超出订单金额,无法申请");
|
|
|
+ throw new GlobalException("退款金额已超出订单金额,无法申请");
|
|
|
}
|
|
|
|
|
|
//待收货 -> 整单退款 -> 退款金额 < 订单金额 - 运费金额 当前配送费为提前支付,退款时直接进行退款
|
|
|
// if (Objects.equals(order.getStatus(), OrderStatus.CONSIGNMENT.value()) && orderRefundParam.getRefundType().equals(RefundType.ALL.value())) {
|
|
|
// Double refundAmount = Arith.sub(order.getActualTotal(), order.getFreightAmount());
|
|
|
// if (orderRefundParam.getRefundAmount() > refundAmount) {
|
|
|
-// throw new YamiShopBindException("退款金额已超出订单金额,无法申请");
|
|
|
+// throw new GlobalException("退款金额已超出订单金额,无法申请");
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
if (!orderRefundService.checkRefundDate(order)) {
|
|
|
- throw new YamiShopBindException("当前订单已确认收货超过" + Constant.MAX_FINALLY_REFUND_TIME + "天,无法退款");
|
|
|
+ throw new GlobalException("当前订单已确认收货超过" + Constant.MAX_FINALLY_REFUND_TIME + "天,无法退款");
|
|
|
}
|
|
|
if (Objects.equals(order.getOrderType(), Constant.ORDER_TYPE_SCORE)) {
|
|
|
- throw new YamiShopBindException("积分商品,无法退款");
|
|
|
+ throw new GlobalException("积分商品,无法退款");
|
|
|
}
|
|
|
if (Objects.equals(orderRefundParam.getRefundType(), RefundType.ALL.value()) && (!Objects.isNull(order.getRefundStatus()) && !Objects.equals(order.getRefundStatus(), RefundStatusEnum.DISAGREE.value()))) {
|
|
|
- throw new YamiShopBindException("该订单已有商品正在退款中,不能再进行整单退款");
|
|
|
+ throw new GlobalException("该订单已有商品正在退款中,不能再进行整单退款");
|
|
|
}
|
|
|
|
|
|
// 已支付订单取消订单,已付款后需要相应处理物流状态
|
|
@@ -168,7 +168,7 @@ public class OrderRefundController {
|
|
|
OrderStatusResponse orderStatusResponse = paoTuiApi.deliveryRoute(orderDetailRequest);
|
|
|
if (ObjectUtil.isNotEmpty(orderStatusResponse.getInfo()) && orderStatusResponse.getInfo().size()>0){
|
|
|
if(orderStatusResponse.getInfo().get(0).getStatus()==40){
|
|
|
- throw new YamiShopBindException("正在配送中,无法取消");
|
|
|
+ throw new GlobalException("正在配送中,无法取消");
|
|
|
}else if(orderStatusResponse.getInfo().get(0).getStatus()<40){
|
|
|
// //先取消配送订单
|
|
|
CancelOrderRequest cancelOrderRequest = new CancelOrderRequest();
|
|
@@ -188,10 +188,10 @@ public class OrderRefundController {
|
|
|
|
|
|
for (OrderRefund orderRefund : orderRefunds) {
|
|
|
if (Objects.equals(RefundType.ALL.value(), orderRefund.getRefundType())) {
|
|
|
- throw new YamiShopBindException("该订单正在进行整单退款,无法进行新的退款操作");
|
|
|
+ throw new GlobalException("该订单正在进行整单退款,无法进行新的退款操作");
|
|
|
}
|
|
|
if (Objects.equals(orderRefund.getOrderItemId(), orderRefundParam.getOrderItemId())) {
|
|
|
- throw new YamiShopBindException("该商品正在进行退款中,无法进行新的退款操作");
|
|
|
+ throw new GlobalException("该商品正在进行退款中,无法进行新的退款操作");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -210,7 +210,7 @@ public class OrderRefundController {
|
|
|
.eq(OrderItem::getOrderItemId, orderRefundParam.getOrderItemId())
|
|
|
.eq(OrderItem::getOrderNumber, orderRefundParam.getOrderNumber()));
|
|
|
if (orderItem == null) {
|
|
|
- throw new YamiShopBindException("该物品在订单中不存在");
|
|
|
+ throw new GlobalException("该物品在订单中不存在");
|
|
|
}
|
|
|
boolean isCanRefund = false;
|
|
|
// 查看是否有支付金额和积分都为空的订单,有则抛出异常
|
|
@@ -221,11 +221,11 @@ public class OrderRefundController {
|
|
|
}
|
|
|
}
|
|
|
if (isCanRefund) {
|
|
|
- throw new YamiShopBindException("该订单部分订单项支付金额和积分为0,无法使用部分退款!");
|
|
|
+ throw new GlobalException("该订单部分订单项支付金额和积分为0,无法使用部分退款!");
|
|
|
}
|
|
|
|
|
|
if (order.getPlatformAmount() > 0 && !Arith.isEquals(orderRefundParam.getRefundAmount(), orderItem.getActualTotal())) {
|
|
|
- throw new YamiShopBindException("该订单有使用平台优惠,无法使用部分退款!");
|
|
|
+ throw new GlobalException("该订单有使用平台优惠,无法使用部分退款!");
|
|
|
}
|
|
|
// 计算该订单项的分销金额
|
|
|
newOrderRefund.setDistributionTotalAmount(orderService.sumTotalDistributionAmountByOrderItem(Collections.singletonList(orderItem)));
|
|
@@ -241,20 +241,20 @@ public class OrderRefundController {
|
|
|
|
|
|
// 判断退款数量是否溢出
|
|
|
if (orderRefundParam.getGoodsNum() > orderItem.getProdCount()) {
|
|
|
- throw new YamiShopBindException("退款物品数量已超出订单中的数量,不允许申请");
|
|
|
+ throw new GlobalException("退款物品数量已超出订单中的数量,不允许申请");
|
|
|
}
|
|
|
|
|
|
// 判断退款金额是否超出订单金额
|
|
|
double refundSingleAmount = Arith.div(orderRefundParam.getRefundAmount(), orderRefundParam.getGoodsNum(), 3);
|
|
|
double singleAmount = Arith.div(orderItem.getActualTotal(), orderItem.getProdCount(), 3);
|
|
|
if (refundSingleAmount > orderItem.getProductTotalAmount() || refundSingleAmount > singleAmount) {
|
|
|
- throw new YamiShopBindException("退款金额已超出订单金额,无法申请");
|
|
|
+ throw new GlobalException("退款金额已超出订单金额,无法申请");
|
|
|
}
|
|
|
|
|
|
// 一个订单项只能申请一次退款
|
|
|
for (OrderRefund orderRefund : orderRefunds) {
|
|
|
if (Objects.equals(orderRefund.getOrderId(), orderItem.getOrderItemId())) {
|
|
|
- throw new YamiShopBindException("退款订单项已处理,请勿重复申请");
|
|
|
+ throw new GlobalException("退款订单项已处理,请勿重复申请");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -343,27 +343,27 @@ public class OrderRefundController {
|
|
|
public ResponseEntity<String> submitExpress(@PathVariable("refundSn") String refundSn) {
|
|
|
OrderRefund orderRefund = orderRefundService.getOrderRefundByRefundSn(refundSn);
|
|
|
if (Objects.isNull(orderRefund)) {
|
|
|
- throw new YamiShopBindException("查询不到退款信息");
|
|
|
+ throw new GlobalException("查询不到退款信息");
|
|
|
}
|
|
|
|
|
|
String userId = SecurityUtils.getUser().getUserId();
|
|
|
if (!Objects.equals(orderRefund.getUserId(), userId)) {
|
|
|
- throw new YamiShopBindException("申请失败,您没有该权限");
|
|
|
+ throw new GlobalException("申请失败,您没有该权限");
|
|
|
}
|
|
|
|
|
|
if (!Objects.equals(orderRefund.getApplyType(), 2)) {
|
|
|
- throw new YamiShopBindException("当前申请类型不允许提交物流信息操作");
|
|
|
+ throw new GlobalException("当前申请类型不允许提交物流信息操作");
|
|
|
}
|
|
|
|
|
|
if (!Objects.equals(orderRefund.getReturnMoneySts(), ReturnMoneyStsType.PROCESSING.value())) {
|
|
|
- throw new YamiShopBindException("当前状态不允许提交物流信息操作");
|
|
|
+ throw new GlobalException("当前状态不允许提交物流信息操作");
|
|
|
}
|
|
|
|
|
|
RefundDelivery refundDelivery = refundDeliveryService.getOne(new LambdaQueryWrapper<RefundDelivery>()
|
|
|
.eq(RefundDelivery::getRefundSn, refundSn));
|
|
|
|
|
|
if (refundDelivery.getPayer().equals("2") && !refundDelivery.isPay()) {
|
|
|
- throw new YamiShopBindException("未支付退货费用");
|
|
|
+ throw new GlobalException("未支付退货费用");
|
|
|
}
|
|
|
Order order = orderService.getById(orderRefund.getOrderId());
|
|
|
UserAddr userAddrOrder = userAddrService.getUserAddrByUserId(order.getAddrOrderId(), userId);
|
|
@@ -439,15 +439,15 @@ public class OrderRefundController {
|
|
|
String userId = SecurityUtils.getUser().getUserId();
|
|
|
OrderRefund orderRefund = orderRefundService.getOrderRefundByRefundSn(orderRefundExpressParam.getRefundSn());
|
|
|
if (Objects.isNull(orderRefund)) {
|
|
|
- throw new YamiShopBindException("查询不到退款信息");
|
|
|
+ throw new GlobalException("查询不到退款信息");
|
|
|
}
|
|
|
|
|
|
if (!Objects.equals(orderRefund.getUserId(), userId)) {
|
|
|
- throw new YamiShopBindException("申请失败,您没有此权限");
|
|
|
+ throw new GlobalException("申请失败,您没有此权限");
|
|
|
}
|
|
|
|
|
|
if (!Objects.equals(orderRefund.getReturnMoneySts(), ReturnMoneyStsType.CONSIGNMENT.value())) {
|
|
|
- throw new YamiShopBindException("当前状态不允许更新物流信息操作");
|
|
|
+ throw new GlobalException("当前状态不允许更新物流信息操作");
|
|
|
}
|
|
|
|
|
|
// 填写物流信息
|
|
@@ -476,19 +476,19 @@ public class OrderRefundController {
|
|
|
public ResponseEntity<String> cancel(@RequestBody String refundSn) {
|
|
|
OrderRefundDto orderRefund = orderRefundService.getOrderRefundByRefundSn(refundSn);
|
|
|
if (Objects.isNull(orderRefund)) {
|
|
|
- throw new YamiShopBindException("撤销失败 退款订单不存在");
|
|
|
+ throw new GlobalException("撤销失败 退款订单不存在");
|
|
|
}
|
|
|
if (Objects.equals(orderRefund.getReturnMoneySts(), ReturnMoneyStsType.PROCESSING.value())) {
|
|
|
- throw new YamiShopBindException("卖家正在处理退款,不能撤销退款申请");
|
|
|
+ throw new GlobalException("卖家正在处理退款,不能撤销退款申请");
|
|
|
}
|
|
|
if (Objects.equals(orderRefund.getReturnMoneySts(), ReturnMoneyStsType.CONSIGNMENT.value())) {
|
|
|
- throw new YamiShopBindException("买家已发货,不能撤销退款申请");
|
|
|
+ throw new GlobalException("买家已发货,不能撤销退款申请");
|
|
|
}
|
|
|
if (Objects.equals(orderRefund.getReturnMoneySts(), ReturnMoneyStsType.RECEIVE.value())) {
|
|
|
- throw new YamiShopBindException("卖家已收货,不能撤销退款申请");
|
|
|
+ throw new GlobalException("卖家已收货,不能撤销退款申请");
|
|
|
}
|
|
|
if (Objects.equals(orderRefund.getReturnMoneySts(), ReturnMoneyStsType.SUCCESS.value())) {
|
|
|
- throw new YamiShopBindException("退款成功,不能撤销退款申请");
|
|
|
+ throw new GlobalException("退款成功,不能撤销退款申请");
|
|
|
}
|
|
|
String userId = SecurityUtils.getUser().getUserId();
|
|
|
|
|
@@ -506,7 +506,7 @@ public class OrderRefundController {
|
|
|
// 订单项数量
|
|
|
int orderItemCount = orderItemService.count(new LambdaQueryWrapper<OrderItem>().eq(OrderItem::getOrderNumber, order.getOrderNumber()));
|
|
|
if (refundCount == orderItemCount) {
|
|
|
- throw new YamiShopBindException("该订单所有商品都进行退款,已无法取消退款");
|
|
|
+ throw new GlobalException("该订单所有商品都进行退款,已无法取消退款");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -514,7 +514,7 @@ public class OrderRefundController {
|
|
|
Objects.equals(orderRefund.getReturnMoneySts(), ReturnMoneyStsType.FAIL.value()) ||
|
|
|
Objects.equals(orderRefund.getReturnMoneySts(), ReturnMoneyStsType.REJECT.value()) ||
|
|
|
Objects.equals(orderRefund.getReturnMoneySts(), ReturnMoneyStsType.CANCEL.value())) {
|
|
|
- throw new YamiShopBindException("撤销失败 当前状态不允许此操作");
|
|
|
+ throw new GlobalException("撤销失败 当前状态不允许此操作");
|
|
|
}
|
|
|
|
|
|
Date now = new Date();
|
|
@@ -550,11 +550,11 @@ public class OrderRefundController {
|
|
|
OrderRefundDto orderRefundDto = orderRefundService.getOrderRefundByRefundSn(refundSn);
|
|
|
|
|
|
if (orderRefundDto == null) {
|
|
|
- throw new YamiShopBindException("查看失败 该退款订单不存在");
|
|
|
+ throw new GlobalException("查看失败 该退款订单不存在");
|
|
|
}
|
|
|
|
|
|
if (!Objects.equals(orderRefundDto.getUserId(), SecurityUtils.getUser().getUserId())) {
|
|
|
- throw new YamiShopBindException("查看失败 您没有此权限");
|
|
|
+ throw new GlobalException("查看失败 您没有此权限");
|
|
|
}
|
|
|
|
|
|
ApiOrderRefundDto apiOrderRefundDto = mapperFacade.map(orderRefundDto, ApiOrderRefundDto.class);
|