mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-16 05:10:04 +08:00
Compare commits
2 Commits
feature-VI
...
feature-bu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22be455773 | ||
|
|
76f23e7d82 |
@@ -9,15 +9,19 @@ import com.jsowell.common.response.RestApiResponse;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.jsowell.pile.dto.MerchantOrderReportDTO;
|
||||
import com.jsowell.pile.dto.ParkingCouponRecordQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessDailySettlementQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessEfficiencyQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessOperationAnalysisQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessScaleQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessWorkbenchSummaryQueryDTO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessDailySettlementDetailVO;
|
||||
import com.jsowell.pile.service.BusinessFinancialService;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessEfficiencyAnalysisVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessEfficiencyVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessGunEfficiencyAnalysisVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessOperationAnalysisVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessScaleVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessWorkbenchSummaryVO;
|
||||
import com.jsowell.pile.vo.web.MerchantOrderReportVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -38,6 +42,59 @@ public class BusinessFinancialController extends BaseController {
|
||||
@Autowired
|
||||
private BusinessFinancialService businessFinancialService;
|
||||
|
||||
/**
|
||||
* 查询工作台首页汇总
|
||||
*
|
||||
* @param dto 查询参数。前端可选传stationIdList,运营商和日期范围由后端按登录账号解析。
|
||||
* @return 工作台首页汇总
|
||||
*/
|
||||
@PostMapping("/workbenchSummary")
|
||||
public RestApiResponse<?> getWorkbenchSummary(@RequestBody(required = false) BusinessWorkbenchSummaryQueryDTO dto) {
|
||||
logger.info("查询工作台首页汇总 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
BusinessWorkbenchSummaryVO result = businessFinancialService.getWorkbenchSummary(dto);
|
||||
response = new RestApiResponse<>(result);
|
||||
logger.info("查询工作台首页汇总成功 today:{}, stationCount:{}",
|
||||
result.getToday(), result.getStationCount());
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("查询工作台首页汇总业务异常 code:{}, message:{}", e.getCode(), e.getMessage(), e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("查询工作台首页汇总系统异常 params:{}", JSONObject.toJSONString(dto), e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询结算日报详情
|
||||
*
|
||||
* @param dto 查询参数。前端传开始日期、结束日期,可选传stationIdList。
|
||||
* @return 结算日报详情
|
||||
*/
|
||||
@PostMapping("/dailySettlementDetail")
|
||||
public RestApiResponse<?> getDailySettlementDetail(@RequestBody BusinessDailySettlementQueryDTO dto) {
|
||||
logger.info("查询结算日报详情 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
if (dto == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
BusinessDailySettlementDetailVO result = businessFinancialService.getDailySettlementDetail(dto);
|
||||
response = new RestApiResponse<>(result);
|
||||
logger.info("查询结算日报详情成功 startTime:{}, endTime:{}",
|
||||
dto.getStartTime(), dto.getEndTime());
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("查询结算日报详情业务异常 code:{}, message:{}", e.getCode(), e.getMessage(), e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("查询结算日报详情系统异常 params:{}", JSONObject.toJSONString(dto), e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的钱包界面查询接口
|
||||
*
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.jsowell.pile.dto.business;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 结算日报详情查询DTO
|
||||
*
|
||||
* @author zhangziao
|
||||
* @date 2026/6/15
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class BusinessDailySettlementQueryDTO {
|
||||
|
||||
/**
|
||||
* 开始日期,格式:yyyy-MM-dd
|
||||
*/
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 结束日期,格式:yyyy-MM-dd
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 站点id列表。运营商账号传当前账号下可见站点id。
|
||||
*/
|
||||
private List<String> stationIdList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.jsowell.pile.dto.business;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工作台首页汇总查询DTO
|
||||
*
|
||||
* @author zhangziao
|
||||
* @date 2026/6/15
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class BusinessWorkbenchSummaryQueryDTO {
|
||||
|
||||
/**
|
||||
* 站点id列表。可选,不传时按当前登录账号权限查询。
|
||||
*/
|
||||
private List<String> stationIdList;
|
||||
|
||||
}
|
||||
@@ -3,20 +3,40 @@ package com.jsowell.pile.service;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.pile.dto.MerchantOrderReportDTO;
|
||||
import com.jsowell.pile.dto.ParkingCouponRecordQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessDailySettlementQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessOperationAnalysisQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessEfficiencyQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessScaleQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessWorkbenchSummaryQueryDTO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessDailySettlementDetailVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessEfficiencyAnalysisVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessEfficiencyVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessGunEfficiencyAnalysisVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessOperationAnalysisVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessScaleVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessWorkbenchSummaryVO;
|
||||
import com.jsowell.pile.vo.web.MerchantOrderReportVO;
|
||||
import com.jsowell.pile.vo.web.ParkingCouponRecordVO;
|
||||
|
||||
public interface BusinessFinancialService {
|
||||
MerchantOrderReportVO getMyWallet(MerchantOrderReportDTO dto);
|
||||
|
||||
/**
|
||||
* 查询工作台首页汇总
|
||||
*
|
||||
* @param dto 查询条件
|
||||
* @return 工作台首页汇总
|
||||
*/
|
||||
BusinessWorkbenchSummaryVO getWorkbenchSummary(BusinessWorkbenchSummaryQueryDTO dto);
|
||||
|
||||
/**
|
||||
* 查询结算日报详情
|
||||
*
|
||||
* @param dto 查询条件
|
||||
* @return 结算日报详情
|
||||
*/
|
||||
BusinessDailySettlementDetailVO getDailySettlementDetail(BusinessDailySettlementQueryDTO dto);
|
||||
|
||||
/**
|
||||
* 分页查询停车优免记录
|
||||
*
|
||||
|
||||
@@ -12,14 +12,18 @@ import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.pile.dto.MerchantOrderReportDTO;
|
||||
import com.jsowell.pile.dto.ParkingCouponRecordQueryDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessDailySettlementQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessEfficiencyQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessOperationAnalysisQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessOperationDateRangeDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessOperationSummaryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessScaleQueryDTO;
|
||||
import com.jsowell.pile.dto.business.BusinessWorkbenchSummaryQueryDTO;
|
||||
import com.jsowell.pile.domain.PileConnectorInfo;
|
||||
import com.jsowell.pile.domain.PileStationInfo;
|
||||
import com.jsowell.pile.domain.SettleOrderReport;
|
||||
import com.jsowell.pile.mapper.OrderBasicInfoMapper;
|
||||
import com.jsowell.pile.service.BusinessFinancialService;
|
||||
import com.jsowell.pile.service.CarCouponRecordService;
|
||||
import com.jsowell.pile.service.ClearingWithdrawInfoService;
|
||||
@@ -28,6 +32,7 @@ import com.jsowell.pile.service.PileStationInfoService;
|
||||
import com.jsowell.pile.service.SettleOrderReportService;
|
||||
import com.jsowell.pile.util.UserUtils;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessDailySettlementDetailVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessEfficiencyAnalysisVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessGunEfficiencyAnalysisVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessEfficiencyVO;
|
||||
@@ -38,7 +43,9 @@ import com.jsowell.pile.vo.uniapp.business.BusinessScaleChartVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessScaleMetricVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessScaleVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessStationRankVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessWorkbenchSummaryVO;
|
||||
import com.jsowell.pile.vo.web.MerchantOrderReportVO;
|
||||
import com.jsowell.pile.vo.web.OrderStatisticsVO;
|
||||
import com.jsowell.pile.vo.web.ParkingCouponRecordVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -52,6 +59,7 @@ import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -85,6 +93,18 @@ public class BusinessFinancialServiceImpl implements BusinessFinancialService {
|
||||
private static final String EFFICIENCY_METRIC_GUN_AVG_ELECTRICITY = "GUN_AVG_ELECTRICITY";
|
||||
private static final String EFFICIENCY_METRIC_POWER_UTILIZATION = "POWER_UTILIZATION";
|
||||
|
||||
private static final String SETTLEMENT_ITEM_SERVICE_FEE = "CHARGE_SERVICE_FEE";
|
||||
private static final String SETTLEMENT_ITEM_ELECTRICITY_FEE = "CHARGE_ELECTRICITY_FEE";
|
||||
private static final String SETTLEMENT_ITEM_PLATFORM_SUBSIDY = "PLATFORM_SERVICE_SUBSIDY";
|
||||
private static final String SETTLEMENT_ITEM_MERCHANT_PLATFORM_FEE = "MERCHANT_PLATFORM_SERVICE_FEE";
|
||||
private static final String WORKBENCH_CARD_ORDER_MANAGEMENT = "ORDER_MANAGEMENT";
|
||||
private static final String WORKBENCH_CARD_BUSINESS_ADVISER = "BUSINESS_ADVISER";
|
||||
private static final String WORKBENCH_CARD_MY_WALLET = "MY_WALLET";
|
||||
private static final String WORKBENCH_CARD_DAILY_SETTLEMENT = "DAILY_SETTLEMENT";
|
||||
private static final String WORKBENCH_CARD_PARKING_DISCOUNT = "PARKING_DISCOUNT";
|
||||
private static final int STATION_QUERY_BATCH_SIZE = 500;
|
||||
private static final int DEFAULT_DECIMAL_SCALE = 2;
|
||||
|
||||
/**
|
||||
* 财务查询通用线程池(支持多方法并行查询)
|
||||
* 核心线程数4:覆盖经营规模(2路)、我的钱包(3路)、经营分析(2路)、枪均效率(2路)等场景
|
||||
@@ -114,6 +134,114 @@ public class BusinessFinancialServiceImpl implements BusinessFinancialService {
|
||||
@Autowired
|
||||
private PileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
@Autowired
|
||||
private OrderBasicInfoMapper orderBasicInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询工作台首页汇总
|
||||
*
|
||||
* @param dto 查询条件
|
||||
* @return 工作台首页汇总
|
||||
*/
|
||||
@Override
|
||||
public BusinessWorkbenchSummaryVO getWorkbenchSummary(BusinessWorkbenchSummaryQueryDTO dto) {
|
||||
if (dto == null) {
|
||||
dto = new BusinessWorkbenchSummaryQueryDTO();
|
||||
}
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
String todayDate = today.toString();
|
||||
String recentStartTime = today.minusDays(6).toString();
|
||||
String recentEndTime = todayDate;
|
||||
|
||||
FinancialScope scope = resolveFinancialScope(dto.getStationIdList());
|
||||
|
||||
CompletableFuture<Long> todayOrderCountFuture = CompletableFuture.supplyAsync(
|
||||
() -> countTodayOrderCount(scope.getStationIdList(), todayDate), FINANCIAL_THREAD_POOL);
|
||||
CompletableFuture<List<SettleOrderReport>> recentReportsFuture = CompletableFuture.supplyAsync(
|
||||
() -> queryRawReports(scope.getStationIdList(), recentStartTime, recentEndTime), FINANCIAL_THREAD_POOL);
|
||||
|
||||
List<SettleOrderReport> recentReports = recentReportsFuture.join();
|
||||
ReportSummary recentSummary = buildReportSummary(recentReports);
|
||||
ReportSummary todaySummary = buildReportSummary(recentReports, todayDate);
|
||||
Long todayOrderCount = todayOrderCountFuture.join();
|
||||
Integer pendingParkingAppealCount = countPendingParkingAppeal(scope.getStationIdList());
|
||||
|
||||
List<BusinessWorkbenchSummaryVO.WorkbenchCard> cardList = new ArrayList<>();
|
||||
cardList.add(buildWorkbenchCard(WORKBENCH_CARD_ORDER_MANAGEMENT, "订单管理", "今日订单量",
|
||||
BigDecimal.valueOf(todayOrderCount), "单"));
|
||||
cardList.add(buildWorkbenchCard(WORKBENCH_CARD_BUSINESS_ADVISER, "经营参谋", "近7天净现金流",
|
||||
formatMoney(recentSummary.getOrderTotalAmount()), "元"));
|
||||
cardList.add(buildWorkbenchCard(WORKBENCH_CARD_MY_WALLET, "我的钱包", "今日到账",
|
||||
formatMoney(todaySummary.getArrivalAmount()), "元"));
|
||||
cardList.add(buildWorkbenchCard(WORKBENCH_CARD_DAILY_SETTLEMENT, "结算日报", "近7天净现金流",
|
||||
formatMoney(recentSummary.getSettlementAmount()), "元"));
|
||||
cardList.add(buildWorkbenchCard(WORKBENCH_CARD_PARKING_DISCOUNT, "停车减免", "待处理申诉",
|
||||
BigDecimal.valueOf(pendingParkingAppealCount), "条"));
|
||||
|
||||
return BusinessWorkbenchSummaryVO.builder()
|
||||
.today(todayDate)
|
||||
.recentStartTime(recentStartTime)
|
||||
.recentEndTime(recentEndTime)
|
||||
.merchantIdList(scope.getMerchantIdList())
|
||||
.stationIdList(scope.getStationIdList())
|
||||
.stationCount(scope.getStationIdList() != null ? scope.getStationIdList().size() : null)
|
||||
.todayOrderCount(todayOrderCount)
|
||||
.recentNetCashFlow(formatMoney(recentSummary.getOrderTotalAmount()))
|
||||
.todayArrivalAmount(formatMoney(todaySummary.getArrivalAmount()))
|
||||
.recentSettlementNetCashFlow(formatMoney(recentSummary.getSettlementAmount()))
|
||||
.pendingParkingAppealCount(pendingParkingAppealCount)
|
||||
.cardList(cardList)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询结算日报详情
|
||||
*
|
||||
* @param dto 查询条件
|
||||
* @return 结算日报详情
|
||||
*/
|
||||
@Override
|
||||
public BusinessDailySettlementDetailVO getDailySettlementDetail(BusinessDailySettlementQueryDTO dto) {
|
||||
validateDailySettlementQuery(dto);
|
||||
|
||||
FinancialScope scope = resolveFinancialScope(dto.getStationIdList());
|
||||
List<SettleOrderReport> reportList = queryRawReports(scope.getStationIdList(), dto.getStartTime(), dto.getEndTime());
|
||||
ReportSummary summary = buildReportSummary(reportList);
|
||||
BigDecimal incomeTotalAmount = summary.getIncomeTotalAmount();
|
||||
BigDecimal merchantPlatformServiceFee = summary.getMerchantPlatformServiceFee();
|
||||
BigDecimal expenseTotalAmount = merchantPlatformServiceFee;
|
||||
|
||||
List<BusinessDailySettlementDetailVO.SettlementItem> incomeItems = new ArrayList<>();
|
||||
incomeItems.add(buildSettlementItem(SETTLEMENT_ITEM_SERVICE_FEE, "充电服务费(元)", summary.getChargeServiceFee()));
|
||||
incomeItems.add(buildSettlementItem(SETTLEMENT_ITEM_ELECTRICITY_FEE, "充电电费(元)", summary.getChargeElectricityFee()));
|
||||
incomeItems.add(buildSettlementItem(SETTLEMENT_ITEM_PLATFORM_SUBSIDY, "平台给商户的服务费补贴(元)", summary.getPlatformServiceSubsidy()));
|
||||
|
||||
List<BusinessDailySettlementDetailVO.SettlementItem> expenseItems = new ArrayList<>();
|
||||
expenseItems.add(buildSettlementItem(SETTLEMENT_ITEM_MERCHANT_PLATFORM_FEE, "商户给平台的服务费(元)", merchantPlatformServiceFee));
|
||||
|
||||
return BusinessDailySettlementDetailVO.builder()
|
||||
.startTime(dto.getStartTime())
|
||||
.endTime(dto.getEndTime())
|
||||
.merchantIdList(scope.getMerchantIdList())
|
||||
.stationCount(scope.getStationIdList() != null ? scope.getStationIdList().size() : null)
|
||||
.settlementAmount(formatMoney(summary.getSettlementAmount()))
|
||||
.incomeTotalAmount(formatMoney(incomeTotalAmount))
|
||||
.expenseTotalAmount(formatMoney(expenseTotalAmount))
|
||||
.totalOrderCount(BigDecimalUtils.normalize(summary.getTotalOrderCount()))
|
||||
.orderTotalAmount(formatMoney(summary.getOrderTotalAmount()))
|
||||
.orderElectricity(formatQuantity(summary.getOrderElectricity()))
|
||||
.chargeServiceFee(formatMoney(summary.getChargeServiceFee()))
|
||||
.chargeElectricityFee(formatMoney(summary.getChargeElectricityFee()))
|
||||
.platformServiceSubsidy(formatMoney(summary.getPlatformServiceSubsidy()))
|
||||
.merchantPlatformServiceFee(formatMoney(merchantPlatformServiceFee))
|
||||
.tradeAmount(formatMoney(summary.getTradeAmount()))
|
||||
.tradeFee(formatMoney(summary.getTradeFee()))
|
||||
.incomeItems(incomeItems)
|
||||
.expenseItems(expenseItems)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的钱包查询
|
||||
* 优化:订单报表DB、汇付余额HTTP、提现金额DB 三个独立数据源并行查询
|
||||
@@ -467,6 +595,268 @@ public class BusinessFinancialServiceImpl implements BusinessFinancialService {
|
||||
return authorizedStationIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验结算日报详情查询条件
|
||||
*
|
||||
* @param dto 查询条件
|
||||
*/
|
||||
private void validateDailySettlementQuery(BusinessDailySettlementQueryDTO dto) {
|
||||
if (dto == null
|
||||
|| StringUtils.isBlank(dto.getStartTime())
|
||||
|| StringUtils.isBlank(dto.getEndTime())) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
try {
|
||||
LocalDate startDate = LocalDate.parse(dto.getStartTime());
|
||||
LocalDate endDate = LocalDate.parse(dto.getEndTime());
|
||||
if (endDate.isBefore(startDate)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析财务接口通用账号和站点范围
|
||||
*/
|
||||
private FinancialScope resolveFinancialScope(List<String> stationIdList) {
|
||||
List<String> merchantIdList = UserUtils.getFirstMerchantIdList();
|
||||
List<String> queryStationIds = stationIdList;
|
||||
if (CollectionUtils.isEmpty(queryStationIds)) {
|
||||
if (CollectionUtils.isEmpty(merchantIdList)) {
|
||||
return new FinancialScope(merchantIdList, Collections.emptyList());
|
||||
}
|
||||
queryStationIds = pileStationInfoService.getStationIdsByMerchantIds(merchantIdList);
|
||||
if (queryStationIds == null) {
|
||||
queryStationIds = Collections.emptyList();
|
||||
}
|
||||
}
|
||||
return new FinancialScope(merchantIdList, resolveStationIds(queryStationIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计今日订单量
|
||||
*/
|
||||
private Long countTodayOrderCount(List<String> stationIdList, String today) {
|
||||
if (stationIdList != null && stationIdList.isEmpty()) {
|
||||
return 0L;
|
||||
}
|
||||
String startTime = today + " 00:00:00";
|
||||
String endTime = today + " 23:59:59";
|
||||
if (stationIdList == null || stationIdList.size() <= STATION_QUERY_BATCH_SIZE) {
|
||||
QueryOrderDTO queryOrderDTO = QueryOrderDTO.builder()
|
||||
.stationIdList(stationIdList)
|
||||
.startTime(startTime)
|
||||
.endTime(endTime)
|
||||
.build();
|
||||
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
|
||||
return statistics != null && statistics.getOrderCount() != null ? statistics.getOrderCount() : 0L;
|
||||
}
|
||||
|
||||
long orderCount = 0L;
|
||||
for (int i = 0; i < stationIdList.size(); i += STATION_QUERY_BATCH_SIZE) {
|
||||
int endIndex = Math.min(i + STATION_QUERY_BATCH_SIZE, stationIdList.size());
|
||||
QueryOrderDTO queryOrderDTO = QueryOrderDTO.builder()
|
||||
.stationIdList(stationIdList.subList(i, endIndex))
|
||||
.startTime(startTime)
|
||||
.endTime(endTime)
|
||||
.build();
|
||||
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
|
||||
if (statistics != null && statistics.getOrderCount() != null) {
|
||||
orderCount += statistics.getOrderCount();
|
||||
}
|
||||
}
|
||||
return orderCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计停车减免待处理申诉数
|
||||
*/
|
||||
private Integer countPendingParkingAppeal(List<String> stationIdList) {
|
||||
if (stationIdList != null && stationIdList.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
// 当前停车减免模块暂无独立申诉状态数据源,预留工作台展示字段。
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建报表汇总数据
|
||||
*/
|
||||
private ReportSummary buildReportSummary(List<SettleOrderReport> reportList) {
|
||||
return buildReportSummary(reportList, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建指定日期的报表汇总数据
|
||||
*/
|
||||
private ReportSummary buildReportSummary(List<SettleOrderReport> reportList, String tradeDate) {
|
||||
ReportSummary summary = new ReportSummary();
|
||||
if (CollectionUtils.isEmpty(reportList)) {
|
||||
return summary;
|
||||
}
|
||||
for (SettleOrderReport report : reportList) {
|
||||
if (StringUtils.isNotBlank(tradeDate) && !StringUtils.equals(tradeDate, report.getTradeDate())) {
|
||||
continue;
|
||||
}
|
||||
summary.add(report);
|
||||
}
|
||||
return summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建工作台卡片
|
||||
*/
|
||||
private BusinessWorkbenchSummaryVO.WorkbenchCard buildWorkbenchCard(String cardCode,
|
||||
String cardName,
|
||||
String metricName,
|
||||
BigDecimal metricValue,
|
||||
String unit) {
|
||||
return BusinessWorkbenchSummaryVO.WorkbenchCard.builder()
|
||||
.cardCode(cardCode)
|
||||
.cardName(cardName)
|
||||
.metricName(metricName)
|
||||
.metricValue(metricValue)
|
||||
.unit(unit)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建结算项
|
||||
*/
|
||||
private BusinessDailySettlementDetailVO.SettlementItem buildSettlementItem(String itemCode,
|
||||
String itemName,
|
||||
BigDecimal amount) {
|
||||
return BusinessDailySettlementDetailVO.SettlementItem.builder()
|
||||
.itemCode(itemCode)
|
||||
.itemName(itemName)
|
||||
.unit("元")
|
||||
.amount(formatMoney(amount))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 金额统一保留两位小数
|
||||
*/
|
||||
private BigDecimal formatMoney(BigDecimal amount) {
|
||||
return formatDecimal(amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数量统一保留两位小数
|
||||
*/
|
||||
private BigDecimal formatQuantity(BigDecimal amount) {
|
||||
return formatDecimal(amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数值统一保留两位小数
|
||||
*/
|
||||
private BigDecimal formatDecimal(BigDecimal amount) {
|
||||
return BigDecimalUtils.nullToZero(amount).setScale(DEFAULT_DECIMAL_SCALE, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
private static class FinancialScope {
|
||||
private final List<String> merchantIdList;
|
||||
private final List<String> stationIdList;
|
||||
|
||||
private FinancialScope(List<String> merchantIdList, List<String> stationIdList) {
|
||||
this.merchantIdList = merchantIdList;
|
||||
this.stationIdList = stationIdList;
|
||||
}
|
||||
|
||||
private List<String> getMerchantIdList() {
|
||||
return merchantIdList;
|
||||
}
|
||||
|
||||
private List<String> getStationIdList() {
|
||||
return stationIdList;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ReportSummary {
|
||||
private BigDecimal orderTotalAmount = BigDecimal.ZERO;
|
||||
private BigDecimal totalOrderCount = BigDecimal.ZERO;
|
||||
private BigDecimal orderElectricity = BigDecimal.ZERO;
|
||||
private BigDecimal chargeServiceFee = BigDecimal.ZERO;
|
||||
private BigDecimal chargeElectricityFee = BigDecimal.ZERO;
|
||||
private BigDecimal platformServiceSubsidy = BigDecimal.ZERO;
|
||||
private BigDecimal settlementAmount = BigDecimal.ZERO;
|
||||
private BigDecimal tradeAmount = BigDecimal.ZERO;
|
||||
private BigDecimal tradeFee = BigDecimal.ZERO;
|
||||
private BigDecimal arrivalAmount = BigDecimal.ZERO;
|
||||
|
||||
private void add(SettleOrderReport report) {
|
||||
BigDecimal reportTotalAmount = BigDecimalUtils.nullToZero(report.getTotalAmount());
|
||||
BigDecimal reportSettleAmount = report.getSettleAmount() != null
|
||||
? report.getSettleAmount() : reportTotalAmount;
|
||||
|
||||
orderTotalAmount = orderTotalAmount.add(reportTotalAmount);
|
||||
totalOrderCount = totalOrderCount.add(BigDecimalUtils.parseOrZero(report.getChargeNum()));
|
||||
orderElectricity = orderElectricity.add(BigDecimalUtils.nullToZero(report.getUseElectricity()));
|
||||
chargeServiceFee = chargeServiceFee.add(BigDecimalUtils.nullToZero(report.getServiceAmount()));
|
||||
chargeElectricityFee = chargeElectricityFee.add(BigDecimalUtils.nullToZero(report.getElectricityAmount()));
|
||||
platformServiceSubsidy = platformServiceSubsidy.add(BigDecimalUtils.nullToZero(report.getVirtualAmount()));
|
||||
settlementAmount = settlementAmount.add(reportSettleAmount);
|
||||
tradeAmount = tradeAmount.add(BigDecimalUtils.nullToZero(report.getTradeAmount()));
|
||||
tradeFee = tradeFee.add(BigDecimalUtils.nullToZero(report.getTradeFee()));
|
||||
arrivalAmount = arrivalAmount.add(report.getTradeAmount() != null
|
||||
? report.getTradeAmount() : reportSettleAmount);
|
||||
}
|
||||
|
||||
private BigDecimal getIncomeTotalAmount() {
|
||||
return chargeServiceFee.add(chargeElectricityFee).add(platformServiceSubsidy);
|
||||
}
|
||||
|
||||
private BigDecimal getMerchantPlatformServiceFee() {
|
||||
BigDecimal fee = getIncomeTotalAmount().subtract(settlementAmount);
|
||||
return fee.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : fee;
|
||||
}
|
||||
|
||||
private BigDecimal getOrderTotalAmount() {
|
||||
return orderTotalAmount;
|
||||
}
|
||||
|
||||
private BigDecimal getTotalOrderCount() {
|
||||
return totalOrderCount;
|
||||
}
|
||||
|
||||
private BigDecimal getOrderElectricity() {
|
||||
return orderElectricity;
|
||||
}
|
||||
|
||||
private BigDecimal getChargeServiceFee() {
|
||||
return chargeServiceFee;
|
||||
}
|
||||
|
||||
private BigDecimal getChargeElectricityFee() {
|
||||
return chargeElectricityFee;
|
||||
}
|
||||
|
||||
private BigDecimal getPlatformServiceSubsidy() {
|
||||
return platformServiceSubsidy;
|
||||
}
|
||||
|
||||
private BigDecimal getSettlementAmount() {
|
||||
return settlementAmount;
|
||||
}
|
||||
|
||||
private BigDecimal getTradeAmount() {
|
||||
return tradeAmount;
|
||||
}
|
||||
|
||||
private BigDecimal getTradeFee() {
|
||||
return tradeFee;
|
||||
}
|
||||
|
||||
private BigDecimal getArrivalAmount() {
|
||||
return arrivalAmount;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前账号可访问的站点ID列表,平台账号返回null表示不限制
|
||||
*
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.jsowell.pile.vo.uniapp.business;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 结算日报详情VO
|
||||
*
|
||||
* @author zhangziao
|
||||
* @date 2026/6/15
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class BusinessDailySettlementDetailVO {
|
||||
|
||||
/**
|
||||
* 查询开始日期
|
||||
*/
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 查询结束日期
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 当前登录账号有权限的一级运营商id列表
|
||||
*/
|
||||
private List<String> merchantIdList;
|
||||
|
||||
/**
|
||||
* 实际参与统计的站点数量
|
||||
*/
|
||||
private Integer stationCount;
|
||||
|
||||
/**
|
||||
* 总结算金额
|
||||
*/
|
||||
private BigDecimal settlementAmount;
|
||||
|
||||
/**
|
||||
* 收入总金额
|
||||
*/
|
||||
private BigDecimal incomeTotalAmount;
|
||||
|
||||
/**
|
||||
* 支出总金额
|
||||
*/
|
||||
private BigDecimal expenseTotalAmount;
|
||||
|
||||
/**
|
||||
* 总订单数
|
||||
*/
|
||||
private BigDecimal totalOrderCount;
|
||||
|
||||
/**
|
||||
* 订单总额
|
||||
*/
|
||||
private BigDecimal orderTotalAmount;
|
||||
|
||||
/**
|
||||
* 订单电量
|
||||
*/
|
||||
private BigDecimal orderElectricity;
|
||||
|
||||
/**
|
||||
* 充电服务费
|
||||
*/
|
||||
private BigDecimal chargeServiceFee;
|
||||
|
||||
/**
|
||||
* 充电电费
|
||||
*/
|
||||
private BigDecimal chargeElectricityFee;
|
||||
|
||||
/**
|
||||
* 平台给商户的服务费补贴
|
||||
*/
|
||||
private BigDecimal platformServiceSubsidy;
|
||||
|
||||
/**
|
||||
* 商户给平台的服务费
|
||||
*/
|
||||
private BigDecimal merchantPlatformServiceFee;
|
||||
|
||||
/**
|
||||
* 交易到账金额
|
||||
*/
|
||||
private BigDecimal tradeAmount;
|
||||
|
||||
/**
|
||||
* 交易手续费
|
||||
*/
|
||||
private BigDecimal tradeFee;
|
||||
|
||||
/**
|
||||
* 收入项列表
|
||||
*/
|
||||
private List<SettlementItem> incomeItems;
|
||||
|
||||
/**
|
||||
* 支出项列表
|
||||
*/
|
||||
private List<SettlementItem> expenseItems;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public static class SettlementItem {
|
||||
|
||||
/**
|
||||
* 项编码
|
||||
*/
|
||||
private String itemCode;
|
||||
|
||||
/**
|
||||
* 项名称
|
||||
*/
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.jsowell.pile.vo.uniapp.business;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工作台首页汇总VO
|
||||
*
|
||||
* @author zhangziao
|
||||
* @date 2026/6/15
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class BusinessWorkbenchSummaryVO {
|
||||
|
||||
/**
|
||||
* 今日日期
|
||||
*/
|
||||
private String today;
|
||||
|
||||
/**
|
||||
* 近7天开始日期
|
||||
*/
|
||||
private String recentStartTime;
|
||||
|
||||
/**
|
||||
* 近7天结束日期
|
||||
*/
|
||||
private String recentEndTime;
|
||||
|
||||
/**
|
||||
* 当前登录账号有权限的一级运营商id列表
|
||||
*/
|
||||
private List<String> merchantIdList;
|
||||
|
||||
/**
|
||||
* 实际参与统计的站点id列表
|
||||
*/
|
||||
private List<String> stationIdList;
|
||||
|
||||
/**
|
||||
* 实际参与统计的站点数量
|
||||
*/
|
||||
private Integer stationCount;
|
||||
|
||||
/**
|
||||
* 今日订单量
|
||||
*/
|
||||
private Long todayOrderCount;
|
||||
|
||||
/**
|
||||
* 经营参谋近7天净现金流
|
||||
*/
|
||||
private BigDecimal recentNetCashFlow;
|
||||
|
||||
/**
|
||||
* 我的钱包今日到账
|
||||
*/
|
||||
private BigDecimal todayArrivalAmount;
|
||||
|
||||
/**
|
||||
* 结算日报近7天净现金流
|
||||
*/
|
||||
private BigDecimal recentSettlementNetCashFlow;
|
||||
|
||||
/**
|
||||
* 停车减免待处理申诉数
|
||||
*/
|
||||
private Integer pendingParkingAppealCount;
|
||||
|
||||
/**
|
||||
* 首页卡片列表
|
||||
*/
|
||||
private List<WorkbenchCard> cardList;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public static class WorkbenchCard {
|
||||
|
||||
/**
|
||||
* 卡片编码
|
||||
*/
|
||||
private String cardCode;
|
||||
|
||||
/**
|
||||
* 卡片名称
|
||||
*/
|
||||
private String cardName;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
private String metricName;
|
||||
|
||||
/**
|
||||
* 指标值
|
||||
*/
|
||||
private BigDecimal metricValue;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String unit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user