Beispiel #1
0
 /**
  * 天津时时彩数据包2解析数据
  * @return \yii\db\ActiveQuery
  */
 public function getAnalysisTjsscsData2()
 {
     return $this->hasOne(AnalysisTjssc::className(), ['tjssc_id' => 'id'])->where(['type' => 2]);
 }
Beispiel #2
0
 /**
  * 记录到 mysql
  */
 private function insert_mysql()
 {
     $exists = Tjssc::findOne(['qishu' => $this->data['qihao'], 'code' => $this->data['code']]);
     if ($exists) {
         exit("天津时时彩数据已经采集过了 时间:" . date('Y-m-d H:i:s') . "\r\n");
     }
     //开奖前三 号码
     $q3 = $this->data['code'][0] . $this->data['code'][1] . $this->data['code'][2];
     //开奖中三 号码
     $z3 = $this->data['code'][1] . $this->data['code'][2] . $this->data['code'][3];
     //后奖中三 号码
     $h3 = $this->data['code'][2] . $this->data['code'][3] . $this->data['code'][4];
     $this->analysisCode();
     list($q3_data1_lucky, $q3_data1_regert, $q3_data2_lucky, $q3_data2_regert) = $this->isLucky($q3);
     //前三中奖情况
     list($z3_data1_lucky, $z3_data1_regert, $z3_data2_lucky, $z3_data2_regert) = $this->isLucky($z3);
     //中三是否中奖
     list($h3_data1_lucky, $h3_data1_regert, $h3_data2_lucky, $h3_data2_regert) = $this->isLucky($h3);
     //侯三是否中奖
     //前三是组6还是组3
     $q3_type = $this->is_type($q3);
     //中三是组6还是组3
     $z3_type = $this->is_type($z3);
     //后三是组6还是组3
     $h3_type = $this->is_type($h3);
     //开启事物
     $innerTransaction = Yii::$app->db->beginTransaction();
     try {
         /* 插入 开奖记录表数据 */
         $tjsscModel = new Tjssc();
         $tjsscModel->qishu = $this->data['qihao'];
         $tjsscModel->one = $this->data['code'][0];
         $tjsscModel->two = $this->data['code'][1];
         $tjsscModel->three = $this->data['code'][2];
         $tjsscModel->four = $this->data['code'][3];
         $tjsscModel->five = $this->data['code'][4];
         $tjsscModel->code = $this->data['code'];
         $tjsscModel->front_three_type = $q3_type;
         $tjsscModel->center_three_type = $z3_type;
         $tjsscModel->after_three_type = $h3_type;
         $tjsscModel->kj_time = $this->data['kjsj'];
         $tjsscModel->time = time();
         $tjsscModel->save();
         /* 插入 开奖记录关联的 数据分析表 数据包1解析的结果 */
         $analysisTjsscModel = new AnalysisTjssc();
         $analysisTjsscModel->tjssc_id = $tjsscModel->id;
         $analysisTjsscModel->front_three_lucky_txt = $q3_data1_lucky;
         $analysisTjsscModel->front_three_regret_txt = $q3_data1_regert;
         $analysisTjsscModel->center_three_lucky_txt = $z3_data1_lucky;
         $analysisTjsscModel->center_three_regret_txt = $z3_data1_regert;
         $analysisTjsscModel->after_three_lucky_txt = $h3_data1_lucky;
         $analysisTjsscModel->after_three_regret_txt = $h3_data1_regert;
         $analysisTjsscModel->data_txt = $this->data_packet_txt;
         $analysisTjsscModel->type = 1;
         $analysisTjsscModel->time = time();
         $analysisTjsscModel->save();
         /* 插入 开奖记录关联的 数据分析表 数据包2解析的结果 */
         $analysisTjsscModel = new AnalysisTjssc();
         $analysisTjsscModel->tjssc_id = $tjsscModel->id;
         $analysisTjsscModel->front_three_lucky_txt = $q3_data2_lucky;
         $analysisTjsscModel->front_three_regret_txt = $q3_data2_regert;
         $analysisTjsscModel->center_three_lucky_txt = $z3_data2_lucky;
         $analysisTjsscModel->center_three_regret_txt = $z3_data2_regert;
         $analysisTjsscModel->after_three_lucky_txt = $h3_data2_lucky;
         $analysisTjsscModel->after_three_regret_txt = $h3_data2_regert;
         $analysisTjsscModel->data_txt = $this->data_packet_txt_2;
         $analysisTjsscModel->type = 2;
         $analysisTjsscModel->time = time();
         $analysisTjsscModel->save();
         $innerTransaction->commit();
         //事物提交
         $this->setLog(true, '天津时时彩数据抓取成功');
         echo "天津时时彩数据抓取成功 时间:" . date('Y-m-d H:i:s') . "\r\n";
     } catch (\Exception $e) {
         $innerTransaction->rollBack();
         $this->setLog(false, '天津时时彩数据与数据分析存入失败');
         exit("天津时时彩数据分析存入失败 时间:" . date('Y-m-d H:i:s') . "\r\n");
     }
 }