袁野 2 months ago
parent 9a57d7b571
commit 33734179ea
  1. 36
      service/src/main/java/com/hfkj/service/order/OrderRefundSuccessService.java
  2. 14
      service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java

@ -7,6 +7,7 @@ import com.hfkj.service.coupon.BsOrderCouponService;
import com.hfkj.service.goods.BsOrderCinemaService; import com.hfkj.service.goods.BsOrderCinemaService;
import com.hfkj.service.goods.BsOrderStarbucksService; import com.hfkj.service.goods.BsOrderStarbucksService;
import com.hfkj.service.goods.impl.BsOrderGoodsServiceImpl; 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.OrderChildProductTypeEnum;
import com.hfkj.sysenum.order.OrderChildStatusEnum; import com.hfkj.sysenum.order.OrderChildStatusEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -35,6 +36,8 @@ public class OrderRefundSuccessService {
private BsOrderCouponService orderCouponService; private BsOrderCouponService orderCouponService;
@Resource @Resource
private BsOrderStarbucksService bsOrderStarbucksService; private BsOrderStarbucksService bsOrderStarbucksService;
@Autowired
private BsOrderMeiTuanServiceImpl bsOrderMeiTuanService;
/** /**
* 订单业务处理 * 订单业务处理
@ -52,6 +55,9 @@ public class OrderRefundSuccessService {
} else if (orderChild.getProductType().equals(OrderChildProductTypeEnum.type3.getCode())) { } else if (orderChild.getProductType().equals(OrderChildProductTypeEnum.type3.getCode())) {
// 电影票退款业务 // 电影票退款业务
cinema(orderChild); cinema(orderChild);
} else if (orderChild.getProductType().equals(OrderChildProductTypeEnum.type5.getCode())) {
// 美团退款业务
meiTuan(orderChild);
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("========================================="); 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<String , Object> 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) { public void starbucks(BsOrderChild childOrder) {
// 查询星巴克订单 // 查询星巴克订单
BsOrderStarbucks orderStarbucks = bsOrderStarbucksService.findGoodsOrder(childOrder.getOrderNo()); BsOrderStarbucks orderStarbucks = bsOrderStarbucksService.findGoodsOrder(childOrder.getOrderNo());

@ -287,6 +287,7 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
BsOrderRefund orderRefund = new BsOrderRefund(); BsOrderRefund orderRefund = new BsOrderRefund();
orderRefund.setMerId(orderChild.getMerId()); orderRefund.setMerId(orderChild.getMerId());
orderRefund.setOrderNo(orderChild.getOrderNo()); orderRefund.setOrderNo(orderChild.getOrderNo());
orderRefund.setTradeRefundNo(tradeRefundNo);
orderRefund.setOrderChildNo(orderChild.getChildOrderNo()); orderRefund.setOrderChildNo(orderChild.getChildOrderNo());
orderRefund.setUserId(order.getUserId()); orderRefund.setUserId(order.getUserId());
orderRefund.setUserPhone(order.getUserPhone()); orderRefund.setUserPhone(order.getUserPhone());
@ -303,12 +304,16 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
} else { } 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(); Long unitPriceIntegral = new BigDecimal(orderChild.getIntegralDiscountPrice()).multiply(proportion).longValue();
// 退金额 // 退金额
BigDecimal price = orderChild.getProductActualPrice().multiply(proportion); BigDecimal price = orderChild.getProductActualPrice().multiply(proportion);
if (price.compareTo(new BigDecimal("0.01")) < 0) {
price = new BigDecimal(0);
}
// 插入退款积分 // 插入退款积分
if (unitPriceIntegral > orderChild.getSurplusRefundIntegral()) { if (unitPriceIntegral > orderChild.getSurplusRefundIntegral()) {
orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral()); orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral());
@ -348,8 +353,15 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
orderRefund.setAccountMerchantKey(orderChild.getSettleAccountKey()); orderRefund.setAccountMerchantKey(orderChild.getSettleAccountKey());
editData(orderRefund); editData(orderRefund);
if (orderRefund.getRefundPrice().compareTo(new BigDecimal(0)) > 0) {
// 资金退款 // 资金退款
orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode()); orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode());
} else {
orderRefund.setRefundStatus(OrderRefundStatusEnum.status2.getCode());
}
editData(orderRefund); editData(orderRefund);
// 退款成功 // 退款成功

Loading…
Cancel
Save