fix(交易统计): 日期区间补齐结束日并修复空值报错

- whereTime between 结束边界停在结束日零点漏掉当天数据,改 whereBetween 并 +86399 按全天统计
- topData series 键位空洞(历史佣金卡片移除)致 JSON 变对象、前端 filter 报错,重排为连续索引;图标序列对齐 8 卡片
- 接口异常时兜底错误文案避免 undefined
This commit is contained in:
吴昊天 2026-10-16 15:15:29 +08:00
parent f0f8f48998
commit c28a941257
4 changed files with 10 additions and 5 deletions

View File

@ -360,7 +360,9 @@ class UserBillDao extends BaseDao
if ($time[0] == $time[1]) {
$query->whereDay($field, $time[0]);
} else {
$query->whereTime($field, 'between', $time);
// whereTime between 对日期字符串的结束边界停在结束日 00:00:00,会漏掉结束日当天数据;
// 与统计口径 searchTimeAttr 的结束日 +86399 对齐,按全天统计
$query->whereBetween($field, [strtotime($time[0]), strtotime($time[1]) + 86399]);
}
})->field("FROM_UNIXTIME($field,'$timeType') as days,$str as num")->group('days')->select()->toArray();
}

View File

@ -428,6 +428,9 @@ class TradeStatisticServices extends BaseService
$data['series'][$k]['rate'] = $v['rate'];
$data['series'][$k]['value'] = array_values($v['value']);
}
// topData 键位不连续(历史支付佣金卡片已移除,键 7 空缺),必须重排为连续索引,
// 否则 JSON 序列化输出对象而非数组,前端 series.filter 直接报错
$data['series'] = array_values($data['series']);
// 仅导出请求时才生成 Excel 文件,普通查询不落盘
if ($isExport) {
/** @var ExportServices $exportService */

View File

@ -438,7 +438,7 @@ function getList() {
})
.catch((res) => {
listLoading.value = false;
ElMessage.error(res.msg);
ElMessage.error(res?.msg || '数据加载失败');
});
}
function getOrder() {}

View File

@ -138,16 +138,16 @@ function getStatistics() {
statisticBottomTradeApi({ data: dataTime.value })
.then(async (res) => {
const cardLists = res.data;
// 图标顺序与后端 series 卡片顺序(营业额/商品支付/购买会员/充值/线下收银/支出/余额支付/商品退款)一致,
// 支付佣金卡片已随佣金体系移除
const incons = [
'iconyingyee',
'iconjiaoyijine',
'iconshangpinzhifujine',
'icongoumaihuiyuanjine',
'iconchongzhijianshu',
'iconxianxiashouyinjine',
'iconzhichujine',
'iconyuezhifujine',
'iconzhifuyongjinjine',
'iconshangpintuikuanjine',
];
for (var i = 0; i < cardLists.series.length; i++) {
@ -158,7 +158,7 @@ function getStatistics() {
spinShow.value = false;
})
.catch((res) => {
ElMessage.error(res.msg);
ElMessage.error(res?.msg || '数据加载失败');
spinShow.value = false;
});
}