123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- namespace bank;
- //招商银行
- class cmbcex implements IBank
- {
- private $mKnown;
- private $mName;
- private $mNo;
- private $mBank;
- 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[3] == '账号名称') {
- $this->mName = $line[4];
- $this->mKnown += 1;
- }
- elseif ($line[6] == '银行账号')
- {
- $this->mNo = $line[7];
- if($this->mNo == '110946610810701') {
- $this->mBank = '招商银行北苑路支行';
- }
- elseif ($this->mNo == '110945155010101') {
- $this->mBank = '招商银行北苑路支行';
- }
- $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 => '流程实例号',
- 13 => '业务名称',
- 14 => '业务参考号',
- 15 => '业务摘要',
- 16 => '其它摘要',
- 17 => '收(付)方分行名',
- 18 => '收(付)方名称',
- 19 => '收(付)方账号',
- 20 => '收(付)方开户行行号',
- 21 => '收(付)方开户行名',
- 22 => '收(付)方开户行地址',
- 23 => '母(子)公司账号分行名',
- 24 => '母(子)公司账号',
- 25 => '母(子)公司名称',
- 26 => '信息标志',
- 27 => '有否附件信息',
- 28 => '冲账标志',
- 29 => '扩展摘要',
- 30 => '交易分析码',
- 31 => '票据号',
- 32 => '商务支付订单号',
- 33 => '内部编号',
- 34 => '公司一卡通号'
- ];
- public function convert($line): array
- {
- $money_type = $line[2];
- $trade_time = strtotime($line[3] . ' ' . sprintf("%06d",intval($line[4])));
- if($trade_time == false) {
- return [];
- }
- $out = mb_str_replace(',', '', $line[7]);
- $in = mb_str_replace(',', '', $line[8]);
- $left = mb_str_replace(',', '', $line[9]);
- $subject = $line[10];
- $trade_no = $line[11];
- $other_name = $line[18];
- $other_no = $line[29];
- $other_bank = $line[21];
- $remark = '';
- $proof_no = '';
- $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;
- }
- }
|