mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
Merge branch 'dev' of https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web into dev
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
package com.jsowell.pile.mapper;
|
||||
|
||||
import com.alipay.api.domain.ChargeOrderInfo;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.OrderDetail;
|
||||
import com.jsowell.pile.domain.OrderSplitRecord;
|
||||
import com.jsowell.pile.domain.UserFrequentedStationInfo;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO;
|
||||
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO;
|
||||
@@ -431,4 +428,10 @@ public interface OrderBasicInfoMapper {
|
||||
@Param("endTime") String endTime
|
||||
);
|
||||
|
||||
/**
|
||||
* 按月份统计订单数量和保险金额
|
||||
* @param dto 查询条件,startTime/endTime 必须是 yyyy-MM 拼装后的时间段
|
||||
* @return List<OrderMonthStatVO>
|
||||
*/
|
||||
List<OrderMonthStatVO> selectOrderCountAndInsuranceByMonth(@Param("dto") QueryOrderDTO dto);
|
||||
}
|
||||
|
||||
@@ -631,4 +631,6 @@ public interface OrderBasicInfoService{
|
||||
* @return
|
||||
*/
|
||||
List<BusinessOrderDetailInfoVO> getOrderDetailByStationIdsForMonth(List<String> stationIds , String startTime , String endTime);
|
||||
|
||||
OrderCountByTimeVO queryOrderInsuranceAmountByTime(QueryOrderDTO dto);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,11 @@ import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -618,7 +622,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
|
||||
// 结算时间设置为当前时间
|
||||
orderInfo.setSettlementTime(new Date());
|
||||
|
||||
|
||||
// 启动失败原因
|
||||
orderInfo.setReason(failedReasonMsg);
|
||||
// 订单退款(结算订单)
|
||||
@@ -5958,5 +5962,77 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
public List<BusinessOrderDetailInfoVO> getOrderDetailByStationIdsForMonth(List<String> stationIds , String startTime , String endTime) {
|
||||
return orderBasicInfoMapper.getOrderDetailByStationIdsForMonth(stationIds, startTime, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单数量与保险金额时间区统计
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public OrderCountByTimeVO queryOrderInsuranceAmountByTime(QueryOrderDTO dto) {
|
||||
if (dto == null) {
|
||||
dto = new QueryOrderDTO();
|
||||
}
|
||||
|
||||
DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
try {
|
||||
// 处理 startTime
|
||||
if (StringUtils.isNotEmpty(dto.getStartTime())) {
|
||||
YearMonth startMonth = YearMonth.parse(dto.getStartTime(), monthFormatter);
|
||||
dto.setStartTime(startMonth.atDay(1).atStartOfDay().format(dateTimeFormatter));
|
||||
}
|
||||
// 处理 endTime,取下个月月初,保证 < endTime 不丢数据
|
||||
if (StringUtils.isNotEmpty(dto.getEndTime())) {
|
||||
YearMonth endMonth = YearMonth.parse(dto.getEndTime(), monthFormatter);
|
||||
dto.setEndTime(endMonth.plusMonths(1).atDay(1).atStartOfDay().format(dateTimeFormatter));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("时间格式错误,应为 yyyy-MM");
|
||||
}
|
||||
|
||||
// 默认本月
|
||||
if (StringUtils.isEmpty(dto.getStartTime()) || StringUtils.isEmpty(dto.getEndTime())) {
|
||||
YearMonth currentMonth = YearMonth.now();
|
||||
dto.setStartTime(currentMonth.atDay(1).atStartOfDay().format(dateTimeFormatter));
|
||||
dto.setEndTime(currentMonth.plusMonths(1).atDay(1).atStartOfDay().format(dateTimeFormatter));
|
||||
}
|
||||
|
||||
// 查询数据库聚合结果
|
||||
List<OrderMonthStatVO> stats = orderBasicInfoMapper.selectOrderCountAndInsuranceByMonth(dto);
|
||||
|
||||
// 封装返回结果
|
||||
BigDecimal totalInsuranceAmount = BigDecimal.ZERO;
|
||||
int totalCount = 0;
|
||||
List<OrderCountByTimeVO.OrderCountByTimeListVO> result = new ArrayList<>();
|
||||
|
||||
for (OrderMonthStatVO stat : stats) {
|
||||
YearMonth ym = YearMonth.parse(stat.getMonth(), monthFormatter);
|
||||
|
||||
OrderCountByTimeVO.OrderCountByTimeListVO vo = new OrderCountByTimeVO.OrderCountByTimeListVO();
|
||||
vo.setStartTime(ym.atDay(1).atStartOfDay().format(dateTimeFormatter));
|
||||
vo.setEndTime(ym.plusMonths(1).atDay(1).atStartOfDay().format(dateTimeFormatter));
|
||||
vo.setCount(stat.getOrderCount());
|
||||
vo.setOrderCount(stat.getOrderCount());
|
||||
BigDecimal insuranceAmount = stat.getInsuranceAmount() == null ? BigDecimal.ZERO : stat.getInsuranceAmount();
|
||||
vo.setInsuranceAmount(totalInsuranceAmount);
|
||||
|
||||
result.add(vo);
|
||||
|
||||
totalCount += stat.getOrderCount();
|
||||
totalInsuranceAmount = totalInsuranceAmount.add(insuranceAmount);
|
||||
}
|
||||
|
||||
OrderCountByTimeVO vo = new OrderCountByTimeVO();
|
||||
vo.setOrderCountByTimeList(result);
|
||||
vo.setTotalCount(totalCount);
|
||||
vo.setTotalInsuranceAmount(totalInsuranceAmount);
|
||||
|
||||
|
||||
logger.info("按月统计结果: {}", JSONObject.toJSONString(vo));
|
||||
return vo;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jsowell.pile.vo.web;
|
||||
|
||||
import com.jsowell.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -13,16 +14,36 @@ import java.math.BigDecimal;
|
||||
@Data
|
||||
public class OccupyOrderVO {
|
||||
private String id;
|
||||
@Excel(name = "占桩订单号")
|
||||
private String occupyCode;
|
||||
|
||||
private String status;
|
||||
|
||||
@Excel(name = "会员ID")
|
||||
private String memberId;
|
||||
|
||||
private String stationId;
|
||||
|
||||
private String plateNumber;
|
||||
|
||||
@Excel(name = "站点名称")
|
||||
private String stationName;
|
||||
|
||||
@Excel(name = "占桩开始时间")
|
||||
private String startTime;
|
||||
|
||||
@Excel(name = "占桩结束时间")
|
||||
private String endTime;
|
||||
|
||||
@Excel(name = "支付状态")
|
||||
private String payStatus;
|
||||
|
||||
@Excel(name = "订单金额")
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
@Excel(name = "充电桩编号")
|
||||
private String pileSn;
|
||||
|
||||
@Excel(name = "充电桩枪口号")
|
||||
private String connectorCode;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.jsowell.pile.vo.web;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class OrderMonthStatVO {
|
||||
private String month;
|
||||
private Integer orderCount;
|
||||
private BigDecimal insuranceAmount;
|
||||
}
|
||||
Reference in New Issue
Block a user