'交易时间', 1 => '借方发生额/元(支取)', 2 => '贷方发生额/元(收入)', 3 => '余额', 4 => '币种', 5 => '对方户名', 6 => '对方账号', 7 => '对方开户机构', 8 => '记账日期', 9 => '摘要', 10 => '备注', 11 => '账户明细编号-交易流水号', 12 => '企业流水号', 13 => '凭证种类', 14 => '凭证号', 15 => '交易介质编号' ]; public function __construct() { $this->clear(); } public function clear() { $this->mKnown = 0; $this->mName = ''; $this->mNo = ''; $this->mBank = ''; } public function match($line) : bool { if(count(self::$format) != count($line)) { return false; } if($this->mKnown != 2) { if($line[0] == '账  号' && $line[2] == '账户名称') { $this->mNo = number_format($line[1],0,'.',''); $this->mName = $line[3]; $this->mKnown += 1; } elseif ($line[0] == '开户行名称') { $this->mBank = $line[1]; if($line[1] == '中国建设银行股份有限公司北京傲城支行') { $this->mNo = '11050160990000000237'; } $this->mKnown += 1; } } $diff = array_diff(self::$format,$line); return empty($diff); } public function convert($line) : array { $trade_time = strtotime($line[0]); if($trade_time == false) { return []; } $out = mb_str_replace(',','',$line[1]); $in = mb_str_replace(',','',$line[2]); $left = mb_str_replace(',','',$line[3]); $money_type = $line[4]; $other_name = $line[5]; $other_no = $line[6]; $other_bank = $line[7]; $post_date = $line[8]; $subject = $line[9]; $remark = $line[10]; $trade_no = $line[11]; $proof_type = $line[13]; $proof_no = $line[14]; $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; } }