diff --git a/service/src/main/java/com/hfkj/service/order/OrderRefundSuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderRefundSuccessService.java index ecae015..35271d0 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderRefundSuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderRefundSuccessService.java @@ -7,6 +7,7 @@ import com.hfkj.service.coupon.BsOrderCouponService; import com.hfkj.service.goods.BsOrderCinemaService; import com.hfkj.service.goods.BsOrderStarbucksService; import com.hfkj.service.goods.impl.BsOrderGoodsServiceImpl; +import com.hfkj.service.goods.impl.BsOrderMeiTuanServiceImpl; import com.hfkj.sysenum.order.OrderChildProductTypeEnum; import com.hfkj.sysenum.order.OrderChildStatusEnum; import org.springframework.beans.factory.annotation.Autowired; @@ -35,6 +36,8 @@ public class OrderRefundSuccessService { private BsOrderCouponService orderCouponService; @Resource private BsOrderStarbucksService bsOrderStarbucksService; + @Autowired + private BsOrderMeiTuanServiceImpl bsOrderMeiTuanService; /** * 订单业务处理 @@ -52,6 +55,9 @@ public class OrderRefundSuccessService { } else if (orderChild.getProductType().equals(OrderChildProductTypeEnum.type3.getCode())) { // 电影票退款业务 cinema(orderChild); + } else if (orderChild.getProductType().equals(OrderChildProductTypeEnum.type5.getCode())) { + // 美团退款业务 + meiTuan(orderChild); } } catch (Exception e) { System.out.println("========================================="); @@ -114,6 +120,36 @@ public class OrderRefundSuccessService { } + /** + * @MethodName meiTuan + * @Description: 美团退款 + * @param childOrder + * @Author: Sum1Dream + * @Date: 2024/9/23 下午2:04 + */ + public void meiTuan(BsOrderChild childOrder) { + // 美团退款 + BsOrderMeituan orderMeiTuan = bsOrderMeiTuanService.findOrderMeiTuan(childOrder.getOrderNo()); + + try { + + if (orderMeiTuan != null) { + Map map = new HashMap<>(); + map.put("orderNo", childOrder.getOrderNo()); + CinemaService.refundMovieOrder(map); + orderMeiTuan.setStatus(OrderChildStatusEnum.status4.getCode()); + orderMeiTuan.setRefundTime(new Date()); + orderMeiTuan.setExceptionStatus(false); + bsOrderMeiTuanService.update(orderMeiTuan); + } + } catch (Exception e) { + orderMeiTuan.setExceptionStatus(true); + orderMeiTuan.setExceptionMsg(e.getMessage()); + bsOrderMeiTuanService.update(orderMeiTuan); + } + + } + public void starbucks(BsOrderChild childOrder) { // 查询星巴克订单 BsOrderStarbucks orderStarbucks = bsOrderStarbucksService.findGoodsOrder(childOrder.getOrderNo()); 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 f63d256..f863f41 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 @@ -287,6 +287,7 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { BsOrderRefund orderRefund = new BsOrderRefund(); orderRefund.setMerId(orderChild.getMerId()); orderRefund.setOrderNo(orderChild.getOrderNo()); + orderRefund.setTradeRefundNo(tradeRefundNo); orderRefund.setOrderChildNo(orderChild.getChildOrderNo()); orderRefund.setUserId(order.getUserId()); orderRefund.setUserPhone(order.getUserPhone()); @@ -303,12 +304,16 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { } else { // 部分退款 // 计算部分退款比例 - BigDecimal proportion = orderChild.getProductTotalPrice().divide(refundPrice, 2, RoundingMode.DOWN); + BigDecimal proportion = refundPrice.divide(orderChild.getProductTotalPrice() , 2 , RoundingMode.HALF_UP); // 退积分 Long unitPriceIntegral = new BigDecimal(orderChild.getIntegralDiscountPrice()).multiply(proportion).longValue(); // 退金额 BigDecimal price = orderChild.getProductActualPrice().multiply(proportion); + if (price.compareTo(new BigDecimal("0.01")) < 0) { + price = new BigDecimal(0); + } + // 插入退款积分 if (unitPriceIntegral > orderChild.getSurplusRefundIntegral()) { orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral()); @@ -348,8 +353,15 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { orderRefund.setAccountMerchantKey(orderChild.getSettleAccountKey()); editData(orderRefund); - // 资金退款 - orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode()); + + + if (orderRefund.getRefundPrice().compareTo(new BigDecimal(0)) > 0) { + // 资金退款 + orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode()); + } else { + orderRefund.setRefundStatus(OrderRefundStatusEnum.status2.getCode()); + } + editData(orderRefund); // 退款成功