forked from Yara724/api
added offline inquiry in system setting also fix some bugs
This commit is contained in:
@@ -242,7 +242,7 @@ export class InquiryRefreshService {
|
||||
|
||||
if (inquiry.mapped?.Error) {
|
||||
this.recordPartyInquiry(inquiries, "thirdParty", role, false, {
|
||||
source: "TEJARAT_BLOCK_INQUIRY",
|
||||
source: inquiry.offline?.source ?? "TEJARAT_BLOCK_INQUIRY",
|
||||
raw: inquiry.raw,
|
||||
mapped: inquiry.mapped,
|
||||
});
|
||||
@@ -252,10 +252,18 @@ export class InquiryRefreshService {
|
||||
message: inquiry.mapped.Error.Message || "third-party inquiry error",
|
||||
};
|
||||
} else {
|
||||
nextParty = this.applyThirdPartyToParty(nextParty, inquiry.raw, inquiry.mapped);
|
||||
nextParty = this.applyThirdPartyToParty(
|
||||
nextParty,
|
||||
inquiry.raw,
|
||||
inquiry.mapped,
|
||||
{
|
||||
source: inquiry.offline?.source,
|
||||
fanavaranDriverId: inquiry.offline?.fanavaranDriverId,
|
||||
},
|
||||
);
|
||||
partyChanged = true;
|
||||
this.recordPartyInquiry(inquiries, "thirdParty", role, true, {
|
||||
source: "TEJARAT_BLOCK_INQUIRY",
|
||||
source: inquiry.offline?.source ?? "TEJARAT_BLOCK_INQUIRY",
|
||||
raw: inquiry.raw,
|
||||
mapped: inquiry.mapped,
|
||||
refreshedAt: new Date().toISOString(),
|
||||
@@ -343,21 +351,30 @@ export class InquiryRefreshService {
|
||||
party: Record<string, any>,
|
||||
raw: Record<string, any>,
|
||||
mapped: Record<string, any>,
|
||||
extras?: {
|
||||
source?: string;
|
||||
fanavaranDriverId?: number;
|
||||
},
|
||||
): Record<string, any> {
|
||||
const next = { ...party };
|
||||
next.vehicle = { ...(next.vehicle || {}) };
|
||||
next.insurance = { ...(next.insurance || {}) };
|
||||
next.person = { ...(next.person || {}) };
|
||||
|
||||
const existingCarBody = next.vehicle.inquiry?.carBody;
|
||||
|
||||
next.vehicle.inquiry = {
|
||||
source: "TEJARAT_BLOCK_INQUIRY",
|
||||
source: extras?.source ?? "TEJARAT_BLOCK_INQUIRY",
|
||||
raw,
|
||||
mapped,
|
||||
refreshedAt: new Date().toISOString(),
|
||||
...(existingCarBody ? { carBody: existingCarBody } : {}),
|
||||
};
|
||||
|
||||
if (extras?.fanavaranDriverId != null) {
|
||||
next.person.fanavaranDriverId = extras.fanavaranDriverId;
|
||||
}
|
||||
|
||||
const vehicleName = this.resolveVehicleName(mapped, raw);
|
||||
if (vehicleName) {
|
||||
next.vehicle.name = vehicleName;
|
||||
|
||||
@@ -1180,6 +1180,7 @@ export class RequestManagementService {
|
||||
// ---- External inquiry 1: Tejarat block inquiry ----
|
||||
let inquiryRaw: any;
|
||||
let inquiryMapped: any;
|
||||
let inquirySource = "TEJARAT_BLOCK_INQUIRY";
|
||||
const inquiryClientId = party.person?.clientId
|
||||
? String(party.person.clientId)
|
||||
: undefined;
|
||||
@@ -1196,6 +1197,9 @@ export class RequestManagementService {
|
||||
);
|
||||
inquiryRaw = inquiry.raw;
|
||||
inquiryMapped = inquiry.mapped;
|
||||
if (inquiry.offline?.source) {
|
||||
inquirySource = inquiry.offline.source;
|
||||
}
|
||||
this.logger.log(
|
||||
`[TEJARAT] block inquiry raw for request=${req._id}: ${JSON.stringify(inquiryRaw)}`,
|
||||
);
|
||||
@@ -1203,10 +1207,14 @@ export class RequestManagementService {
|
||||
`[TEJARAT] block inquiry mapped for request=${req._id}: ${JSON.stringify(inquiryMapped)}`,
|
||||
);
|
||||
this.recordPartyCaseInquiryStatus(req, "thirdParty", role, true, {
|
||||
source: "TEJARAT_BLOCK_INQUIRY",
|
||||
source: inquirySource,
|
||||
raw: inquiryRaw,
|
||||
mapped: inquiryMapped,
|
||||
});
|
||||
if (inquiry.offline?.fanavaranDriverId != null) {
|
||||
if (!party.person) party.person = {} as any;
|
||||
party.person.fanavaranDriverId = inquiry.offline.fanavaranDriverId;
|
||||
}
|
||||
} catch (err: any) {
|
||||
this.logger.error(
|
||||
`[TEJARAT] block inquiry failed for request=${req._id}: ${err?.message || err}`,
|
||||
@@ -1378,7 +1386,7 @@ export class RequestManagementService {
|
||||
party.vehicle.name = inquiryMapped?.MapTypNam;
|
||||
party.vehicle.type = `${inquiryMapped?.UsageField} / ${inquiryMapped?.MapUsageName || "-"}`;
|
||||
party.vehicle.inquiry = {
|
||||
source: "TEJARAT_BLOCK_INQUIRY",
|
||||
source: inquirySource,
|
||||
raw: inquiryRaw,
|
||||
mapped: inquiryMapped,
|
||||
};
|
||||
@@ -8546,6 +8554,7 @@ export class RequestManagementService {
|
||||
|
||||
let inquiryRaw: any;
|
||||
let inquiryMapped: any;
|
||||
let inquirySource = "TEJARAT_BLOCK_INQUIRY";
|
||||
try {
|
||||
const inquiry = await this.sandHubService.getTejaratBlockInquiry(
|
||||
{
|
||||
@@ -8556,11 +8565,18 @@ export class RequestManagementService {
|
||||
);
|
||||
inquiryRaw = inquiry.raw;
|
||||
inquiryMapped = inquiry.mapped;
|
||||
if (inquiry.offline?.source) {
|
||||
inquirySource = inquiry.offline.source;
|
||||
}
|
||||
this.recordPartyCaseInquiryStatus(req, "thirdParty", partyRole, true, {
|
||||
source: "TEJARAT_BLOCK_INQUIRY",
|
||||
source: inquirySource,
|
||||
raw: inquiryRaw,
|
||||
mapped: inquiryMapped,
|
||||
});
|
||||
if (inquiry.offline?.fanavaranDriverId != null) {
|
||||
if (!party.person) party.person = {} as any;
|
||||
party.person.fanavaranDriverId = inquiry.offline.fanavaranDriverId;
|
||||
}
|
||||
} catch (err: any) {
|
||||
this.logger.error(
|
||||
`[V3] plate inquiry failed for ${roleLabel} party (request=${req._id}): ${err?.message || err}`,
|
||||
@@ -8623,7 +8639,7 @@ export class RequestManagementService {
|
||||
party.vehicle.name = inquiryMapped?.MapTypNam;
|
||||
party.vehicle.type = `${inquiryMapped?.UsageField ?? ""} / ${inquiryMapped?.UsageName ?? inquiryMapped?.MapUsageName ?? "-"}`;
|
||||
party.vehicle.inquiry = {
|
||||
source: "TEJARAT_BLOCK_INQUIRY",
|
||||
source: inquirySource,
|
||||
raw: inquiryRaw,
|
||||
mapped: inquiryMapped,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user