mirror of
				https://gitee.com/hhyykk/ipms-sjy-ui.git
				synced 2025-11-04 12:18:43 +08:00 
			
		
		
		
	统计:Review修改
This commit is contained in:
		
							
								
								
									
										5
									
								
								src/api/mall/statistics/common.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/api/mall/statistics/common.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
/** 数据对照 Response VO */
 | 
			
		||||
export interface DataComparisonRespVO<T> {
 | 
			
		||||
  value: T
 | 
			
		||||
  reference: T
 | 
			
		||||
}
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import request from '@/config/axios'
 | 
			
		||||
import dayjs from 'dayjs'
 | 
			
		||||
import { TradeStatisticsComparisonRespVO } from '@/api/mall/statistics/trade'
 | 
			
		||||
import { DataComparisonRespVO } from '@/api/mall/statistics/common'
 | 
			
		||||
import { formatDate } from '@/utils/formatTime'
 | 
			
		||||
 | 
			
		||||
/** 会员分析 Request VO */
 | 
			
		||||
@@ -10,17 +10,17 @@ export interface MemberAnalyseReqVO {
 | 
			
		||||
 | 
			
		||||
/** 会员分析 Response VO */
 | 
			
		||||
export interface MemberAnalyseRespVO {
 | 
			
		||||
  visitorCount: number
 | 
			
		||||
  visitUserCount: number
 | 
			
		||||
  orderUserCount: number
 | 
			
		||||
  payUserCount: number
 | 
			
		||||
  atv: number
 | 
			
		||||
  comparison: TradeStatisticsComparisonRespVO<MemberAnalyseComparisonRespVO>
 | 
			
		||||
  comparison: DataComparisonRespVO<MemberAnalyseComparisonRespVO>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 会员分析对照数据 Response VO */
 | 
			
		||||
export interface MemberAnalyseComparisonRespVO {
 | 
			
		||||
  userCount: number
 | 
			
		||||
  activeUserCount: number
 | 
			
		||||
  registerUserCount: number
 | 
			
		||||
  visitUserCount: number
 | 
			
		||||
  rechargeUserCount: number
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -29,8 +29,8 @@ export interface MemberAreaStatisticsRespVO {
 | 
			
		||||
  areaId: number
 | 
			
		||||
  areaName: string
 | 
			
		||||
  userCount: number
 | 
			
		||||
  orderCreateCount: number
 | 
			
		||||
  orderPayCount: number
 | 
			
		||||
  orderCreateUserCount: number
 | 
			
		||||
  orderPayUserCount: number
 | 
			
		||||
  orderPayPrice: number
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -106,7 +106,7 @@ export const getMemberTerminalStatisticsList = () => {
 | 
			
		||||
 | 
			
		||||
// 获得用户数量量对照
 | 
			
		||||
export const getUserCountComparison = () => {
 | 
			
		||||
  return request.get<TradeStatisticsComparisonRespVO<MemberCountRespVO>>({
 | 
			
		||||
  return request.get<DataComparisonRespVO<MemberCountRespVO>>({
 | 
			
		||||
    url: '/statistics/member/user-count-comparison'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,7 @@
 | 
			
		||||
import request from '@/config/axios'
 | 
			
		||||
import dayjs from 'dayjs'
 | 
			
		||||
import { formatDate } from '@/utils/formatTime'
 | 
			
		||||
 | 
			
		||||
/** 交易统计对照 Response VO */
 | 
			
		||||
export interface TradeStatisticsComparisonRespVO<T> {
 | 
			
		||||
  value: T
 | 
			
		||||
  reference: T
 | 
			
		||||
}
 | 
			
		||||
import { DataComparisonRespVO } from '@/api/mall/statistics/common'
 | 
			
		||||
 | 
			
		||||
/** 交易统计 Response VO */
 | 
			
		||||
export interface TradeSummaryRespVO {
 | 
			
		||||
@@ -24,11 +19,11 @@ export interface TradeTrendReqVO {
 | 
			
		||||
/** 交易状况统计 Response VO */
 | 
			
		||||
export interface TradeTrendSummaryRespVO {
 | 
			
		||||
  time: string
 | 
			
		||||
  turnover: number
 | 
			
		||||
  turnoverPrice: number
 | 
			
		||||
  orderPayPrice: number
 | 
			
		||||
  rechargePrice: number
 | 
			
		||||
  expensePrice: number
 | 
			
		||||
  balancePrice: number
 | 
			
		||||
  orderWalletPayPrice: number
 | 
			
		||||
  brokerageSettlementPrice: number
 | 
			
		||||
  orderRefundPrice: number
 | 
			
		||||
}
 | 
			
		||||
@@ -65,31 +60,31 @@ export interface TradeOrderTrendRespVO {
 | 
			
		||||
 | 
			
		||||
// 查询交易统计
 | 
			
		||||
export const getTradeStatisticsSummary = () => {
 | 
			
		||||
  return request.get<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>>({
 | 
			
		||||
  return request.get<DataComparisonRespVO<TradeSummaryRespVO>>({
 | 
			
		||||
    url: '/statistics/trade/summary'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 获得交易状况统计
 | 
			
		||||
export const getTradeTrendSummary = (params: TradeTrendReqVO) => {
 | 
			
		||||
  return request.get<TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO>>({
 | 
			
		||||
  return request.get<DataComparisonRespVO<TradeTrendSummaryRespVO>>({
 | 
			
		||||
    url: '/statistics/trade/trend/summary',
 | 
			
		||||
    params: formatDateParam(params)
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 获得交易状况明细
 | 
			
		||||
export const getTradeTrendList = (params: TradeTrendReqVO) => {
 | 
			
		||||
export const getTradeStatisticsList = (params: TradeTrendReqVO) => {
 | 
			
		||||
  return request.get<TradeTrendSummaryRespVO[]>({
 | 
			
		||||
    url: '/statistics/trade/trend/list',
 | 
			
		||||
    url: '/statistics/trade/list',
 | 
			
		||||
    params: formatDateParam(params)
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 导出交易状况明细
 | 
			
		||||
export const exportTradeTrend = (params: TradeTrendReqVO) => {
 | 
			
		||||
export const exportTradeStatisticsExcel = (params: TradeTrendReqVO) => {
 | 
			
		||||
  return request.download({
 | 
			
		||||
    url: '/statistics/trade/trend/export-excel',
 | 
			
		||||
    url: '/statistics/trade/export-excel',
 | 
			
		||||
    params: formatDateParam(params)
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
@@ -101,7 +96,7 @@ export const getOrderCount = async () => {
 | 
			
		||||
 | 
			
		||||
// 获得交易订单数量对照
 | 
			
		||||
export const getOrderComparison = async () => {
 | 
			
		||||
  return await request.get<TradeStatisticsComparisonRespVO<TradeOrderSummaryRespVO>>({
 | 
			
		||||
  return await request.get<DataComparisonRespVO<TradeOrderSummaryRespVO>>({
 | 
			
		||||
    url: `/statistics/trade/order-comparison`
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
@@ -112,7 +107,7 @@ export const getOrderCountTrendComparison = (
 | 
			
		||||
  beginTime: dayjs.ConfigType,
 | 
			
		||||
  endTime: dayjs.ConfigType
 | 
			
		||||
) => {
 | 
			
		||||
  return request.get<TradeStatisticsComparisonRespVO<TradeOrderTrendRespVO>[]>({
 | 
			
		||||
  return request.get<DataComparisonRespVO<TradeOrderTrendRespVO>[]>({
 | 
			
		||||
    url: '/statistics/trade/order-count-trend',
 | 
			
		||||
    params: { type, beginTime: formatDate(beginTime), endTime: formatDate(endTime) }
 | 
			
		||||
  })
 | 
			
		||||
 
 | 
			
		||||
@@ -66,10 +66,8 @@
 | 
			
		||||
<script lang="ts" setup>
 | 
			
		||||
import * as TradeStatisticsApi from '@/api/mall/statistics/trade'
 | 
			
		||||
import * as MemberStatisticsApi from '@/api/mall/statistics/member'
 | 
			
		||||
import {
 | 
			
		||||
  TradeOrderSummaryRespVO,
 | 
			
		||||
  TradeStatisticsComparisonRespVO
 | 
			
		||||
} from '@/api/mall/statistics/trade'
 | 
			
		||||
import { DataComparisonRespVO } from '@/api/mall/statistics/common'
 | 
			
		||||
import { TradeOrderSummaryRespVO } from '@/api/mall/statistics/trade'
 | 
			
		||||
import { MemberCountRespVO } from '@/api/mall/statistics/member'
 | 
			
		||||
import { fenToYuan } from '@/utils'
 | 
			
		||||
import ComparisonCard from './components/ComparisonCard.vue'
 | 
			
		||||
@@ -84,8 +82,8 @@ import MemberFunnelCard from '@/views/mall/statistics/member/components/MemberFu
 | 
			
		||||
defineOptions({ name: 'MallHome' })
 | 
			
		||||
 | 
			
		||||
const loading = ref(true) // 加载中
 | 
			
		||||
const orderComparison = ref<TradeStatisticsComparisonRespVO<TradeOrderSummaryRespVO>>() // 交易对照数据
 | 
			
		||||
const userComparison = ref<TradeStatisticsComparisonRespVO<MemberCountRespVO>>() // 用户对照数据
 | 
			
		||||
const orderComparison = ref<DataComparisonRespVO<TradeOrderSummaryRespVO>>() // 交易对照数据
 | 
			
		||||
const userComparison = ref<DataComparisonRespVO<MemberCountRespVO>>() // 用户对照数据
 | 
			
		||||
 | 
			
		||||
/** 查询交易对照卡片数据 */
 | 
			
		||||
const getOrderComparison = async () => {
 | 
			
		||||
 
 | 
			
		||||
@@ -12,13 +12,13 @@
 | 
			
		||||
        <div class="h-full w-75% bg-blue-50 <lg:w-35% <xl:w-55%">
 | 
			
		||||
          <div class="ml-15 h-full flex flex-col justify-center">
 | 
			
		||||
            <div class="font-bold">
 | 
			
		||||
              注册用户数量:{{ analyseData?.comparison?.value?.userCount || 0 }}
 | 
			
		||||
              注册用户数量:{{ analyseData?.comparison?.value?.registerUserCount || 0 }}
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="mt-2 text-3.5">
 | 
			
		||||
              环比增长率:{{
 | 
			
		||||
                calculateRelativeRate(
 | 
			
		||||
                  analyseData?.comparison?.value?.userCount,
 | 
			
		||||
                  analyseData?.comparison?.reference?.userCount
 | 
			
		||||
                  analyseData?.comparison?.value?.registerUserCount,
 | 
			
		||||
                  analyseData?.comparison?.reference?.registerUserCount
 | 
			
		||||
                )
 | 
			
		||||
              }}%
 | 
			
		||||
            </div>
 | 
			
		||||
@@ -27,7 +27,7 @@
 | 
			
		||||
        <div
 | 
			
		||||
          class="trapezoid1 ml--38.5 mt-1.5 h-full w-77 flex flex-col items-center justify-center bg-blue-5 text-3.5 text-white"
 | 
			
		||||
        >
 | 
			
		||||
          <span class="text-6 font-bold">{{ analyseData?.visitorCount || 0 }}</span>
 | 
			
		||||
          <span class="text-6 font-bold">{{ analyseData?.visitUserCount || 0 }}</span>
 | 
			
		||||
          <span>访客</span>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
@@ -35,13 +35,13 @@
 | 
			
		||||
        <div class="h-full w-75% flex bg-cyan-50 <lg:w-35% <xl:w-55%">
 | 
			
		||||
          <div class="ml-15 h-full flex flex-col justify-center">
 | 
			
		||||
            <div class="font-bold">
 | 
			
		||||
              活跃用户数量:{{ analyseData?.comparison?.value?.activeUserCount || 0 }}
 | 
			
		||||
              活跃用户数量:{{ analyseData?.comparison?.value?.visitUserCount || 0 }}
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="mt-2 text-3.5">
 | 
			
		||||
              环比增长率:{{
 | 
			
		||||
                calculateRelativeRate(
 | 
			
		||||
                  analyseData?.comparison?.value?.activeUserCount,
 | 
			
		||||
                  analyseData?.comparison?.reference?.activeUserCount
 | 
			
		||||
                  analyseData?.comparison?.value?.visitUserCount,
 | 
			
		||||
                  analyseData?.comparison?.reference?.visitUserCount
 | 
			
		||||
                )
 | 
			
		||||
              }}%
 | 
			
		||||
            </div>
 | 
			
		||||
 
 | 
			
		||||
@@ -82,14 +82,14 @@
 | 
			
		||||
                />
 | 
			
		||||
                <el-table-column
 | 
			
		||||
                  label="订单创建数量"
 | 
			
		||||
                  prop="orderCreateCount"
 | 
			
		||||
                  prop="orderCreateUserCount"
 | 
			
		||||
                  align="center"
 | 
			
		||||
                  min-width="135"
 | 
			
		||||
                  sortable
 | 
			
		||||
                />
 | 
			
		||||
                <el-table-column
 | 
			
		||||
                  label="订单支付数量"
 | 
			
		||||
                  prop="orderPayCount"
 | 
			
		||||
                  prop="orderPayUserCount"
 | 
			
		||||
                  align="center"
 | 
			
		||||
                  min-width="135"
 | 
			
		||||
                  sortable
 | 
			
		||||
 
 | 
			
		||||
@@ -84,11 +84,11 @@
 | 
			
		||||
            icon-bg-color="text-blue-500"
 | 
			
		||||
            prefix="¥"
 | 
			
		||||
            :decimals="2"
 | 
			
		||||
            :value="fenToYuan(trendSummary?.value?.turnover || 0)"
 | 
			
		||||
            :value="fenToYuan(trendSummary?.value?.turnoverPrice || 0)"
 | 
			
		||||
            :percent="
 | 
			
		||||
              calculateRelativeRate(
 | 
			
		||||
                trendSummary?.value?.turnover,
 | 
			
		||||
                trendSummary?.reference?.turnover
 | 
			
		||||
                trendSummary?.value?.turnoverPrice,
 | 
			
		||||
                trendSummary?.reference?.turnoverPrice
 | 
			
		||||
              )
 | 
			
		||||
            "
 | 
			
		||||
          />
 | 
			
		||||
@@ -156,11 +156,11 @@
 | 
			
		||||
            icon-bg-color="text-cyan-500"
 | 
			
		||||
            prefix="¥"
 | 
			
		||||
            :decimals="2"
 | 
			
		||||
            :value="fenToYuan(trendSummary?.value?.balancePrice || 0)"
 | 
			
		||||
            :value="fenToYuan(trendSummary?.value?.orderWalletPayPrice || 0)"
 | 
			
		||||
            :percent="
 | 
			
		||||
              calculateRelativeRate(
 | 
			
		||||
                trendSummary?.value?.balancePrice,
 | 
			
		||||
                trendSummary?.reference?.balancePrice
 | 
			
		||||
                trendSummary?.value?.orderWalletPayPrice,
 | 
			
		||||
                trendSummary?.reference?.orderWalletPayPrice
 | 
			
		||||
              )
 | 
			
		||||
            "
 | 
			
		||||
          />
 | 
			
		||||
@@ -214,11 +214,8 @@ import * as TradeStatisticsApi from '@/api/mall/statistics/trade'
 | 
			
		||||
import TradeStatisticValue from './components/TradeStatisticValue.vue'
 | 
			
		||||
import TradeTrendValue from './components/TradeTrendValue.vue'
 | 
			
		||||
import { EChartsOption } from 'echarts'
 | 
			
		||||
import {
 | 
			
		||||
  TradeStatisticsComparisonRespVO,
 | 
			
		||||
  TradeSummaryRespVO,
 | 
			
		||||
  TradeTrendSummaryRespVO
 | 
			
		||||
} from '@/api/mall/statistics/trade'
 | 
			
		||||
import { DataComparisonRespVO } from '@/api/mall/statistics/common'
 | 
			
		||||
import { TradeSummaryRespVO, TradeTrendSummaryRespVO } from '@/api/mall/statistics/trade'
 | 
			
		||||
import { calculateRelativeRate, fenToYuan } from '@/utils'
 | 
			
		||||
import download from '@/utils/download'
 | 
			
		||||
import { CardTitle } from '@/components/Card'
 | 
			
		||||
@@ -231,14 +228,14 @@ const message = useMessage() // 消息弹窗
 | 
			
		||||
const loading = ref(true) // 加载中
 | 
			
		||||
const trendLoading = ref(true) // 交易状态加载中
 | 
			
		||||
const exportLoading = ref(false) // 导出的加载中
 | 
			
		||||
const summary = ref<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>>() // 交易统计数据
 | 
			
		||||
const trendSummary = ref<TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO>>() // 交易状况统计数据
 | 
			
		||||
const summary = ref<DataComparisonRespVO<TradeSummaryRespVO>>() // 交易统计数据
 | 
			
		||||
const trendSummary = ref<DataComparisonRespVO<TradeTrendSummaryRespVO>>() // 交易状况统计数据
 | 
			
		||||
const shortcutDateRangePicker = ref()
 | 
			
		||||
 | 
			
		||||
/** 折线图配置 */
 | 
			
		||||
const lineChartOptions = reactive<EChartsOption>({
 | 
			
		||||
  dataset: {
 | 
			
		||||
    dimensions: ['date', 'turnover', 'orderPayPrice', 'rechargePrice', 'expensePrice'],
 | 
			
		||||
    dimensions: ['date', 'turnoverPrice', 'orderPayPrice', 'rechargePrice', 'expensePrice'],
 | 
			
		||||
    source: []
 | 
			
		||||
  },
 | 
			
		||||
  grid: {
 | 
			
		||||
@@ -293,7 +290,7 @@ const lineChartOptions = reactive<EChartsOption>({
 | 
			
		||||
/** 处理交易状况查询 */
 | 
			
		||||
const getTradeTrendData = async () => {
 | 
			
		||||
  trendLoading.value = true
 | 
			
		||||
  await Promise.all([getTradeTrendSummary(), getTradeTrendList()])
 | 
			
		||||
  await Promise.all([getTradeTrendSummary(), getTradeStatisticsList()])
 | 
			
		||||
  trendLoading.value = false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -309,13 +306,13 @@ const getTradeTrendSummary = async () => {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 查询交易状况数据列表 */
 | 
			
		||||
const getTradeTrendList = async () => {
 | 
			
		||||
const getTradeStatisticsList = async () => {
 | 
			
		||||
  // 查询数据
 | 
			
		||||
  const times = shortcutDateRangePicker.value.times
 | 
			
		||||
  const list = await TradeStatisticsApi.getTradeTrendList({ times })
 | 
			
		||||
  const list = await TradeStatisticsApi.getTradeStatisticsList({ times })
 | 
			
		||||
  // 处理数据
 | 
			
		||||
  for (let item of list) {
 | 
			
		||||
    item.turnover = fenToYuan(item.turnover)
 | 
			
		||||
    item.turnoverPrice = fenToYuan(item.turnoverPrice)
 | 
			
		||||
    item.orderPayPrice = fenToYuan(item.orderPayPrice)
 | 
			
		||||
    item.rechargePrice = fenToYuan(item.rechargePrice)
 | 
			
		||||
    item.expensePrice = fenToYuan(item.expensePrice)
 | 
			
		||||
@@ -334,7 +331,7 @@ const handleExport = async () => {
 | 
			
		||||
    // 发起导出
 | 
			
		||||
    exportLoading.value = true
 | 
			
		||||
    const times = shortcutDateRangePicker.value.times
 | 
			
		||||
    const data = await TradeStatisticsApi.exportTradeTrend({ times })
 | 
			
		||||
    const data = await TradeStatisticsApi.exportTradeStatisticsExcel({ times })
 | 
			
		||||
    download.excel(data, '交易状况.xls')
 | 
			
		||||
  } catch {
 | 
			
		||||
  } finally {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user