From ca35e1a4afa82b5a4be63d1c0c2e71f9743d7cab Mon Sep 17 00:00:00 2001 From: owen Date: Sat, 16 Dec 2023 23:48:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=EF=BC=9A=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mall/statistics/product.ts | 52 +++ src/api/mall/statistics/trade.ts | 4 +- src/config/axios/service.ts | 24 +- src/utils/index.ts | 9 + .../product/components/ProductRank.vue | 104 ++++++ .../product/components/ProductSummary.vue | 304 ++++++++++++++++++ src/views/mall/statistics/product/index.vue | 14 + src/views/mall/statistics/trade/index.vue | 6 +- 8 files changed, 492 insertions(+), 25 deletions(-) create mode 100644 src/api/mall/statistics/product.ts create mode 100644 src/views/mall/statistics/product/components/ProductRank.vue create mode 100644 src/views/mall/statistics/product/components/ProductSummary.vue create mode 100644 src/views/mall/statistics/product/index.vue diff --git a/src/api/mall/statistics/product.ts b/src/api/mall/statistics/product.ts new file mode 100644 index 00000000..798a2fa8 --- /dev/null +++ b/src/api/mall/statistics/product.ts @@ -0,0 +1,52 @@ +import request from '@/config/axios' +import { DataComparisonRespVO } from '@/api/mall/statistics/common' + +export interface ProductStatisticsVO { + id: number + day: string + spuId: number + spuName: string + spuPicUrl: string + browseCount: number + browseUserCount: number + favoriteCount: number + cartCount: number + orderCount: number + orderPayCount: number + orderPayPrice: number + afterSaleCount: number + afterSaleRefundPrice: number + browseConvertPercent: number +} + +// 商品统计 API +export const ProductStatisticsApi = { + // 获得商品统计分析 + getProductStatisticsAnalyse: (params: any) => { + return request.get>({ + url: '/statistics/product/analyse', + params + }) + }, + // 获得商品状况明细 + getProductStatisticsList: (params: any) => { + return request.get({ + url: '/statistics/product/list', + params + }) + }, + // 导出获得商品状况明细 Excel + exportProductStatisticsExcel: (params: any) => { + return request.download({ + url: '/statistics/product/export-excel', + params + }) + }, + // 获得商品排行榜分页 + getProductStatisticsRankPage: async (params: any) => { + return await request.get({ + url: `/statistics/product/rank-page`, + params + }) + } +} diff --git a/src/api/mall/statistics/trade.ts b/src/api/mall/statistics/trade.ts index 94052597..e59952a6 100644 --- a/src/api/mall/statistics/trade.ts +++ b/src/api/mall/statistics/trade.ts @@ -66,9 +66,9 @@ export const getTradeStatisticsSummary = () => { } // 获得交易状况统计 -export const getTradeTrendSummary = (params: TradeTrendReqVO) => { +export const getTradeStatisticsAnalyse = (params: TradeTrendReqVO) => { return request.get>({ - url: '/statistics/trade/trend/summary', + url: '/statistics/trade/analyse', params: formatDateParam(params) }) } diff --git a/src/config/axios/service.ts b/src/config/axios/service.ts index 6413e945..fed526cd 100644 --- a/src/config/axios/service.ts +++ b/src/config/axios/service.ts @@ -70,27 +70,11 @@ service.interceptors.request.use( } // get参数编码 if (config.method?.toUpperCase() === 'GET' && params) { - let url = config.url + '?' - for (const propName of Object.keys(params)) { - const value = params[propName] - if (value !== void 0 && value !== null && typeof value !== 'undefined') { - if (typeof value === 'object') { - for (const val of Object.keys(value)) { - const params = propName + '[' + val + ']' - const subPart = encodeURIComponent(params) + '=' - url += subPart + encodeURIComponent(value[val]) + '&' - } - } else { - url += `${propName}=${encodeURIComponent(value)}&` - } - } - } - // 给 get 请求加上时间戳参数,避免从缓存中拿数据 - // const now = new Date().getTime() - // params = params.substring(0, url.length - 1) + `?_t=${now}` - url = url.slice(0, -1) config.params = {} - config.url = url + const paramsStr = qs.stringify(params, { allowDots: true }) + if (paramsStr) { + config.url = config.url + '?' + paramsStr + } } return config }, diff --git a/src/utils/index.ts b/src/utils/index.ts index 6ee53e71..771bb7a4 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -285,3 +285,12 @@ export const getUrlValue = (key: string, urlStr: string = location.href): string export const getUrlNumberValue = (key: string, urlStr: string = location.href): number => { return toNumber(getUrlValue(key, urlStr)) } + +/** + * 构建排序字段 + * @param prop 字段名称 + * @param order 顺序 + */ +export const buildSortingField = ({ prop, order }) => { + return { field: prop, order: order === 'ascending' ? 'asc' : 'desc' } +} diff --git a/src/views/mall/statistics/product/components/ProductRank.vue b/src/views/mall/statistics/product/components/ProductRank.vue new file mode 100644 index 00000000..a6285e1b --- /dev/null +++ b/src/views/mall/statistics/product/components/ProductRank.vue @@ -0,0 +1,104 @@ + + + diff --git a/src/views/mall/statistics/product/components/ProductSummary.vue b/src/views/mall/statistics/product/components/ProductSummary.vue new file mode 100644 index 00000000..d28660e2 --- /dev/null +++ b/src/views/mall/statistics/product/components/ProductSummary.vue @@ -0,0 +1,304 @@ + + + diff --git a/src/views/mall/statistics/product/index.vue b/src/views/mall/statistics/product/index.vue new file mode 100644 index 00000000..e0948a7c --- /dev/null +++ b/src/views/mall/statistics/product/index.vue @@ -0,0 +1,14 @@ + + + diff --git a/src/views/mall/statistics/trade/index.vue b/src/views/mall/statistics/trade/index.vue index 86deaa87..1b296b1b 100644 --- a/src/views/mall/statistics/trade/index.vue +++ b/src/views/mall/statistics/trade/index.vue @@ -298,7 +298,7 @@ const getTradeTrendData = async () => { times[0] = DateUtil.formatDate(dayjs(times[0]).subtract(1, 'd')) } // 查询数据 - await Promise.all([getTradeTrendSummary(), getTradeStatisticsList()]) + await Promise.all([getTradeStatisticsAnalyse(), getTradeStatisticsList()]) trendLoading.value = false } @@ -308,9 +308,9 @@ const getTradeStatisticsSummary = async () => { } /** 查询交易状况数据统计 */ -const getTradeTrendSummary = async () => { +const getTradeStatisticsAnalyse = async () => { const times = shortcutDateRangePicker.value.times - trendSummary.value = await TradeStatisticsApi.getTradeTrendSummary({ times }) + trendSummary.value = await TradeStatisticsApi.getTradeStatisticsAnalyse({ times }) } /** 查询交易状况数据列表 */