コード例 #1
0
ファイル: Codeold.php プロジェクト: aiyeyun/grab
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAnalysisolds()
 {
     return $this->hasOne(Analysisold::className(), ['code_id' => 'id']);
 }
コード例 #2
0
ファイル: GrabOld.php プロジェクト: aiyeyun/grab
 private function find($qihao, $urlName, $code, $code_id)
 {
     //数据分析
     $config = Configure::findOne(['type' => 2]);
     //旧时时彩 系统报警配置
     $model = Comparison::findOne(['type' => 2]);
     //旧时时彩 数据本
     $data = $model->txt;
     //记录中奖与未中奖号码
     $dataTxts = str_replace("\r\n", ' ', $data);
     //将回车转换为空格
     $dataArr = explode(' ', $dataTxts);
     $dataArr = array_filter($dataArr);
     //将中奖号码前三 后三
     $codeTxts = str_replace(" ", '', $code);
     $qian3 = $codeTxts[0] . $codeTxts[1] . $codeTxts[2];
     $center3 = $codeTxts[1] . $codeTxts[2] . $codeTxts[3];
     $hou3 = $codeTxts[2] . $codeTxts[3] . $codeTxts[4];
     $qian3 = intval($qian3);
     $center3 = intval($center3);
     $hou3 = intval($hou3);
     //当前开奖号码 对比 数据库
     $qian3_lucky = array();
     $qian3_regret = $dataArr;
     $center3_lucky = array();
     $center3_regret = $dataArr;
     $hou3_lucky = array();
     $hou3_regret = $dataArr;
     foreach ($dataArr as $key => $val) {
         //前三对比
         if (intval($val) == $qian3) {
             array_push($qian3_lucky, $val);
             // 添加到前三中奖数据里
             unset($qian3_regret[$key]);
         }
         //中三对比
         if (intval($val) == $center3) {
             array_push($center3_lucky, $val);
             // 添加到前三中奖数据里
             unset($center3_regret[$key]);
         }
         //后三对比
         if (intval($val) == $hou3) {
             array_push($hou3_lucky, $val);
             // 添加到后三中奖数据里
             unset($hou3_regret[$key]);
         }
     }
     //分析的数据转换成 上传数据本的格式
     $qian3_lucky_txt = null;
     foreach ($qian3_lucky as $key => $val) {
         $qian3_lucky_txt .= $val . "\r\n";
     }
     $qian3_regret_txt = null;
     foreach ($qian3_regret as $key => $val) {
         $qian3_regret_txt .= $val . "\r\n";
     }
     $center3_lucky_txt = null;
     foreach ($center3_lucky as $key => $val) {
         $center3_lucky_txt .= $val . "\r\n";
     }
     $center3_regret_txt = null;
     foreach ($center3_regret as $key => $val) {
         $center3_regret_txt .= $val . "\r\n";
     }
     $hou3_lucky_txt = null;
     foreach ($hou3_lucky as $key => $val) {
         $hou3_lucky_txt .= $val . "\r\n";
     }
     $hou3_regret_txt = null;
     foreach ($hou3_regret as $key => $val) {
         $hou3_regret_txt .= $val . "\r\n";
     }
     //分析后的数据 存入数据库
     $analysisold = new Analysisold();
     $analysisold->code_id = $code_id;
     $analysisold->front_three_lucky_txt = $qian3_lucky_txt;
     $analysisold->front_three_regret_txt = $qian3_regret_txt;
     $analysisold->center_three_lucky_txt = $center3_lucky_txt;
     $analysisold->center_three_regret_txt = $center3_regret_txt;
     $analysisold->after_three_lucky_txt = $hou3_lucky_txt;
     $analysisold->after_three_regret_txt = $hou3_regret_txt;
     $analysisold->data_txt = $data;
     $analysisold->time = time();
     $analysisold->save();
     $config = Configure::findOne(['type' => 2]);
     //旧时时彩 系统报警配置
     if ($config->state == 1) {
         //系统开启邮件 通知
         if (date('H', time()) > intval($config->start_time) && date('H', time()) < intval($config->end_time)) {
             //            if(true ) {
             //报警时间段内
             if ($config->forever == 1) {
                 //每一期 邮件通知打开
                 $cfg = array('type' => 1, 'qihao' => $qihao, 'code' => $code, 'urlName' => $urlName, 'qian3_lucky_txt' => $qian3_lucky_txt, 'qian3_regret_txt' => $qian3_regret_txt, 'center3_lucky_txt' => $center3_lucky_txt, 'center3_regret_txt' => $center3_regret_txt, 'hou3_lucky_txt' => $hou3_lucky_txt, 'hou3_regret_txt' => $hou3_regret_txt);
                 $this->send($cfg);
             }
             // 用户设置 几期都未中奖 报警通知
             $NewestCodes = Codeold::find()->orderBy('time DESC')->limit($config->regret_number)->all();
             if (count($NewestCodes) == $config->regret_number) {
                 $codeQian3Lucky = true;
                 $codeCenter3Lucky = true;
                 $codeHou3Lucky = true;
                 $q3_number = 0;
                 $c3_number = 0;
                 $h3_number = 0;
                 foreach ($NewestCodes as $codeold) {
                     if (!empty($codeold->analysisolds->front_three_lucky_txt)) {
                         //前三有中奖
                         $codeQian3Lucky = false;
                         $q3_number += 1;
                     }
                     if (!empty($codeold->analysisolds->center_three_lucky_txt)) {
                         //中三有中奖
                         $codeCenter3Lucky = false;
                         $c3_number += 1;
                     }
                     if (!empty($codeold->analysisolds->after_three_lucky_txt)) {
                         //后三有中奖
                         $codeHou3Lucky = false;
                         $h3_number += 1;
                     }
                 }
                 if ($codeQian3Lucky || $codeHou3Lucky) {
                     //发送报警通知 当前 $config->regret_number 内 都未中奖
                     $cfg = array('type' => 2, 'regret_number' => $config->regret_number, 'NewestCodes' => $NewestCodes, 'q3' => $q3_number, 'c3' => $c3_number, 'h3' => $h3_number);
                     $this->send($cfg);
                 }
             }
         }
     }
 }