chalcedonyt / laravel-cos-processor
提供上传 COS(支票外包服务)文件的功能。
dev-master / 1.0.x-dev
2016-10-31 01:23 UTC
Requires
- php: ~5.5|~7.0
- illuminate/support: ~5.1
Requires (Dev)
- fzaninotto/faker: ~1.4
- illuminate/database: ~5.1
- illuminate/filesystem: ~5.1
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~4.0||~5.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is not auto-updated.
Last update: 2024-09-14 19:47:31 UTC
README
COS(支票外包服务)处理辅助函数。根据支付条目生成文件。目前支持大华银行和汇丰银行。请查看 documentation/ 目录下的原始文件。
安装
通过 Composer
$ composer require chalcedonyt/laravel-cos-processor
创建适配器
创建一个实现 Chalcedonyt\\COSProcessor\\Adapter\\BeneficiaryAdapterInterface
接口的适配器。这应该将你的模型转换为将用于 COS 条目的属性。参考 Chalcedonyt\\COSProcessor\\Adapter\\ExampleBeneficiaryAdapter
作为一个例子。
配置
php artisan vendor:publish
应该会将 cos_processor.php
发布到配置文件夹。使用账户的配置选项编辑此文件。将 "beneficiary_adapter"
更改为之前创建的适配器的类。
使用 - 生成上传文件
调用相关的 COSUploadProcessorFactory 子类,并传入你的数据和配置键。
$beneficiaries = TestPayment::all(); $cos = HSBCCOSUploadProcessorFactory::createCsvString($beneficiaries, 'cos_processor.hsbc_example'); echo $cos;
使用 - 处理汇丰银行的结果文件
汇丰银行 COS 将返回一个包含 COS 上传结果的 csv 文件。请参考 tests/ifile_result.csv
作为一个例子。你可以使用以下代码将该文件处理成 COSResult
数组
//the first line is the Header $handle = fopen( __DIR__ ."/ifile_result.csv", "r"); $index = 0; $results = []; while (($line = fgets($handle)) !== false) { if( $index++ !== 0){ $adapter = new HSBCCOSResultAdapter($line); $results[] = $adapter -> getCosResult(); } } fclose($handle);
许可证
MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件。