From 648dcb23e49c4c3e3bf4f3cf61a89873157fdc9a Mon Sep 17 00:00:00 2001
From: liujiang <569804566@qq.com>
Date: Tue, 22 Jul 2025 17:06:15 +0800
Subject: [PATCH] =?UTF-8?q?master=EF=BC=9AAPP=20=E6=A1=A3=E5=8F=A3?=
=?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A6=82=E8=A7=88=E8=B0=83=E6=95=B4=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../xkt/vo/store/StoreIndexOverviewResVO.java | 4 ++
.../vo/store/StoreIndexSaleRevenueResVO.java | 3 +-
.../mapper/quartz/DailySaleCustomerMapper.xml | 19 +++++++++
.../dto/store/StoreIndexOverviewResDTO.java | 4 ++
.../store/StoreIndexSaleRevenueResDTO.java | 4 +-
.../ruoyi/xkt/dto/store/StoreOverviewDTO.java | 1 +
.../xkt/mapper/DailySaleCustomerMapper.java | 21 +++++++++-
.../xkt/mapper/DailySaleProductMapper.java | 9 ++--
.../xkt/service/impl/StoreServiceImpl.java | 41 +++++++++++++------
9 files changed, 85 insertions(+), 21 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/store/StoreIndexOverviewResVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/store/StoreIndexOverviewResVO.java
index 1109f85f4..90ac6841f 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/store/StoreIndexOverviewResVO.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/store/StoreIndexOverviewResVO.java
@@ -29,5 +29,9 @@ public class StoreIndexOverviewResVO {
private Integer storageNum;
@ApiModelProperty(value = "累计客户数")
private Integer customerNum;
+ @ApiModelProperty(value = "销售大客户")
+ private String topSaleCusName;
+ @ApiModelProperty(value = "销售大客户金额")
+ private BigDecimal topSaleCusAmount;
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/store/StoreIndexSaleRevenueResVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/store/StoreIndexSaleRevenueResVO.java
index 4c6f6ffe9..6dbc4c483 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/store/StoreIndexSaleRevenueResVO.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/store/StoreIndexSaleRevenueResVO.java
@@ -21,8 +21,7 @@ public class StoreIndexSaleRevenueResVO {
private Long storeId;
@ApiModelProperty(value = "销售出库金额")
private BigDecimal saleAmount;
- @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "单据日期")
- private Date voucherDate;
+ private Integer day;
}
diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleCustomerMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleCustomerMapper.xml
index 6f0c18678..7586d55ab 100644
--- a/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleCustomerMapper.xml
+++ b/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleCustomerMapper.xml
@@ -46,4 +46,23 @@
LIMIT 10
+
+
\ No newline at end of file
diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreIndexOverviewResDTO.java b/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreIndexOverviewResDTO.java
index 5f8c4588a..5af15a7fb 100644
--- a/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreIndexOverviewResDTO.java
+++ b/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreIndexOverviewResDTO.java
@@ -31,5 +31,9 @@ public class StoreIndexOverviewResDTO {
private Integer storageNum;
@ApiModelProperty(value = "累计客户数")
private Integer customerNum;
+ @ApiModelProperty(value = "销售大客户")
+ private String topSaleCusName;
+ @ApiModelProperty(value = "销售大客户金额")
+ private BigDecimal topSaleCusAmount;
}
diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreIndexSaleRevenueResDTO.java b/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreIndexSaleRevenueResDTO.java
index a4f90abac..27be47c8e 100644
--- a/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreIndexSaleRevenueResDTO.java
+++ b/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreIndexSaleRevenueResDTO.java
@@ -3,6 +3,7 @@ package com.ruoyi.xkt.dto.store;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
+import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
@@ -14,6 +15,7 @@ import java.util.Date;
*/
@ApiModel("档口首页销售额")
@Data
+@Accessors(chain = true)
public class StoreIndexSaleRevenueResDTO {
@ApiModelProperty(value = "档口ID")
@@ -21,6 +23,6 @@ public class StoreIndexSaleRevenueResDTO {
@ApiModelProperty(value = "销售出库金额")
private BigDecimal saleAmount;
@ApiModelProperty(value = "单据日期")
- private Date voucherDate;
+ private Integer day;
}
diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreOverviewDTO.java b/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreOverviewDTO.java
index 6cd98556e..097f0fc17 100644
--- a/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreOverviewDTO.java
+++ b/xkt/src/main/java/com/ruoyi/xkt/dto/store/StoreOverviewDTO.java
@@ -1,5 +1,6 @@
package com.ruoyi.xkt.dto.store;
+import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
diff --git a/xkt/src/main/java/com/ruoyi/xkt/mapper/DailySaleCustomerMapper.java b/xkt/src/main/java/com/ruoyi/xkt/mapper/DailySaleCustomerMapper.java
index 218dcfb18..d48b07c29 100644
--- a/xkt/src/main/java/com/ruoyi/xkt/mapper/DailySaleCustomerMapper.java
+++ b/xkt/src/main/java/com/ruoyi/xkt/mapper/DailySaleCustomerMapper.java
@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.xkt.domain.DailySaleCustomer;
import com.ruoyi.xkt.dto.dailySale.DailySaleCusDTO;
import com.ruoyi.xkt.dto.store.StoreIndexCusSaleTop10ResDTO;
+import com.ruoyi.xkt.dto.store.StoreIndexOverviewResDTO;
import com.ruoyi.xkt.dto.store.StoreSaleCustomerTop10DTO;
+import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
@@ -21,9 +23,24 @@ public interface DailySaleCustomerMapper extends BaseMapper {
/**
* 档口客户销售榜前10
*
- * @param saleCusTop10DTO 查询入参
+ * @param storeId storeId
+ * @param voucherDateStart 开始时间
+ * @param voucherDateEnd 结束时间
* @return List
*/
- List selectTop10SaleCustomerList(StoreSaleCustomerTop10DTO saleCusTop10DTO);
+ List selectTop10SaleCustomerList(@Param("storeId") Long storeId,
+ @Param("voucherDateStart") String voucherDateStart,
+ @Param("voucherDateEnd") String voucherDateEnd);
+ /**
+ * 筛选销售额最大的客户
+ *
+ * @param storeId 档口ID
+ * @param voucherDateStart 开始时间
+ * @param voucherDateEnd 结束时间
+ * @return StoreIndexOverviewResDTO
+ */
+ StoreIndexOverviewResDTO getMaxSaleCus(@Param("storeId") Long storeId,
+ @Param("voucherDateStart") String voucherDateStart,
+ @Param("voucherDateEnd") String voucherDateEnd);
}
diff --git a/xkt/src/main/java/com/ruoyi/xkt/mapper/DailySaleProductMapper.java b/xkt/src/main/java/com/ruoyi/xkt/mapper/DailySaleProductMapper.java
index e4eded304..dff8814b3 100644
--- a/xkt/src/main/java/com/ruoyi/xkt/mapper/DailySaleProductMapper.java
+++ b/xkt/src/main/java/com/ruoyi/xkt/mapper/DailySaleProductMapper.java
@@ -7,7 +7,6 @@ import com.ruoyi.xkt.dto.dailySale.DailySaleProdDTO;
import com.ruoyi.xkt.dto.dailyStoreProd.DailyStoreProdSaleDTO;
import com.ruoyi.xkt.dto.dailyStoreTag.DailyStoreTagDTO;
import com.ruoyi.xkt.dto.store.StoreIndexSaleTop10ResDTO;
-import com.ruoyi.xkt.dto.store.StoreSaleTop10DTO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@@ -40,10 +39,14 @@ public interface DailySaleProductMapper extends BaseMapper {
/**
* 获取档口首页商品销量前10
*
- * @param saleTop10DTO 查询入参
+ * @param storeId storeId
+ * @param voucherDateStart 开始时间
+ * @param voucherDateEnd 结束时间
* @return List
*/
- List selectTop10SaleList(StoreSaleTop10DTO saleTop10DTO);
+ List selectTop10SaleList(@Param("storeId") Long storeId,
+ @Param("voucherDateStart") String voucherDateStart,
+ @Param("voucherDateEnd") String voucherDateEnd);
/**
* 获取爆款频出的前50商品及档口
diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreServiceImpl.java
index 2fbc85fa6..456f1ee7a 100644
--- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreServiceImpl.java
+++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreServiceImpl.java
@@ -2,6 +2,7 @@ package com.ruoyi.xkt.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import co.elastic.clients.elasticsearch.core.BulkResponse;
import co.elastic.clients.elasticsearch.core.bulk.BulkOperation;
@@ -274,12 +275,16 @@ public class StoreServiceImpl implements IStoreService {
@Override
@Transactional(readOnly = true)
public StoreIndexOverviewResDTO indexOverview(StoreOverviewDTO overviewDTO) {
- List saleList = this.dailySaleMapper.selectList(new LambdaQueryWrapper()
- .eq(DailySale::getStoreId, overviewDTO.getStoreId()).eq(DailySale::getDelFlag, Constants.UNDELETED)
- .between(DailySale::getVoucherDate, overviewDTO.getVoucherDateStart(), overviewDTO.getVoucherDateEnd()));
- if (CollectionUtils.isEmpty(saleList)) {
- return new StoreIndexOverviewResDTO();
- }
+ final String voucherDateStart = DateUtil.formatDate(overviewDTO.getVoucherDateStart());
+ final String voucherDateEnd = DateUtil.formatDate(overviewDTO.getVoucherDateEnd());
+ // 档口销售数据
+ List saleList = Optional.ofNullable(this.dailySaleMapper.selectList(new LambdaQueryWrapper()
+ .eq(DailySale::getStoreId, overviewDTO.getStoreId()).eq(DailySale::getDelFlag, Constants.UNDELETED)
+ .between(DailySale::getVoucherDate, voucherDateStart, voucherDateEnd)))
+ .orElse(Collections.emptyList());
+ saleList = CollectionUtils.isNotEmpty(saleList) ? saleList : Collections.emptyList();
+ // 最大销售额客户
+ StoreIndexOverviewResDTO maxSaleCus = this.dailySaleCusMapper.getMaxSaleCus(overviewDTO.getStoreId(), voucherDateStart, voucherDateEnd);
// 总的销售出库金额
BigDecimal saleAmount = saleList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSaleAmount(), BigDecimal.ZERO)).reduce(BigDecimal.ZERO, BigDecimal::add);
// 总的销售退货金额
@@ -293,7 +298,9 @@ public class StoreServiceImpl implements IStoreService {
// 总的累计客户数
Integer customerNum = saleList.stream().map(x -> ObjectUtils.defaultIfNull(x.getCustomerNum(), 0)).reduce(0, Integer::sum);
return new StoreIndexOverviewResDTO().setSaleAmount(saleAmount).setRefundAmount(refundAmount).setSaleNum(saleNum).setRefundNum(refundNum)
- .setStorageNum(storageNum).setCustomerNum(customerNum);
+ .setStorageNum(storageNum).setCustomerNum(customerNum).setStoreId(overviewDTO.getStoreId())
+ .setTopSaleCusName(ObjectUtils.isNotEmpty(maxSaleCus) ? maxSaleCus.getTopSaleCusName() : "")
+ .setTopSaleCusAmount(ObjectUtils.isNotEmpty(maxSaleCus) ? maxSaleCus.getTopSaleCusAmount() : null);
}
/**
@@ -305,10 +312,16 @@ public class StoreServiceImpl implements IStoreService {
@Override
@Transactional(readOnly = true)
public List indexSaleRevenue(StoreSaleRevenueDTO revenueDTO) {
- List saleList = this.dailySaleMapper.selectList(new LambdaQueryWrapper()
- .eq(DailySale::getStoreId, revenueDTO.getStoreId()).eq(DailySale::getDelFlag, Constants.UNDELETED)
- .between(DailySale::getVoucherDate, revenueDTO.getVoucherDateStart(), revenueDTO.getVoucherDateEnd()));
- return BeanUtil.copyToList(saleList, StoreIndexSaleRevenueResDTO.class);
+ final String voucherDateStart = DateUtil.formatDate(revenueDTO.getVoucherDateStart());
+ final String voucherDateEnd = DateUtil.formatDate(revenueDTO.getVoucherDateEnd());
+ List saleList = Optional.ofNullable(this.dailySaleMapper.selectList(new LambdaQueryWrapper()
+ .eq(DailySale::getStoreId, revenueDTO.getStoreId()).eq(DailySale::getDelFlag, Constants.UNDELETED)
+ .between(DailySale::getVoucherDate, voucherDateStart, voucherDateEnd)))
+ .orElse(Collections.emptyList());
+ return saleList.stream().map(x -> BeanUtil.toBean(x, StoreIndexSaleRevenueResDTO.class)
+ .setDay(x.getVoucherDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().getDayOfMonth()))
+ .sorted(Comparator.comparingInt(StoreIndexSaleRevenueResDTO::getDay))
+ .collect(Collectors.toList());
}
/**
@@ -412,7 +425,8 @@ public class StoreServiceImpl implements IStoreService {
@Override
@Transactional(readOnly = true)
public List indexTop10Sale(StoreSaleTop10DTO saleTop10DTO) {
- return this.dailySaleProdMapper.selectTop10SaleList(saleTop10DTO);
+ return this.dailySaleProdMapper.selectTop10SaleList(saleTop10DTO.getStoreId(),
+ DateUtil.formatDate(saleTop10DTO.getVoucherDateStart()), DateUtil.formatDate(saleTop10DTO.getVoucherDateEnd()));
}
/**
@@ -424,7 +438,8 @@ public class StoreServiceImpl implements IStoreService {
@Override
@Transactional(readOnly = true)
public List indexTop10SaleCus(StoreSaleCustomerTop10DTO saleCusTop10DTO) {
- return this.dailySaleCusMapper.selectTop10SaleCustomerList(saleCusTop10DTO);
+ return this.dailySaleCusMapper.selectTop10SaleCustomerList(saleCusTop10DTO.getStoreId(),
+ DateUtil.formatDate(saleCusTop10DTO.getVoucherDateStart()), DateUtil.formatDate(saleCusTop10DTO.getVoucherDateEnd()));
}
/**