|
|
@@ -1,6 +1,7 @@
|
|
|
package com.fs.course.task;
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
@@ -274,51 +275,76 @@ public class VideoTask {
|
|
|
* 补发完课积分
|
|
|
*/
|
|
|
public void reissueFinishVideoIntegral() {
|
|
|
- //查询发送奖励方式
|
|
|
String json = configService.selectConfigByKey("course.config");
|
|
|
- if (StringUtils.isNotBlank(json)) {
|
|
|
- CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
- if (config != null) {
|
|
|
- Integer rewardType = config.getRewardType();
|
|
|
- if (rewardType != null && rewardType == 2) {
|
|
|
- List<FsCourseWatchLog> watchingLogs = courseWatchLogMapper.findWatchLogsIdExitAndFinish();
|
|
|
- if (watchingLogs != null && !watchingLogs.isEmpty()) {
|
|
|
- //查询积分记录 是否存在
|
|
|
- for (FsCourseWatchLog watchingLog : watchingLogs) {
|
|
|
- FsUserIntegralLogs queryParam = new FsUserIntegralLogs();
|
|
|
- queryParam.setUserId(watchingLog.getUserId());
|
|
|
- queryParam.setBusinessId(watchingLog.getLogId().toString());
|
|
|
- queryParam.setLogType(FsUserIntegralLogTypeEnum.TYPE_17.getValue());
|
|
|
- //查询积分记录 是否存在
|
|
|
- Long num = fsUserIntegralLogsMapper.selectFsUserIntegralLogsListCOUNT(queryParam);
|
|
|
- if (num == null || num == 0){
|
|
|
- try {
|
|
|
- FsCourseSendRewardUParam param = new FsCourseSendRewardUParam();
|
|
|
- param.setIsAuto(1);
|
|
|
- param.setVideoId(watchingLog.getVideoId());
|
|
|
- param.setQwUserId(watchingLog.getQwUserId().toString());
|
|
|
- param.setCompanyUserId(watchingLog.getCompanyUserId());
|
|
|
- param.setCompanyId(watchingLog.getCompanyId());
|
|
|
- param.setCourseId(watchingLog.getCourseId());
|
|
|
- param.setQwExternalId(watchingLog.getQwExternalContactId());
|
|
|
- param.setSource(watchingLog.getWatchType() == 2?2:1);
|
|
|
- param.setSendType(watchingLog.getSendType());
|
|
|
- param.setPeriodId(watchingLog.getPeriodId());
|
|
|
- param.setUserId(watchingLog.getUserId());
|
|
|
- param.setAppId("");
|
|
|
- courseVideoService.sendRewardByFsUser(param);
|
|
|
- log.info("补发积分 userId:{},watchLogsId:{}",watchingLog.getUserId(),watchingLog.getLogId());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("补发积分失败 userId:{},watchLogsId:{}",watchingLog.getUserId(),watchingLog.getLogId());
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ if (StringUtils.isBlank(json)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
+ if (config == null || config.getRewardType() == null || config.getRewardType() != 2) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FsCourseWatchLog> watchingLogs = courseWatchLogMapper.findWatchLogsIdExitAndFinish();
|
|
|
+ if (watchingLogs == null || watchingLogs.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ log.info("补发完课积分开始,待处理数量:{}", watchingLogs.size());
|
|
|
+
|
|
|
+ int successCount = 0;
|
|
|
+ int skipCount = 0;
|
|
|
+ int failCount = 0;
|
|
|
+ for (FsCourseWatchLog watchingLog : watchingLogs) {
|
|
|
+ if (watchingLog.getUserId() == null || watchingLog.getLogId() == null || watchingLog.getVideoId() == null) {
|
|
|
+ skipCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 看课记录上 reward_type 非空表示已发放过奖励,直接跳过
|
|
|
+ if (watchingLog.getRewardType() != null) {
|
|
|
+ skipCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ FsUserIntegralLogs queryParam = new FsUserIntegralLogs();
|
|
|
+ queryParam.setUserId(watchingLog.getUserId());
|
|
|
+ queryParam.setBusinessId(watchingLog.getLogId().toString());
|
|
|
+ queryParam.setLogType(FsUserIntegralLogTypeEnum.TYPE_17.getValue());
|
|
|
+ Long num = fsUserIntegralLogsMapper.selectFsUserIntegralLogsListCOUNT(queryParam);
|
|
|
+ if (num != null && num > 0) {
|
|
|
+ skipCount++;
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
+ try {
|
|
|
+ FsCourseSendRewardUParam param = new FsCourseSendRewardUParam();
|
|
|
+ param.setIsAuto(1);
|
|
|
+ param.setVideoId(watchingLog.getVideoId());
|
|
|
+ param.setQwUserId(watchingLog.getQwUserId() != null ? watchingLog.getQwUserId().toString() : null);
|
|
|
+ param.setCompanyUserId(watchingLog.getCompanyUserId());
|
|
|
+ param.setCompanyId(watchingLog.getCompanyId());
|
|
|
+ param.setCourseId(watchingLog.getCourseId());
|
|
|
+ param.setQwExternalId(watchingLog.getQwExternalContactId());
|
|
|
+ param.setSource(watchingLog.getWatchType() != null && watchingLog.getWatchType() == 2 ? 2 : 1);
|
|
|
+ param.setSendType(watchingLog.getSendType());
|
|
|
+ param.setPeriodId(watchingLog.getPeriodId());
|
|
|
+ param.setUserId(watchingLog.getUserId());
|
|
|
+ param.setAppId("");
|
|
|
+ R result = courseVideoService.sendRewardByFsUser(param);
|
|
|
+ Object code = result != null ? result.get("code") : null;
|
|
|
+ Object msg = result != null ? result.get("msg") : null;
|
|
|
+ if (code != null && "200".equals(code.toString())) {
|
|
|
+ successCount++;
|
|
|
+ log.info("补发积分成功 userId:{},watchLogsId:{},msg:{}", watchingLog.getUserId(), watchingLog.getLogId(), msg);
|
|
|
+ } else {
|
|
|
+ failCount++;
|
|
|
+ log.warn("补发积分未发放 userId:{},watchLogsId:{},code:{},msg:{}",
|
|
|
+ watchingLog.getUserId(), watchingLog.getLogId(), code, msg);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ failCount++;
|
|
|
+ log.error("补发积分异常 userId:{},watchLogsId:{}", watchingLog.getUserId(), watchingLog.getLogId(), e);
|
|
|
+ }
|
|
|
}
|
|
|
+ log.info("补发完课积分结束,成功:{},跳过:{},失败:{}", successCount, skipCount, failCount);
|
|
|
}
|
|
|
|
|
|
}
|