123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- namespace bank;
- //建设银行
- class ccb implements IBank
- {
- private $mKnown;
- private $mName;
- private $mNo;
- private $mBank;
- static $format = [
- 0 => '交易时间',
- 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;
- }
- }
|