parent
acecd3bef4
commit
c592310fa9
|
|
@ -15,20 +15,20 @@ export class SyncTmsJob implements IJob {
|
||||||
logger: ILogger;
|
logger: ILogger;
|
||||||
|
|
||||||
@Inject()
|
@Inject()
|
||||||
logisticsService: LogisticsService;
|
logisticsService: LogisticsService;
|
||||||
|
|
||||||
@InjectEntityModel(Shipment)
|
@InjectEntityModel(Shipment)
|
||||||
shipmentModel: Repository<Shipment>
|
shipmentModel: Repository<Shipment>
|
||||||
|
|
||||||
async onTick() {
|
async onTick() {
|
||||||
const shipments:Shipment[] = await this.shipmentModel.findBy({ tracking_provider: 'freightwaves',finished: false });
|
const shipments: Shipment[] = await this.shipmentModel.findBy({ tracking_provider: 'freightwaves', finished: false });
|
||||||
const results = await Promise.all(
|
const results = await Promise.all(
|
||||||
shipments.map(async shipment => {
|
shipments.map(async shipment => {
|
||||||
return await this.logisticsService.updateFreightwavesShipmentState(shipment);
|
return await this.logisticsService.updateFreightwavesShipmentState(shipment);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
this.logger.info(`更新运单状态完毕 ${JSON.stringify(results)}`);
|
this.logger.info(`更新运单状态完毕 ${JSON.stringify(results)}`);
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
onComplete(result: any) {
|
onComplete(result: any) {
|
||||||
|
|
|
||||||
|
|
@ -140,20 +140,20 @@ interface QueryOrderResponseData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改订单响应数据接口
|
// 修改订单响应数据接口
|
||||||
interface ModifyOrderResponseData extends CreateOrderResponseData {}
|
interface ModifyOrderResponseData extends CreateOrderResponseData { }
|
||||||
|
|
||||||
// 订单退款响应数据接口
|
// 订单退款响应数据接口
|
||||||
interface RefundOrderResponseData {}
|
interface RefundOrderResponseData { }
|
||||||
|
|
||||||
@Provide()
|
@Provide()
|
||||||
export class FreightwavesService {
|
export class FreightwavesService {
|
||||||
@Inject() logger;
|
@Inject() logger;
|
||||||
|
|
||||||
// 默认配置
|
// 默认配置
|
||||||
private config: FreightwavesConfig = {
|
private config: FreightwavesConfig = {
|
||||||
appSecret: 'gELCHguGmdTLo!zfihfM91hae8G@9Sz23Mh6pHrt',
|
appSecret: 'gELCHguGmdTLo!zfihfM91hae8G@9Sz23Mh6pHrt',
|
||||||
apiBaseUrl: 'http://tms.freightwaves.ca:8901/',
|
apiBaseUrl: 'http://tms.freightwaves.ca:8901/',
|
||||||
partner: '25072621035200000060'
|
partner: '25072621035200000060'
|
||||||
};
|
};
|
||||||
|
|
||||||
// 初始化配置
|
// 初始化配置
|
||||||
|
|
@ -180,11 +180,11 @@ export class FreightwavesService {
|
||||||
};
|
};
|
||||||
|
|
||||||
// 记录请求前的详细信息
|
// 记录请求前的详细信息
|
||||||
console.log(`Sending request to: ${this.config.apiBaseUrl}${url}`,JSON.stringify({
|
console.log(`Sending request to: ${this.config.apiBaseUrl}${url}`, JSON.stringify({
|
||||||
headers,
|
headers,
|
||||||
data
|
data
|
||||||
}))
|
}))
|
||||||
console.log('Request data:', `${this.config.apiBaseUrl}${url}`, data,headers);
|
console.log('Request data:', `${this.config.apiBaseUrl}${url}`, data, headers);
|
||||||
// 发送请求 - 临时禁用SSL证书验证以解决UNABLE_TO_VERIFY_LEAF_SIGNATURE错误
|
// 发送请求 - 临时禁用SSL证书验证以解决UNABLE_TO_VERIFY_LEAF_SIGNATURE错误
|
||||||
const response = await axios.post<FreightwavesResponse<T>>(
|
const response = await axios.post<FreightwavesResponse<T>>(
|
||||||
`${this.config.apiBaseUrl}${url}`,
|
`${this.config.apiBaseUrl}${url}`,
|
||||||
|
|
@ -403,7 +403,7 @@ export class FreightwavesService {
|
||||||
|
|
||||||
// 注意:在实际环境中取消注释以下行来执行真实请求
|
// 注意:在实际环境中取消注释以下行来执行真实请求
|
||||||
const result = await this.createOrder(testParams);
|
const result = await this.createOrder(testParams);
|
||||||
this.log('创建订单成功:', result);
|
this.log('创建订单成功:', result);
|
||||||
|
|
||||||
|
|
||||||
// 返回模拟结果
|
// 返回模拟结果
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue