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 | 556 | RLock lock = redissonClient.getLock(OrderConstant.OrderLock + orderOperateDto.getCode()); |
557 | 557 | try{ |
558 | 558 | lock.lock(); |
559 | - orderService.cancelOrder(orderOperateDto, OrderOrderState.BUYER_CANCEL); | |
559 | + return orderService.cancelOrder(orderOperateDto, OrderOrderState.BUYER_CANCEL); | |
560 | 560 | }finally { |
561 | 561 | lock.unlock(); |
562 | 562 | } |
563 | - return Message.success(); | |
564 | 563 | } |
565 | 564 | |
566 | 565 | /** |
... | ... | @@ -579,11 +578,10 @@ public class OrderController { |
579 | 578 | RLock lock = redissonClient.getLock(OrderConstant.OrderLock + orderOperateDto.getCode()); |
580 | 579 | try{ |
581 | 580 | lock.lock(); |
582 | - orderService.cancelOrder(orderOperateDto, OrderOrderState.SELLER_CANCEL); | |
581 | + return orderService.cancelOrder(orderOperateDto, OrderOrderState.SELLER_CANCEL); | |
583 | 582 | }finally { |
584 | 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 | 145 | * @param orderOperateDto |
146 | 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 | 199 | |
200 | 200 | @Transactional |
201 | 201 | @Override |
202 | - public void cancelOrder(OrderOperateDto orderOperateDto, OrderOrderState state) { | |
202 | + public Message cancelOrder(OrderOperateDto orderOperateDto, OrderOrderState state) { | |
203 | 203 | Order order = getOrderAndCheckState(null, orderOperateDto.getCode(), orderOperateDto.getMarketId(),state,null); |
204 | 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 | 212 | orderCouponService.returnCoupon(order); |
211 | 213 | //变更订单状态 |
212 | 214 | updateOrderByOperate(order,orderOperateDto,state.getCodeInteger(),OrderState.CANCEL.getCodeInteger()); |
215 | + return message; | |
213 | 216 | } |
214 | 217 | |
215 | 218 | @Transactional(rollbackFor = Exception.class) |
216 | - public boolean cancelWeChatPay(Order order) { | |
219 | + public Message cancelWeChatPay(Order order) { | |
217 | 220 | OrderPayment orderPayment = orderPaymentService.getOrderPaymentById(order.getId(), order.getMarketId(), OrderPaymentState.WAIT_PAY.getCodeInteger()); |
218 | 221 | if(orderPayment!=null&&orderPayment.getPayChannel().equals(OrderPaymentAllChannel.BUYER_WX_CHANNEL.getCode())&&StringUtils.isNotBlank(orderPayment.getTradeId())){ |
219 | 222 | RLock lock = redissonClient.getLock(OrderConstant.OrderLock + orderPayment.getTradeId()); |
220 | 223 | try{ |
221 | 224 | lock.lock(); |
222 | 225 | if(StringUtils.isNotBlank(orderPayment.getTradeId())){ |
223 | - this.wxChatPayCloseUnLock(orderPayment.getTradeId(),order.getMarketId()); | |
226 | + return this.wxChatPayCloseUnLock(orderPayment.getTradeId(),order.getMarketId()); | |
224 | 227 | } |
225 | 228 | }finally{ |
226 | 229 | lock.unlock(); |
227 | 230 | } |
228 | 231 | } |
229 | - return true; | |
232 | + return Message.success(); | |
230 | 233 | } |
231 | 234 | |
232 | 235 | private void checkOperate(Order order, OrderOperateDto orderOperateDto, OrderOrderState state) { | ... | ... |