feat(express): 快递接口支持启用/停用,过滤取消状态订单
- express_interface 新增 is_enabled 字段(1=启用, 0=停用) - expressInterface service 支持 is_enabled 筛选与编辑 - express 运单分配跳过停用接口 + 取消状态订单过滤 - 迁移: 20260724100000-add-is-enabled-to-wms-express-interface
This commit is contained in:
parent
f40370baca
commit
972c912e53
@ -180,6 +180,12 @@ module.exports = app => {
|
||||
defaultValue: 0,
|
||||
comment: '是否隐藏物品信息',
|
||||
},
|
||||
is_enabled: {
|
||||
type: TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 1,
|
||||
comment: '是否启用(1=启用,0=停用)',
|
||||
},
|
||||
shipperno: {
|
||||
type: STRING(255),
|
||||
allowNull: true,
|
||||
|
||||
@ -110,6 +110,9 @@ class expressInterfaceService extends MainService {
|
||||
shop_name: {
|
||||
field: 'shop_name',
|
||||
},
|
||||
is_enabled: {
|
||||
field: 'is_enabled',
|
||||
},
|
||||
quickWhere: {
|
||||
bucket: 'quick',
|
||||
},
|
||||
@ -269,6 +272,8 @@ class expressInterfaceService extends MainService {
|
||||
providerType,
|
||||
providerid,
|
||||
providerId,
|
||||
is_enabled: isEnabledSnake,
|
||||
isEnabled: isEnabledCamel,
|
||||
...rest
|
||||
} = data || {};
|
||||
|
||||
@ -328,6 +333,9 @@ class expressInterfaceService extends MainService {
|
||||
if (providerid !== undefined || providerId !== undefined) {
|
||||
payload.providerid = providerid !== undefined ? providerid : providerId;
|
||||
}
|
||||
if (isEnabledSnake !== undefined || isEnabledCamel !== undefined) {
|
||||
payload.is_enabled = isEnabledSnake !== undefined ? isEnabledSnake : isEnabledCamel;
|
||||
}
|
||||
|
||||
return await this.callSystemExpressInterface('update', payload, '更新快递接口失败');
|
||||
}
|
||||
|
||||
@ -632,6 +632,9 @@ class ExpressService extends Service {
|
||||
id: {
|
||||
[Op.in]: normalizedOrderIds,
|
||||
},
|
||||
status: {
|
||||
[Op.ne]: 'cancel',
|
||||
},
|
||||
},
|
||||
transaction,
|
||||
});
|
||||
@ -695,7 +698,12 @@ class ExpressService extends Service {
|
||||
order_flag: normalizedErrorMessage,
|
||||
updated_at: new Date(),
|
||||
}, {
|
||||
where,
|
||||
where: {
|
||||
...where,
|
||||
status: {
|
||||
[Op.ne]: 'cancel',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -1788,6 +1796,11 @@ class ExpressService extends Service {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 停用的快递接口不允许分配运单号
|
||||
if (Number(item.is_enabled) !== 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const candidateCodes = [
|
||||
normalizeCode(item.sys_express_code),
|
||||
normalizeCode(item.express_code),
|
||||
@ -2046,7 +2059,7 @@ class ExpressService extends Service {
|
||||
items: this.normalizeWaybillAsyncItems(orderDelivery.items),
|
||||
items_count: this.normalizeWaybillAsyncNumber(orderDelivery.items_count),
|
||||
items_total: this.normalizeWaybillAsyncNumber(orderDelivery.items_total),
|
||||
items_weight: this.normalizeWaybillAsyncNumber(orderDelivery.items_weight),
|
||||
items_weight: this.normalizeWaybillAsyncNumber(orderDelivery.items_weight), // 单位 g,传递给下游快递平台
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -307,6 +307,9 @@ class SettingExpressInterfaceService extends Service {
|
||||
shop_name: {
|
||||
field: 'shop_name',
|
||||
},
|
||||
is_enabled: {
|
||||
field: 'is_enabled',
|
||||
},
|
||||
quickWhere: {
|
||||
bucket: 'quick',
|
||||
},
|
||||
@ -366,12 +369,16 @@ class SettingExpressInterfaceService extends Service {
|
||||
includes[0].attributes = [ 'code', 'name' ];
|
||||
}
|
||||
|
||||
if (full && ctx.model && ctx.model.Shop) {
|
||||
includes.push({
|
||||
if (ctx.model && ctx.model.Shop) {
|
||||
const shopInclude = {
|
||||
model: ctx.model.Shop,
|
||||
as: 'shop',
|
||||
required: false,
|
||||
});
|
||||
};
|
||||
if (!full) {
|
||||
shopInclude.attributes = [ 'id', 'shop_name' ];
|
||||
}
|
||||
includes.push(shopInclude);
|
||||
}
|
||||
|
||||
return includes;
|
||||
@ -742,6 +749,7 @@ class SettingExpressInterfaceService extends Service {
|
||||
weight_type: row.weight_type === undefined || row.weight_type === null ? null : Number(row.weight_type),
|
||||
viewer: this.normalizeOptionalText(row.viewer, 'viewer', 50),
|
||||
client_id: this.normalizeOptionalText(row.client_id, 'client_id', 50),
|
||||
is_enabled: row.is_enabled === undefined || row.is_enabled === null ? null : Number(row.is_enabled),
|
||||
is_share: row.is_share === undefined || row.is_share === null ? null : Number(row.is_share),
|
||||
ispickup: row.ispickup === undefined || row.ispickup === null ? null : Number(row.ispickup),
|
||||
shipperno: this.normalizeOptionalText(row.shipperno, 'shipperno', 255),
|
||||
@ -754,7 +762,11 @@ class SettingExpressInterfaceService extends Service {
|
||||
town_name: this.normalizeOptionalText(row.town_name, 'town_name', 255),
|
||||
site_code: this.normalizeOptionalText(row.site_code, 'site_code', 255),
|
||||
product_type: this.normalizeOptionalText(row.product_type, 'product_type', 50),
|
||||
shop_name: this.normalizeOptionalText(row.shop_name, 'shop_name', 255),
|
||||
shop_name: this.normalizeOptionalText(
|
||||
(row.shop && row.shop.shop_name) || row.shop_name,
|
||||
'shop_name',
|
||||
255
|
||||
),
|
||||
express,
|
||||
express_name: express ? express.name : null,
|
||||
express_polyapi_extra_info: express ? express.polyapi_extra_info : null,
|
||||
@ -1075,7 +1087,7 @@ class SettingExpressInterfaceService extends Service {
|
||||
'sys_express_code',
|
||||
'sender_name', 'sender_tel', 'weight', 'viewer', 'client_id', 'is_share',
|
||||
'province_name', 'city_name', 'district_name', 'site_code',
|
||||
'product_type', 'weight_type', 'shop_name', 'address', 'town_name', 'ispickup', 'shipperno', 'template_url', 'ext_data',
|
||||
'product_type', 'weight_type', 'shop_name', 'address', 'town_name', 'ispickup', 'shipperno', 'template_url', 'ext_data', 'is_enabled',
|
||||
],
|
||||
order: [[ 'weight', 'ASC' ], [ 'id', 'DESC' ]],
|
||||
offset,
|
||||
@ -1353,6 +1365,8 @@ class SettingExpressInterfaceService extends Service {
|
||||
|| Object.prototype.hasOwnProperty.call(data, 'shopName');
|
||||
const hasExtData = Object.prototype.hasOwnProperty.call(data, 'ext_data')
|
||||
|| Object.prototype.hasOwnProperty.call(data, 'extData');
|
||||
const hasIsEnabled = Object.prototype.hasOwnProperty.call(data, 'is_enabled')
|
||||
|| Object.prototype.hasOwnProperty.call(data, 'isEnabled');
|
||||
|
||||
if (!hasName && !hasExpressCode && !hasPlatformCode && !hasSysExpressCode
|
||||
&& !hasSenderName && !hasSenderTel && !hasWeight && !hasWeightType
|
||||
@ -1360,7 +1374,7 @@ class SettingExpressInterfaceService extends Service {
|
||||
&& !hasProviderType && !hasProviderId && !hasViewer && !hasClientId && !hasIsPickup
|
||||
&& !hasShipperNo && !hasTemplateUrl && !hasProvinceName && !hasCityName
|
||||
&& !hasDistrictName && !hasAddress && !hasTownName && !hasSiteCode
|
||||
&& !hasProductType && !hasShopName && !hasExtData) {
|
||||
&& !hasProductType && !hasShopName && !hasExtData && !hasIsEnabled) {
|
||||
throw this.createError('至少需要提供一个可更新字段', 400);
|
||||
}
|
||||
|
||||
@ -1556,6 +1570,14 @@ class SettingExpressInterfaceService extends Service {
|
||||
);
|
||||
}
|
||||
|
||||
if (hasIsEnabled) {
|
||||
updates.is_enabled = this.normalizeFlag(
|
||||
data.is_enabled !== undefined ? data.is_enabled : data.isEnabled,
|
||||
'is_enabled',
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
if (hasExpressCode || hasPlatformCode || hasSysExpressCode) {
|
||||
updates.sys_express_code = await this.resolveSysExpressCode({
|
||||
expressCode: nextExpressCode,
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn('wms_express_interface', 'is_enabled', {
|
||||
type: Sequelize.TINYINT(1),
|
||||
allowNull: true,
|
||||
defaultValue: 1,
|
||||
comment: '是否启用(1=启用,0=停用)',
|
||||
after: 'is_hide_goods',
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface, Sequelize) {
|
||||
await queryInterface.removeColumn('wms_express_interface', 'is_enabled');
|
||||
},
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user