From b1be5b1e0913ecad4742dd9cdf73375288e6b3b6 Mon Sep 17 00:00:00 2001 From: "s.yahyaee" Date: Tue, 17 Mar 2026 18:53:47 +0330 Subject: [PATCH] Disabled Inquiry --- .../request-management.service.ts | 34 ++-- src/sand-hub/sand-hub.service.ts | 159 +++++++++++++++++- 2 files changed, 169 insertions(+), 24 deletions(-) diff --git a/src/request-management/request-management.service.ts b/src/request-management/request-management.service.ts index ce82201..2b42af3 100644 --- a/src/request-management/request-management.service.ts +++ b/src/request-management/request-management.service.ts @@ -750,12 +750,12 @@ export class RequestManagementService { let inquiryRaw: any; let inquiryMapped: any; try { - // const inquiry = await this.sandHubService.getTejaratBlockInquiry({ - // plate: body.plate, - // nationalCodeOfInsurer: body.nationalCodeOfInsurer, - // }); - // inquiryRaw = inquiry.raw; - // inquiryMapped = inquiry.mapped; + const inquiry = await this.sandHubService.getTejaratBlockInquiry({ + plate: body.plate, + nationalCodeOfInsurer: body.nationalCodeOfInsurer, + }); + inquiryRaw = inquiry.raw; + inquiryMapped = inquiry.mapped; this.logger.log( `[TEJARAT] block inquiry raw for request=${req._id}: ${JSON.stringify(inquiryRaw)}`, ); @@ -1664,10 +1664,10 @@ export class RequestManagementService { // TODO: Activate // --- Proceed with existing logic if the check passes --- // 1) Main third-party/block inquiry (existing behavior) - // const sanHubResponse = await this.sandHubService.getSandHubResponse({ - // plate: body.plate, - // nationalCodeOfInsurer: body.nationalCodeOfInsurer, - // }); + const sanHubResponse = await this.sandHubService.getSandHubResponse({ + plate: body.plate, + nationalCodeOfInsurer: body.nationalCodeOfInsurer, + }); // if (sanHubResponse.Error) { // throw new HttpException( @@ -1696,13 +1696,13 @@ export class RequestManagementService { // ); // } - // return await this.addPlate( - // sanHubResponse, - // request, - // user, - // body, - // isFirstParty ? "firstParty" : "secondParty", - // ); + return await this.addPlate( + sanHubResponse, + request, + user, + body, + isFirstParty ? "firstParty" : "secondParty", + ); } async carBodyFormStep( diff --git a/src/sand-hub/sand-hub.service.ts b/src/sand-hub/sand-hub.service.ts index 3cf40cb..72a4cf9 100644 --- a/src/sand-hub/sand-hub.service.ts +++ b/src/sand-hub/sand-hub.service.ts @@ -183,7 +183,79 @@ export class SandHubService { }; const requestUrl = `${baseUrl}/block-inquiry-tejarat`; - const raw = await this.makeTejaratRequest(requestUrl, requestPayload); + // const raw = await this.makeTejaratRequest(requestUrl, requestPayload); + const raw = { + "PrntPlcyCmpDocNo": "1403/1143-70591/200/35", + "MapTypNam": "پرايد هاچ بک -111", + "MtrNum": "5215907", + "ShsNum": "NAS431100E5798656", + "DisFnYrNum": "0", + "DisLfYrNum": "0", + "DisPrsnYrNum": "0", + "DisPrsnYrPrcnt": "0", + "DisFnYrPrcnt": "0", + "DisLfYrPrcnt": "0", + "vin": "IRPC941V2BD798656", + "MapVehicleSystemName": "ثبت نشده", + "LfCvrCptl": 0, + "FnCvrCptl": 0, + "PrsnCvrCptl": 0, + "VehicleSystemCode": 1, + "EdrsJson": "[{\"id\":1,\"Dsc\":\" الحاقيه توضيحات ندارد\"}]", + "PersonCvrCptl": 12000000000, + "LifeCvrCptl": 16000000000, + "FinancialCvrCptl": 4000000000, + "CarGroupCode": 3, + "CylCnt": 4, + "LastCompanyDocumentNumber": "03/1031/2835/1001/662", + "UsageCode": "8", + "MapUsageCode": 1, + "MapUsageName": "شخصي", + "Plk1": 59, + "Plk2": 16, + "Plk3": 419, + "PlkSrl": 78, + "PrintEndorsCompanyDocumentNumber": "بيمه نامه الحاقيه ندارد.", + "EndorseDate": null, + "InsuranceFullName": null, + "SystemField": "سايپا", + "TypeField": "111SE", + "UsageField": "سواري", + "MainColorField": "سفيد", + "SecondColorField": "سفيد شيري", + "ModelField": "1394", + "CapacityField": "جمعا 4 نفر", + "CylinderNumberField": "4", + "EngineNumberField": "5215907", + "ChassisNumberField": "NAS431100E5798656", + "VinNumberField": "IRPC941V2BD798656", + "InstallDateField": "1403/03/01", + "AxelNumberField": "2", + "WheelNumberField": "4", + "CompanyName": "بیمه سامان", + "CompanyCode": "15", + "IssueDate": "1403/04/06", + "SatrtDate": "1403/04/06", + "EndDate": "1404/04/06", + "Thrname": "", + "EndorseText": null, + "PolicyHealthLossCount": 0, + "PolicyFinancialLossCount": 0, + "PolicyPersonLossCount": 0, + "Tonage": 0, + "ThirdPolicyCode": 10502330579, + "DiscountPersonPercent": null, + "DiscountThirdPercent": null, + "SystemCodeCii": 0, + "SystemNameCii": "ثبت نشده", + "TypeCodeCii": 12189, + "TypeNameCii": "پرايد هاچ بک -111", + "UsageNameCii": "سواري", + "UsageCodeCii": 1, + "ModelCii": 1394, + "damageTypes": [], + "StatusTypeCode": 1 + } const mapped = this.mapNewApiResponseToOldFormat(raw); return { raw, mapped }; } @@ -293,15 +365,88 @@ export class SandHubService { rightTwoDigits: String(userDetail.plate.ir), nationalCode: userDetail.nationalCodeOfInsurer, }; - const requestUrl = `${process.env.SANDHUB_BASE_URL}/block-inquiry-tejarat`; - const response = await this.makeSandHubRequest(requestUrl, requestPayload); + // const requestUrl = `${process.env.SANDHUB_BASE_URL}/block-inquiry-tejarat`; + // const response = await this.makeSandHubRequest(requestUrl, requestPayload); + + let response = { + "PrntPlcyCmpDocNo": "1403/1143-70591/200/35", + "MapTypNam": "پرايد هاچ بک -111", + "MtrNum": "5215907", + "ShsNum": "NAS431100E5798656", + "DisFnYrNum": "0", + "DisLfYrNum": "0", + "DisPrsnYrNum": "0", + "DisPrsnYrPrcnt": "0", + "DisFnYrPrcnt": "0", + "DisLfYrPrcnt": "0", + "vin": "IRPC941V2BD798656", + "MapVehicleSystemName": "ثبت نشده", + "LfCvrCptl": 0, + "FnCvrCptl": 0, + "PrsnCvrCptl": 0, + "VehicleSystemCode": 1, + "EdrsJson": "[{\"id\":1,\"Dsc\":\" الحاقيه توضيحات ندارد\"}]", + "PersonCvrCptl": 12000000000, + "LifeCvrCptl": 16000000000, + "FinancialCvrCptl": 4000000000, + "CarGroupCode": 3, + "CylCnt": 4, + "LastCompanyDocumentNumber": "03/1031/2835/1001/662", + "UsageCode": "8", + "MapUsageCode": 1, + "MapUsageName": "شخصي", + "Plk1": 59, + "Plk2": 16, + "Plk3": 419, + "PlkSrl": 78, + "PrintEndorsCompanyDocumentNumber": "بيمه نامه الحاقيه ندارد.", + "EndorseDate": null, + "InsuranceFullName": null, + "SystemField": "سايپا", + "TypeField": "111SE", + "UsageField": "سواري", + "MainColorField": "سفيد", + "SecondColorField": "سفيد شيري", + "ModelField": "1394", + "CapacityField": "جمعا 4 نفر", + "CylinderNumberField": "4", + "EngineNumberField": "5215907", + "ChassisNumberField": "NAS431100E5798656", + "VinNumberField": "IRPC941V2BD798656", + "InstallDateField": "1403/03/01", + "AxelNumberField": "2", + "WheelNumberField": "4", + "CompanyName": "بیمه سامان", + "CompanyCode": "15", + "IssueDate": "1403/04/06", + "SatrtDate": "1403/04/06", + "EndDate": "1404/04/06", + "Thrname": "", + "EndorseText": null, + "PolicyHealthLossCount": 0, + "PolicyFinancialLossCount": 0, + "PolicyPersonLossCount": 0, + "Tonage": 0, + "ThirdPolicyCode": 10502330579, + "DiscountPersonPercent": null, + "DiscountThirdPercent": null, + "SystemCodeCii": 0, + "SystemNameCii": "ثبت نشده", + "TypeCodeCii": 12189, + "TypeNameCii": "پرايد هاچ بک -111", + "UsageNameCii": "سواري", + "UsageCodeCii": 1, + "ModelCii": 1394, + "damageTypes": [], + "StatusTypeCode": 1 + } - // Map the new API response format to the old format + // // Map the new API response format to the old format let result = this.mapNewApiResponseToOldFormat(response); - if (result.usgCod !== "8") { - throw new Error("خودرو شما شخصی / سواری نمی باشد") - } + // if (result.usgCod !== "8") { + // throw new Error("خودرو شما شخصی / سواری نمی باشد") + // } return result; } catch (err) {