From 63645f8a4f5853b4353e78e89d5df782cbb0ac9f Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 29 May 2024 15:46:06 +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 --- .../order/controller/OrderPayController.java | 5 +++- .../order/impl/BsOrderRefundServiceImpl.java | 26 ++++++++++++++++++- .../order/impl/BsOrderServiceImpl.java | 14 +++++++--- .../UserIntegralRecordSourceTypeEnum.java | 5 ++++ 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/order/src/main/java/com/order/controller/OrderPayController.java b/order/src/main/java/com/order/controller/OrderPayController.java index 95a5a14..b2e1c1b 100644 --- a/order/src/main/java/com/order/controller/OrderPayController.java +++ b/order/src/main/java/com/order/controller/OrderPayController.java @@ -92,8 +92,10 @@ public class OrderPayController { Map preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), body.getString("openId"), order); for (OrderChildModel orderChild : order.getOrderChildList()) { orderChild.setSettleAccount(merPay.getPayMerNo()); + orderChild.setSettleAccountKey(merPay.getPayMerKey()); orderChildService.editData(orderChild); } + orderService.cacheDelete(order.getOrderNo()); return ResponseMsgUtil.success(preorder); } catch (Exception e) { @@ -135,7 +137,7 @@ public class OrderPayController { orderChild.setSettleAccountKey(merPay.getPayMerKey()); orderChildService.editData(orderChild); } - + orderService.cacheDelete(order.getOrderNo()); return ResponseMsgUtil.success(preorder); } catch (Exception e) { log.error("error!",e); @@ -182,6 +184,7 @@ public class OrderPayController { orderChild.setSettleAccountKey(merPay.getPayMerKey()); orderChildService.editData(orderChild); } + orderService.cacheDelete(order.getOrderNo()); return ResponseMsgUtil.success(orderPayService.hltCardPay(merPay.getHltInstCode(),order, card)); } else { 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 28d52ce..a48a6ae 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 @@ -19,6 +19,9 @@ import com.hfkj.service.order.BsOrderChildService; import com.hfkj.service.order.BsOrderRefundService; import com.hfkj.service.order.BsOrderService; import com.hfkj.service.pay.HuiPayService; +import com.hfkj.service.user.UserIntegralService; +import com.hfkj.sysenum.UserIntegralRecordOpUserTypeEnum; +import com.hfkj.sysenum.UserIntegralRecordSourceTypeEnum; import com.hfkj.sysenum.mer.PayPlatformEnum; import com.hfkj.sysenum.order.*; import org.apache.commons.collections4.MapUtils; @@ -32,6 +35,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -50,6 +54,8 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { @Resource private BsOrderChildService orderChildService; @Resource + private UserIntegralService userIntegralService; + @Resource private BsMerPayConfigService merPayConfigService; @Override public void editData(BsOrderRefund data) { @@ -174,10 +180,28 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { orderRefund.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString()))); orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue()); } + + + if (orderRefund.getRefundIntegral() > 0L) { + Map opUser = new HashMap<>(); + opUser.put("opUserType", orderRefund.getOpUserType()); + opUser.put("opUserId", orderRefund.getUserId()); + opUser.put("opUserPhone", orderRefund.getUserPhone()); + + Map source = new HashMap<>(); + source.put("sourceType", UserIntegralRecordSourceTypeEnum.type2.getCode()); + source.put("sourceId", orderChild.getId()); + source.put("sourceOrderNo", orderChild.getChildOrderNo()); + source.put("sourceContent", "商品订单退款退回积分"); + + // 退款积分 + userIntegralService.entry(orderRefund.getUserId(),orderRefund.getRefundIntegral(), opUser, source); + } + orderRefund.setRefundRemark(remark); orderRefund.setRefundStatus(OrderRefundStatusEnum.status1.getCode()); orderRefund.setAccountMerchantNo(orderChild.getSettleAccount()); - orderRefund.setAccountMerchantNo(orderChild.getSettleAccountKey()); + orderRefund.setAccountMerchantKey(orderChild.getSettleAccountKey()); editData(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 5e0be76..b0174a7 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 @@ -1,5 +1,6 @@ package com.hfkj.service.order.impl; +import com.hfkj.common.exception.BaseException; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; @@ -228,11 +229,14 @@ public class BsOrderServiceImpl implements BsOrderService { )); } + childOrder.setIntegralDiscountPrice(childOrder.getSurplusRefundIntegral()); childOrder.setCouponDiscountPrice( + // 可退款金额大于0 可退款金额+可退款积分=优惠券优惠 childOrder.getSurplusRefundPrice().compareTo(BigDecimal.ZERO) == 1 - ? childOrder.getProductTotalPrice().subtract(childOrder.getSurplusRefundPrice()) + ? childOrder.getProductTotalPrice().subtract( + childOrder.getSurplusRefundPrice().add(new BigDecimal(childOrder.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100")))) : childOrder.getSurplusRefundPrice()); - childOrder.setIntegralDiscountPrice(childOrder.getSurplusRefundIntegral()); + childOrder.setTotalDeductionPrice( childOrder.getCouponDiscountPrice() .add(new BigDecimal(childOrder.getIntegralDiscountPrice().toString()).divide(new BigDecimal("100"))) @@ -307,12 +311,12 @@ public class BsOrderServiceImpl implements BsOrderService { deduction.setCouponDiscountPrice(discount.getPrice()); // 卡卷类型 1:满减 2:抵扣 3:折扣 if (1 == discount.getType()) { - deduction.setCouponDiscountActualPrice(discount.getPrice()); - } else if (2 == discount.getType()) { if (discount.getCondition().compareTo(order.getProductTotalPrice()) < 0) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未满足优惠券满减条件"); } deduction.setCouponDiscountActualPrice(discount.getPrice()); + } else if (2 == discount.getType()) { + deduction.setCouponDiscountActualPrice(discount.getPrice()); } else if (3 == discount.getType()) { deduction.setCouponDiscountPrice(discount.getPercentage()); deduction.setCouponDiscountActualPrice( @@ -326,6 +330,8 @@ public class BsOrderServiceImpl implements BsOrderService { deduction.setTotalDeductionPrice(deduction.getCouponDiscountActualPrice() .add(new BigDecimal(deduction.getIntegralDiscountPrice().toString()).divide(new BigDecimal("100")))); orderDeductionService.editData(deduction); + } catch (BaseException e) { + throw e; } catch (Exception e) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券使用异常"); } finally { diff --git a/service/src/main/java/com/hfkj/sysenum/UserIntegralRecordSourceTypeEnum.java b/service/src/main/java/com/hfkj/sysenum/UserIntegralRecordSourceTypeEnum.java index 2b1299c..2eef6cd 100644 --- a/service/src/main/java/com/hfkj/sysenum/UserIntegralRecordSourceTypeEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/UserIntegralRecordSourceTypeEnum.java @@ -14,6 +14,11 @@ public enum UserIntegralRecordSourceTypeEnum { * 交易订单 */ type1(1, "交易订单"), + + /** + * 商品订单 + */ + type2(1, "商品订单"), ; private int code;