From 8f5eb54e929cfb9cda2aa2398f7145b1492aafcc Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 6 Feb 2023 17:15:58 +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 --- hai-order/src/main/resources/prod/logback.xml | 84 +++++++++++++++++++ .../order/service/impl/OrderServiceImpl.java | 12 +++ .../impl/HighDiscountPackageServiceImpl.java | 46 +++++++--- .../impl/HighDiscountUserRelServiceImpl.java | 8 ++ 4 files changed, 138 insertions(+), 12 deletions(-) diff --git a/hai-order/src/main/resources/prod/logback.xml b/hai-order/src/main/resources/prod/logback.xml index 516350df..17bea0c3 100644 --- a/hai-order/src/main/resources/prod/logback.xml +++ b/hai-order/src/main/resources/prod/logback.xml @@ -57,6 +57,74 @@ UTF-8 + + log/HltCardLog.log + + log/hlt/hltcard.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/PayNotify.log + + log/paynotify/paynotify.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/QzLog.log + + log/QzLog/QzLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/RechargeLog.log + + log/RechargeLog/RechargeLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + @@ -69,4 +137,20 @@ + + + + + + + + + + + + + + + + diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 1764be8a..1e966ba6 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -291,6 +291,18 @@ public class OrderServiceImpl implements OrderService { if (!order.getProductType().equals(OrderProductType.PRODUCT_TYPE9.getNumber())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此优惠券只能充值话费中使用"); } + } else if (discountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type4.getType())) { + if (!order.getProductType().equals(OrderProductType.PRODUCT_TYPE2.getNumber())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此优惠券只能肯德基中使用"); + } + } else if (discountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type5.getType())) { + if (!order.getProductType().equals(OrderProductType.PRODUCT_TYPE1.getNumber())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此优惠券只能星巴克中使用"); + } + } else if (discountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type6.getType())) { + if (!order.getProductType().equals(OrderProductType.PRODUCT_TYPE3.getNumber())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此优惠券只能第三方会员充值中使用"); + } } else if (discountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type7.getType())) { if (!order.getProductType().equals(OrderProductType.PRODUCT_TYPE6.getNumber())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此优惠券只能加油订单中使用"); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java index 8f539976..d7c8c78b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java @@ -11,6 +11,7 @@ import com.hai.common.utils.IDGenerator; import com.hai.common.utils.RedisUtil; import com.hai.dao.*; import com.hai.entity.*; +import com.hai.enum_type.DiscountPlatform; import com.hai.model.UserInfoModel; import com.hai.service.*; import com.hai.service.HighDiscountPackageService; @@ -265,7 +266,6 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic @Transactional(propagation= Propagation.REQUIRES_NEW) public HighDiscountPackageActual freeUserDiscountPackage(Map map) throws Exception { - HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(MapUtils.getInteger(map , "discountPackageId")); // 查询优惠券包实际库存 @@ -282,6 +282,39 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic // 循环赠送优惠券 for (HighDiscountPackageDiscountActual actualList: discountPackageDiscountActual) { + HighDiscount discount = highDiscountService.getDiscountById(actualList.getDiscountId()); + if (discount == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券信息不存在"); + } + HighDiscountUserRel userRel = new HighDiscountUserRel(); + userRel.setDiscountPlatform(DiscountPlatform.getPlatformByCode(discount.getPlatform()).getNumber()); + userRel.setDiscountCompanyId(discount.getCompanyId()); + userRel.setDiscountId(discount.getId()); + userRel.setDiscountName(discount.getDiscountName()); + userRel.setDiscountImg(discount.getDiscountImg()); + userRel.setDiscountUseScope(discount.getUseScope()); + userRel.setDiscountUsingRange(discount.getUsingRange()); + userRel.setDiscountType(discount.getDiscountType()); + userRel.setDiscountCondition(discount.getDiscountCondition()); + userRel.setDiscountPrice(discount.getDiscountPrice()); + userRel.setAgentId(actualList.getAgentId()); + userRel.setUserId(MapUtils.getLong(map , "userId")); + userRel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 + userRel.setCreateTime(new Date()); + userRel.setDiscountAgentCodeId(actualList.getAgentDiscountCodeId()); + // 计算使用有效期 + Calendar userEndTime = Calendar.getInstance(); + userEndTime.setTime(new Date()); + userEndTime.set(Calendar.HOUR_OF_DAY, 23); + userEndTime.set(Calendar.MINUTE, 59); + userEndTime.set(Calendar.SECOND, 59); + userEndTime.add(Calendar.DATE, discount.getEffectiveDay()); + + if (userEndTime.getTime().compareTo(discount.getSalesEndTime()) == 1) { + userRel.setUseEndTime(discount.getSalesEndTime()); + } else { + userRel.setUseEndTime(userEndTime.getTime()); + } HighDiscountUserRel highDiscountUserRel = new HighDiscountUserRel(); highDiscountUserRel.setDiscountId(actualList.getDiscountId()); @@ -291,17 +324,6 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic highDiscountUserRel.setStatus(1); highDiscountUserRel.setCreateTime(new Date()); - HighDiscount highDiscount = highDiscountService.getDiscountById(actualList.getDiscountId()); - - // 计算使用有效期 - Calendar userEndTime = Calendar.getInstance(); - userEndTime.setTime(new Date()); - userEndTime.set(Calendar.HOUR_OF_DAY, 23); - userEndTime.set(Calendar.MINUTE, 59); - userEndTime.set(Calendar.SECOND, 59); - userEndTime.add(Calendar.DATE, highDiscount.getEffectiveDay()); - highDiscountUserRel.setUseEndTime(userEndTime.getTime()); - HighDiscountAgentCode discountAgentCode = highDiscountAgentCodeService.getCodeById(actualList.getAgentDiscountCodeId()); // 修改优惠券二维码状态 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java index d997906a..0fa3492d 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java @@ -162,7 +162,15 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic HighDiscountUserRel userRel = new HighDiscountUserRel(); userRel.setDiscountPlatform(DiscountPlatform.getPlatformByCode(discount.getPlatform()).getNumber()); + userRel.setDiscountCompanyId(discount.getCompanyId()); userRel.setDiscountId(discountAgentRel.getDiscountId()); + userRel.setDiscountName(discount.getDiscountName()); + userRel.setDiscountImg(discount.getDiscountImg()); + userRel.setDiscountUseScope(discount.getUseScope()); + userRel.setDiscountUsingRange(discount.getUsingRange()); + userRel.setDiscountType(discount.getDiscountType()); + userRel.setDiscountCondition(discount.getDiscountCondition()); + userRel.setDiscountPrice(discount.getDiscountPrice()); userRel.setAgentId(discountAgentRel.getAgentId()); userRel.setUserId(userId); userRel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用