From 23b5f5c2cbd6a30a78f1a28be4a7aa627fc54c95 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 28 Mar 2023 09:53:10 +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 --- .../controller/BsTradeOrderController.java | 8 ++- .../impl/BsTradeOrderRefundServiceImpl.java | 51 +++++++++++++++---- .../service/impl/BsTradeOrderServiceImpl.java | 2 + 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java b/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java index 1f9ae7b..52cfe65 100644 --- a/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java +++ b/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java @@ -242,8 +242,14 @@ public class BsTradeOrderController { // 优惠活动 BsStoreDiscountActivity storeDiscountActivity = null; - if (StringUtils.isNotBlank(body.getString("userPhone")) && body.getLong("storeDiscountId") != null) { + if (body.getLong("storeDiscountId") != null) { storeDiscountActivity = storeDiscountActivityService.getDetailById(body.getLong("storeDiscountId")); + if (storeDiscountActivity != null) { + if (!storeDiscountActivity.getPartakeWay().equals(StoreDiscountActivityPartakeWayEnum.type1.getNumber()) + && StringUtils.isBlank(body.getString("userPhone"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, storeDiscountActivity.getName() + ",需要登录才能参加"); + } + } } // 用户优惠券 diff --git a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java index deb8282..c9c23a1 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java @@ -3,15 +3,21 @@ package com.hfkj.service.impl; import com.hfkj.channel.ccb.CCBTradeService; import com.hfkj.channel.weixin.WeiXinPayService; import com.hfkj.dao.BsTradeOrderRefundMapper; -import com.hfkj.entity.BsTradeOrderRefund; -import com.hfkj.entity.BsTradeOrderRefundExample; +import com.hfkj.entity.*; import com.hfkj.channel.lakala.LaKaLaTradeService; +import com.hfkj.service.BsStoreDiscountActivityPartakeUserService; +import com.hfkj.service.BsStoreDiscountActivityService; import com.hfkj.service.BsTradeOrderRefundService; +import com.hfkj.service.BsTradeOrderService; import com.hfkj.sysenum.PlatformTypeEnum; +import com.hfkj.sysenum.StoreDiscountActivityPartakeWayEnum; +import com.hfkj.sysenum.TradeOrderStatusEnum; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -21,6 +27,14 @@ public class BsTradeOrderRefundServiceImpl implements BsTradeOrderRefundService @Resource private BsTradeOrderRefundMapper tradeOrderRefundMapper; + @Resource + private BsTradeOrderService tradeOrderService; + + @Resource + private BsStoreDiscountActivityService storeDiscountActivityService; + @Resource + private BsStoreDiscountActivityPartakeUserService discountActivityPartakeUserService; + @Resource private LaKaLaTradeService laKaLaTradeService; @@ -46,19 +60,38 @@ public class BsTradeOrderRefundServiceImpl implements BsTradeOrderRefundService public Map tradeOrderRefund(BsTradeOrderRefund tradeOrderRefund) throws Exception { editOrderRefund(tradeOrderRefund); + Map refund = new HashMap<>(); if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type1.getNumber())) { - return laKaLaTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); - } + refund = laKaLaTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); - if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type3.getNumber())) { - return ccbTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); + } else if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type3.getNumber())) { + refund = ccbTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); + + } else if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) { + refund = weiXinPayService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); } - if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) { - return weiXinPayService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); + // 交易订单 + BsTradeOrder tradeOrder = tradeOrderService.getOrderByTradeNoId(tradeOrderRefund.getTradeOrderId()); + if (tradeOrder != null) { + // 退回门店优惠活动 + if (tradeOrder.getStoreDiscountId() != null) { + BsStoreDiscountActivity storeDiscountActivity = storeDiscountActivityService.getDetailById(tradeOrder.getStoreDiscountId()); + if (storeDiscountActivity != null + && !storeDiscountActivity.getPartakeWay().equals(StoreDiscountActivityPartakeWayEnum.type1.getNumber()) + && StringUtils.isNotBlank(tradeOrder.getUserPhone())) { + + BsStoreDiscountActivityPartakeUser partakeUser = discountActivityPartakeUserService.getPartakeUser(tradeOrder.getUserPhone(), tradeOrder.getStoreDiscountId()); + if (partakeUser != null) { + partakeUser.setPartakeSurplusNum(partakeUser.getPartakeSurplusNum() + 1); + partakeUser.setPartakeUseNum(partakeUser.getPartakeUseNum() - 1); + discountActivityPartakeUserService.editData(partakeUser); + } + } + } } - return null; + return refund; } @Override diff --git a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java index e2bab7e..0bd80fb 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java @@ -99,6 +99,8 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService { tradeOrder.setTradeAmount(tradeAmount); tradeOrder.setTradeActualAmount(tradeAmount); tradeOrder.setStoreDiscountSatisfy(false); + tradeOrder.setUserPhone(userPhone); + // 门店优惠 if (storeDiscount != null) {