WMS_MAIN/app/service/systemMethods/order/expectionOrder.js
2026-03-25 23:26:10 +08:00

91 lines
2.6 KiB
JavaScript

'use strict';
const OrderBaseService = require('./base');
class ExpectionOrderService extends OrderBaseService {
constructor(ctx) {
super(ctx);
const _noNeedLogin = '';
const _noNeedRight = 'getexpectionOrderlist';
const _noNeedLog = 'getexpectionOrderlist';
const _noNeedAuth = 'getexpectionOrderlist';
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
}
async getexpectionOrderlist(data = {}) {
try {
const warehouseId = this.ensureWarehouseId(data);
const { Op } = this.app.Sequelize;
const { DeliveryModel } = await this.getOrderModels(warehouseId);
this.prepareWhereContext(data);
const whereData = this.ctx.where || {};
const where = this.buildWhere(whereData, warehouseId);
const hasExceptionFilter = [
'status',
'post_status',
'storage_status',
'pick_status',
'pack_status',
'inspection_status',
'print_status',
'claim_status',
'outbound_status',
'intercept_status',
].some(key => this.hasWhereValue(whereData, key));
if (!hasExceptionFilter) {
where[Op.or] = [
{ status: 'error' },
{ post_status: 'error' },
{ storage_status: 'error' },
{ pick_status: 'error' },
{ pack_status: 'error' },
{ inspection_status: 'error' },
{ print_status: 'error' },
{ claim_status: 'error' },
{ outbound_status: 'error' },
{ intercept_status: 'exception' },
];
}
const { page, pageSize, offset } = this.getPagination(data.pagination);
const result = await DeliveryModel.findAndCountAll({
where,
attributes: [
'id',
'delivery_order_code',
'status',
'post_status',
'pick_status',
'pack_status',
'inspection_status',
'outbound_status',
'intercept_status',
'updated_at',
'store_id',
'warehouse_id',
'buyer_nick',
'logistics_name',
],
offset,
limit: pageSize,
order: [ [ 'updated_at', 'DESC' ], [ 'id', 'DESC' ] ],
raw: true,
});
return this.success('ok', {
data: this.buildListData(result.rows, result.count, page, pageSize, {
queryInfo: {
defaultExceptionFilter: !hasExceptionFilter,
},
}),
code: 200,
});
} catch (error) {
return this.fail(error.message, { code: 500 });
}
}
}
module.exports = ExpectionOrderService;