Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.czg.order.service;
|
||||
|
||||
import com.czg.order.vo.CostLineChartVO;
|
||||
import com.czg.order.vo.CountPayTypeVo;
|
||||
import com.czg.order.vo.ProfitRateVO;
|
||||
import com.czg.order.vo.TotalVo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.order.entity.ShopOrderStatistic;
|
||||
@@ -40,6 +42,16 @@ public interface ShopOrderStatisticService extends IService<ShopOrderStatistic>
|
||||
* 获取支付方式数据
|
||||
*/
|
||||
List<CountPayTypeVo> getSummaryPayTypeData(Long shopId, Integer day);
|
||||
/**
|
||||
* 利润率折线图
|
||||
*/
|
||||
List<ProfitRateVO> profitRateBarChart(Long shopId, Integer day);
|
||||
|
||||
/**
|
||||
* 成本折线图
|
||||
*/
|
||||
List<CostLineChartVO> costLineChart(Long shopId, Integer day);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.czg.order.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 成本折线图 左下下
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class CostLineChartVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
private BigDecimal productCostAmount;
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate tradeDay;
|
||||
|
||||
|
||||
public CostLineChartVO(LocalDate tradeDay) {
|
||||
this.tradeDay = tradeDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并实时数据和历史数据,并填充缺失的日期
|
||||
*/
|
||||
public static List<CostLineChartVO> mergeAndFillData(CostLineChartVO onlineData, List<CostLineChartVO> historyData,
|
||||
LocalDate startDate, LocalDate endDate) {
|
||||
// 创建日期到数据的映射,方便查找
|
||||
Map<LocalDate, CostLineChartVO> dataMap = new HashMap<>();
|
||||
|
||||
// 将历史数据放入映射
|
||||
for (CostLineChartVO vo : historyData) {
|
||||
if (vo.getTradeDay() != null) {
|
||||
dataMap.put(vo.getTradeDay(), vo);
|
||||
}
|
||||
}
|
||||
dataMap.put(onlineData.getTradeDay(), onlineData);
|
||||
|
||||
List<CostLineChartVO> result = new ArrayList<>();
|
||||
LocalDate currentDay = startDate;
|
||||
|
||||
while (!currentDay.isAfter(endDate)) {
|
||||
if (dataMap.containsKey(currentDay)) {
|
||||
result.add(dataMap.get(currentDay));
|
||||
} else {
|
||||
// 创建空的TotalVo填充缺失的日期
|
||||
CostLineChartVO emptyVo = new CostLineChartVO(currentDay);
|
||||
result.add(emptyVo);
|
||||
}
|
||||
currentDay = currentDay.plusDays(1);
|
||||
}
|
||||
// 按日期排序确保顺序正确
|
||||
result.sort(Comparator.comparing(CostLineChartVO::getTradeDay));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,21 @@ public class CountPayTypeVo {
|
||||
PAY_TYPE_MAPPING.put("creditPay", "挂账支付");
|
||||
}
|
||||
|
||||
/**
|
||||
* 实时数据
|
||||
*/
|
||||
public static List<CountPayTypeVo> realTimeDataByDay(Map<String, BigDecimal> realTimeData) {
|
||||
List<CountPayTypeVo> result = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : PAY_TYPE_MAPPING.entrySet()) {
|
||||
String payCode = entry.getKey();
|
||||
String payName = entry.getValue();
|
||||
|
||||
BigDecimal totalCount = getSafeValue(realTimeData, payCode);
|
||||
result.add(new CountPayTypeVo(totalCount.intValue(), payName));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并实时数据和历史统计数据
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.czg.order.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* 毛利率/净利率 柱状图 左下下
|
||||
* 利润率柱状图
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ProfitRateVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 毛利率
|
||||
*/
|
||||
private BigDecimal profitRate;
|
||||
/**
|
||||
* 净利润率
|
||||
*/
|
||||
private BigDecimal netProfitRate;
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate tradeDay;
|
||||
|
||||
|
||||
public ProfitRateVO(LocalDate tradeDay) {
|
||||
this.tradeDay = tradeDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并实时数据和历史数据,并填充缺失的日期
|
||||
*/
|
||||
public static List<ProfitRateVO> mergeAndFillData(ProfitRateVO onlineData, List<ProfitRateVO> historyData,
|
||||
LocalDate startDate, LocalDate endDate) {
|
||||
// 创建日期到数据的映射,方便查找
|
||||
Map<LocalDate, ProfitRateVO> dataMap = new HashMap<>();
|
||||
|
||||
// 将历史数据放入映射
|
||||
for (ProfitRateVO vo : historyData) {
|
||||
if (vo.getTradeDay() != null) {
|
||||
dataMap.put(vo.getTradeDay(), vo);
|
||||
}
|
||||
}
|
||||
dataMap.put(onlineData.getTradeDay(), onlineData);
|
||||
|
||||
List<ProfitRateVO> result = new ArrayList<>();
|
||||
LocalDate currentDay = startDate;
|
||||
|
||||
while (!currentDay.isAfter(endDate)) {
|
||||
if (dataMap.containsKey(currentDay)) {
|
||||
result.add(dataMap.get(currentDay));
|
||||
} else {
|
||||
// 创建空的TotalVo填充缺失的日期
|
||||
ProfitRateVO emptyVo = new ProfitRateVO(currentDay);
|
||||
result.add(emptyVo);
|
||||
}
|
||||
currentDay = currentDay.plusDays(1);
|
||||
}
|
||||
// 按日期排序确保顺序正确
|
||||
result.sort(Comparator.comparing(ProfitRateVO::getTradeDay));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
alipay:
|
||||
sms:
|
||||
key: LTAI5tPdEfYSZcqHbjCrtPRD
|
||||
secret: DZjyHBq3nTujF0NMLxnZgsecU8ZCvy
|
||||
templateCode: SMS_244665149
|
||||
Reference in New Issue
Block a user