From 6e16e9725d3f7760a6e5a6b2a8f825c657f7dc92 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 20 May 2024 09:38:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/OrderCouponController.java | 26 +++++++++++++++++++ .../coupon/BsOrderCouponNoService.java | 2 +- .../service/order/OrderCancelService.java | 1 + .../BsOrderAfterSalesApplyServiceImpl.java | 1 - .../order/impl/BsOrderRefundServiceImpl.java | 11 +++++--- .../order/impl/BsOrderServiceImpl.java | 8 +++--- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/order/src/main/java/com/order/controller/business/OrderCouponController.java b/order/src/main/java/com/order/controller/business/OrderCouponController.java index 1b452f9..6959902 100644 --- a/order/src/main/java/com/order/controller/business/OrderCouponController.java +++ b/order/src/main/java/com/order/controller/business/OrderCouponController.java @@ -2,8 +2,13 @@ package com.order.controller.business; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsOrderCoupon; import com.hfkj.model.ResponseData; +import com.hfkj.service.coupon.BsOrderCouponNoService; import com.hfkj.service.coupon.BsOrderCouponService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -32,6 +37,27 @@ public class OrderCouponController { @Resource private BsOrderCouponService orderCouponService; + @Resource + private BsOrderCouponNoService orderCouponNoService; + + @RequestMapping(value="/queryCouNo",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询卡密") + public ResponseData queryCouNo(@RequestParam(value = "orderChildNo" , required = true) String orderChildNo) { + try { + // 卡券订单 + BsOrderCoupon orderCoupon = orderCouponService.getDetailByChildOrderNo(orderChildNo); + if (orderCoupon == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的卡券订单"); + } + + return ResponseMsgUtil.success(orderCouponNoService.getListByCouponOrderId(orderCoupon.getId())); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } @RequestMapping(value="/queryDetail",method = RequestMethod.GET) @ResponseBody diff --git a/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponNoService.java b/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponNoService.java index bbbeeaa..03c0741 100644 --- a/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponNoService.java +++ b/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponNoService.java @@ -19,7 +19,7 @@ public interface BsOrderCouponNoService { /** * 查询列表 - * @param couponOrderNo + * @param couponOrderId * @return */ List getListByCouponOrderId(Long couponOrderId); diff --git a/service/src/main/java/com/hfkj/service/order/OrderCancelService.java b/service/src/main/java/com/hfkj/service/order/OrderCancelService.java index eb6b89f..21e0857 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCancelService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCancelService.java @@ -47,6 +47,7 @@ public class OrderCancelService { * @param order * @throws Exception */ + @Transactional(propagation = Propagation.NOT_SUPPORTED, isolation = Isolation.READ_UNCOMMITTED) public void orderBusHandle(OrderModel order) { for (OrderChildModel childOrder : order.getOrderChildList()) { if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) { diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java index eb4e3c3..6f52e1e 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java @@ -201,7 +201,6 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply if (apply == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的申请"); } - // 退款 BsOrderRefund orderRefund = orderRefundService.tradeOrderChildRefund(apply.getChildOrderNo(), apply.getProductCount(), null); if (orderRefund.getRefundStatus().equals(OrderRefundStatusEnum.status2.getCode())) { diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java index a1b831c..3ae2f32 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java @@ -22,6 +22,7 @@ import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -57,6 +58,7 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { } @Override + @Transactional(propagation = Propagation.NOT_SUPPORTED, isolation = Isolation.READ_UNCOMMITTED) public boolean refundMoney(BsOrderRefund orderRefund) { try { if (OrderPayChannelEnum.type1.getCode() == orderRefund.getRefundPayChannel()) { @@ -81,7 +83,7 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { } else if (OrderPayChannelEnum.type3.getCode() ==orderRefund.getRefundPayChannel()) { // TODO 暂无该支付方式 }*/ else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!未知的支付方式"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!该支付方式暂不支持退款"); } } catch (BaseException e) { orderRefund.setRefundStatus(OrderRefundStatusEnum.status3.getCode()); @@ -125,13 +127,14 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { } @Override + @Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) public BsOrderRefund tradeOrderChildRefund(String childOrderNo, Integer productCount, String remark) { // 查询子订单 OrderChildModel orderChild = orderChildService.getDetail(childOrderNo); if (orderChild == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的子订单"); } - if (productCount > orderChild.getProductCount()) { + if (productCount > orderChild.getSurplusRefundCount()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!退货数量超过子订单可退数量"); } // 查询交易订单 @@ -179,10 +182,10 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { orderChild.setSurplusRefundCount(orderChild.getSurplusRefundCount() - productCount); orderChild.setSurplusRefundPrice(orderChild.getSurplusRefundPrice().subtract(orderRefund.getRefundPrice())); orderChild.setSurplusRefundIntegral(orderChild.getSurplusRefundIntegral() - orderRefund.getRefundIntegral()); - orderChild.setStatus(orderChild.getProductCount()==0?OrderChildStatusEnum.status4.getCode():orderChild.getStatus()); + orderChild.setStatus(orderChild.getSurplusRefundCount()==0?OrderChildStatusEnum.status4.getCode():orderChild.getStatus()); orderChildService.editData(orderChild); } - return orderRefund; + return orderRefund; } diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java index 0c59155..841228f 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java @@ -180,8 +180,7 @@ public class BsOrderServiceImpl implements BsOrderService { // 处理业务 orderPaySuccessHandle(order); } - - // 缓存 + // 更新缓存 cache(order); return order; } @@ -207,6 +206,8 @@ public class BsOrderServiceImpl implements BsOrderService { } // 取消订单业务 orderCancelService.orderBusHandle(order); + // 更新缓存 + cache(order); return order; } @@ -220,9 +221,8 @@ public class BsOrderServiceImpl implements BsOrderService { childOrder.setStatus(OrderChildStatusEnum.status2.getCode()); orderChildService.editData(childOrder); } - // 缓存 + // 更新缓存 cache(order); - // 处理业务 orderPaySuccessService.orderBusHandle(order); }