Files
lotteryLaravel/app/Services/Integration/PartnerSiteConfig.php
kang 1e7b2b31ee feat: enhance reconciliation job processing and reporting features
- Updated ReconcileItemIndexController to include admin user validation and improved transfer order handling.
- Refactored ReconcileJobStoreController to ensure date range handling is more precise with start and end of day adjustments.
- Enhanced various report controllers to include currency code in responses for better financial clarity.
- Introduced new methods in AdminReconcileJobService for wallet transfer job creation and improved item scanning logic.
- Added wallet lookup idempotent path configuration for integration services to enhance API interactions.
2026-06-16 13:50:55 +08:00

86 lines
3.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Services\Integration;
/**
* 运行时主站接入配置(由库表或 legacy env 解析而来)。
*/
final readonly class PartnerSiteConfig
{
public const SOURCE_DATABASE = 'database';
public const SOURCE_LEGACY_ENV = 'legacy_env';
public function __construct(
public string $siteCode,
public bool $enabled,
public ?string $walletApiUrl,
public string $walletDebitPath,
public string $walletCreditPath,
public string $walletBalancePath,
public string $walletLookupIdempotentPath,
public ?string $ssoJwtSecret,
public ?string $walletApiKey,
public int $walletTimeoutSeconds,
public string $source,
) {}
public function hasWalletApi(): bool
{
return is_string($this->walletApiUrl) && trim($this->walletApiUrl) !== '';
}
public function hasSsoSecret(): bool
{
return is_string($this->ssoJwtSecret) && $this->ssoJwtSecret !== '';
}
/**
* 可安全写入 Cache 的数组形态(避免 readonly 对象序列化产生 __PHP_Incomplete_Class
*
* @return array<string, mixed>
*/
public function toCacheArray(): array
{
return [
'site_code' => $this->siteCode,
'enabled' => $this->enabled,
'wallet_api_url' => $this->walletApiUrl,
'wallet_debit_path' => $this->walletDebitPath,
'wallet_credit_path' => $this->walletCreditPath,
'wallet_balance_path' => $this->walletBalancePath,
'wallet_lookup_idempotent_path' => $this->walletLookupIdempotentPath,
'sso_jwt_secret' => $this->ssoJwtSecret,
'wallet_api_key' => $this->walletApiKey,
'wallet_timeout_seconds' => $this->walletTimeoutSeconds,
'source' => $this->source,
];
}
/**
* @param array<string, mixed> $data
*/
public static function fromCacheArray(array $data): self
{
return new self(
siteCode: (string) ($data['site_code'] ?? ''),
enabled: (bool) ($data['enabled'] ?? false),
walletApiUrl: isset($data['wallet_api_url']) && is_string($data['wallet_api_url']) && $data['wallet_api_url'] !== ''
? $data['wallet_api_url']
: null,
walletDebitPath: (string) ($data['wallet_debit_path'] ?? '/wallet/debit-for-lottery'),
walletCreditPath: (string) ($data['wallet_credit_path'] ?? '/wallet/credit-from-lottery'),
walletBalancePath: (string) ($data['wallet_balance_path'] ?? '/wallet/balance'),
walletLookupIdempotentPath: (string) ($data['wallet_lookup_idempotent_path'] ?? '/wallet/lookup-idempotent'),
ssoJwtSecret: isset($data['sso_jwt_secret']) && is_string($data['sso_jwt_secret']) && $data['sso_jwt_secret'] !== ''
? $data['sso_jwt_secret']
: null,
walletApiKey: isset($data['wallet_api_key']) && is_string($data['wallet_api_key']) && $data['wallet_api_key'] !== ''
? $data['wallet_api_key']
: null,
walletTimeoutSeconds: max(1, (int) ($data['wallet_timeout_seconds'] ?? 10)),
source: (string) ($data['source'] ?? self::SOURCE_DATABASE),
);
}
}