forked from Yara724/api
added offline inquiry in system setting also fix some bugs
This commit is contained in:
@@ -15,6 +15,8 @@ import { ExternalInquirySettingsService } from "src/client/external-inquiry-sett
|
||||
import { PlateNormalizerService } from "src/utils/plate-normalizer/plate-normalizer.service";
|
||||
import type { ExternalInquiryType } from "src/common/types/external-inquiry.types";
|
||||
import type { MockInquiryCompanyContext } from "src/common/types/external-inquiry.types";
|
||||
import { OfflineInquiryService } from "src/offline-inquiry/offline-inquiry.service";
|
||||
import { resolveFanavaranClientKey } from "src/core/config/fanavaran-client.config";
|
||||
import { SandHubDetailDto, SandHubInquiryOptions } from "./dto/sand-hub.dto";
|
||||
import { jalaliToGregorianDate } from "src/helpers/date-jalali";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
@@ -41,6 +43,7 @@ export class SandHubService {
|
||||
private readonly sandHubDbService: SandHubDbService,
|
||||
private readonly externalInquirySettings: ExternalInquirySettingsService,
|
||||
private readonly plateNormalizer: PlateNormalizerService,
|
||||
private readonly offlineInquiryService: OfflineInquiryService,
|
||||
) {}
|
||||
|
||||
private clientRefFrom(options?: SandHubInquiryOptions): string | undefined {
|
||||
@@ -731,6 +734,7 @@ export class SandHubService {
|
||||
/**
|
||||
* Tejarat block inquiry (replaces SandHub call for V2 flows).
|
||||
* Returns both raw + mapped (old-format) response.
|
||||
* Offline seeded hits (per Fanavaran clientKey) are checked first.
|
||||
*/
|
||||
async getTejaratBlockInquiry(
|
||||
userDetail: SandHubDetailDto,
|
||||
@@ -738,7 +742,34 @@ export class SandHubService {
|
||||
): Promise<{
|
||||
raw: any;
|
||||
mapped: any;
|
||||
offline?: {
|
||||
source: string;
|
||||
fanavaranDriverId?: number;
|
||||
insurance?: Record<string, unknown>;
|
||||
person?: Record<string, unknown>;
|
||||
};
|
||||
}> {
|
||||
const offlineHit = await this.offlineInquiryService.findPlateInquiry({
|
||||
clientKey: resolveFanavaranClientKey(),
|
||||
nationalCode: String(userDetail.nationalCodeOfInsurer),
|
||||
leftDigits: String(userDetail.plate.leftDigits),
|
||||
centerAlphabet: String(userDetail.plate.centerAlphabet),
|
||||
centerDigits: String(userDetail.plate.centerDigits),
|
||||
ir: String(userDetail.plate.ir),
|
||||
});
|
||||
if (offlineHit) {
|
||||
return {
|
||||
raw: offlineHit.raw,
|
||||
mapped: offlineHit.mapped,
|
||||
offline: {
|
||||
source: offlineHit.source,
|
||||
fanavaranDriverId: offlineHit.fanavaranDriverId,
|
||||
insurance: offlineHit.insurance,
|
||||
person: offlineHit.person,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const ctx = await this.mockCompanyContext(options);
|
||||
if (this.shouldUseEsgInquiryProvider()) {
|
||||
const baseUrl = process.env.ESG_URL ?? "http://192.168.20.22:8085";
|
||||
|
||||
Reference in New Issue
Block a user