diff --git a/src/controller/logistics.controller.ts b/src/controller/logistics.controller.ts index 41ab6bb..23ef859 100644 --- a/src/controller/logistics.controller.ts +++ b/src/controller/logistics.controller.ts @@ -195,7 +195,7 @@ export class LogisticsController { ) @Post('/getShipmentLabel/:shipmentId') async getShipmentLabel( - @Param('shipmentId') shipmentId: string + @Param('shipmentId') shipmentId: number ) { try { const res = await this.logisticsService.getShipmentLabel(shipmentId); @@ -224,7 +224,7 @@ export class LogisticsController { @ApiOkResponse() @Post('/updateState/:id') async updateShipmentState( - @Param('shipmentId') shipmentId: string + @Param('shipmentId') shipmentId: number ) { try { const data = await this.logisticsService.updateShipmentStateById(shipmentId); @@ -236,7 +236,7 @@ export class LogisticsController { @ApiOkResponse() @Del('/shipment/:id') - async delShipment(@Param('id') id: string, @User() user) { + async delShipment(@Param('id') id: number, @User() user) { try { const data = await this.logisticsService.delShipment(id, user.id); return successResponse(data); @@ -260,7 +260,7 @@ export class LogisticsController { @ApiOkResponse() @Post('/getListByTrackingId') - async getListByTrackingId(@Query('shipment_id') shipment_id: string) { + async getListByTrackingId(@Query('shipment_id') shipment_id: number) { try { return successResponse( await this.logisticsService.getListByTrackingId(shipment_id) diff --git a/src/entity/order.entity.ts b/src/entity/order.entity.ts index 62d15b0..792400f 100644 --- a/src/entity/order.entity.ts +++ b/src/entity/order.entity.ts @@ -50,7 +50,7 @@ export class Order { @ApiProperty() @Column({ name: 'shipment_id', nullable: true }) @Expose() - shipmentId: string; + shipmentId: number; @OneToOne(() => Shipment) @JoinColumn({ name: 'shipment_id' }) diff --git a/src/entity/order_shipment.entity.ts b/src/entity/order_shipment.entity.ts index 7ac348d..ea6774d 100644 --- a/src/entity/order_shipment.entity.ts +++ b/src/entity/order_shipment.entity.ts @@ -13,7 +13,7 @@ export class OrderShipment { @ApiProperty() @Column() - shipment_id: string; + shipment_id: number; @ApiProperty() @Column() diff --git a/src/entity/shipment.entity.ts b/src/entity/shipment.entity.ts index 5d3b4f6..947db07 100644 --- a/src/entity/shipment.entity.ts +++ b/src/entity/shipment.entity.ts @@ -19,7 +19,7 @@ export class Shipment { @ApiProperty() @PrimaryGeneratedColumn() @Expose() - id: string; + id: number; @ApiProperty() @Column({ nullable: true }) diff --git a/src/service/canadaPost.service.ts b/src/service/canadaPost.service.ts index fc38a66..0edee31 100644 --- a/src/service/canadaPost.service.ts +++ b/src/service/canadaPost.service.ts @@ -157,7 +157,7 @@ export class CanadaPostService { } /** 取消运单 */ - async cancelShipment(shipmentId: string) { + async cancelShipment(shipmentId: number) { const url = `${this.url}/rs/${this.customerNumber}/${this.customerNumber}/shipment/${shipmentId}`; const res = await axios.delete(url, { diff --git a/src/service/freightcom.service.ts b/src/service/freightcom.service.ts index 0426c21..6b901fc 100644 --- a/src/service/freightcom.service.ts +++ b/src/service/freightcom.service.ts @@ -98,7 +98,7 @@ export class FreightcomService { } // 查询运单详细信息 - async getShipment(shipment_id: string) { + async getShipment(shipment_id: number) { let { status, data } = await axios.request({ url: `${this.apiUrl}/shipment/${shipment_id}`, method: 'GET', @@ -117,7 +117,7 @@ export class FreightcomService { } // 取消发货 - async cancelShipment(shipment_id: string) { + async cancelShipment(shipment_id: number) { const response = await axios.request({ url: `${this.apiUrl}/shipment/${shipment_id}`, method: 'DELETE', diff --git a/src/service/logistics.service.ts b/src/service/logistics.service.ts index 08fb5e1..28087cc 100644 --- a/src/service/logistics.service.ts +++ b/src/service/logistics.service.ts @@ -136,7 +136,7 @@ export class LogisticsService { } } - async updateShipmentStateById(id: string) { + async updateShipmentStateById(id: number) { const shipment:Shipment = await this.shipmentModel.findOneBy({ id : id }); return this.updateShipmentState(shipment); } @@ -224,7 +224,7 @@ export class LogisticsService { } } - async removeShipment(shipmentId) { + async removeShipment(shipmentId: number) { try { const shipment:Shipment = await this.shipmentModel.findOneBy({id: shipmentId}); if (shipment.state !== '190') { // todo,写常数 @@ -439,6 +439,11 @@ export class LogisticsService { } } + async updateShipmentItem(shipmentId: number, sales: OrderSale[]) { + const shipment:Shipment = await this.shipmentModel.findOneBy({ id: shipmentId }); + console.log(shipment); + } + async syncShipment() { try { const shipments = await this.shipmentModel.find({ @@ -487,8 +492,8 @@ export class LogisticsService { } } - async getShipment(id: string) { - const orderShipments = await this.orderShipmentModel.find({ + async getShipment(id: number) { + const orderShipments:OrderShipment[] = await this.orderShipmentModel.find({ where: { shipment_id: id }, }); if (!orderShipments || orderShipments.length === 0) return; @@ -520,7 +525,7 @@ export class LogisticsService { } } - async delShipment(id: string, userId: number) { + async delShipment(id: number, userId: number) { const shipment = await this.shipmentModel.findOneBy({ id }); if (!shipment) throw new Error('物流不存在'); @@ -540,9 +545,9 @@ export class LogisticsService { const orderShipments = await orderShipmentRepo.findBy({ shipment_id: id, }); - const shipmentItems = await shipmentItemRepo.findBy({ shipment_id: Number(id) }); + const shipmentItems = await shipmentItemRepo.findBy({ shipment_id: id }); await shipmentRepo.delete({ id }); - await shipmentItemRepo.delete({ shipment_id: Number(id) }); + await shipmentItemRepo.delete({ shipment_id: id }); await orderShipmentRepo.delete({ shipment_id: id }); for (const item of shipmentItems) { const stock = await stockRepo.findOne({ @@ -587,7 +592,7 @@ export class LogisticsService { })); } - async getListByTrackingId(id: string) { + async getListByTrackingId(id: number) { const qb = ` SELECT oi.name,