主页信息

This commit is contained in:
csc 2025-10-20 16:06:00 +08:00
parent da80439fcc
commit de0c9afa81
8 changed files with 72 additions and 23 deletions

View File

@ -2,7 +2,7 @@ import { request } from '@/service/request';
/** 获取营销用户卡片数据 */
export function getMktCardData(startDate: string,endDate: string) {
return request<null>({
return request<any>({
url: '/common/statistics/getMktCardData',
method: 'get',
params: {startDate,endDate}

View File

@ -321,6 +321,7 @@ onMounted(() => {
i.time = getRelativeTime(i.time)
}
})
//
getPricingSummary().then(res => {
let tmp = []
for (let key in pricingSummaryName) {

View File

@ -88,6 +88,10 @@ const fetchCardData = async () => {
throw new Error('Failed to fetch card data');
}
if (data.startDate && data.endDate) {
formattedDateRange.value = `${data.startDate}${data.endDate}`;
}
// API
return cardTemplate.map(item => {
const apiValue = data[item.key as keyof typeof data];
@ -128,15 +132,17 @@ const handleQuickChange = (type: 'today' | 'week' | 'month') => {
emit('quick-change', type);
};
const formattedDateRange = computed(() => {
if (!props.dateRange || props.dateRange.length !== 2) return '';
// const formattedDateRange = computed(() => {
// if (!props.dateRange || props.dateRange.length !== 2) return '';
//
// const format = 'YYYY-MM-DD';
// const start = dayjs(props.dateRange[0]).format(format);
// const end = dayjs(props.dateRange[1]).format(format);
//
// return start === end ? `${start}` : `${start} ${end}`;
// });
const format = 'YYYY-MM-DD';
const start = dayjs(props.dateRange[0]).format(format);
const end = dayjs(props.dateRange[1]).format(format);
return start === end ? `${start}` : `${start}${end}`;
});
const formattedDateRange = ref('');
interface GradientBgProps {
gradientColor: string;
@ -156,7 +162,7 @@ function getGradientColor(color: MktCardData['color']) {
<div class="date-range-display">
<div class="title-container">
<span class="title">营销数据概览</span>
<span class="value">{{ formattedDateRange }} </span>
<span class="value">{{ formattedDateRange }}</span>
</div>
</div>
<div class="date-controls">

View File

@ -56,6 +56,12 @@ public interface MarketingPerformanceMapper extends BaseMapperPlus<MarketingPerf
})
HomePageMarketingPerformanceSummary homePageMarketingPerformanceSummary();
@DataPermission({
@DataColumn(key = "deptName", value = "create_dept"),
@DataColumn(key = "userName", value = "create_by")
})
HomePageMarketingPerformanceSummary homePageMarketingPerformanceTotal();
@DataPermission({
@DataColumn(key = "deptName", value = "create_dept"),
@DataColumn(key = "userName", value = "create_by")

View File

@ -1,5 +1,7 @@
package org.dromara.statistics.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -7,7 +9,6 @@ import org.dromara.business.mapper.BusinessSubcategoryMapper;
import org.dromara.common.core.domain.R;
import org.dromara.mps.domain.MpsMarket;
import org.dromara.mps.mapper.MpsMarketMapper;
import org.dromara.report.domain.MarketingPerformance;
import org.dromara.report.mapper.MarketingPerformanceMapper;
import org.dromara.statistics.domain.vo.*;
import org.dromara.system.domain.vo.SysOperLogVo;
@ -18,10 +19,10 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAccessor;
import java.util.*;
import java.util.stream.Collectors;
@ -50,21 +51,34 @@ public class StatisticsController {
// 营销人员卡片数据
@GetMapping("/getMktCardData")
public R<MktCardVo> getMktCardData(String startDate, String endDate) {
public R<MktCardVo> getMktCardData(/*String startDate, String endDate*/) {
MktCardVo mktCardVo = new MktCardVo();
LambdaQueryWrapper<MarketingPerformance> mp = new LambdaQueryWrapper<>();
mp.select(MarketingPerformance::getRecordDate, MarketingPerformance::getTotalCount, MarketingPerformance::getTotalAmount);
//查询出日期最近的一条
mp.orderByDesc(MarketingPerformance::getRecordDate);
mp.last("limit 1");
MarketingPerformance marketingPerformance = marketingPerformanceMapper.homePageSelectOne(mp);
mktCardVo.setMpsCount(Math.toIntExact(marketingPerformance == null ? 0L : marketingPerformance.getTotalCount())); // 总计件量
mktCardVo.setMpsAmt(marketingPerformance == null ? BigDecimal.ZERO : marketingPerformance.getTotalAmount()); // 总计价额
HomePageMarketingPerformanceSummary summary = marketingPerformanceMapper.homePageMarketingPerformanceTotal();
Long busiCount = businessSubcategoryMapper.selectCount(new LambdaQueryWrapper<>());
mktCardVo.setBusiCount(Math.toIntExact(busiCount)); // 产品种类
Integer customerCount = mpsMarketMapper.selectCountByCustId(startDate, endDate);
if (summary == null) {
mktCardVo.setMpsCount(0);
mktCardVo.setMpsAmt("0");
mktCardVo.setCustomerCount(0);
mktCardVo.setStartDate(null);
mktCardVo.setEndDate(null);
return R.ok(mktCardVo);
}
mktCardVo.setMpsCount(summary.getCount()); // 总计件量
mktCardVo.setMpsAmt(summary.getTotal()); // 总计价额
//解析 日期
TemporalAccessor parse = FULL_DATE_FORMATTER.parse(summary.getRecordDate());
//获取月初
DateTime dateTime = DateUtil.beginOfMonth(DateUtil.date(parse));
String startDate = FULL_DATE_FORMATTER.format(dateTime.toLocalDateTime());
Integer customerCount = mpsMarketMapper.selectCountByCustId(startDate, summary.getRecordDate());
mktCardVo.setCustomerCount(Math.toIntExact(customerCount)); // 客户数量
mktCardVo.setStartDate(startDate);
mktCardVo.setEndDate(summary.getRecordDate());
return R.ok(mktCardVo);
}

View File

@ -51,4 +51,12 @@ public class HomePageMarketingPerformanceSummary {
* total
*/
String total;
/**
* count
*/
Integer count;
/**
* recordDate
*/
String recordDate;
}

View File

@ -14,7 +14,7 @@ public class MktCardVo {
/**
* 总计价额
*/
private BigDecimal mpsAmt;
private String mpsAmt;
/**
* 产品种类(营销产品的种类数量)
@ -26,4 +26,8 @@ public class MktCardVo {
*/
private int customerCount;
String startDate;
String endDate;
}

View File

@ -223,4 +223,14 @@
where record_date = (select max(record_date) from marketing_performance)
</select>
<!-- 主页计价汇总-->
<select id="homePageMarketingPerformanceTotal" resultType="org.dromara.statistics.domain.vo.HomePageMarketingPerformanceSummary">
select
sum(total_count) as count,
sum(total_amount) as total,
max(record_date) as record_date
from marketing_performance
where record_date = (select max(record_date) from marketing_performance)
</select>
</mapper>