From 76097a795ef5108693c94a5063665920b9c2ce0f Mon Sep 17 00:00:00 2001 From: wst <2450473462@qq.com> Date: Sat, 14 Dec 2024 15:48:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=80=E6=9C=89=E6=9C=89=E5=85=B3?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=9A=84=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E9=83=BD=E5=8A=A0=E4=B8=8A=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coupon/service/impl/CouponServiceImpl.java | 7 +++++++ .../service/impl/CouponUseServiceImpl.java | 13 +++++++++---- .../order/service/impl/OrderServiceImpl.java | 12 ++++++++++++ .../java/com/skyeye/xxljob/ShopXxlJob.java | 18 ++++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java index 44f7f59d..9adb4abb 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java @@ -34,6 +34,9 @@ import com.skyeye.eve.rest.quartz.SysQuartzMation; import com.skyeye.eve.service.IQuartzService; import com.skyeye.exception.CustomException; import com.skyeye.rest.shopmaterialnorms.sevice.IShopMaterialNormsService; +import com.skyeye.xxljob.ShopXxlJob; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -69,6 +72,8 @@ public class CouponServiceImpl extends SkyeyeBusinessServiceImpl @Autowired private ShopTradeCartService shopTradeCartService; + private static Logger log = LoggerFactory.getLogger(ShopXxlJob.class); + @Override public void createPrepose(Order order) { // 订单编号 @@ -256,7 +261,9 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl public void createPostpose(Order order, String userId) { orderItemService.setValueAndCreateEntity(order, userId); couponUseService.updateState(order.getCouponUseId());// 更新用户领取的优惠券状态 + log.info("订单id:"+order.getId()+"创建定时任务-- 开始"); startUpTaskQuartz(order.getId(), order.getOddNumber(), DateUtil.getTimeAndToString()); + log.info("订单id:"+order.getId()+"创建定时任务-- 结束"); shopTradeCartService.deleteMySelect(userId); } @@ -473,6 +480,9 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl updateWrapper.set(MybatisPlusUtil.toColumns(Order::getCancelType), params.get("cancelType")); updateWrapper.set(MybatisPlusUtil.toColumns(Order::getCancelTime), DateUtil.getTimeAndToString()); update(updateWrapper); + log.info("订单id" + one.getId() + "取消订单--取消定时任务-- 开始"); + iQuartzService.stopAndDeleteTaskQuartz(one.getId());// 删除任务 + log.info("订单id" + one.getId() + "取消订单--取消定时任务-- 结束"); refreshCache(params.get("id").toString()); } else { throw new CustomException("订单不可取消"); @@ -530,7 +540,9 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl updateWrapper.set(MybatisPlusUtil.toColumns(Order::getExtensionNo), payOrderRespDTO.get("no").toString()); update(updateWrapper); refreshCache(id); + log.info("订单id" + one.getId() + "支付成功--删除定时任务-- 开始"); iQuartzService.stopAndDeleteTaskQuartz(id);// 删除定时任务 + log.info("订单id" + one.getId() + "支付成功--删除定时任务-- 结束"); } @Override diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/xxljob/ShopXxlJob.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/xxljob/ShopXxlJob.java index 44448b04..39aac077 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/xxljob/ShopXxlJob.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/xxljob/ShopXxlJob.java @@ -11,6 +11,8 @@ import com.skyeye.eve.service.IQuartzService; import com.skyeye.order.service.OrderService; import com.xxl.job.core.context.XxlJobHelper; import com.xxl.job.core.handler.annotation.XxlJob; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -39,16 +41,24 @@ public class ShopXxlJob { @Autowired private IQuartzService iQuartzService; + private static Logger log = LoggerFactory.getLogger(ShopXxlJob.class); + @XxlJob("setShopCouponStateService") public void setShopCouponStateService() { String param = XxlJobHelper.getJobParam(); Map paramMap = JSONUtil.toBean(param, null); String couponId = paramMap.get("objectId");// 优惠券id try { + log.info("优惠券id(couponId)" + couponId + "---修改优惠券的状态---开始"); couponService.setStateByCoupon(couponId);// 修改优惠券的状态 + log.info("优惠券id(couponId)" + couponId + "---修改优惠券的状态---结束"); + log.info("优惠券id(couponId)" + couponId + "---修改领取的优惠券的状态---开始"); couponUseService.setCouponUseStateByDate(couponId);// 修改领取的优惠券的状态 + log.info("优惠券id(couponId)" + couponId + "---修改领取的优惠券的状态---结束"); } finally { + log.info("优惠券id(couponId)" + couponId + "---删除任务---开始"); iQuartzService.stopAndDeleteTaskQuartz(couponId);// 删除任务 + log.info("优惠券id(couponId)" + couponId + "---删除任务---结束"); } } @@ -59,9 +69,13 @@ public class ShopXxlJob { String userId = paramMap.get("userId"); String couponUseId = paramMap.get("objectId");// 领取的优惠券id try { + log.info("领取优惠券的id(couponUseId)" + couponUseId + "---修改领取的优惠券的状态---开始"); couponUseService.setCouponUseStateByTerm(userId, couponUseId);// 修改领取的优惠券的状态} + log.info("领取优惠券的id(couponUseId)" + couponUseId + "---修改领取的优惠券的状态---结束"); } finally { + log.info("领取优惠券的id(couponUseId)" + couponUseId + "---删除任务---开始"); iQuartzService.stopAndDeleteTaskQuartz(couponUseId);// 删除任务 + log.info("领取优惠券的id(couponUseId)" + couponUseId + "---删除任务---结束"); } } @@ -71,9 +85,13 @@ public class ShopXxlJob { Map paramMap = JSONUtil.toBean(param, null); String orderId = paramMap.get("objectId");// 订单的主键id try { + log.info("订单的主键id(orderId)" + orderId + "---修改订单的状态为取消---开始"); orderService.setOrderCancle(orderId);// 修改订单的状态为取消 + log.info("订单的主键id(orderId)" + orderId + "---修改订单的状态为取消---结束"); } finally { + log.info("订单的主键id(orderId)" + orderId + "---删除任务---开始"); iQuartzService.stopAndDeleteTaskQuartz(orderId);// 删除任务 + log.info("订单的主键id(orderId)" + orderId + "---删除任务---结束"); } } }