/** * 记录到 mysql */ private function insert_mysql() { $exists = Xjssc::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 { /* 插入 开奖记录表数据 */ $xjsscModel = new Xjssc(); $xjsscModel->qishu = $this->data['qihao']; $xjsscModel->one = $this->data['code'][0]; $xjsscModel->two = $this->data['code'][1]; $xjsscModel->three = $this->data['code'][2]; $xjsscModel->four = $this->data['code'][3]; $xjsscModel->five = $this->data['code'][4]; $xjsscModel->code = $this->data['code']; $xjsscModel->front_three_type = $q3_type; $xjsscModel->center_three_type = $z3_type; $xjsscModel->after_three_type = $h3_type; $xjsscModel->kj_time = $this->data['kjsj']; $xjsscModel->time = time(); $xjsscModel->save(); /* 插入 开奖记录关联的 数据分析表 数据包1解析的结果 */ $analysisXjsscModel = new AnalysisXjssc(); $analysisXjsscModel->xjssc_id = $xjsscModel->id; $analysisXjsscModel->front_three_lucky_txt = $q3_data1_lucky; $analysisXjsscModel->front_three_regret_txt = $q3_data1_regert; $analysisXjsscModel->center_three_lucky_txt = $z3_data1_lucky; $analysisXjsscModel->center_three_regret_txt = $z3_data1_regert; $analysisXjsscModel->after_three_lucky_txt = $h3_data1_lucky; $analysisXjsscModel->after_three_regret_txt = $h3_data1_regert; $analysisXjsscModel->data_txt = $this->data_packet_txt; $analysisXjsscModel->type = 1; $analysisXjsscModel->time = time(); $analysisXjsscModel->save(); /* 插入 开奖记录关联的 数据分析表 数据包1解析的结果 */ $analysisXjsscModel = new AnalysisXjssc(); $analysisXjsscModel->xjssc_id = $xjsscModel->id; $analysisXjsscModel->front_three_lucky_txt = $q3_data2_lucky; $analysisXjsscModel->front_three_regret_txt = $q3_data2_regert; $analysisXjsscModel->center_three_lucky_txt = $z3_data2_lucky; $analysisXjsscModel->center_three_regret_txt = $z3_data2_regert; $analysisXjsscModel->after_three_lucky_txt = $h3_data2_lucky; $analysisXjsscModel->after_three_regret_txt = $h3_data2_regert; $analysisXjsscModel->data_txt = $this->data_packet_txt_2; $analysisXjsscModel->type = 2; $analysisXjsscModel->time = time(); $analysisXjsscModel->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"); } }
/** * 新疆时时彩数据包2解析数据 * @return \yii\db\ActiveQuery */ public function getAnalysisXjsscsData2() { return $this->hasOne(AnalysisXjssc::className(), ['xjssc_id' => 'id'])->where(['type' => 2]); }