mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2025-01-30 11:08:28 +08:00
feat: 所有有关定时任务的区域都加上日志
This commit is contained in:
parent
e26d0c3e2d
commit
76097a795e
4 changed files with 46 additions and 4 deletions
|
@ -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<CouponDao, Coup
|
|||
@Autowired
|
||||
private CouponStoreService couponStoreService;
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(ShopXxlJob.class);
|
||||
|
||||
@Override
|
||||
public void validatorEntity(Coupon coupon) {
|
||||
// 模板新增
|
||||
|
@ -136,7 +141,9 @@ public class CouponServiceImpl extends SkyeyeBusinessServiceImpl<CouponDao, Coup
|
|||
// }
|
||||
if (StrUtil.isNotEmpty(entity.getTemplateId())) {// 优惠券
|
||||
if (Objects.equals(entity.getValidityType(), CouponValidityType.DATE.getKey())) {
|
||||
log.info("优惠券id" + entity.getId() + "创建定时任务-- 开始");
|
||||
startUpTaskQuartz(entity.getId(), entity.getName(), entity.getValidEndTime());
|
||||
log.info("优惠券id" + entity.getId() + "创建定时任务-- 结束");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,9 @@ import com.skyeye.coupon.service.CouponUseService;
|
|||
import com.skyeye.eve.rest.quartz.SysQuartzMation;
|
||||
import com.skyeye.eve.service.IQuartzService;
|
||||
import com.skyeye.exception.CustomException;
|
||||
import org.joda.time.LocalDate;
|
||||
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;
|
||||
|
||||
|
@ -44,7 +46,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @ClassName: CouponUseServiceImpl
|
||||
|
@ -67,6 +68,8 @@ public class CouponUseServiceImpl extends SkyeyeBusinessServiceImpl<CouponUseDao
|
|||
@Autowired
|
||||
private IQuartzService iQuartzService;
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(ShopXxlJob.class);
|
||||
|
||||
private void check(Coupon coupon) {
|
||||
if (ObjectUtil.isEmpty(coupon)) {
|
||||
throw new CustomException("优惠券不存在");
|
||||
|
@ -117,8 +120,8 @@ public class CouponUseServiceImpl extends SkyeyeBusinessServiceImpl<CouponUseDao
|
|||
couponUse.setValidEndTime(coupon.getValidEndTime());
|
||||
} else {
|
||||
DateFormat df = new SimpleDateFormat(DateUtil.YYYY_MM_DD_HH_MM_SS);
|
||||
couponUse.setValidStartTime(df.format(DateUtil.getAfDate(LocalDate.now().toDate(), coupon.getFixedStartTime(), "d")));
|
||||
couponUse.setValidEndTime(df.format(DateUtil.getAfDate(LocalDate.now().toDate(), coupon.getFixedEndTime(), "d")));
|
||||
couponUse.setValidStartTime(df.format(DateUtil.getAfDate(DateUtil.getPointTime(DateUtil.getTimeAndToString(), DateUtil.YYYY_MM_DD_HH_MM_SS), coupon.getFixedStartTime(), "d")));
|
||||
couponUse.setValidEndTime(df.format(DateUtil.getAfDate(DateUtil.getPointTime(DateUtil.getTimeAndToString(), DateUtil.YYYY_MM_DD_HH_MM_SS), coupon.getFixedEndTime(), "d")));
|
||||
}
|
||||
// 领取非固定类型优惠券时,借助couponMation成员变量存储优惠券信息,便于后置执行新增定时任务
|
||||
couponUse.setCouponMation(coupon);
|
||||
|
@ -145,7 +148,9 @@ public class CouponUseServiceImpl extends SkyeyeBusinessServiceImpl<CouponUseDao
|
|||
// 定时任务
|
||||
Coupon couponMation = couponUse.getCouponMation();
|
||||
if (Objects.equals(couponMation.getValidityType(), CouponValidityType.TERM.getKey())) {
|
||||
log.info("领取优惠券的id(couponUseId)" + couponUse.getId() +"创建定时任务--开始");
|
||||
startUpTaskQuartz(couponUse.getId(), couponMation.getName(), couponUse.getValidEndTime());
|
||||
log.info("领取优惠券的id(couponUseId)" + couponUse.getId() + "创建定时任务--结束");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,10 @@ import com.skyeye.rest.shopmaterialnorms.sevice.IShopMaterialNormsService;
|
|||
import com.skyeye.store.entity.ShopAddress;
|
||||
import com.skyeye.store.service.ShopAddressService;
|
||||
import com.skyeye.store.service.ShopTradeCartService;
|
||||
import com.skyeye.xxljob.ShopXxlJob;
|
||||
import com.xxl.job.core.util.IpUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -104,6 +107,8 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl<OrderDao, Order>
|
|||
@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<OrderDao, Order>
|
|||
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<OrderDao, Order>
|
|||
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<OrderDao, Order>
|
|||
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
|
||||
|
|
|
@ -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<String, String> 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<String, String> 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 + "---删除任务---结束");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue