cmbc28.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. namespace bank;
  3. //招商银行
  4. class cmbc28 implements IBank
  5. {
  6. private $mKnown;
  7. private $mName;
  8. private $mNo;
  9. private $mBank;
  10. public function __construct()
  11. {
  12. $this->clear();
  13. }
  14. public function clear()
  15. {
  16. $this->mKnown = 0;
  17. $this->mName = '';
  18. $this->mNo = '';
  19. $this->mBank = '';
  20. }
  21. public function match($line): bool
  22. {
  23. if(count(self::$format) != count($line)) {
  24. return false;
  25. }
  26. if ($this->mKnown != 2)
  27. {
  28. if ($line[0] == '标题' && $line[3] == '账号名称') {
  29. $this->mName = $line[4];
  30. $this->mKnown += 1;
  31. }
  32. elseif ($line[6] == '银行账号')
  33. {
  34. $this->mNo = $line[7];
  35. if($this->mNo == '110946610810701') {
  36. $this->mBank = '招商银行北苑路支行';
  37. }
  38. elseif ($this->mNo == '110945155010101') {
  39. $this->mBank = '招商银行北苑路支行';
  40. }
  41. $this->mKnown += 1;
  42. }
  43. }
  44. $diff = array_diff(self::$format, $line);
  45. return empty($diff);
  46. }
  47. static $format = [
  48. 0 => '账号',
  49. 1 => '账号名称',
  50. 2 => '币种',
  51. 3 => '交易日',
  52. 4 => '交易时间',
  53. 5 => '起息日',
  54. 6 => '交易类型',
  55. 7 => '借方金额',
  56. 8 => '贷方金额',
  57. 9 => '余额',
  58. 10 => '用途',
  59. 11 => '流水号',
  60. 12 => '收(付)方名称',
  61. 13 => '收(付)方账号',
  62. 14 => '收(付)方开户行行号',
  63. 15 => '收(付)方开户行名',
  64. 16 => '收(付)方开户行地址',
  65. 17 => '母(子)公司账号分行名',
  66. 18 => '母(子)公司账号',
  67. 19 => '母(子)公司名称',
  68. 20 => '信息标志',
  69. 21 => '有否附件信息',
  70. 22 => '冲账标志',
  71. 23 => '扩展摘要',
  72. 24 => '交易分析码',
  73. 25 => '票据号',
  74. 26 => '商务支付订单号',
  75. 27 => '内部编号',
  76. 28 => '公司一卡通号'
  77. ];
  78. public function convert($line): array
  79. {
  80. $money_type = $line[2];
  81. $trade_time = strtotime($line[3] . ' ' . sprintf("%06d",intval($line[4])));
  82. if($trade_time == false) {
  83. return [];
  84. }
  85. $out = mb_str_replace(',', '', $line[7]);
  86. $in = mb_str_replace(',', '', $line[8]);
  87. $left = mb_str_replace(',', '', $line[9]);
  88. $subject = $line[10];
  89. $trade_no = $line[11];
  90. $other_name = $line[12];
  91. $other_no = $line[13];
  92. $other_bank = $line[15];
  93. $remark = '';
  94. $proof_no = '';
  95. $post_date = '';
  96. $proof_type = '';
  97. $result = [
  98. 'trade_time' => $trade_time,
  99. 'out_amount' => $out,
  100. 'in_amount' => $in,
  101. 'left_amount' => $left,
  102. 'money_type' => $money_type,
  103. 'other_name' => $other_name,
  104. 'other_no' => $other_no,
  105. 'other_bank' => $other_bank,
  106. 'post_date' => $post_date,
  107. 'rsubject' => $subject,
  108. 'remark' => $remark,
  109. 'trade_no' => $trade_no,
  110. 'proof_type' => $proof_type,
  111. 'proof_no' => $proof_no,
  112. 'self_name' => $this->mName,
  113. 'self_no' => $this->mNo,
  114. 'self_bank' => $this->mBank,
  115. 'service_charge' => 0.0
  116. ];
  117. return $result;
  118. }
  119. }