forked from yoone/API
1
0
Fork 0

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')
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)

View File

@ -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' })

View File

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

View File

@ -19,7 +19,7 @@ export class Shipment {
@ApiProperty()
@PrimaryGeneratedColumn()
@Expose()
id: string;
id: number;
@ApiProperty()
@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 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({
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',

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 });
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,