bcm.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace bank;
  3. //交通银行
  4. class bcm 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. $this->mKnown = false;
  16. $this->mName = '';
  17. $this->mNo = '';
  18. $this->mBank = '';
  19. }
  20. public function match($line) : bool
  21. {
  22. if(count(self::$format) != count($line)) {
  23. return false;
  24. }
  25. if($this->mKnown == false)
  26. {
  27. if($line[0] == '查询账号:' && $line[2] == '户 名:') {
  28. $this->mNo = number_format($line[1],0,'.','');
  29. $this->mName = $line[3];
  30. $this->mKnown = true;
  31. }
  32. }
  33. $diff = array_diff(self::$format,$line);
  34. return empty($diff);
  35. }
  36. static $format = [
  37. 0 => '交易时间',
  38. 1 => '摘要',
  39. 2 => '凭证种类',
  40. 3 => '凭证号码',
  41. 4 => '企业业务编号',
  42. 5 => '发生额',
  43. 6 => '币种',
  44. 7 => '余额',
  45. 8 => '对方账号',
  46. 9 => '对方户名',
  47. 10 => '对方行名',
  48. 11 => '借贷标志',
  49. 12 => '卡号',
  50. 13 => '核心流水号'
  51. ];
  52. public function convert($line) : array
  53. {
  54. $trade_time = strtotime($line[0]);
  55. if($trade_time == false) {
  56. return [];
  57. }
  58. $subject = $line[1];
  59. $proof_type = $line[2];
  60. $proof_no = $line[3];
  61. if($line[11] === '贷') {
  62. $in = mb_str_replace(',','',$line[5]);
  63. $out = '0';
  64. } else {
  65. $out = mb_str_replace(',','',$line[5]);
  66. $in = 0;
  67. }
  68. $money_type = $line[6];
  69. $left = mb_str_replace(',','',$line[7]);
  70. $other_no = $line[8];
  71. $other_name = $line[9];
  72. $other_bank = $line[10];
  73. $post_date = '';
  74. $trade_no = $line[13];
  75. $remark = '';
  76. $result = [
  77. 'trade_time' => $trade_time,
  78. 'out_amount' => $out,
  79. 'in_amount' => $in,
  80. 'left_amount' => $left,
  81. 'money_type' => $money_type,
  82. 'other_name' => $other_name,
  83. 'other_no' => $other_no,
  84. 'other_bank' => $other_bank,
  85. 'post_date' => $post_date,
  86. 'rsubject' => $subject,
  87. 'remark' => $remark,
  88. 'trade_no' => $trade_no,
  89. 'proof_type' => $proof_type,
  90. 'proof_no' => $proof_no,
  91. 'self_name' => $this->mName,
  92. 'self_no' => $this->mNo,
  93. 'self_bank' => $this->mBank,
  94. 'service_charge' => 0.0
  95. ];
  96. return $result;
  97. }
  98. }