megachriz / afasprofit
用于连接 Afas Profit 的 PHP API。
3.2.0
2022-10-05 13:02 UTC
Requires
- php: >=7.3
- drupal/core-plugin: ^9.0|^10.0
- hanneskod/classtools: ~1.0
- openlss/lib-array2xml: ~0.0
- symfony/dependency-injection: >=4.4 <7.0.0
- symfony/finder: >=4.4 <7.0.0
Requires (Dev)
- kzykhys/php-csv-parser: ~1.4
- phpunit/phpunit: ~8.5
- symfony/event-dispatcher: >=4.4 <7.0.0
Suggests
- kzykhys/php-csv-parser: To use the getListFromCsv() method from the service 'afas.country.manager'.
- symfony/event-dispatcher: To react on Profit calls.
This package is not auto-updated.
Last update: 2024-09-24 17:41:40 UTC
README
用于连接 Afas Profit 的 PHP API。
功能
- 从 Profit GetConnectors 获取数据。
- 使用 Profit UpdateConnectors 插入、更新或删除 Profit 中的数据。
- 使用 Profit Subjectconnectors 从 Profit 获取文件。
- 使用 Profit DataConnector 获取 UpdateConnectors XML Schema。
用法
从 Profit 获取数据(GetConnector)
use Afas\Core\Server; // Initialize server. $server = new Server('https://12345.soap.afas.online/profitservices', 'ABCDEFGHIJK1234'); // Get data from GetConnector 'Products', filter by 'sku'. $products = $server->get('Products') ->filter('sku', '2612') ->execute() ->asArray();
将数据插入到 Profit 中(UpdateConnector)
use Afas\Core\Server; // Initialize server. $server = new Server('https://12345.soap.afas.online/profitservices', 'ABCDEFGHIJK1234'); // Insert an order into Profit. $server->insert('FbSales', [ 'OrNu' => 'test_001', 'DbId' => 123456, 'War' => 1, 'FbSalesLines' => [ [ 'ItCd' => 1201, 'QuUn' => 1, ], [ 'ItCd' => 1202, 'QuUn' => 1, ], ], ]) ->execute();
更新 Profit 中的数据(UpdateConnector)
use Afas\Core\Server; // Initialize server. $server = new Server('https://12345.soap.afas.online/profitservices', 'ABCDEFGHIJK1234'); // Update an existing order, change quantity of existing item. $server->update('FbSales', [ 'OrNu' => 'test_001', 'FbSalesLines' => [ [ 'GuLi' => '{6BA270E1-BFA7-4B67-86FF-72391A2CB5E3}', 'QuUn' => 2, ], ], ]) ->execute();
从 Profit 删除数据(UpdateConnector)
use Afas\Core\Server; // Initialize server. $server = new Server('https://12345.soap.afas.online/profitservices', 'ABCDEFGHIJK1234'); $server->delete('FbSales', [ 'OrNu' => 'test_001', ]) ->execute();
从 Profit 获取文件(SubjectConnector)
use Afas\Afas; use Afas\Core\Connector\SubjectConnector; use Afas\Core\Server; // Initialize server. $server = new Server('https://12345.soap.afas.online/profitservices', 'ABCDEFGHIJK1234'); // Create Soap client. /** @var \Afas\Component\Soap\SoapClientInterface $client */ $client = Afas::service('afas.soap_client_factory')->create($server); // Create SubjectConnector. $connector = new SubjectConnector($client, $server); // To get an attachment, pass a subject ID and a file ID. $attachment = $connector->getAttachment(300001, '8D36870843A516C2514D74BE69F87E15');
从 Profit 获取 Profit UpdateConnector 的 XML Schema(DataConnector)
use Afas\Afas; use Afas\Core\Connector\DataConnector; use Afas\Core\Server; // Initialize server. $server = new Server('https://12345.soap.afas.online/profitservices', 'ABCDEFGHIJK1234'); // Create Soap client. /** @var \Afas\Component\Soap\SoapClientInterface $client */ $client = Afas::service('afas.soap_client_factory')->create($server); // Create DataConnector. $connector = new DataConnector($client, $server); // Get schema. /** @var \Afas\Core\Result\DataConnectorResult $result */ $result = $connector->getXmlSchema('FbSales'); // Save complete schema. file_put_contents('FbSales.xsd', $result->asArray()[0]['Schema']); // Or save without custom fields. file_put_contents('FbSales.xsd', $result->removeCustomFieldsFromSchema()[0]['Schema']);