- 新增步骤 5.5:启动前通过 ss + fuser -k 强制释放目标端口残留进程 - 健康检查重试次数从 5 次增加到 10 次,最长等待从 10s 延长至 20s - 健康检查失败日志增加启动日志路径提示
89 lines
2.2 KiB
JavaScript
89 lines
2.2 KiB
JavaScript
'use strict';
|
||
|
||
const MainService = require('../main');
|
||
|
||
class WarehouseStoreService extends MainService {
|
||
/**
|
||
* 查询当前仓库下已授权的货主列表。
|
||
* 返回货主基本信息(id、公司名、联系人、联系电话、授权状态)。
|
||
* @param {Object} options 请求参数。
|
||
* @param {Object} options.body 请求体。
|
||
* @return {Promise<Object>} 货主列表。
|
||
*/
|
||
async list({ body = {} } = {}) {
|
||
const { ctx } = this;
|
||
const { warehouseId } = this.getInfo();
|
||
|
||
const page = Math.max(1, Number(body.page) || 1);
|
||
const pageSize = Math.min(100, Math.max(1, Number(body.pageSize) || 20));
|
||
|
||
// 通过 store_warehouse 关联查询已授权的货主
|
||
const { StoreWarehouse, Store } = ctx.model;
|
||
|
||
const where = {
|
||
warehouse_id: warehouseId,
|
||
auth_status: 2, // 已通过
|
||
warehouse_use_status: 1, // 仓库侧可用
|
||
};
|
||
|
||
const { count: total, rows } = await StoreWarehouse.findAndCountAll({
|
||
attributes: [
|
||
'id',
|
||
'store_id',
|
||
'auth_status',
|
||
'auth_start',
|
||
'auth_end',
|
||
'store_remask',
|
||
'warehouse_remask',
|
||
],
|
||
where,
|
||
include: [
|
||
{
|
||
model: Store,
|
||
as: 'store',
|
||
attributes: [
|
||
'id',
|
||
'company_name',
|
||
'contact_person',
|
||
'contact_phone',
|
||
'status',
|
||
],
|
||
required: true,
|
||
where: {
|
||
status: 1, // 启用
|
||
},
|
||
},
|
||
],
|
||
offset: (page - 1) * pageSize,
|
||
limit: pageSize,
|
||
order: [[ 'id', 'DESC' ]],
|
||
raw: true,
|
||
});
|
||
|
||
const list = rows.map(row => ({
|
||
store_id: row['store.id'],
|
||
company_name: row['store.company_name'],
|
||
contact_person: row['store.contact_person'],
|
||
contact_phone: row['store.contact_phone'],
|
||
contract_id: row.id,
|
||
auth_status: row.auth_status,
|
||
auth_start: row.auth_start,
|
||
auth_end: row.auth_end,
|
||
store_remask: row.store_remask,
|
||
warehouse_remask: row.warehouse_remask,
|
||
}));
|
||
|
||
return {
|
||
list,
|
||
pagination: {
|
||
page,
|
||
pageSize,
|
||
total,
|
||
totalPages: Math.ceil(total / pageSize),
|
||
},
|
||
};
|
||
}
|
||
}
|
||
|
||
module.exports = WarehouseStoreService;
|