fix(shopOrder): 修复导出商品总数量和完善导出字段

- 新增 getGoodsTotalNum 函数,基于订单商品明细求总数量,修正商品总数量计算错误
- 修改导出商品总数量列,避免使用订单级 totalNum 字段,确保数量正确
- 补齐导出字段,从8列扩展至15列,包含收货人、联系电话、配送方式等物流关键字段
- 导出数据信息同步商品明细,通过 Promise.all 调用逐单获取商品详情
- 支持按当前标签筛选导出,确保导出数据符合当前视图筛选条件
- 增加辅助函数优化代码结构,如 getShopName、getDeliveryTypeLabel 等
This commit is contained in:
2026-07-23 08:00:34 +08:00
parent 708bc7fc80
commit 44e416525d
2 changed files with 31 additions and 1 deletions

View File

@@ -230,6 +230,12 @@ const getGoodsSummary = (goods?: any[]) => {
.join('');
};
// 商品总数量:基于实际取到的商品明细求和(订单级 totalNum 列表接口可能不返回,以明细为准)
const getGoodsTotalNum = (goods?: any[]) => {
if (!goods || !goods.length) return 0;
return goods.reduce((sum, g) => sum + (Number(g.totalNum) || 0), 0);
};
// 自提/发货店铺名称
const getShopName = (d: ShopOrder) => {
if (d.deliveryType === 1) return d.selfTakeMerchantName || '';
@@ -278,7 +284,7 @@ const handleExport = async () => {
`${d.address || ''}`,
`${getDeliveryTypeLabel(d.deliveryType)}`,
`${getGoodsSummary(goodsList[idx])}`,
`${d.totalNum ?? ''}`,
`${getGoodsTotalNum(goodsList[idx])}`,
`${d.payPrice || ''}`,
`${
d.sendStartTime && d.sendEndTime