forked from yoone/API
Compare commits
5 Commits
f2f72f8c44
...
4eeda35c2d
| Author | SHA1 | Date |
|---|---|---|
|
|
4eeda35c2d | |
|
|
4877783e3f | |
|
|
d354267572 | |
|
|
c3acb66fd9 | |
|
|
f6327a9e09 |
|
|
@ -27,6 +27,9 @@ export class QueryCustomerListDTO {
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
customerId: number;
|
customerId: number;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
phone: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CustomerTagDTO {
|
export class CustomerTagDTO {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,10 @@ export class ShipmentBookDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@Rule(RuleType.string())
|
@Rule(RuleType.string())
|
||||||
shipmentPlatform: string;
|
shipmentPlatform: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@Rule(RuleType.any())
|
||||||
|
courierCompany: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ShipmentFeeBookDTO {
|
export class ShipmentFeeBookDTO {
|
||||||
|
|
@ -30,6 +34,8 @@ export class ShipmentFeeBookDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
shipmentPlatform: string;
|
shipmentPlatform: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
|
courierCompany: string;
|
||||||
|
@ApiProperty()
|
||||||
stockPointId: number;
|
stockPointId: number;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
sender: string;
|
sender: string;
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,17 @@ export class CustomerService {
|
||||||
first_purchase_date,
|
first_purchase_date,
|
||||||
customerId,
|
customerId,
|
||||||
rate,
|
rate,
|
||||||
|
phone,
|
||||||
} = param;
|
} = param;
|
||||||
|
|
||||||
const whereConds: string[] = [];
|
const whereConds: string[] = [];
|
||||||
const havingConds: string[] = [];
|
const havingConds: string[] = [];
|
||||||
|
|
||||||
|
// phone过滤
|
||||||
|
if (phone) {
|
||||||
|
whereConds.push(`o.billing LIKE '%${phone}%'`)
|
||||||
|
}
|
||||||
|
|
||||||
// 邮箱搜索
|
// 邮箱搜索
|
||||||
if (email) {
|
if (email) {
|
||||||
whereConds.push(`o.customer_email LIKE '%${email}%'`);
|
whereConds.push(`o.customer_email LIKE '%${email}%'`);
|
||||||
|
|
|
||||||
|
|
@ -339,8 +339,6 @@ export class LogisticsService {
|
||||||
throw new Error('不支持的运单平台');
|
throw new Error('不支持的运单平台');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
@ -363,12 +361,7 @@ export class LogisticsService {
|
||||||
try {
|
try {
|
||||||
resShipmentOrder = await this.mepShipment(data, order);
|
resShipmentOrder = await this.mepShipment(data, order);
|
||||||
|
|
||||||
// 记录物流信息,并将订单状态转到完成,uniuni状态为SUCCESS,tms.freightwaves状态为00000200
|
|
||||||
if (resShipmentOrder.status === 'SUCCESS' || resShipmentOrder.code === '00000200') {
|
|
||||||
order.orderStatus = ErpOrderStatus.COMPLETED;
|
order.orderStatus = ErpOrderStatus.COMPLETED;
|
||||||
} else {
|
|
||||||
throw new Error('运单生成失败');
|
|
||||||
}
|
|
||||||
const dataSource = this.dataSourceManager.getDataSource('default');
|
const dataSource = this.dataSourceManager.getDataSource('default');
|
||||||
let transactionError = undefined;
|
let transactionError = undefined;
|
||||||
let shipmentId = undefined;
|
let shipmentId = undefined;
|
||||||
|
|
@ -467,7 +460,7 @@ export class LogisticsService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (resShipmentOrder.status === 'SUCCESS') {
|
if (resShipmentOrder?.status === 'SUCCESS') {
|
||||||
await this.uniExpressService.deleteShipment(resShipmentOrder.data.tno);
|
await this.uniExpressService.deleteShipment(resShipmentOrder.data.tno);
|
||||||
}
|
}
|
||||||
throw new Error(`上游请求错误:${error}`);
|
throw new Error(`上游请求错误:${error}`);
|
||||||
|
|
@ -732,12 +725,18 @@ export class LogisticsService {
|
||||||
};
|
};
|
||||||
// 添加运单
|
// 添加运单
|
||||||
resShipmentOrder = await this.uniExpressService.createShipment(reqBody);
|
resShipmentOrder = await this.uniExpressService.createShipment(reqBody);
|
||||||
|
|
||||||
|
// 记录物流信息,并将订单状态转到完成,uniuni状态为SUCCESS,tms.freightwaves状态为00000200
|
||||||
|
if (resShipmentOrder.status !== 'SUCCESS') {
|
||||||
|
throw new Error('运单生成失败');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.shipmentPlatform === 'freightwaves') {
|
if (data.shipmentPlatform === 'freightwaves') {
|
||||||
// 根据TMS系统对接说明文档格式化参数
|
// 根据TMS系统对接说明文档格式化参数
|
||||||
const reqBody: any = {
|
const reqBody: any = {
|
||||||
shipCompany: 'UPSYYZ7000NEW',
|
// shipCompany: 'UPSYYZ7000NEW',
|
||||||
|
shipCompany: data.courierCompany,
|
||||||
partnerOrderNumber: order.siteId + '-' + order.externalOrderId,
|
partnerOrderNumber: order.siteId + '-' + order.externalOrderId,
|
||||||
warehouseId: '25072621030107400060',
|
warehouseId: '25072621030107400060',
|
||||||
shipper: {
|
shipper: {
|
||||||
|
|
@ -804,7 +803,10 @@ export class LogisticsService {
|
||||||
resShipmentOrder = await this.freightwavesService.createOrder(reqBody); // 创建订单
|
resShipmentOrder = await this.freightwavesService.createOrder(reqBody); // 创建订单
|
||||||
//tms只返回了物流订单号,需要查询一次来获取完整的物流信息
|
//tms只返回了物流订单号,需要查询一次来获取完整的物流信息
|
||||||
const queryRes = await this.freightwavesService.queryOrder({ shipOrderId: resShipmentOrder.shipOrderId }); // 查询订单
|
const queryRes = await this.freightwavesService.queryOrder({ shipOrderId: resShipmentOrder.shipOrderId }); // 查询订单
|
||||||
resShipmentOrder.push(queryRes);
|
return {
|
||||||
|
...resShipmentOrder,
|
||||||
|
...queryRes
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resShipmentOrder;
|
return resShipmentOrder;
|
||||||
|
|
@ -815,11 +817,7 @@ export class LogisticsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将ShipmentFeeBookDTO转换为freightwaves的RateTryRequest格式
|
|
||||||
* @param data ShipmentFeeBookDTO数据
|
|
||||||
* @returns RateTryRequest格式的数据
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* 将ShipmentFeeBookDTO转换为freightwaves的RateTryRequest格式
|
* 将ShipmentFeeBookDTO转换为freightwaves的RateTryRequest格式
|
||||||
* @param data ShipmentFeeBookDTO数据
|
* @param data ShipmentFeeBookDTO数据
|
||||||
|
|
@ -836,7 +834,8 @@ export class LogisticsService {
|
||||||
const address = shipments?.address;
|
const address = shipments?.address;
|
||||||
// 转换为RateTryRequest格式
|
// 转换为RateTryRequest格式
|
||||||
const r = {
|
const r = {
|
||||||
shipCompany: 'UPSYYZ7000NEW', // 必填,但ShipmentFeeBookDTO中缺少
|
// shipCompany: 'UPSYYZ7000NEW',
|
||||||
|
shipCompany: data.courierCompany,
|
||||||
partnerOrderNumber: `order-${Date.now()}`, // 必填,使用时间戳生成
|
partnerOrderNumber: `order-${Date.now()}`, // 必填,使用时间戳生成
|
||||||
warehouseId: '25072621030107400060', // 可选,使用stockPointId转换
|
warehouseId: '25072621030107400060', // 可选,使用stockPointId转换
|
||||||
shipper: {
|
shipper: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue