clear(); } public function clear() { $this->mKnown = false; $this->mName = ''; $this->mNo = ''; $this->mBank = ''; } public function match($line) : bool { if(count(self::$format) != count($line)) { return false; } if($this->mKnown == false) { if($line[0] == '查询账号:' && $line[2] == '户 名:') { $this->mNo = number_format($line[1],0,'.',''); $this->mName = $line[3]; $this->mKnown = true; } } $diff = array_diff(self::$format,$line); return empty($diff); } static $format = [ 0 => '交易时间', 1 => '摘要', 2 => '凭证种类', 3 => '凭证号码', 4 => '企业业务编号', 5 => '发生额', 6 => '币种', 7 => '余额', 8 => '对方账号', 9 => '对方户名', 10 => '对方行名', 11 => '借贷标志', 12 => '卡号', 13 => '核心流水号' ]; public function convert($line) : array { $trade_time = strtotime($line[0]); if($trade_time == false) { return []; } $subject = $line[1]; $proof_type = $line[2]; $proof_no = $line[3]; if($line[11] === '贷') { $in = mb_str_replace(',','',$line[5]); $out = '0'; } else { $out = mb_str_replace(',','',$line[5]); $in = 0; } $money_type = $line[6]; $left = mb_str_replace(',','',$line[7]); $other_no = $line[8]; $other_name = $line[9]; $other_bank = $line[10]; $post_date = ''; $trade_no = $line[13]; $remark = ''; $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; } }