|
|
@@ -1,14 +1,38 @@
|
|
|
package com.zhongzheng.controller.grade;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.modules.base.service.IProfileTpService;
|
|
|
+import com.zhongzheng.modules.base.vo.ProfileTpVo;
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
+import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
+import com.zhongzheng.modules.grade.service.IClassGradeGoodsService;
|
|
|
+import com.zhongzheng.modules.grade.service.IClassGradeService;
|
|
|
+import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
+import com.zhongzheng.modules.inform.bo.InformUserAddBo;
|
|
|
import com.zhongzheng.modules.inform.domain.Inform;
|
|
|
+import com.zhongzheng.modules.inform.service.IInformRemindService;
|
|
|
import com.zhongzheng.modules.inform.service.IInformService;
|
|
|
+import com.zhongzheng.modules.inform.service.IInformUserService;
|
|
|
+import com.zhongzheng.modules.inform.vo.InformRemindVo;
|
|
|
+import com.zhongzheng.modules.order.bo.OrderGoodsAddBo;
|
|
|
+import com.zhongzheng.modules.order.mapper.OrderMapper;
|
|
|
+import com.zhongzheng.modules.order.service.IOrderBusinessService;
|
|
|
+import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
+import com.zhongzheng.modules.order.vo.OrderGoodsVo;
|
|
|
+import com.zhongzheng.modules.user.service.IUserService;
|
|
|
+import com.zhongzheng.modules.user.vo.UserVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Configuration //1.主要用于标记配置类,兼备Component的效果。
|
|
|
@EnableScheduling // 2.开启定时任务
|
|
|
@@ -16,11 +40,135 @@ public class SaticScheduleTask {
|
|
|
|
|
|
@Autowired
|
|
|
private IInformService informService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IInformRemindService informRemindService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IProfileTpService iProfileTpService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrderMapper orderMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private com.zhongzheng.modules.alisms.service.IAliSmsService IAliSmsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IInformUserService iInformUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOrderGoodsService iOrderGoodsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOrderBusinessService iOrderBusinessService;
|
|
|
+ @Autowired
|
|
|
+ private IGoodsService iGoodsService;
|
|
|
+ @Autowired
|
|
|
+ private IClassGradeService iClassGradeService;
|
|
|
+ @Autowired
|
|
|
+ private IClassGradeUserService iClassGradeUserService;
|
|
|
+ @Autowired
|
|
|
+ private IClassGradeGoodsService iClassGradeGoodsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserService iUserService;
|
|
|
+
|
|
|
+ @Value("${aliyun.sms.OpenTheGoodsCode}")
|
|
|
+ private String OpenTheGoodsCode;
|
|
|
+
|
|
|
+ @Value("${aliyun.sms.informationNotificationCode}")
|
|
|
+ private String informationNotificationCode;
|
|
|
+
|
|
|
//3.添加定时任务
|
|
|
//@Scheduled(cron = "0/2 * * * * ?")
|
|
|
//或直接指定时间间隔,例如:5秒
|
|
|
- @Scheduled(fixedRate=5000)
|
|
|
+ @Scheduled(fixedRate = 5000)
|
|
|
private void configureTasks() {
|
|
|
- //List<Inform> informs = informService.selectTasks();
|
|
|
+ InformRemindVo informRemindVo = informRemindService.queryById(1L);
|
|
|
+ List<OrderGoodsVo> orderGoodsVo = iOrderGoodsService.selectOrderGoods();
|
|
|
+
|
|
|
+ InformRemindVo informRemindTwoVo = informRemindService.queryById(2L);
|
|
|
+ if (!CollectionUtils.isEmpty(orderGoodsVo)) {
|
|
|
+ for (OrderGoodsVo goodsVo : orderGoodsVo) {
|
|
|
+ ProfileTpVo profileTpVo = iProfileTpService.queryByGoodsId(goodsVo.getGoodsId());
|
|
|
+ if (informRemindVo.getWayStatus() == 1 && profileTpVo == null) {
|
|
|
+ InformUserAddBo informUserAddBo = new InformUserAddBo();
|
|
|
+ informUserAddBo.setUserId(goodsVo.getUserId());
|
|
|
+ informUserAddBo.setSendStatus(1);
|
|
|
+ informUserAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setRemindId(1L);
|
|
|
+ informUserAddBo.setSystemStatus(1);
|
|
|
+ informUserAddBo.setRemind("商品开通提醒");
|
|
|
+ informUserAddBo.setGoodsId(goodsVo.getGoodsId());
|
|
|
+ GoodsVo goodsVo1 = iGoodsService.queryById(goodsVo.getGoodsId());
|
|
|
+ informUserAddBo.setText("尊敬的用户:您购买的" + goodsVo1.getGoodsName() + "已经开通,请尽快去学习吧。");
|
|
|
+ iInformUserService.insertByAddBo(informUserAddBo);
|
|
|
+ }
|
|
|
+ if (informRemindTwoVo.getWayStatus() == 1 && profileTpVo != null) {
|
|
|
+ InformUserAddBo informUserAddBo = new InformUserAddBo();
|
|
|
+ informUserAddBo.setUserId(goodsVo.getUserId());
|
|
|
+ informUserAddBo.setSendTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setSendStatus(1);
|
|
|
+ informUserAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setRemindId(2L);
|
|
|
+ informUserAddBo.setSystemStatus(1);
|
|
|
+ informUserAddBo.setRemind("完善报名资料通知");
|
|
|
+ informUserAddBo.setGoodsId(goodsVo.getGoodsId());
|
|
|
+ GoodsVo goodsVo1 = iGoodsService.queryById(goodsVo.getGoodsId());
|
|
|
+ informUserAddBo.setText("尊敬的用户:已为您开通了" + goodsVo1.getGoodsName() + "课程,本课程需完善信息方可学习,请尽快去完善资料吧");
|
|
|
+ iInformUserService.insertByAddBo(informUserAddBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<OrderGoodsVo> orderGoodsTwoVo = iOrderGoodsService.selectOrderTwoGoods();
|
|
|
+ if (!CollectionUtils.isEmpty(orderGoodsTwoVo)) {
|
|
|
+ for (OrderGoodsVo goodsVo : orderGoodsTwoVo) {
|
|
|
+ ProfileTpVo profileTpVo = iProfileTpService.queryByGoodsId(goodsVo.getGoodsId());
|
|
|
+ if (informRemindVo.getNoteStatus() == 1 && profileTpVo == null) {
|
|
|
+ InformUserAddBo informUserAddBo = new InformUserAddBo();
|
|
|
+ informUserAddBo.setUserId(goodsVo.getUserId());
|
|
|
+ informUserAddBo.setSendTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setSendStatus(1);
|
|
|
+ informUserAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setRemindId(1L);
|
|
|
+ informUserAddBo.setSystemStatus(3);
|
|
|
+ informUserAddBo.setRemind("商品开通提醒");
|
|
|
+ informUserAddBo.setGoodsId(goodsVo.getGoodsId());
|
|
|
+ GoodsVo goodsVo1 = iGoodsService.queryById(goodsVo.getGoodsId());
|
|
|
+ informUserAddBo.setText("尊敬的用户:您购买的" + goodsVo1.getGoodsName() + "已经开通,请尽快去学习吧。");
|
|
|
+ iInformUserService.insertByAddBo(informUserAddBo);
|
|
|
+ UserVo userVo = iUserService.queryById(goodsVo.getUserId());
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("goods", goodsVo1.getGoodsName());
|
|
|
+ IAliSmsService.sendInformSms(userVo.getTelphone(), JSON.toJSONString(param), OpenTheGoodsCode);
|
|
|
+ }
|
|
|
+ if (informRemindTwoVo.getNoteStatus() == 1 && profileTpVo != null) {
|
|
|
+ InformUserAddBo informUserAddBo = new InformUserAddBo();
|
|
|
+ informUserAddBo.setUserId(goodsVo.getUserId());
|
|
|
+ informUserAddBo.setSendTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setSendStatus(1);
|
|
|
+ informUserAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ informUserAddBo.setRemindId(1L);
|
|
|
+ informUserAddBo.setSystemStatus(3);
|
|
|
+ informUserAddBo.setRemind("商品开通提醒");
|
|
|
+ informUserAddBo.setGoodsId(goodsVo.getGoodsId());
|
|
|
+ GoodsVo goodsVo1 = iGoodsService.queryById(goodsVo.getGoodsId());
|
|
|
+ informUserAddBo.setText("尊敬的用户:您购买的" + goodsVo1.getGoodsName() + "已经开通,请尽快去学习吧。");
|
|
|
+ iInformUserService.insertByAddBo(informUserAddBo);
|
|
|
+ UserVo userVo = iUserService.queryById(goodsVo.getUserId());
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("goods", goodsVo1.getGoodsName());
|
|
|
+ IAliSmsService.sendInformSms(userVo.getTelphone(), JSON.toJSONString(param), informationNotificationCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|