<commit_before>import BlueBirdPromise = require('bluebird');
import {INotificationService} from "./INotificationService";
import {LotteryDbService} from "../dbservices/ORMService";

import moment  = require('moment');
import {Config, CONFIG_CONST} from "../../config/Config";
import {EmailSender} from "../email/EmailSender";
import {TimeService} from "../time/TimeService";
import {InvestInfo} from "../../models/db/InvestInfo";
import {CONST_INVEST_TABLE} from "../../models/db/CONST_INVEST_TABLE";
import {CONST_INVEST_TOTAL_TABLE} from "../../models/db/CONST_INVEST_TOTAL_TABLE";
import {RuntimeConfig} from "../../config/RuntimeConfig";


let log4js = require('log4js'),
    log = log4js.getLogger('NotificationService');

/**
 *
 * 通知配置类
 */
class NotificationConfig {
    //数据库中 当天已经保存的最新的投注期号 用于不重复发送通知邮件
    public static lastedRealInvestPeriod: string = null;
    //数据库中 当天第一条记录的投注期号 用于不重复发送通知邮件
    public static todayFirstRealInvestPeriod: string = null;
    //数据库中 达到利润预警值的投注期号 用于不重复发送通知邮件
    public static todayMaxOrMinProfitInvestPeriod: string = null;
}

/**
 *
 * 消息通知服务
 */
export class NotificationService implements INotificationService {

    /**
     *
     * 间隔2分钟检查是否需要发送通知  入口方法
     */
    public start(): void {
        //5分钟检查一次是否需要发送通知
        setInterval(() => {

            //当天第1期错误提醒
            this.sendTodayFirstErrorWarnEmail()
                .catch((err) => {
                    if (err) {
                        log.error("当天第1期错误提醒邮件通知异常");
                        log.error(err);
                    }
                });
            //多个邮件同时发送需要设置间隔，否则上面的邮件无法正常发送
            setTimeout(() => {
                //连错2期提醒
                this.sendContinueWinOrLoseWarnEmail(2, false)
                    .catch((err) => {
                        if (err) {
                            log.error("连错2期提醒邮件通知异常");
                            log.error(err);
                        }
                    });
            }, 10000);
            setTimeout(() => {
                //最大最小利润预警
                this.sendMaxOrMinProfitNotification()
                    .catch((err) => {
                        if (err) {
                            log.error("最大最小利润预警邮件通知异常");
                            log.error(err);
                        }
                    });
            }, 10000);

        }, 120000);
    }

    /**
     *
     * 达到指定利润发送预警邮件
     */
    public async sendMaxOrMinProfitNotification(): BlueBirdPromise<any> {
        //当天
        let today: string = moment().format("YYYY-MM-DD");
        let historyData: Array<InvestInfo> = await LotteryDbService.getInvestInfoHistory(CONFIG_CONST.currentSelectedInvestPlanType, 1, today + " 10:00:00");
        if (!historyData || historyData.length == 0) return BlueBirdPromise.resolve(false);

        let emailTitle: string = "方案【" + CONFIG_CONST.currentSelectedInvestPlanType + "】最高最低利润预警";
        //当前账号余额
        let currentAccountBalance: number = historyData[0].currentAccountBalance;
<commit_msg>移除多余的通知项<commit_after>import BlueBirdPromise = require('bluebird');
import {INotificationService} from "./INotificationService";
import {LotteryDbService} from "../dbservices/ORMService";

import moment  = require('moment');
import {Config, CONFIG_CONST} from "../../config/Config";
import {EmailSender} from "../email/EmailSender";
import {TimeService} from "../time/TimeService";
import {InvestInfo} from "../../models/db/InvestInfo";
import {CONST_INVEST_TABLE} from "../../models/db/CONST_INVEST_TABLE";
import {CONST_INVEST_TOTAL_TABLE} from "../../models/db/CONST_INVEST_TOTAL_TABLE";
import {RuntimeConfig} from "../../config/RuntimeConfig";


let log4js = require('log4js'),
    log = log4js.getLogger('NotificationService');

/**
 *
 * 通知配置类
 */
class NotificationConfig {
    //数据库中 当天已经保存的最新的投注期号 用于不重复发送通知邮件
    public static lastedRealInvestPeriod: string = null;
    //数据库中 当天第一条记录的投注期号 用于不重复发送通知邮件
    public static todayFirstRealInvestPeriod: string = null;
    //数据库中 达到利润预警值的投注期号 用于不重复发送通知邮件
    public static todayMaxOrMinProfitInvestPeriod: string = null;
}

/**
 *
 * 消息通知服务
 */
export class NotificationService implements INotificationService {

    /**
     *
     * 间隔2分钟检查是否需要发送通知  入口方法
     */
    public start(): void {
        //5分钟检查一次是否需要发送通知
        setInterval(() => {

            // //当天第1期错误提醒
            // this.sendTodayFirstErrorWarnEmail()
            //     .catch((err) => {
            //         if (err) {
            //             log.error("当天第1期错误提醒邮件通知异常");
            //             log.error(err);
            //         }
            //     });
            //多个邮件同时发送需要设置间隔，否则上面的邮件无法正常发送
            setTimeout(() => {
                //连错2期提醒
                this.sendContinueWinOrLoseWarnEmail(2, false)
                    .catch((err) => {
                        if (err) {
                            log.error("连错2期提醒邮件通知异常");
                            log.error(err);
                        }
                    });
            }, 100);
            setTimeout(() => {
                //最大最小利润预警
                this.sendMaxOrMinProfitNotification()
                    .catch((err) => {
                        if (err) {
                            log.error("最大最小利润预警邮件通知异常");
                            log.error(err);
                        }
                    });
            }, 10000);

        }, 120000);
    }

    /**
     *
     * 达到指定利润发送预警邮件
     */
    public async sendMaxOrMinProfitNotification(): BlueBirdPromise<any> {
        //当天
        let today: string = moment().format("YYYY-MM-DD");
        let historyData: Array<InvestInfo> = await LotteryDbService.getInvestInfoHistory(CONFIG_CONST.currentSelectedInvestPlanType, 1, today + " 10:00:00");
        if (!historyData || historyData.length == 0) return BlueBirdPromise.resolve(false);

        let emailTitle: string = "方案【" + CONFIG_CONST.currentSelectedInvestPlanType + "】最高最低利润预警";
        //当前账号余额
        let currentAccountBalance: number = historyData[0].currentAccountBalance;

{'fraction_non_alphanumeric': 0.12452392780261633, 'fraction_numerical': 0.011260142407683391, 'mean_word_length': 1.8477133427628478, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '927987', 'n_tokens_mistral': 2062, 'n_tokens_neox': 2110, 'n_words': 302}