Commit 836c1a6545040769ae433218ee841fff9b67b679
1 parent
0ca5cd93
update:取消时重新实现。
Showing
3 changed files
with
12 additions
and
11 deletions
etrade-order/src/main/java/com/diligrp/etrade/order/api/OrderController.java
@@ -556,11 +556,10 @@ public class OrderController { | @@ -556,11 +556,10 @@ public class OrderController { | ||
556 | RLock lock = redissonClient.getLock(OrderConstant.OrderLock + orderOperateDto.getCode()); | 556 | RLock lock = redissonClient.getLock(OrderConstant.OrderLock + orderOperateDto.getCode()); |
557 | try{ | 557 | try{ |
558 | lock.lock(); | 558 | lock.lock(); |
559 | - orderService.cancelOrder(orderOperateDto, OrderOrderState.BUYER_CANCEL); | 559 | + return orderService.cancelOrder(orderOperateDto, OrderOrderState.BUYER_CANCEL); |
560 | }finally { | 560 | }finally { |
561 | lock.unlock(); | 561 | lock.unlock(); |
562 | } | 562 | } |
563 | - return Message.success(); | ||
564 | } | 563 | } |
565 | 564 | ||
566 | /** | 565 | /** |
@@ -579,11 +578,10 @@ public class OrderController { | @@ -579,11 +578,10 @@ public class OrderController { | ||
579 | RLock lock = redissonClient.getLock(OrderConstant.OrderLock + orderOperateDto.getCode()); | 578 | RLock lock = redissonClient.getLock(OrderConstant.OrderLock + orderOperateDto.getCode()); |
580 | try{ | 579 | try{ |
581 | lock.lock(); | 580 | lock.lock(); |
582 | - orderService.cancelOrder(orderOperateDto, OrderOrderState.SELLER_CANCEL); | 581 | + return orderService.cancelOrder(orderOperateDto, OrderOrderState.SELLER_CANCEL); |
583 | }finally { | 582 | }finally { |
584 | lock.unlock(); | 583 | lock.unlock(); |
585 | } | 584 | } |
586 | - return Message.success(); | ||
587 | } | 585 | } |
588 | 586 | ||
589 | /** | 587 | /** |
etrade-order/src/main/java/com/diligrp/etrade/order/service/OrderService.java
@@ -145,7 +145,7 @@ public interface OrderService { | @@ -145,7 +145,7 @@ public interface OrderService { | ||
145 | * @param orderOperateDto | 145 | * @param orderOperateDto |
146 | * @param codeInteger | 146 | * @param codeInteger |
147 | */ | 147 | */ |
148 | - void cancelOrder(OrderOperateDto orderOperateDto, OrderOrderState codeInteger); | 148 | + Message cancelOrder(OrderOperateDto orderOperateDto, OrderOrderState codeInteger); |
149 | 149 | ||
150 | /** | 150 | /** |
151 | * 超时取消取消订单 | 151 | * 超时取消取消订单 |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderServiceImpl.java
@@ -199,34 +199,37 @@ public class OrderServiceImpl implements OrderService { | @@ -199,34 +199,37 @@ public class OrderServiceImpl implements OrderService { | ||
199 | 199 | ||
200 | @Transactional | 200 | @Transactional |
201 | @Override | 201 | @Override |
202 | - public void cancelOrder(OrderOperateDto orderOperateDto, OrderOrderState state) { | 202 | + public Message cancelOrder(OrderOperateDto orderOperateDto, OrderOrderState state) { |
203 | Order order = getOrderAndCheckState(null, orderOperateDto.getCode(), orderOperateDto.getMarketId(),state,null); | 203 | Order order = getOrderAndCheckState(null, orderOperateDto.getCode(), orderOperateDto.getMarketId(),state,null); |
204 | checkOperate(order,orderOperateDto,state); | 204 | checkOperate(order,orderOperateDto,state); |
205 | //检查是否微信支付如果是,需要额外终止微信预交款单 | 205 | //检查是否微信支付如果是,需要额外终止微信预交款单 |
206 | - if(!cancelWeChatPay(order)){ | ||
207 | - throw new OrderException(OrderErrorCode.PARAM_ERROR,"存在无法取消的微信待支付信息,请等待微信支付结果或重试"); | 206 | + Message message = cancelWeChatPay(order); |
207 | + | ||
208 | + if(!message.isSuccess()){ | ||
209 | + return message; | ||
208 | } | 210 | } |
209 | //退款优惠券 | 211 | //退款优惠券 |
210 | orderCouponService.returnCoupon(order); | 212 | orderCouponService.returnCoupon(order); |
211 | //变更订单状态 | 213 | //变更订单状态 |
212 | updateOrderByOperate(order,orderOperateDto,state.getCodeInteger(),OrderState.CANCEL.getCodeInteger()); | 214 | updateOrderByOperate(order,orderOperateDto,state.getCodeInteger(),OrderState.CANCEL.getCodeInteger()); |
215 | + return message; | ||
213 | } | 216 | } |
214 | 217 | ||
215 | @Transactional(rollbackFor = Exception.class) | 218 | @Transactional(rollbackFor = Exception.class) |
216 | - public boolean cancelWeChatPay(Order order) { | 219 | + public Message cancelWeChatPay(Order order) { |
217 | OrderPayment orderPayment = orderPaymentService.getOrderPaymentById(order.getId(), order.getMarketId(), OrderPaymentState.WAIT_PAY.getCodeInteger()); | 220 | OrderPayment orderPayment = orderPaymentService.getOrderPaymentById(order.getId(), order.getMarketId(), OrderPaymentState.WAIT_PAY.getCodeInteger()); |
218 | if(orderPayment!=null&&orderPayment.getPayChannel().equals(OrderPaymentAllChannel.BUYER_WX_CHANNEL.getCode())&&StringUtils.isNotBlank(orderPayment.getTradeId())){ | 221 | if(orderPayment!=null&&orderPayment.getPayChannel().equals(OrderPaymentAllChannel.BUYER_WX_CHANNEL.getCode())&&StringUtils.isNotBlank(orderPayment.getTradeId())){ |
219 | RLock lock = redissonClient.getLock(OrderConstant.OrderLock + orderPayment.getTradeId()); | 222 | RLock lock = redissonClient.getLock(OrderConstant.OrderLock + orderPayment.getTradeId()); |
220 | try{ | 223 | try{ |
221 | lock.lock(); | 224 | lock.lock(); |
222 | if(StringUtils.isNotBlank(orderPayment.getTradeId())){ | 225 | if(StringUtils.isNotBlank(orderPayment.getTradeId())){ |
223 | - this.wxChatPayCloseUnLock(orderPayment.getTradeId(),order.getMarketId()); | 226 | + return this.wxChatPayCloseUnLock(orderPayment.getTradeId(),order.getMarketId()); |
224 | } | 227 | } |
225 | }finally{ | 228 | }finally{ |
226 | lock.unlock(); | 229 | lock.unlock(); |
227 | } | 230 | } |
228 | } | 231 | } |
229 | - return true; | 232 | + return Message.success(); |
230 | } | 233 | } |
231 | 234 | ||
232 | private void checkOperate(Order order, OrderOperateDto orderOperateDto, OrderOrderState state) { | 235 | private void checkOperate(Order order, OrderOperateDto orderOperateDto, OrderOrderState state) { |