clear(); } public function clear() { $this->mKnown = 0; $this->mName = ''; $this->mNo = ''; $this->mBank = ''; } public function match($line): bool { if ($this->mKnown != 2) { if ($line[0] == '账号') { $this->mNo = number_format($line[1], 0, '.', ''); if($this->mNo == '91160078801900002501') { $this->mBank = '上海浦东发展银行北京亚运村支行'; } elseif($this->mNo == '91160078801200002500') { $this->mBank = '上海浦东发展银行北京亚运村支行'; } $this->mKnown += 1; } elseif ($line[0] == '账户名称') { $this->mName = $line[1]; $this->mKnown += 1; } } $diff = array_diff(self::$format, $line); return empty($diff); } static $format = [ 0 => '交易日期', 1 => '交易时间', 2 => '申请日期', 3 => '凭证号', 4 => '借方金额', 5 => '贷方金额', 6 => '余额', 7 => '对方账号', 8 => '对方户名', 9 => '对方行名', 10 => '交易流水号', 11 => '摘要', 12 => '备注']; public function convert($line): array { $trade_time = strtotime($line[0] . ' ' . sprintf("%06d",intval($line[1]))); if($trade_time == false) { return []; } $proof_no = $line[3]; $out = mb_str_replace(',', '', $line[4]); $in = mb_str_replace(',', '', $line[5]); $left = mb_str_replace(',', '', $line[6]); $other_no = $line[7]; $other_name = $line[8]; $other_bank = $line[9]; $trade_no = $line[10]; $subject = $line[11]; $remark = $line[12]; $money_type = ''; $post_date = ''; $proof_type = ''; $result = [ 'trade_time' => $trade_time, 'out_amount' => $out, 'in_amount' => $in, 'left_amount' => $left, 'money_type' => $money_type, 'other_name' => $other_name, 'other_no' => $other_no, 'other_bank' => $other_bank, 'post_date' => $post_date, 'rsubject' => $subject, 'remark' => $remark, 'trade_no' => $trade_no, 'proof_type' => $proof_type, 'proof_no' => $proof_no, 'self_name' => $this->mName, 'self_no' => $this->mNo, 'self_bank' => $this->mBank, 'service_charge' => 0.0 ]; return $result; } }