更新10.14
This commit is contained in:
parent
f306c1e6ab
commit
f3229ce2ff
@ -333,6 +333,17 @@ public class AllOrderInfoController extends BaseController {
|
||||
return getSuccessResult(allOrderInfoService.getDataShow(map));
|
||||
}
|
||||
|
||||
/**
|
||||
* 油站首页数据统计
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getDataCount")
|
||||
public ResponseObject getDataCount(String startTime, String endTime) {
|
||||
return getSuccessResult(allOrderInfoService.getDataCount(startTime, endTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费记录(小程序)
|
||||
* @param pageNo
|
||||
|
@ -188,4 +188,12 @@ AllOrderActivityVo getOneByOrderId(Integer orderId);
|
||||
* @return
|
||||
*/
|
||||
AllOrderInfoUniVo queryByOrderNo(String orderNo);
|
||||
|
||||
/**
|
||||
* 油站首页数据统计
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
HomeDataShowVo getDataCount(String startTime, String endTime);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.fuint.business.order.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
@ -1792,9 +1793,9 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
|
||||
productionAllOrderInfos += 1;
|
||||
}
|
||||
}
|
||||
Double i = ((double)oilAllOrderInfos / (oilAllOrderInfos + productionAllOrderInfos)) * 100;
|
||||
Double i = ((double) oilAllOrderInfos / (oilAllOrderInfos + productionAllOrderInfos)) * 100;
|
||||
Double shareOfOilTransactions = Double.valueOf((getFormattedResult(i)));
|
||||
Double shareOfNonOilTransactions = Double.valueOf(getFormattedResult(((double)productionAllOrderInfos / (oilAllOrderInfos + productionAllOrderInfos)) * 100));
|
||||
Double shareOfNonOilTransactions = Double.valueOf(getFormattedResult(((double) productionAllOrderInfos / (oilAllOrderInfos + productionAllOrderInfos)) * 100));
|
||||
|
||||
HomeDataAnalysisVo oilhomeDataAnalysisVo = new HomeDataAnalysisVo();
|
||||
oilhomeDataAnalysisVo.setName("油品交易占比");
|
||||
@ -1832,25 +1833,25 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
|
||||
HomeDataAnalysisVo mtUserVo = new HomeDataAnalysisVo();
|
||||
mtUserVo.setName("会员充值占比");
|
||||
mtUserVo.setType(3);
|
||||
mtUserVo.setValue(Double.parseDouble(getFormattedResult(((double)mtUser / sum) * 100)));
|
||||
mtUserVo.setValue(Double.parseDouble(getFormattedResult(((double) mtUser / sum) * 100)));
|
||||
list.add(mtUserVo);
|
||||
|
||||
HomeDataAnalysisVo productVo = new HomeDataAnalysisVo();
|
||||
productVo.setName("商品交易占比");
|
||||
productVo.setType(3);
|
||||
productVo.setValue(Double.parseDouble(getFormattedResult(((double)product / sum) * 100)));
|
||||
productVo.setValue(Double.parseDouble(getFormattedResult(((double) product / sum) * 100)));
|
||||
list.add(productVo);
|
||||
|
||||
HomeDataAnalysisVo oilRechargeVo = new HomeDataAnalysisVo();
|
||||
oilRechargeVo.setName("油品交易占比");
|
||||
oilRechargeVo.setType(3);
|
||||
oilRechargeVo.setValue(Double.parseDouble(getFormattedResult(((double)oilRecharge / sum) * 100)));
|
||||
oilRechargeVo.setValue(Double.parseDouble(getFormattedResult(((double) oilRecharge / sum) * 100)));
|
||||
list.add(oilRechargeVo);
|
||||
|
||||
HomeDataAnalysisVo pointMallVo = new HomeDataAnalysisVo();
|
||||
pointMallVo.setName("积分商城交易占比");
|
||||
pointMallVo.setType(3);
|
||||
pointMallVo.setValue(Double.parseDouble(getFormattedResult((double)pointMall / sum * 100)));
|
||||
pointMallVo.setValue(Double.parseDouble(getFormattedResult((double) pointMall / sum * 100)));
|
||||
list.add(pointMallVo);
|
||||
return list;
|
||||
}
|
||||
@ -1881,8 +1882,8 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
|
||||
List<Double> oilPrices = new ArrayList<>();
|
||||
for (OilNumber oilNumber : oilNumbers) {
|
||||
//查询油品交易总金额
|
||||
double price = oilOrderMapper.selectSumMoneyByDayAndOilNumber(oilNumber.getOilName(), day, nowAccountInfo.getStoreId());
|
||||
oilPrices.add(price);
|
||||
double price = oilOrderMapper.selectSumMoneyByDayAndOilNumber(oilNumber.getOilName(), day, nowAccountInfo.getStoreId());
|
||||
oilPrices.add(price);
|
||||
}
|
||||
mapData.put("oilPrices", oilPrices);
|
||||
oilData.add(mapData);
|
||||
@ -1894,6 +1895,7 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
|
||||
|
||||
/**
|
||||
* 获取时间段内的所有日期
|
||||
*
|
||||
* @param startTime
|
||||
* @return
|
||||
*/
|
||||
@ -1997,6 +1999,99 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 油站首页数据统计
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public HomeDataShowVo getDataCount(String startTime, String endTime) {
|
||||
HomeDataShowVo homeDataShowVo = new HomeDataShowVo();
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
if (ObjectUtil.isNotEmpty(startTime) && ObjectUtil.isNotEmpty(endTime)) {
|
||||
List<AllOrderInfo> allOrderInfos = baseMapper.selectList(new LambdaQueryWrapper<AllOrderInfo>()
|
||||
.eq(AllOrderInfo::getStoreId, nowAccountInfo.getStoreId())
|
||||
.eq(AllOrderInfo::getStatus, "paid")
|
||||
.between(AllOrderInfo::getPayTime, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime))));
|
||||
|
||||
List<String> allDatesBetween = getAllDatesBetween(startTime, endTime);
|
||||
|
||||
List<String> oilNames = new ArrayList<>();
|
||||
List<Map<String, Object>> oilData = new ArrayList<>();
|
||||
oilNames.add("油品交易额");
|
||||
oilNames.add("会员充值金额");
|
||||
oilNames.add("非油品交易额");
|
||||
oilNames.add("会员消费金额");
|
||||
for (String time : allDatesBetween) {
|
||||
DateTime dateTime = DateUtil.beginOfDay(DateUtil.parse(time));
|
||||
DateTime dateTime1 = DateUtil.endOfDay(dateTime);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("time", time);
|
||||
List<Double> money = new ArrayList<>();
|
||||
//油品交易额
|
||||
List<AllOrderInfo> oilOrder = filterOrders(allOrderInfos, dateTime, dateTime1, "1", null, null);
|
||||
double sum = oilOrder.stream().mapToDouble(AllOrderInfo::getPayMoney).sum();
|
||||
money.add(sum);
|
||||
//会员充值金额
|
||||
List<AllOrderInfo> mtTopUp = filterOrders(allOrderInfos, dateTime, dateTime1, null, "充值", null);
|
||||
double mtSum = mtTopUp.stream().mapToDouble(AllOrderInfo::getPayMoney).sum();
|
||||
money.add(mtSum);
|
||||
//非油品交易额
|
||||
List<AllOrderInfo> otherOrder = filterOrders(allOrderInfos, dateTime, dateTime1, null, null, "2");
|
||||
double otherSum = otherOrder.stream().mapToDouble(AllOrderInfo::getPayMoney).sum();
|
||||
money.add(otherSum);
|
||||
//会员消费金额
|
||||
List<AllOrderInfo> userOrder = filterOrders(allOrderInfos, dateTime, dateTime1, null, "订单", null);
|
||||
double userSum = userOrder.stream().mapToDouble(AllOrderInfo::getPayMoney).sum();
|
||||
money.add(userSum);
|
||||
|
||||
params.put("money", money);
|
||||
oilData.add(params);
|
||||
}
|
||||
homeDataShowVo.setOilNames(oilNames);
|
||||
homeDataShowVo.setOilData(oilData);
|
||||
}
|
||||
return homeDataShowVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据开始时间、结束时间、订单类型和内容过滤订单。
|
||||
*
|
||||
* @param orders 订单集合
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @param type 订单类型(如果为空,则不筛选类型)
|
||||
* @param content 内容(如果不为空,筛选包含该内容的订单)
|
||||
* @return 符合条件的订单集合
|
||||
*/
|
||||
public List<AllOrderInfo> filterOrders(
|
||||
List<AllOrderInfo> orders,
|
||||
Date startTime,
|
||||
Date endTime,
|
||||
String type,
|
||||
String content,
|
||||
String excludeType
|
||||
) {
|
||||
return orders.stream()
|
||||
.filter(order ->
|
||||
// 检查payTime是否在开始和结束时间范围内
|
||||
(startTime == null || !order.getPayTime().before(startTime)) &&
|
||||
(endTime == null || !order.getPayTime().after(endTime)) &&
|
||||
|
||||
// 检查type是否匹配
|
||||
(type == null || order.getType().equals(type)) &&
|
||||
|
||||
// 检查excludeType,排除指定type的订单
|
||||
(excludeType == null || !order.getType().equals(excludeType)) &&
|
||||
|
||||
// 检查content是否包含指定内容
|
||||
(content == null || order.getContent() != null && order.getContent().contains(content))
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
private long dayCount(String beginTimeStr, String endTimeStr) {
|
||||
// 将字符串表示的时间转换成 LocalDate 对象
|
||||
|
Loading…
Reference in New Issue
Block a user