|
|
@@ -2,24 +2,18 @@ package com.kym.admin.jobs;
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.kym.common.utils.CommUtil;
|
|
|
-import com.kym.entity.admin.Activity;
|
|
|
-import com.kym.entity.admin.ActivityStation;
|
|
|
-import com.kym.entity.admin.Banner;
|
|
|
-import com.kym.entity.admin.RechargeRights;
|
|
|
+import com.kym.entity.admin.*;
|
|
|
import com.kym.entity.admin.delay.DelayActivity;
|
|
|
-import com.kym.service.admin.ActivityService;
|
|
|
-import com.kym.service.admin.ActivityStationService;
|
|
|
-import com.kym.service.admin.BannerService;
|
|
|
-import com.kym.service.admin.RechargeRightsService;
|
|
|
+import com.kym.service.admin.*;
|
|
|
import com.kym.service.jobs.DelayService;
|
|
|
import com.kym.service.jobs.DelayedItem;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
|
+import org.springframework.context.annotation.Scope;
|
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
|
import org.springframework.context.event.EventListener;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import org.springframework.context.annotation.Scope;
|
|
|
import java.util.concurrent.DelayQueue;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
@@ -43,16 +37,19 @@ public class ActivityDelayJob implements DelayService<DelayActivity> {
|
|
|
private final ActivityService activityService;
|
|
|
private final ActivityStationService activityStationService;
|
|
|
private final RechargeRightsService rechargeRightsService;
|
|
|
+
|
|
|
+ private final CouponService couponService;
|
|
|
private final BannerService bannerService;
|
|
|
/**
|
|
|
* 线程池
|
|
|
*/
|
|
|
private final ExecutorService executor = Executors.newFixedThreadPool(1);
|
|
|
|
|
|
- public ActivityDelayJob(ActivityService activityService, ActivityStationService activityStationService, RechargeRightsService rechargeRightsService, BannerService bannerService) {
|
|
|
+ public ActivityDelayJob(ActivityService activityService, ActivityStationService activityStationService, RechargeRightsService rechargeRightsService, CouponService couponService, BannerService bannerService) {
|
|
|
this.activityService = activityService;
|
|
|
this.activityStationService = activityStationService;
|
|
|
this.rechargeRightsService = rechargeRightsService;
|
|
|
+ this.couponService = couponService;
|
|
|
this.bannerService = bannerService;
|
|
|
}
|
|
|
|
|
|
@@ -68,6 +65,7 @@ public class ActivityDelayJob implements DelayService<DelayActivity> {
|
|
|
.setId(act.getId())
|
|
|
.setName(act.getName())
|
|
|
.setExecuteTime(act.getStartTime())
|
|
|
+ .setDiscountType(act.getDiscountType())
|
|
|
.setType(DelayActivity.TYPE_启动))
|
|
|
.toList();
|
|
|
|
|
|
@@ -76,6 +74,7 @@ public class ActivityDelayJob implements DelayService<DelayActivity> {
|
|
|
.setId(act.getId())
|
|
|
.setName(act.getName())
|
|
|
.setExecuteTime(act.getEndTime())
|
|
|
+ .setDiscountType(act.getDiscountType())
|
|
|
.setType(DelayActivity.TYPE_结束))
|
|
|
.toList();
|
|
|
|
|
|
@@ -99,8 +98,17 @@ public class ActivityDelayJob implements DelayService<DelayActivity> {
|
|
|
activityService.lambdaUpdate().set(Activity::getStatus, Activity.STATUS_进行中).eq(Activity::getId, delayActivity.getId()).update();
|
|
|
// 修改活动站点关联表状态为进行中
|
|
|
activityStationService.lambdaUpdate().set(ActivityStation::getStatus, Activity.STATUS_进行中).eq(ActivityStation::getActivityId, delayActivity.getId()).update();
|
|
|
- // 修改充值权益为进行中
|
|
|
- rechargeRightsService.lambdaUpdate().set(RechargeRights::getStatus, RechargeRights.STATUS_进行中).eq(RechargeRights::getActivityId, delayActivity.getId()).update();
|
|
|
+
|
|
|
+ // 判断活动优惠类型,分别处理活动启动逻辑
|
|
|
+ if (delayActivity.getDiscountType().equals(Activity.DISCOUNT_TYPE_服务费折扣权益)) {
|
|
|
+ // 修改充值权益为进行中
|
|
|
+ rechargeRightsService.lambdaUpdate().set(RechargeRights::getStatus, RechargeRights.STATUS_进行中).eq(RechargeRights::getActivityId, delayActivity.getId()).update();
|
|
|
+ }
|
|
|
+ if (delayActivity.getDiscountType().equals(Activity.DISCOUNT_TYPE_优惠券)) {
|
|
|
+ // 修改优惠券状态为进行中
|
|
|
+ couponService.lambdaUpdate().set(Coupon::getStatus, Coupon.STATUS_进行中).eq(Coupon::getActivityId, delayActivity.getId()).update();
|
|
|
+ }
|
|
|
+
|
|
|
// 修改banner状态为有效
|
|
|
bannerService.lambdaUpdate().set(Banner::getStatus, Banner.STATUS_有效).eq(Banner::getActivityId, delayActivity.getId()).update();
|
|
|
log.info("活动id:{},活动名:{}启动中...", delayActivity.getId(), delayActivity.getName());
|
|
|
@@ -111,8 +119,17 @@ public class ActivityDelayJob implements DelayService<DelayActivity> {
|
|
|
activityService.lambdaUpdate().set(Activity::getStatus, Activity.STATUS_已结束).eq(Activity::getId, delayActivity.getId()).update();
|
|
|
// 修改活动站点关联表状态为已结束
|
|
|
activityStationService.lambdaUpdate().set(ActivityStation::getStatus, Activity.STATUS_已结束).eq(ActivityStation::getActivityId, delayActivity.getId()).update();
|
|
|
- // 修改充值权益为进行中
|
|
|
- rechargeRightsService.lambdaUpdate().set(RechargeRights::getStatus, RechargeRights.STATUS_已结束).eq(RechargeRights::getActivityId, delayActivity.getId()).update();
|
|
|
+
|
|
|
+ // 判断活动优惠类型,分别处理活动结束逻辑
|
|
|
+ if (delayActivity.getDiscountType().equals(Activity.DISCOUNT_TYPE_服务费折扣权益)) {
|
|
|
+ // 修改充值权益为已结束
|
|
|
+ rechargeRightsService.lambdaUpdate().set(RechargeRights::getStatus, RechargeRights.STATUS_已结束).eq(RechargeRights::getActivityId, delayActivity.getId()).update();
|
|
|
+ }
|
|
|
+ if (delayActivity.getDiscountType().equals(Activity.DISCOUNT_TYPE_优惠券)) {
|
|
|
+ // 修改优惠券状态为已结束
|
|
|
+ couponService.lambdaUpdate().set(Coupon::getStatus, Coupon.STATUS_已结束).eq(Coupon::getActivityId, delayActivity.getId()).update();
|
|
|
+ }
|
|
|
+
|
|
|
// 修改banner状态为失效
|
|
|
bannerService.lambdaUpdate().set(Banner::getStatus, Banner.STATUS_无效).eq(Banner::getActivityId, delayActivity.getId()).update();
|
|
|
log.info("活动id:{},活动名:{}已结束...", delayActivity.getId(), delayActivity.getName());
|