This commit is contained in:
5
apps/web-antd/src/api/mall/statistics/common.ts
Normal file
5
apps/web-antd/src/api/mall/statistics/common.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
/** 数据对照 Response */
|
||||
export interface MallDataComparisonResp<T> {
|
||||
value: T;
|
||||
reference: T;
|
||||
}
|
131
apps/web-antd/src/api/mall/statistics/member.ts
Normal file
131
apps/web-antd/src/api/mall/statistics/member.ts
Normal file
@@ -0,0 +1,131 @@
|
||||
import type { MallDataComparisonResp } from './common';
|
||||
|
||||
import { formatDate } from '@vben/utils';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MallMemberStatisticsApi {
|
||||
/** 会员分析 Request */
|
||||
export interface AnalyseReq {
|
||||
times: Date[];
|
||||
}
|
||||
|
||||
/** 会员分析对照数据 Response */
|
||||
export interface AnalyseComparison {
|
||||
registerUserCount: number;
|
||||
visitUserCount: number;
|
||||
rechargeUserCount: number;
|
||||
}
|
||||
|
||||
/** 会员分析 Response */
|
||||
export interface Analyse {
|
||||
visitUserCount: number;
|
||||
orderUserCount: number;
|
||||
payUserCount: number;
|
||||
atv: number;
|
||||
comparison: MallDataComparisonResp<AnalyseComparison>;
|
||||
}
|
||||
|
||||
/** 会员地区统计 Response */
|
||||
export interface AreaStatistics {
|
||||
areaId: number;
|
||||
areaName: string;
|
||||
userCount: number;
|
||||
orderCreateUserCount: number;
|
||||
orderPayUserCount: number;
|
||||
orderPayPrice: number;
|
||||
}
|
||||
|
||||
/** 会员性别统计 Response */
|
||||
export interface SexStatistics {
|
||||
sex: number;
|
||||
userCount: number;
|
||||
}
|
||||
|
||||
/** 会员统计 Response */
|
||||
export interface Summary {
|
||||
userCount: number;
|
||||
rechargeUserCount: number;
|
||||
rechargePrice: number;
|
||||
expensePrice: number;
|
||||
}
|
||||
|
||||
/** 会员终端统计 Response */
|
||||
export interface TerminalStatistics {
|
||||
terminal: number;
|
||||
userCount: number;
|
||||
}
|
||||
|
||||
/** 会员数量统计 Response */
|
||||
export interface Count {
|
||||
/** 用户访问量 */
|
||||
visitUserCount: string;
|
||||
/** 注册用户数量 */
|
||||
registerUserCount: number;
|
||||
}
|
||||
|
||||
/** 会员注册数量 Response */
|
||||
export interface RegisterCount {
|
||||
date: string;
|
||||
count: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询会员统计 */
|
||||
export function getMemberSummary() {
|
||||
return requestClient.get<MallMemberStatisticsApi.Summary>(
|
||||
'/statistics/member/summary',
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询会员分析数据 */
|
||||
export function getMemberAnalyse(params: MallMemberStatisticsApi.AnalyseReq) {
|
||||
return requestClient.get<MallMemberStatisticsApi.Analyse>(
|
||||
'/statistics/member/analyse',
|
||||
{
|
||||
params: {
|
||||
times: [formatDate(params.times[0]), formatDate(params.times[1])],
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 按照省份,查询会员统计列表 */
|
||||
export function getMemberAreaStatisticsList() {
|
||||
return requestClient.get<MallMemberStatisticsApi.AreaStatistics[]>(
|
||||
'/statistics/member/area-statistics-list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 按照性别,查询会员统计列表 */
|
||||
export function getMemberSexStatisticsList() {
|
||||
return requestClient.get<MallMemberStatisticsApi.SexStatistics[]>(
|
||||
'/statistics/member/sex-statistics-list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 按照终端,查询会员统计列表 */
|
||||
export function getMemberTerminalStatisticsList() {
|
||||
return requestClient.get<MallMemberStatisticsApi.TerminalStatistics[]>(
|
||||
'/statistics/member/terminal-statistics-list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 获得用户数量量对照 */
|
||||
export function getUserCountComparison() {
|
||||
return requestClient.get<
|
||||
MallDataComparisonResp<MallMemberStatisticsApi.Count>
|
||||
>('/statistics/member/user-count-comparison');
|
||||
}
|
||||
|
||||
/** 获得会员注册数量列表 */
|
||||
export function getMemberRegisterCountList(beginTime: Date, endTime: Date) {
|
||||
return requestClient.get<MallMemberStatisticsApi.RegisterCount[]>(
|
||||
'/statistics/member/register-count-list',
|
||||
{
|
||||
params: {
|
||||
times: [formatDate(beginTime), formatDate(endTime)],
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
16
apps/web-antd/src/api/mall/statistics/pay.ts
Normal file
16
apps/web-antd/src/api/mall/statistics/pay.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MallPayStatisticsApi {
|
||||
/** 支付统计 */
|
||||
export interface PaySummaryResp {
|
||||
/** 充值金额,单位分 */
|
||||
rechargePrice: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取钱包充值金额 */
|
||||
export function getWalletRechargePrice() {
|
||||
return requestClient.get<MallPayStatisticsApi.PaySummaryResp>(
|
||||
'/statistics/pay/summary',
|
||||
);
|
||||
}
|
68
apps/web-antd/src/api/mall/statistics/product.ts
Normal file
68
apps/web-antd/src/api/mall/statistics/product.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import type { PageParam, PageResult } from '../../../types';
|
||||
|
||||
import type { MallDataComparisonResp } from './common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MallProductStatisticsApi {
|
||||
/** 商品统计数据 */
|
||||
export interface ProductStatistics {
|
||||
/** 编号 */
|
||||
id: number;
|
||||
/** 统计日期 */
|
||||
day: string;
|
||||
/** 商品 SPU 编号 */
|
||||
spuId: number;
|
||||
/** 商品 SPU 名称 */
|
||||
spuName: string;
|
||||
/** 商品 SPU 图片 */
|
||||
spuPicUrl: string;
|
||||
/** 浏览次数 */
|
||||
browseCount: number;
|
||||
/** 浏览人数 */
|
||||
browseUserCount: number;
|
||||
/** 收藏次数 */
|
||||
favoriteCount: number;
|
||||
/** 加购次数 */
|
||||
cartCount: number;
|
||||
/** 下单次数 */
|
||||
orderCount: number;
|
||||
/** 支付次数 */
|
||||
orderPayCount: number;
|
||||
/** 支付金额 */
|
||||
orderPayPrice: number;
|
||||
/** 售后次数 */
|
||||
afterSaleCount: number;
|
||||
/** 退款金额 */
|
||||
afterSaleRefundPrice: number;
|
||||
/** 浏览转化率 */
|
||||
browseConvertPercent: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 获得商品统计分析 */
|
||||
export function getProductStatisticsAnalyse(params: PageParam) {
|
||||
return requestClient.get<
|
||||
MallDataComparisonResp<MallProductStatisticsApi.ProductStatistics>
|
||||
>('/statistics/product/analyse', { params });
|
||||
}
|
||||
|
||||
/** 获得商品状况明细 */
|
||||
export function getProductStatisticsList(params: PageParam) {
|
||||
return requestClient.get<MallProductStatisticsApi.ProductStatistics[]>(
|
||||
'/statistics/product/list',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出获得商品状况明细 Excel */
|
||||
export function exportProductStatisticsExcel(params: PageParam) {
|
||||
return requestClient.download('/statistics/product/export-excel', { params });
|
||||
}
|
||||
|
||||
/** 获得商品排行榜分页 */
|
||||
export function getProductStatisticsRankPage(params: PageParam) {
|
||||
return requestClient.get<
|
||||
PageResult<MallProductStatisticsApi.ProductStatistics>
|
||||
>('/statistics/product/rank-page', { params });
|
||||
}
|
135
apps/web-antd/src/api/mall/statistics/trade.ts
Normal file
135
apps/web-antd/src/api/mall/statistics/trade.ts
Normal file
@@ -0,0 +1,135 @@
|
||||
import type { MallDataComparisonResp } from './common';
|
||||
|
||||
import { formatDate } from '@vben/utils';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MallTradeStatisticsApi {
|
||||
/** 交易统计 Response */
|
||||
export interface TradeSummary {
|
||||
yesterdayOrderCount: number;
|
||||
monthOrderCount: number;
|
||||
yesterdayPayPrice: number;
|
||||
monthPayPrice: number;
|
||||
}
|
||||
|
||||
/** 交易状况 Request */
|
||||
export interface TradeTrendReq {
|
||||
times: [Date, Date];
|
||||
}
|
||||
|
||||
/** 交易状况统计 Response */
|
||||
export interface TradeTrendSummary {
|
||||
time: string;
|
||||
turnoverPrice: number;
|
||||
orderPayPrice: number;
|
||||
rechargePrice: number;
|
||||
expensePrice: number;
|
||||
walletPayPrice: number;
|
||||
brokerageSettlementPrice: number;
|
||||
afterSaleRefundPrice: number;
|
||||
}
|
||||
|
||||
/** 交易订单数量 Response */
|
||||
export interface TradeOrderCount {
|
||||
/** 待发货 */
|
||||
undelivered?: number;
|
||||
/** 待核销 */
|
||||
pickUp?: number;
|
||||
/** 退款中 */
|
||||
afterSaleApply?: number;
|
||||
/** 提现待审核 */
|
||||
auditingWithdraw?: number;
|
||||
}
|
||||
|
||||
/** 交易订单统计 Response */
|
||||
export interface TradeOrderSummary {
|
||||
/** 支付订单商品数 */
|
||||
orderPayCount?: number;
|
||||
/** 总支付金额,单位:分 */
|
||||
orderPayPrice?: number;
|
||||
}
|
||||
|
||||
/** 订单量趋势统计 Response */
|
||||
export interface TradeOrderTrend {
|
||||
/** 日期 */
|
||||
date: string;
|
||||
/** 订单数量 */
|
||||
orderPayCount: number;
|
||||
/** 订单支付金额 */
|
||||
orderPayPrice: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 时间参数需要格式化, 确保接口能识别 */
|
||||
const formatDateParam = (params: MallTradeStatisticsApi.TradeTrendReq) => {
|
||||
return {
|
||||
times: [formatDate(params.times[0]), formatDate(params.times[1])],
|
||||
} as MallTradeStatisticsApi.TradeTrendReq;
|
||||
};
|
||||
|
||||
/** 查询交易统计 */
|
||||
export function getTradeStatisticsSummary() {
|
||||
return requestClient.get<
|
||||
MallDataComparisonResp<MallTradeStatisticsApi.TradeSummary>
|
||||
>('/statistics/trade/summary');
|
||||
}
|
||||
|
||||
/** 获得交易状况统计 */
|
||||
export function getTradeStatisticsAnalyse(
|
||||
params: MallTradeStatisticsApi.TradeTrendReq,
|
||||
) {
|
||||
return requestClient.get<
|
||||
MallDataComparisonResp<MallTradeStatisticsApi.TradeTrendSummary>
|
||||
>('/statistics/trade/analyse', { params: formatDateParam(params) });
|
||||
}
|
||||
|
||||
/** 获得交易状况明细 */
|
||||
export function getTradeStatisticsList(
|
||||
params: MallTradeStatisticsApi.TradeTrendReq,
|
||||
) {
|
||||
return requestClient.get<MallTradeStatisticsApi.TradeTrendSummary[]>(
|
||||
'/statistics/trade/list',
|
||||
{ params: formatDateParam(params) },
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出交易状况明细 */
|
||||
export function exportTradeStatisticsExcel(
|
||||
params: MallTradeStatisticsApi.TradeTrendReq,
|
||||
) {
|
||||
return requestClient.download('/statistics/trade/export-excel', {
|
||||
params: formatDateParam(params),
|
||||
});
|
||||
}
|
||||
|
||||
/** 获得交易订单数量 */
|
||||
export function getOrderCount() {
|
||||
return requestClient.get<MallTradeStatisticsApi.TradeOrderCount>(
|
||||
'/statistics/trade/order-count',
|
||||
);
|
||||
}
|
||||
|
||||
/** 获得交易订单数量对照 */
|
||||
export function getOrderComparison() {
|
||||
return requestClient.get<
|
||||
MallDataComparisonResp<MallTradeStatisticsApi.TradeOrderSummary>
|
||||
>('/statistics/trade/order-comparison');
|
||||
}
|
||||
|
||||
/** 获得订单量趋势统计 */
|
||||
export function getOrderCountTrendComparison(
|
||||
type: number,
|
||||
beginTime: Date,
|
||||
endTime: Date,
|
||||
) {
|
||||
return requestClient.get<
|
||||
MallDataComparisonResp<MallTradeStatisticsApi.TradeOrderTrend>[]
|
||||
>('/statistics/trade/order-count-trend', {
|
||||
params: {
|
||||
type,
|
||||
beginTime: formatDate(beginTime),
|
||||
endTime: formatDate(endTime),
|
||||
},
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user