spdb.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace bank;
  3. //浦发银行
  4. class spdb 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 ($this->mKnown != 2)
  24. {
  25. if ($line[0] == '账号') {
  26. $this->mNo = number_format($line[1], 0, '.', '');
  27. if($this->mNo == '91160078801900002501') {
  28. $this->mBank = '上海浦东发展银行北京亚运村支行';
  29. }
  30. elseif($this->mNo == '91160078801200002500') {
  31. $this->mBank = '上海浦东发展银行北京亚运村支行';
  32. }
  33. $this->mKnown += 1;
  34. }
  35. elseif ($line[0] == '账户名称') {
  36. $this->mName = $line[1];
  37. $this->mKnown += 1;
  38. }
  39. }
  40. $diff = array_diff(self::$format, $line);
  41. return empty($diff);
  42. }
  43. static $format = [
  44. 0 => '交易日期',
  45. 1 => '交易时间',
  46. 2 => '申请日期',
  47. 3 => '凭证号',
  48. 4 => '借方金额',
  49. 5 => '贷方金额',
  50. 6 => '余额',
  51. 7 => '对方账号',
  52. 8 => '对方户名',
  53. 9 => '对方行名',
  54. 10 => '交易流水号',
  55. 11 => '摘要',
  56. 12 => '备注'];
  57. public function convert($line): array
  58. {
  59. $trade_time = strtotime($line[0] . ' ' . sprintf("%06d",intval($line[1])));
  60. if($trade_time == false) {
  61. return [];
  62. }
  63. $proof_no = $line[3];
  64. $out = mb_str_replace(',', '', $line[4]);
  65. $in = mb_str_replace(',', '', $line[5]);
  66. $left = mb_str_replace(',', '', $line[6]);
  67. $other_no = $line[7];
  68. $other_name = $line[8];
  69. $other_bank = $line[9];
  70. $trade_no = $line[10];
  71. $subject = $line[11];
  72. $remark = $line[12];
  73. $money_type = '';
  74. $post_date = '';
  75. $proof_type = '';
  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. }