Fix: change all shipment_id type from string to number

This commit is contained in:
黄珑 2025-08-16 14:29:25 +08:00
parent 14913f4db4
commit 9c54d60d91
7 changed files with 23 additions and 18 deletions

View File

@ -195,7 +195,7 @@ export class LogisticsController {
) )
@Post('/getShipmentLabel/:shipmentId') @Post('/getShipmentLabel/:shipmentId')
async getShipmentLabel( async getShipmentLabel(
@Param('shipmentId') shipmentId: string @Param('shipmentId') shipmentId: number
) { ) {
try { try {
const res = await this.logisticsService.getShipmentLabel(shipmentId); const res = await this.logisticsService.getShipmentLabel(shipmentId);
@ -224,7 +224,7 @@ export class LogisticsController {
@ApiOkResponse() @ApiOkResponse()
@Post('/updateState/:id') @Post('/updateState/:id')
async updateShipmentState( async updateShipmentState(
@Param('shipmentId') shipmentId: string @Param('shipmentId') shipmentId: number
) { ) {
try { try {
const data = await this.logisticsService.updateShipmentStateById(shipmentId); const data = await this.logisticsService.updateShipmentStateById(shipmentId);
@ -236,7 +236,7 @@ export class LogisticsController {
@ApiOkResponse() @ApiOkResponse()
@Del('/shipment/:id') @Del('/shipment/:id')
async delShipment(@Param('id') id: string, @User() user) { async delShipment(@Param('id') id: number, @User() user) {
try { try {
const data = await this.logisticsService.delShipment(id, user.id); const data = await this.logisticsService.delShipment(id, user.id);
return successResponse(data); return successResponse(data);
@ -260,7 +260,7 @@ export class LogisticsController {
@ApiOkResponse() @ApiOkResponse()
@Post('/getListByTrackingId') @Post('/getListByTrackingId')
async getListByTrackingId(@Query('shipment_id') shipment_id: string) { async getListByTrackingId(@Query('shipment_id') shipment_id: number) {
try { try {
return successResponse( return successResponse(
await this.logisticsService.getListByTrackingId(shipment_id) await this.logisticsService.getListByTrackingId(shipment_id)

View File

@ -50,7 +50,7 @@ export class Order {
@ApiProperty() @ApiProperty()
@Column({ name: 'shipment_id', nullable: true }) @Column({ name: 'shipment_id', nullable: true })
@Expose() @Expose()
shipmentId: string; shipmentId: number;
@OneToOne(() => Shipment) @OneToOne(() => Shipment)
@JoinColumn({ name: 'shipment_id' }) @JoinColumn({ name: 'shipment_id' })

View File

@ -13,7 +13,7 @@ export class OrderShipment {
@ApiProperty() @ApiProperty()
@Column() @Column()
shipment_id: string; shipment_id: number;
@ApiProperty() @ApiProperty()
@Column() @Column()

View File

@ -19,7 +19,7 @@ export class Shipment {
@ApiProperty() @ApiProperty()
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
@Expose() @Expose()
id: string; id: number;
@ApiProperty() @ApiProperty()
@Column({ nullable: true }) @Column({ nullable: true })

View File

@ -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 url = `${this.url}/rs/${this.customerNumber}/${this.customerNumber}/shipment/${shipmentId}`;
const res = await axios.delete(url, { const res = await axios.delete(url, {

View File

@ -98,7 +98,7 @@ export class FreightcomService {
} }
// 查询运单详细信息 // 查询运单详细信息
async getShipment(shipment_id: string) { async getShipment(shipment_id: number) {
let { status, data } = await axios.request({ let { status, data } = await axios.request({
url: `${this.apiUrl}/shipment/${shipment_id}`, url: `${this.apiUrl}/shipment/${shipment_id}`,
method: 'GET', method: 'GET',
@ -117,7 +117,7 @@ export class FreightcomService {
} }
// 取消发货 // 取消发货
async cancelShipment(shipment_id: string) { async cancelShipment(shipment_id: number) {
const response = await axios.request({ const response = await axios.request({
url: `${this.apiUrl}/shipment/${shipment_id}`, url: `${this.apiUrl}/shipment/${shipment_id}`,
method: 'DELETE', method: 'DELETE',

View File

@ -136,7 +136,7 @@ export class LogisticsService {
} }
} }
async updateShipmentStateById(id: string) { async updateShipmentStateById(id: number) {
const shipment:Shipment = await this.shipmentModel.findOneBy({ id : id }); const shipment:Shipment = await this.shipmentModel.findOneBy({ id : id });
return this.updateShipmentState(shipment); return this.updateShipmentState(shipment);
} }
@ -224,7 +224,7 @@ export class LogisticsService {
} }
} }
async removeShipment(shipmentId) { async removeShipment(shipmentId: number) {
try { try {
const shipment:Shipment = await this.shipmentModel.findOneBy({id: shipmentId}); const shipment:Shipment = await this.shipmentModel.findOneBy({id: shipmentId});
if (shipment.state !== '190') { // todo写常数 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() { async syncShipment() {
try { try {
const shipments = await this.shipmentModel.find({ const shipments = await this.shipmentModel.find({
@ -487,8 +492,8 @@ export class LogisticsService {
} }
} }
async getShipment(id: string) { async getShipment(id: number) {
const orderShipments = await this.orderShipmentModel.find({ const orderShipments:OrderShipment[] = await this.orderShipmentModel.find({
where: { shipment_id: id }, where: { shipment_id: id },
}); });
if (!orderShipments || orderShipments.length === 0) return; 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 }); const shipment = await this.shipmentModel.findOneBy({ id });
if (!shipment) throw new Error('物流不存在'); if (!shipment) throw new Error('物流不存在');
@ -540,9 +545,9 @@ export class LogisticsService {
const orderShipments = await orderShipmentRepo.findBy({ const orderShipments = await orderShipmentRepo.findBy({
shipment_id: id, 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 shipmentRepo.delete({ id });
await shipmentItemRepo.delete({ shipment_id: Number(id) }); await shipmentItemRepo.delete({ shipment_id: id });
await orderShipmentRepo.delete({ shipment_id: id }); await orderShipmentRepo.delete({ shipment_id: id });
for (const item of shipmentItems) { for (const item of shipmentItems) {
const stock = await stockRepo.findOne({ const stock = await stockRepo.findOne({
@ -587,7 +592,7 @@ export class LogisticsService {
})); }));
} }
async getListByTrackingId(id: string) { async getListByTrackingId(id: number) {
const qb = ` const qb = `
SELECT SELECT
oi.name, oi.name,