From b69882bdf56305be94a361525342987fe3c64385 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 12 九月 2024 09:19:01 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile
---
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 188 ++++++++++++++++++++++++++++++++++++++--------
1 files changed, 153 insertions(+), 35 deletions(-)
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
index 4ca77f9..50d9583 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -450,8 +450,14 @@
this.save(chargingOrder);
//添加订单的计费策略
- TAccountingStrategy accountingStrategy = accountingStrategyClient.getAccountingStrategyById(tChargingGun.getAccountingStrategyId()).getData();
- List<TAccountingStrategyDetail> strategyDetailList = accountingStrategyDetailClient.getListByAccountingStrategyId(tChargingGun.getAccountingStrategyId()).getData();
+ Integer accountingStrategyId = tChargingGun.getAccountingStrategyId();
+ if(null == accountingStrategyId){
+ //查询站点上面的计费策略
+ Site site = siteClient.getSiteByIds(Arrays.asList(tChargingGun.getSiteId())).getData().get(0);
+ accountingStrategyId = site.getAccountingStrategyId();
+ }
+ TAccountingStrategy accountingStrategy = accountingStrategyClient.getAccountingStrategyById(accountingStrategyId).getData();
+ List<TAccountingStrategyDetail> strategyDetailList = accountingStrategyDetailClient.getListByAccountingStrategyId(accountingStrategyId).getData();
AccountingStrategyOrder accountingStrategyOrder = new AccountingStrategyOrder();
BeanUtils.copyProperties(accountingStrategy, accountingStrategyOrder);
accountingStrategyOrder.setChargingOrderId(chargingOrder.getId());
@@ -1384,6 +1390,22 @@
TChargingOrder chargingOrder= this.getById(uid);
ChargingOrderListInfoVO chargingOrderListInfoVO = new ChargingOrderListInfoVO();
+ chargingOrderListInfoVO.setElectrovalence(chargingOrder.getElectrovalence());
+ chargingOrderListInfoVO.setServiceCharge(chargingOrder.getServiceCharge());
+ if (chargingOrder.getElectrovalence()!=null && chargingOrder.getServiceCharge()!=null){
+ chargingOrderListInfoVO.setTotal(chargingOrder.getElectrovalence().add(chargingOrder.getServiceCharge()));
+ }else{
+ chargingOrderListInfoVO.setTotal(new BigDecimal("0"));
+ }
+ if (chargingOrderListInfoVO.getTotal().compareTo(new BigDecimal("0"))>0){
+ if (chargingOrder.getCouponDiscountAmount()!=null&& chargingOrder.getVipDiscountAmount()!=null&& chargingOrder.getSharingAmount()!=null&& chargingOrder.getCommissionAmount()!=null){
+ chargingOrderListInfoVO.setRealTotal(chargingOrderListInfoVO.getTotal().subtract(chargingOrder.getCouponDiscountAmount()).subtract(chargingOrder.getVipDiscountAmount()).subtract(chargingOrder.getSharingAmount()).subtract(chargingOrder.getCommissionAmount()));
+ }else{
+ chargingOrderListInfoVO.setRealTotal(chargingOrderListInfoVO.getTotal());
+ }
+ }else{
+ chargingOrderListInfoVO.setRealTotal(new BigDecimal("0"));
+ }
chargingOrderListInfoVO.setCode(chargingOrder.getCode());
List<Site> data = siteClient.getSiteByIds(Arrays.asList(chargingOrder.getSiteId())).getData();
if (!data.isEmpty()){
@@ -1782,18 +1804,25 @@
String startTime = dto.getStartTime();
String endTime = dto.getEndTime();
// 将这两个时间转化为localDateTime
- tSettlementConfirm.setStartTime(LocalDateTime.parse(startTime));
- tSettlementConfirm.setEndTime(LocalDateTime.parse(endTime));
+ // 创建 DateTimeFormatter 对象,指定格式
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
+
+ // 将字符串解析为 LocalDateTime 对象
+ LocalDateTime localDateTime = LocalDateTime.parse(startTime, formatter);
+ LocalDateTime localDateTime1 = LocalDateTime.parse(endTime, formatter);
+ tSettlementConfirm.setEndTime(localDateTime1);
+ tSettlementConfirm.setStartTime(localDateTime);
+
// 根据站点id和开始时间和结束时间和归属日期 查询充电订单列表
QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>()
.eq("site_id", dto.getSiteId())
.eq("recharge_payment_status",2);
switch (dto.getType()){
case 1:
- eq.between("start_time", startTime, endTime);
+ eq.between("start_time", localDateTime, localDateTime1);
break;
case 2:
- eq.between("end_time", startTime, endTime);
+ eq.between("end_time", localDateTime, localDateTime1);
break;
}
List<TChargingOrder> tChargingOrders = this.baseMapper.selectList(eq);
@@ -1817,13 +1846,23 @@
BigDecimal paymentAmount = new BigDecimal("0");
for (TChargingOrder tChargingOrder : tChargingOrders) {
// 累加充电总度数
- chargingElectronic = chargingElectronic.add(tChargingOrder.getChargingCapacity());
+ if (tChargingOrder.getChargingCapacity()!=null){
+ chargingElectronic = chargingElectronic.add(tChargingOrder.getChargingCapacity());
+
+ }
// 累加分佣
- sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount());
+ if (tChargingOrder.getSharingAmount()!=null) {
+ sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount());
+ }
// 累加电费
+ if (tChargingOrder.getElectrovalence()!=null) {
electrovalence = electrovalence.add(tChargingOrder.getElectrovalence());
+ }
// 累加服务费
- serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge());
+ if (tChargingOrder.getServiceCharge()!=null){
+ serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge());
+
+ }
// 累加会员折扣
if (tChargingOrder.getVipDiscountAmount()!=null){
vipDiscount = vipDiscount.add(tChargingOrder.getVipDiscountAmount());
@@ -1832,11 +1871,13 @@
if (tChargingOrder.getCouponDiscountAmount()!=null){
couponDiscount = couponDiscount.add(tChargingOrder.getCouponDiscountAmount());
}
- if (tChargingOrder.getRefundStatus() == 2){
+ if (tChargingOrder.getRefundStatus()!=null &&tChargingOrder.getRefundStatus() == 2){
// 如果成功退款 那么减去退款金额
paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount().subtract(tChargingOrder.getRefundAmount()));
}else{
- paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount());
+ if (tChargingOrder.getPaymentAmount()!=null){
+ paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount());
+ }
}
}
// 三方交易手续费 三方收费*0.6%
@@ -1852,34 +1893,36 @@
tSettlementConfirm.setVipDiscount(vipDiscount);
tSettlementConfirm.setCouponDiscount(couponDiscount);
tSettlementConfirm.setSiteId(dto.getSiteId());
- tSettlementConfirm.setMeteringElectronic(dto.getData().getMeteringElectronic());
tSettlementConfirm.setChargingElectronic(chargingElectronic);
- tSettlementConfirm.setLossElectronic(dto.getData().getLossElectronic());
tSettlementConfirm.setIncome(chargingElectronic.add(serviceCharge));
- tSettlementConfirm.setVenue(dto.getData().getVenue());
- tSettlementConfirm.setMetering(dto.getData().getMetering());
- tSettlementConfirm.setClean(dto.getData().getClean());
- tSettlementConfirm.setMaintain(dto.getData().getMaintain());
- tSettlementConfirm.setCost(dto.getData().getVenue().add(dto.getData().getClean()).add(dto.getData().getMaintain()));
tSettlementConfirm.setProfitMoney(new BigDecimal("0"));
tSettlementConfirm.setNewMoney(new BigDecimal("0"));
tSettlementConfirm.setNewSettlement(new BigDecimal("0"));
tSettlementConfirm.setVipDiscount(vipDiscount);
tSettlementConfirm.setCouponDiscount(couponDiscount);
- tSettlementConfirm.setSupplyElectronic(dto.getData().getSupplyElectronic());
tSettlementConfirm.setType(dto.getType());
- tSettlementConfirm.setProportionPartner(dto.getData().getProportionPartner());
- tSettlementConfirm.setProportionMoney(dto.getData().getProportionMoney());
- tSettlementConfirm.setTotalElectronic(dto.getData().getTotalElectronic());
- tSettlementConfirm.setTotalService(dto.getData().getTotalService());
- tSettlementConfirm.setRemark(dto.getData().getRemark());
- tSettlementConfirm.setServicePartner(dto.getData().getServicePartner());
- tSettlementConfirm.setServiceMoney(dto.getData().getServiceMoney());
- tSettlementConfirm.setTotalService(dto.getData().getTotalService());
- tSettlementConfirm.setServiceRemark(dto.getData().getServiceRemark());
- tSettlementConfirm.setDistribution(dto.getData().getDistribution());
- tSettlementConfirm.setIncome(dto.getData().getElectrovalence().add(dto.getData().getServiceCharge()));
+
if (dto.getState() == 2){
+ tSettlementConfirm.setSupplyElectronic(dto.getSupplyElectronic());
+ tSettlementConfirm.setVenue(dto.getVenue());
+ tSettlementConfirm.setMetering(dto.getMetering());
+ tSettlementConfirm.setClean(dto.getClean());
+ tSettlementConfirm.setLossElectronic(dto.getLossElectronic());
+ tSettlementConfirm.setMaintain(dto.getMaintain());
+
+ tSettlementConfirm.setMeteringElectronic(dto.getMeteringElectronic());
+ tSettlementConfirm.setProportionPartner(dto.getProportionPartner());
+ tSettlementConfirm.setProportionMoney(dto.getProportionMoney());
+ tSettlementConfirm.setTotalElectronic(dto.getTotalElectronic());
+ tSettlementConfirm.setTotalService(dto.getTotalService());
+ tSettlementConfirm.setRemark(dto.getRemark());
+ tSettlementConfirm.setServicePartner(dto.getServicePartner());
+ tSettlementConfirm.setServiceMoney(dto.getServiceMoney());
+ tSettlementConfirm.setTotalService(dto.getTotalService());
+ tSettlementConfirm.setServiceRemark(dto.getServiceRemark());
+ tSettlementConfirm.setDistribution(dto.getDistribution());
+ tSettlementConfirm.setIncome(dto.getElectrovalence().add(dto.getServiceCharge()));
+ tSettlementConfirm.setCost(dto.getVenue().add(dto.getClean()).add(dto.getMaintain()));
tSettlementConfirmMapper.insert(tSettlementConfirm);
}
return tSettlementConfirm;
@@ -1906,7 +1949,7 @@
}
pageInfo.setRecords(list);
- return null;
+ return pageInfo;
}
@Override
@@ -2066,13 +2109,23 @@
tSettlementConfirm.setVipDiscount(vipDiscount);
tSettlementConfirm.setCouponDiscount(couponDiscount);
// 本月
- BigDecimal subtract = income.subtract(beforeIncome).divide(beforeIncome).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100"));
- tSettlementConfirm.setIncomePercentage(subtract+"%");
+ if (beforeIncome.compareTo(new BigDecimal("0")) == 0){
+ tSettlementConfirm.setIncomePercentage(0+"%");
+ tSettlementConfirm.setIncomePercentage(0+"%");
+ }else{
+ BigDecimal subtract = income.subtract(beforeIncome).divide(beforeIncome).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100"));
+ tSettlementConfirm.setIncomePercentage(subtract+"%");
+ tSettlementConfirm.setIncomePercentage(subtract+"%");
+
+ }
// 比较总利润 收入合计-成本合计
BigDecimal subtract1 = income.subtract(cost);
BigDecimal subtract2 = beforeIncome.subtract(beforeCost);
- tSettlementConfirm.setTotalPercentage(subtract1.subtract(subtract2).divide(subtract2).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100"))+"%");
- tSettlementConfirm.setIncomePercentage(subtract+"%");
+ if (subtract2.compareTo(new BigDecimal("0")) == 0){
+ tSettlementConfirm.setTotalPercentage(0+"%");
+ }else{
+ tSettlementConfirm.setTotalPercentage(subtract1.subtract(subtract2).divide(subtract2).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100"))+"%");
+ }
tSettlementConfirm.setElectronicRefund(0);
// 查询上次汇报数据 进行比对涨幅跌幅
total.add(tSettlementConfirm);
@@ -2081,6 +2134,71 @@
return res;
}
+ @Override
+ public List<Map<String, Object>> countBySource(List<Integer> siteIds) {
+ return this.baseMapper.countBySource(siteIds);
+ }
+
+ @Override
+ public List<Map<String, Object>> equipmentUserType1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
+ return this.baseMapper.equipmentUserType1(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> equipmentUserType2(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
+ return this.baseMapper.equipmentUserType2(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> equipmentMapbroke1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
+ return this.baseMapper.equipmentMapbroke1(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> equipmentMapbroke2(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
+ return this.baseMapper.equipmentMapbroke2(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> equipmentMapOut1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
+ return this.baseMapper.equipmentMapOut1(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> equipmentMapOut2(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
+ return this.baseMapper.equipmentMapOut2(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> needElec(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
+ return this.baseMapper.needElec(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> getHourType(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto) {
+ return this.baseMapper.getHourType(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> getDateType(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto) {
+ return this.baseMapper.getDateType(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> getMonthType(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto) {
+ return this.baseMapper.getMonthType(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> getchargingCapacity(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto) {
+ return this.baseMapper.getchargingCapacity(siteIds,statisticsQueryDto);
+ }
+
+ @Override
+ public List<Map<String, Object>> countAllUserData() {
+ return this.baseMapper.countAllUserData();
+ }
+
public static void main(String[] args) {
// String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss"));
// String format1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss"));
--
Gitblit v1.7.1