|
@@ -104,25 +104,8 @@ public class LiveCompletionPointsTask {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- processCompletionByWatchDuration(activeLives, (liveId, userId, duration) -> {
|
|
|
|
|
- LiveCompletionCouponNotifyResult notifyResult =
|
|
|
|
|
- completionCouponService.prepareCompletionCouponNotify(liveId, userId, duration);
|
|
|
|
|
- if (notifyResult == null || !notifyResult.isShouldNotify()) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- String bizName = resolveCompletionCouponBizName(notifyResult);
|
|
|
|
|
- Long bizId = notifyResult.getCoupon() != null ? notifyResult.getCoupon().getCouponId() : null;
|
|
|
|
|
- LiveConsoleOpLog opLog = liveConsoleOpLogService.saveLog(
|
|
|
|
|
- liveId,
|
|
|
|
|
- LiveConsoleOpLog.OP_COMPLETION_COUPON,
|
|
|
|
|
- LiveConsoleOpLog.HANDLE_AUTO,
|
|
|
|
|
- bizId,
|
|
|
|
|
- bizName
|
|
|
|
|
- );
|
|
|
|
|
- if (pushCompletionCouponQuestion(liveId, userId, notifyResult, opLog)) {
|
|
|
|
|
- completionCouponService.markCompletionCouponNotified(liveId, userId);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ processCompletionByWatchDuration(activeLives, (liveId, userId, duration) ->
|
|
|
|
|
+ dispatchCompletionCouponNotify(liveId, userId, duration, false));
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("检查完课优惠券定时任务执行失败", e);
|
|
log.error("检查完课优惠券定时任务执行失败", e);
|
|
@@ -139,21 +122,50 @@ public class LiveCompletionPointsTask {
|
|
|
if (notifyResult == null || !notifyResult.isShouldNotify()) {
|
|
if (notifyResult == null || !notifyResult.isShouldNotify()) {
|
|
|
return R.ok("当前无需推送弹窗").put("data", notifyResult);
|
|
return R.ok("当前无需推送弹窗").put("data", notifyResult);
|
|
|
}
|
|
}
|
|
|
- boolean pushed = pushCompletionCouponQuestion(liveId, userId, notifyResult);
|
|
|
|
|
- if (pushed) {
|
|
|
|
|
- completionCouponService.markCompletionCouponNotified(liveId, userId);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ LiveConsoleOpLog opLog = saveAndPushCompletionCouponNotify(liveId, userId, notifyResult);
|
|
|
|
|
+ boolean pushed = opLog != null;
|
|
|
return pushed
|
|
return pushed
|
|
|
- ? R.ok("今日问题弹窗 WebSocket 推送成功").put("data", notifyResult).put("pushed", true)
|
|
|
|
|
- : R.error("用户未在线,WebSocket 推送失败").put("data", notifyResult).put("pushed", false);
|
|
|
|
|
|
|
+ ? R.ok("今日问题弹窗 WebSocket 推送成功")
|
|
|
|
|
+ .put("data", notifyResult)
|
|
|
|
|
+ .put("pushed", true)
|
|
|
|
|
+ .put("opLogId", opLog.getId())
|
|
|
|
|
+ : R.error("用户未在线,WebSocket 推送失败")
|
|
|
|
|
+ .put("data", notifyResult)
|
|
|
|
|
+ .put("pushed", false);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("手动触发完课优惠券弹窗失败, liveId={}, userId={}", liveId, userId, e);
|
|
log.error("手动触发完课优惠券弹窗失败, liveId={}, userId={}", liveId, userId, e);
|
|
|
return R.error("触发失败:" + e.getMessage());
|
|
return R.error("触发失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private boolean pushCompletionCouponQuestion(Long liveId, Long userId, LiveCompletionCouponNotifyResult notifyResult) {
|
|
|
|
|
- return pushCompletionCouponQuestion(liveId, userId, notifyResult, null);
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 完课优惠券弹窗:与定时任务一致,先写留存再推送 WebSocket
|
|
|
|
|
+ */
|
|
|
|
|
+ private LiveConsoleOpLog dispatchCompletionCouponNotify(Long liveId, Long userId, Long watchDuration, boolean forcePush) {
|
|
|
|
|
+ LiveCompletionCouponNotifyResult notifyResult =
|
|
|
|
|
+ completionCouponService.prepareCompletionCouponNotify(liveId, userId, watchDuration, forcePush);
|
|
|
|
|
+ if (notifyResult == null || !notifyResult.isShouldNotify()) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return saveAndPushCompletionCouponNotify(liveId, userId, notifyResult);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private LiveConsoleOpLog saveAndPushCompletionCouponNotify(Long liveId, Long userId,
|
|
|
|
|
+ LiveCompletionCouponNotifyResult notifyResult) {
|
|
|
|
|
+ String bizName = resolveCompletionCouponBizName(notifyResult);
|
|
|
|
|
+ Long bizId = notifyResult.getCoupon() != null ? notifyResult.getCoupon().getCouponId() : null;
|
|
|
|
|
+ LiveConsoleOpLog opLog = liveConsoleOpLogService.saveLog(
|
|
|
|
|
+ liveId,
|
|
|
|
|
+ LiveConsoleOpLog.OP_COMPLETION_COUPON,
|
|
|
|
|
+ LiveConsoleOpLog.HANDLE_AUTO,
|
|
|
|
|
+ bizId,
|
|
|
|
|
+ bizName
|
|
|
|
|
+ );
|
|
|
|
|
+ if (pushCompletionCouponQuestion(liveId, userId, notifyResult, opLog)) {
|
|
|
|
|
+ completionCouponService.markCompletionCouponNotified(liveId, userId);
|
|
|
|
|
+ return opLog;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean pushCompletionCouponQuestion(Long liveId, Long userId, LiveCompletionCouponNotifyResult notifyResult,
|
|
private boolean pushCompletionCouponQuestion(Long liveId, Long userId, LiveCompletionCouponNotifyResult notifyResult,
|