hfb.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace bank;
  3. //汇元宝
  4. class hfb implements IBank
  5. {
  6. private $mName;
  7. private $mNo;
  8. private $mBank;
  9. public function __construct()
  10. {
  11. $this->clear();
  12. }
  13. public function clear()
  14. {
  15. $this->mName = '汇元银通(北京)在线支付技术有限公司';
  16. $this->mNo = '210401354';
  17. $this->mBank = '汇元银通-备付金账户';
  18. }
  19. public function match($line): bool
  20. {
  21. $diff = array_diff(self::$format, $line);
  22. return empty($diff);
  23. }
  24. static $format = [
  25. 0 => '明细记录ID',
  26. 1 => '批次号',
  27. 2 => '商户内码',
  28. 3 => '持卡人',
  29. 4 => '收款卡号',
  30. 5 => '银行名称',
  31. 6 => '开户行名称',
  32. 7 => '商户流水号',
  33. 8 => '付款金额',
  34. 9 => '手续费',
  35. 10 => '付款状态',
  36. 11 => '审核状态',
  37. 12 => '付款创建时间',
  38. 13 => '备注说明',
  39. 14 => '处理说明'];
  40. public function convert($line): array
  41. {
  42. $trade_no = $line[0];
  43. $other_name = $line[3];
  44. $other_no = $line[4];
  45. $other_bank = $line[6];
  46. $out = mb_str_replace(['¥',','], '', $line[8]);
  47. $money_type = '人民币';
  48. $in = 0.00;
  49. $service_charge = mb_str_replace(['¥',','], '', $line[9]);
  50. if(trim($line[10]) !== '成功') {
  51. return [];
  52. }
  53. $trade_time = strtotime($line[12]);
  54. $remark = "$line[13]-$line[14]";
  55. $left = '';
  56. $subject = '';
  57. $post_date = '';
  58. $proof_type = '';
  59. $proof_no = '';
  60. $result = [
  61. 'trade_time' => $trade_time,
  62. 'out_amount' => $out,
  63. 'in_amount' => $in,
  64. 'left_amount' => $left,
  65. 'money_type' => $money_type,
  66. 'other_name' => $other_name,
  67. 'other_no' => $other_no,
  68. 'other_bank' => $other_bank,
  69. 'post_date' => $post_date,
  70. 'rsubject' => $subject,
  71. 'remark' => $remark,
  72. 'trade_no' => $trade_no,
  73. 'proof_type' => $proof_type,
  74. 'proof_no' => $proof_no,
  75. 'self_name' => $this->mName,
  76. 'self_no' => $this->mNo,
  77. 'self_bank' => $this->mBank,
  78. 'service_charge' => $service_charge
  79. ];
  80. return $result;
  81. }
  82. }