From 0325d5bd06ea7c7230ea2dd9e78a076cbf41afb9 Mon Sep 17 00:00:00 2001 From: 陶杰 <1378534974@qq.com> Date: 星期二, 03 九月 2024 17:33:22 +0800 Subject: [PATCH] 1.优惠券相关代码提交 --- src/main/java/com/mzl/flower/schedule/ScheduleService.java | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 52 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/mzl/flower/schedule/ScheduleService.java b/src/main/java/com/mzl/flower/schedule/ScheduleService.java index c45f66b..1cf21b0 100644 --- a/src/main/java/com/mzl/flower/schedule/ScheduleService.java +++ b/src/main/java/com/mzl/flower/schedule/ScheduleService.java @@ -9,14 +9,17 @@ import com.mzl.flower.mapper.flower.FlowerCategoryMapper; import com.mzl.flower.mapper.partner.PartnerMapper; import com.mzl.flower.mapper.payment.OrderMapper; +import com.mzl.flower.service.coupon.CouponRecordService; import com.mzl.flower.service.flower.FlowerCategoryService; import com.mzl.flower.service.flower.FlowerService; +import com.mzl.flower.service.menber.impl.GrowthValueDealService; import com.mzl.flower.service.payment.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import java.time.LocalDate; import java.time.LocalDateTime; @@ -56,6 +59,12 @@ @Autowired private OrderItemSettlementService orderItemSettlementService; + + @Autowired + private GrowthValueDealService growthValueDealService; + + @Autowired + private CouponRecordService couponRecordService; @Scheduled(cron = "1 0/20 * * * ?") public void calculateAvePrice() { @@ -133,7 +142,12 @@ @Scheduled(cron = "1 20 0/1 * * ?") public void autoReceive() { log.info("自动收货开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); - orderService.autoReceive(); + List<Order> ls = orderService.autoReceive(); + if(ls != null && ls.size() > 0){ + for(Order o : ls){ + orderService.processAfterReceive(o); + } + } log.info("自动收货结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); } @@ -164,6 +178,7 @@ for(Transfer t : ls){ try { paymentV3Service.checkTransferStatus(t); + settlementService.updateSettlementStatus(t.getId()); } catch (Exception e) { log.error(e.getMessage(), e); } @@ -179,4 +194,40 @@ billService.generateBill(date.plusDays(-1)); log.info("账单结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); } + + //成长值降级定时任务 + @Scheduled(cron = "0 0 5 * * ?") + public void deductGrowthValue() { + log.info("成长值扣除开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); + //获取当前员工 + List<Order> orderList = orderMapper.getOrderInfoByReceiveTime(); + if(!CollectionUtils.isEmpty(orderList)){ + orderList.forEach(o->{ + try { + growthValueDealService.deductionGrowthValue(o); + } catch (Exception e) { + // 记录错误信息,例如将错误信息写入日志 + log.info("处理订单 " + o.getId() + " 时出错: " + e.getMessage()); + } + }); + } + log.info("成长值扣除结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); + } + + + @Scheduled(cron = "0 30 0 1 * ?") + public void grantVipCouponRecordList() { + log.info("会员优惠券开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); + couponRecordService.grantVipCouponRecordList(); + log.info("会员优惠券结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); + } + + @Scheduled(cron = "0 30 0 1 * ?") + public void expiredCouponRecordLastMon() { + log.info("会员优惠券开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); + couponRecordService.expiredCouponRecordLastMon(); + log.info("会员优惠券结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); + } + + } -- Gitblit v1.9.3