From 9cf68def59e9331dc470b06ece538ed5543e2526 Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期四, 17 十月 2024 22:35:10 +0800
Subject: [PATCH] 1.小程序-供应商-统计
---
src/main/java/com/mzl/flower/mapper/report/OrderReportMapper.java | 3
src/main/java/com/mzl/flower/service/report/OrderReportService.java | 15 ++
src/main/resources/mapper/report/OrderReportMapper.xml | 130 ++++++++++++++++++++++++++
src/main/java/com/mzl/flower/dto/response/report/AppSupplierStatisticsVO.java | 30 ++++++
src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java | 12 ++
src/main/java/com/mzl/flower/dto/request/report/QueryAppSupplierDTO.java | 20 ++++
src/main/java/com/mzl/flower/dto/response/supplier/SupplierOrderDTO.java | 23 ++++
src/main/java/com/mzl/flower/service/impl/report/OrderReportServiceImpl.java | 57 +++++++++++
8 files changed, 286 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/mzl/flower/dto/request/report/QueryAppSupplierDTO.java b/src/main/java/com/mzl/flower/dto/request/report/QueryAppSupplierDTO.java
new file mode 100644
index 0000000..aee1e7d
--- /dev/null
+++ b/src/main/java/com/mzl/flower/dto/request/report/QueryAppSupplierDTO.java
@@ -0,0 +1,20 @@
+package com.mzl.flower.dto.request.report;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+public class QueryAppSupplierDTO {
+
+ @ApiModelProperty("供应商ID")
+ private Long supplierId;
+
+ @ApiModelProperty("当天的开始时间")
+ private LocalDateTime startDateTime;
+
+ @ApiModelProperty("当天的结束时间")
+ private LocalDateTime endDateTime;
+
+}
diff --git a/src/main/java/com/mzl/flower/dto/response/report/AppSupplierStatisticsVO.java b/src/main/java/com/mzl/flower/dto/response/report/AppSupplierStatisticsVO.java
new file mode 100644
index 0000000..c28de73
--- /dev/null
+++ b/src/main/java/com/mzl/flower/dto/response/report/AppSupplierStatisticsVO.java
@@ -0,0 +1,30 @@
+package com.mzl.flower.dto.response.report;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class AppSupplierStatisticsVO {
+
+ @ApiModelProperty("总成交:花农售卖全部的底价合计")
+ private String allSupplierAmount;
+ @ApiModelProperty("本月成交:本月售卖的底价合计")
+ private String curMonSupplierAmount;
+ @ApiModelProperty("上月成交:上月售卖的底价合计")
+ private String lastMonSupplierAmount;
+ @ApiModelProperty("今日成交:今日售卖的底价合计")
+ private String todaySupplierAmount;
+ @ApiModelProperty("缺货(本月):本月质检缺货,并且web端审核通过的数量合计")
+ private String curMonLackNum;
+ @ApiModelProperty("上月质检缺货,并且web端审核通过的数量合计")
+ private String lastMonLackNum;
+ @ApiModelProperty("本月质检降级,并且web端审核通过的数量合计")
+ private String curMonReduceNum;
+ @ApiModelProperty("上月质检降级,并且web端审核通过的数量合计")
+ private String lastMonReduceNum;
+ @ApiModelProperty("本月质检补货,并且web端审核通过的数量合计")
+ private String curMonReplaceNum;
+ @ApiModelProperty("上月质检补货,并且web端审核通过的数量合计")
+ private String lastMonReplaceNum;
+
+}
diff --git a/src/main/java/com/mzl/flower/dto/response/supplier/SupplierOrderDTO.java b/src/main/java/com/mzl/flower/dto/response/supplier/SupplierOrderDTO.java
index 6272fc3..6af5324 100644
--- a/src/main/java/com/mzl/flower/dto/response/supplier/SupplierOrderDTO.java
+++ b/src/main/java/com/mzl/flower/dto/response/supplier/SupplierOrderDTO.java
@@ -37,4 +37,27 @@
@ApiModelProperty("今日配送总数")
private Integer deliverTotal;
+
+ @ApiModelProperty("总成交:花农售卖全部的底价合计")
+ private String allSupplierAmount;
+ @ApiModelProperty("本月成交:本月售卖的底价合计")
+ private String curMonSupplierAmount;
+ @ApiModelProperty("上月成交:上月售卖的底价合计")
+ private String lastMonSupplierAmount;
+ @ApiModelProperty("今日成交:今日售卖的底价合计")
+ private String todaySupplierAmount;
+ @ApiModelProperty("缺货(本月):本月质检缺货,并且web端审核通过的数量合计")
+ private String curMonLackNum;
+ @ApiModelProperty("上月质检缺货,并且web端审核通过的数量合计")
+ private String lastMonLackNum;
+ @ApiModelProperty("本月质检降级,并且web端审核通过的数量合计")
+ private String curMonReduceNum;
+ @ApiModelProperty("上月质检降级,并且web端审核通过的数量合计")
+ private String lastMonReduceNum;
+ @ApiModelProperty("本月质检补货,并且web端审核通过的数量合计")
+ private String curMonReplaceNum;
+ @ApiModelProperty("上月质检补货,并且web端审核通过的数量合计")
+ private String lastMonReplaceNum;
+
+
}
diff --git a/src/main/java/com/mzl/flower/mapper/report/OrderReportMapper.java b/src/main/java/com/mzl/flower/mapper/report/OrderReportMapper.java
index 561639b..20963e1 100644
--- a/src/main/java/com/mzl/flower/mapper/report/OrderReportMapper.java
+++ b/src/main/java/com/mzl/flower/mapper/report/OrderReportMapper.java
@@ -1,6 +1,7 @@
package com.mzl.flower.mapper.report;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.mzl.flower.dto.request.report.QueryAppSupplierDTO;
import com.mzl.flower.dto.response.report.*;
import com.mzl.flower.dto.request.report.QueryPartnerOrderDTO;
import com.mzl.flower.dto.response.report.OrderDetailReportResultVO;
@@ -29,4 +30,6 @@
List<OrderSupplierReportResultVO> getOrderSupplierReport(@Param("dto") SupplierReportCalendarBO calendarBO);
OrderSupplierReportResultVO getOrderSupplierCountReport(@Param("dto") SupplierReportCalendarBO calendarBO);
+
+ AppSupplierStatisticsVO getAppSupplierAmountStatistics(@Param("dto") QueryAppSupplierDTO dto);
}
diff --git a/src/main/java/com/mzl/flower/service/impl/report/OrderReportServiceImpl.java b/src/main/java/com/mzl/flower/service/impl/report/OrderReportServiceImpl.java
index c5d1640..9427397 100644
--- a/src/main/java/com/mzl/flower/service/impl/report/OrderReportServiceImpl.java
+++ b/src/main/java/com/mzl/flower/service/impl/report/OrderReportServiceImpl.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.config.exception.ValidationException;
+import com.mzl.flower.dto.request.report.QueryAppSupplierDTO;
import com.mzl.flower.dto.request.report.QueryOrderDTO;
import com.mzl.flower.dto.request.report.QueryPartnerOrderDTO;
import com.mzl.flower.dto.request.report.QuerySupplierDTO;
@@ -16,6 +17,7 @@
import com.mzl.flower.service.report.OrderReportService;
import com.mzl.flower.utils.ExcelExportUtil;
import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.hpsf.Decimal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@@ -341,6 +343,33 @@
log.error(e.getMessage(), e);
}
}
+
+ @Override
+ public AppSupplierStatisticsVO getAppSupplierStatistics(QueryAppSupplierDTO dto) {
+
+ // TODO
+
+ // 总成交:花农售卖全部的底价合计,
+ // 本月成交:本月售卖的底价合计,
+ // 上月成交:上月售卖的底价合计,
+ // 今日成交:今日售卖的底价合计,
+ // 近30天成交扎数:最近30天扎数合计(已有),
+ // 今日成交扎数(已有)
+ // 缺货(本月):本月质检缺货,并且web端审核通过的数量合计,
+ // 缺货(上月):上月质检缺货,并且web端审核通过的数量合计,
+ // 降级(本月):本月质检降级,并且web端审核通过的数量合计,
+ // 降级(上月):上月质检降级,并且web端审核通过的数量合计,
+ // 补货(本月):本月质检补货,并且web端审核通过的数量合计,
+ // 补货(上月):上月质检补货,并且web端审核通过的数量合计,
+
+ // 当天的开始时间
+ dto.setStartDateTime(getCurDayStartTime());
+ // 当天的结束时间
+ dto.setEndDateTime(getCurDayEndTime());
+
+ return orderReportMapper.getAppSupplierAmountStatistics(dto);
+ }
+
// 计算 startDate 的前一天 17:00:00
public static LocalDateTime calculateStartTime(LocalDateTime startDateTime) {
// 获取 LocalDate 部分
@@ -370,5 +399,33 @@
return endOfDay;
}
+ // 获取当天的开始时间
+ public static LocalDateTime getCurDayStartTime() {
+ LocalDateTime now = LocalDateTime.now();
+ LocalTime cutoffTime = LocalTime.of(17, 0);
+
+ if (now.toLocalTime().isAfter(cutoffTime)) {
+ // 当前时间大于17:00
+ return LocalDateTime.of(now.toLocalDate(), cutoffTime);
+ } else {
+ // 当前时间小于等于17:00
+ return LocalDateTime.of(now.minusDays(1).toLocalDate(), cutoffTime);
+ }
+ }
+
+ // 获取当天的结束时间
+ public static LocalDateTime getCurDayEndTime() {
+ LocalDateTime now = LocalDateTime.now();
+ LocalTime cutoffTime = LocalTime.of(17, 0);
+
+ if (now.toLocalTime().isAfter(cutoffTime)) {
+ // 当前时间大于17:00,结束时间为明天17:00
+ return LocalDateTime.of(now.plusDays(1).toLocalDate(), cutoffTime);
+ } else {
+ // 当前时间小于等于17:00,结束时间为当天17:00
+ return LocalDateTime.of(now.toLocalDate(), cutoffTime);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java b/src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java
index ade0675..54010dd 100644
--- a/src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java
+++ b/src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java
@@ -7,9 +7,11 @@
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.constant.Constants;
import com.mzl.flower.dto.request.payment.*;
+import com.mzl.flower.dto.request.report.QueryAppSupplierDTO;
import com.mzl.flower.dto.response.flower.ParamItemDTO;
import com.mzl.flower.dto.response.flower.StationStatisticDTO;
import com.mzl.flower.dto.response.payment.*;
+import com.mzl.flower.dto.response.report.AppSupplierStatisticsVO;
import com.mzl.flower.dto.response.supplier.SupplierOrderDTO;
import com.mzl.flower.entity.payment.*;
import com.mzl.flower.entity.supplier.Station;
@@ -21,6 +23,7 @@
import com.mzl.flower.mapper.supplier.StationMapper;
import com.mzl.flower.service.BaseService;
import com.mzl.flower.service.flower.FlowerParamService;
+import com.mzl.flower.service.report.OrderReportService;
import com.mzl.flower.utils.UUIDGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -73,6 +76,9 @@
@Autowired
private OrderItemSettlementService orderItemSettlementService;
+
+ @Autowired
+ private OrderReportService orderReportService;
public void createDeliveryOrder(Order order) {
String orderId = order.getId();
@@ -528,6 +534,12 @@
LocalDateTime s1 = endDate.plusDays(-30);
Integer dealCountDay30 = deliveryOrderItemMapper.getDoItemCount(supplierId, null, s1, endDate);
dto.setDealCountDay30(dealCountDay30);
+
+ // 供应商 总成交、本月成交、上月成交、今日成交、缺货(本月)、上月质检缺货、本月质检降级、上月质检降级、本月质检补货、上月质检补货
+ QueryAppSupplierDTO appDto=new QueryAppSupplierDTO();
+ appDto.setSupplierId(supplierId);
+ final AppSupplierStatisticsVO appSupplierStatistics = orderReportService.getAppSupplierStatistics(appDto);
+ BeanUtils.copyProperties(appSupplierStatistics,dto);
}
return dto;
diff --git a/src/main/java/com/mzl/flower/service/report/OrderReportService.java b/src/main/java/com/mzl/flower/service/report/OrderReportService.java
index 221239d..1f68fb9 100644
--- a/src/main/java/com/mzl/flower/service/report/OrderReportService.java
+++ b/src/main/java/com/mzl/flower/service/report/OrderReportService.java
@@ -1,13 +1,11 @@
package com.mzl.flower.service.report;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.mzl.flower.dto.request.report.QueryAppSupplierDTO;
import com.mzl.flower.dto.request.report.QueryOrderDTO;
import com.mzl.flower.dto.request.report.QuerySupplierDTO;
import com.mzl.flower.dto.request.report.QueryPartnerOrderDTO;
-import com.mzl.flower.dto.response.report.OrderDetailReportResultVO;
-import com.mzl.flower.dto.response.report.OrderPartnerReportResultVO;
-import com.mzl.flower.dto.response.report.OrderReportResultVO;
-import com.mzl.flower.dto.response.report.OrderSupplierReportResultVO;
+import com.mzl.flower.dto.response.report.*;
import javax.servlet.http.HttpServletResponse;
@@ -46,4 +44,13 @@
OrderSupplierReportResultVO getOrderSupplierClout(QuerySupplierDTO dto);
void exportSupplierList(HttpServletResponse response, QuerySupplierDTO dto);
+
+
+ /**
+ * 获取App供应商那个统计数据
+ * @param dto
+ * @return
+ */
+ AppSupplierStatisticsVO getAppSupplierStatistics(QueryAppSupplierDTO dto);
+
}
diff --git a/src/main/resources/mapper/report/OrderReportMapper.xml b/src/main/resources/mapper/report/OrderReportMapper.xml
index 64045e7..9fee255 100644
--- a/src/main/resources/mapper/report/OrderReportMapper.xml
+++ b/src/main/resources/mapper/report/OrderReportMapper.xml
@@ -593,4 +593,134 @@
) s group by dateinfo,supplier_id
) s2
</select>
+ <select id="getAppSupplierAmountStatistics"
+ resultType="com.mzl.flower.dto.response.report.AppSupplierStatisticsVO">
+ select
+ ( <include refid="all_supplier_amount"></include> ) as all_supplier_amount
+ , ( <include refid="cur_mon_supplier_amount"></include> ) as cur_mon_supplier_amount
+ , ( <include refid="last_mon_supplier_amount"></include> ) as last_mon_supplier_amount
+ , ( <include refid="today_supplier_amount"></include> ) as today_supplier_amount
+ , ( <include refid="cur_mon_lack_num"></include> ) as cur_mon_lack_num
+ , ( <include refid="last_mon_lack_num"></include> ) as last_mon_lack_num
+ , ( <include refid="cur_mon_reduce_num"></include> ) as cur_mon_reduce_num
+ , ( <include refid="last_mon_reduce_num"></include> ) as last_mon_reduce_num
+ , ( <include refid="cur_mon_replace_num"></include> ) as cur_mon_replace_num
+ , ( <include refid="last_mon_replace_num"></include> ) as last_mon_replace_num
+
+ </select>
+
+ <!--供应商总价款-->
+ <sql id="all_supplier_amount">
+ select IFNULL(sum(oi.supplier_price*oi.num),0) as supplier_amount from t_order_item oi where oi.supplier_id=287
+ </sql>
+ <!--本月成交:本月售卖的底价合计-->
+ <sql id="cur_mon_supplier_amount">
+ select IFNULL(sum(oi.supplier_price*oi.num),0) as cur_mon_supplier_amount
+ from t_order_item oi
+ left join t_order o
+ on oi.order_id = o.id
+ where oi.supplier_id = #{dto.supplierId}
+ and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time <= DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
+ </sql>
+ <!--上月成交:上月售卖的底价合计-->
+ <sql id="last_mon_supplier_amount">
+ select IFNULL(sum(oi.supplier_price*oi.num),0) as last_mon_supplier_amount
+ from t_order_item oi
+ left join t_order o
+ on oi.order_id = o.id
+ where oi.supplier_id = #{dto.supplierId}
+ and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time <= DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
+ </sql>
+ <!--今日成交:今日售卖的底价合计 // todo 需要根据当前时间判断今日的开始时间和结束时间-->
+ <sql id="today_supplier_amount">
+ select IFNULL(sum(oi.supplier_price*oi.num),0) as today_supplier_amount
+ from t_order_item oi
+ left join t_order o
+ on oi.order_id = o.id
+ where oi.supplier_id = #{dto.supplierId}
+ and o.payment_time > #{dto.startDateTime}
+ and o.payment_time <= #{dto.endDateTime}
+ </sql>
+ <!--缺货(本月):本月质检缺货,并且web端审核通过的数量合计-->
+ <sql id="cur_mon_lack_num">
+ select IFNULL(sum(oic.num),0) as cur_mon_lack_num
+ from t_order_item_check oic
+ left join t_order_item oi
+ on oic.order_item_id=oi.ID
+ left join t_order o
+ on oi.order_id = o.id
+ where oi.supplier_id = #{dto.supplierId}
+ and oic.type = 'lack' and oic.audit_status='AGREED'
+ and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time <= DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
+ </sql>
+ <!--缺货(上月):上月质检缺货,并且web端审核通过的数量合计-->
+ <sql id="last_mon_lack_num">
+ select IFNULL(sum(oic.num),0) as last_mon_lack_num
+ from t_order_item_check oic
+ left join t_order_item oi
+ on oic.order_item_id=oi.ID
+ left join t_order o
+ on oi.order_id = o.id
+ where oi.supplier_id = #{dto.supplierId}
+ and oic.type = 'lack' and oic.audit_status='AGREED'
+ and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time <= DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
+ </sql>
+ <!--降级(本月):本月质检降级,并且web端审核通过的数量合计-->
+ <sql id="cur_mon_reduce_num">
+ select IFNULL(sum(oic.num),0) as cur_mon_reduce_num
+ from t_order_item_check oic
+ left join t_order_item oi
+ on oic.order_item_id=oi.ID
+ left join t_order o
+ on oi.order_id = o.id
+ where oi.supplier_id = #{dto.supplierId}
+ and oic.type = 'reduce' and oic.audit_status='AGREED'
+ and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time <= DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
+ </sql>
+
+<!-- 降级(上月):上月质检降级,并且web端审核通过的数量合计-->
+ <sql id="last_mon_reduce_num">
+ select IFNULL(sum(oic.num),0) as last_mon_reduce_num
+ from t_order_item_check oic
+ left join t_order_item oi
+ on oic.order_item_id=oi.ID
+ left join t_order o
+ on oi.order_id = o.id
+ where oi.supplier_id = #{dto.supplierId}
+ and oic.type = 'reduce' and oic.audit_status='AGREED'
+ and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time <= DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
+ </sql>
+<!-- 补货(本月):本月质检补货,并且web端审核通过的数量合计-->
+ <sql id="cur_mon_replace_num">
+ select IFNULL(sum(oic.num),0) as cur_mon_replace_num
+ from t_order_item_check oic
+ left join t_order_item oi
+ on oic.order_item_id=oi.ID
+ left join t_order o
+ on oi.order_id = o.id
+ where oi.supplier_id = #{dto.supplierId}
+ and oic.type = 'replace' and oic.audit_status='AGREED'
+ and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time <= DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
+ </sql>
+ <!-- 补货(上月):上月质检补货,并且web端审核通过的数量合计-->
+ <sql id="last_mon_replace_num">
+ select IFNULL(sum(oic.num),0) as last_mon_replace_num
+ from t_order_item_check oic
+ left join t_order_item oi
+ on oic.order_item_id=oi.ID
+ left join t_order o
+ on oi.order_id = o.id
+ where oi.supplier_id = #{dto.supplierId}
+ and oic.type = 'replace' and oic.audit_status='AGREED'
+ and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time <= DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
+ </sql>
+
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3