PHP code example of shengya / kingdee

1. Go to this page and download the library: Download shengya/kingdee library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shengya / kingdee example snippets




use Shengya\Kingdee\Config\KingdeeConfig;
use Shengya\Kingdee\KingdeeClient;
use Shengya\Kingdee\Recorder\NullCallRecorder;

$config = new KingdeeConfig([
    'enabled' => true,
    'base_url' => 'https://kingdee.example.com/K3Cloud/',
    'account_set' => 'your-account-set',
    'username' => 'your-api-user',
    'password' => 'your-api-password',
    'lcid' => 2052,
    'timeout' => 60,
    'connect_timeout' => 10,
    'auth' => [
        'format' => 1,
        'user_agent' => 'ShengyaKingdeeSdk',
        'version' => '1.0',
    ],
    'endpoints' => [
        'login' => 'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc',
        'query' => 'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc',
        'view' => 'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc',
        'save' => 'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc',
        'submit' => 'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit.common.kdsvc',
        'audit' => 'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit.common.kdsvc',
    ],
    'query' => ['limit' => 1000, 'start_row' => 0],
    'retry' => ['max_attempts' => 2, 'delay_ms' => 300],
]);

// 空记录器适合无框架示例;生产环境应注入日志或数据库记录器。
$client = new KingdeeClient($config, new NullCallRecorder());
$rows = $client->query('BD_Customer', ['FCUSTID', 'FNumber', 'FName'])->rows();



return [
    'sdk' => [
        // 连接、账套、认证、端点、分页和重试配置。
    ],
    'operations' => [
        // 业务单据 FormId 及转换规则。
    ],
    'base_data' => [
        // 组织、客户、物料等 14 类 FormId。
    ],
    'base_data_storage' => [
        // 连接、分表、同步批次表和分页条数。
    ],
    'records' => [
        // 调用记录连接、表名和降级日志通道。
    ],
    'documents' => [
        'connection' => 'mysql',
        'tables' => [
            'invoice_applications' => 'kd_invoice_applications',
            'invoice_application_lines' => 'kd_invoice_application_lines',
            'receipts' => 'kd_receipts',
            'deferred_income_applications' => 'kd_deferred_income_applications',
            'deferred_income_application_lines' => 'kd_deferred_income_application_lines',
        ],
    ],
    'sensitive_keys' => [
        'password', 'token', 'authorization', 'cookie', 'bankaccount', 'mobile',
    ],
];



use Shengya\Kingdee\Contracts\KingdeeClientInterface;

final class CustomerService
{
    private $kingdee;

    public function __construct(KingdeeClientInterface $kingdee)
    {
        $this->kingdee = $kingdee;
    }

    public function customers(): array
    {
        return $this->kingdee
            ->query('BD_Customer', ['FCUSTID', 'FNumber', 'FName'])
            ->rows();
    }
}
bash
php artisan vendor:publish \
  --provider="Shengya\\KingdeeLaravel\\KingdeeServiceProvider" \
  --tag=kingdee-migrations