From d2230c638cc57b7dc4fa4570e79cbc93107926b0 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 24 十月 2024 15:44:38 +0800
Subject: [PATCH] 合并代码
---
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java | 197 ++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 160 insertions(+), 37 deletions(-)
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
index 0c4df93..7785418 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -3,9 +3,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
-import java.time.DayOfWeek;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
+import java.time.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -23,6 +21,7 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
+import com.ruoyi.common.core.web.domain.BasePojo;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.core.web.domain.AjaxResult;
@@ -65,7 +64,6 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
-import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
@@ -94,7 +92,8 @@
private TokenService tokenService;
@Autowired
private TOrderEvaluateService orderEvaluateService;
-
+ @Autowired
+ private TGrantVipService tGrantVipService;
@Resource
private WxPaymentClient wxPaymentClient;
@@ -135,6 +134,15 @@
@Resource
private TOrderInvoiceService invoiceService;
+ /**
+ * 远程调用 增加管理后台赠送会员记录
+ * @return
+ */
+ @ResponseBody
+ @PostMapping(value = "/management/give/vip")
+ public R managementGiveVip(@RequestBody TGrantVip grantVip) {
+ return R.ok(tGrantVipService.save(grantVip));
+ }
/**
* 远程调用根据枪id 查询最新的订单id 用户后台结束充电
@@ -183,7 +191,7 @@
payOrderInfoDto.setTradeNo(byId.getRechargeSerialNumber());
payOrderInfoDto.setPayType(byId.getRechargePaymentType());
payOrderInfoDto.setPayAmount(byId.getPaymentAmount());
- payOrderInfoDto.setPayTime(byId.getPayTime());
+ payOrderInfoDto.setPayTime(byId.getCreateTime());
payOrderInfoDto.setRefundAmount(byId.getRefundAmount());
return R.ok(payOrderInfoDto);
case 2:
@@ -194,7 +202,7 @@
payOrderInfoDto1.setTradeNo(byId1.getSerialNumber());
payOrderInfoDto1.setPayType(byId1.getPaymentType());
payOrderInfoDto1.setPayAmount(byId1.getPaymentAmount());
- payOrderInfoDto1.setPayTime(byId1.getPayTime());
+ payOrderInfoDto1.setPayTime(byId1.getCreateTime());
payOrderInfoDto1.setRefundAmount(byId1.getRefundAmount());
return R.ok(payOrderInfoDto1);
case 3:
@@ -205,7 +213,7 @@
payOrderInfoDto2.setTradeNo(byId2.getSerialNumber());
payOrderInfoDto2.setPayType(byId2.getPaymentType());
payOrderInfoDto2.setPayAmount(byId2.getPaymentAmount());
- payOrderInfoDto2.setPayTime(byId2.getPayTime());
+ payOrderInfoDto2.setPayTime(byId2.getCreateTime());
payOrderInfoDto2.setRefundAmount(byId2.getRefundAmount());
return R.ok(payOrderInfoDto2);
//todo luo 停车场订单
@@ -250,7 +258,7 @@
@ResponseBody
@GetMapping(value = "/pay/order/charging")
@ApiOperation(value = "充电信息", tags = {"管理后台-支付订单-订单信息"})
- public R refundDetail(Long orderId) {
+ public R<PayOrderChargingInfo> refundDetail(Long orderId) {
PayOrderChargingInfo payOrderChargingInfo = new PayOrderChargingInfo();
TChargingOrder byId = chargingOrderService.getById(orderId);
List<Site> data = siteClient.getSiteByIds(Collections.singletonList(byId.getSiteId())).getData();
@@ -263,7 +271,20 @@
List<TAppUserCar> data3 = appUserCarClient.getCarByIds(Collections.singletonList(byId.getAppUserCarId())).getData();
payOrderChargingInfo.setCarNum(data3.get(0).getLicensePlate());
}
- return R.ok();
+ payOrderChargingInfo.setTChargingOrder(byId);
+
+ Long count = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, orderId).count();
+ payOrderChargingInfo.setPeriodCount(count);
+ if (byId.getAppUserCarId()!=null) {
+ List<Long> carid = new ArrayList<>();
+ carid.add(byId.getAppUserCarId());
+ R<List<TAppUserCar>> carByIds = appUserCarClient.getCarByIds(carid);
+ payOrderChargingInfo.setCarNum(carByIds.getData().get(0).getLicensePlate());
+ }
+ payOrderChargingInfo.setStartTime(byId.getStartTime());
+ payOrderChargingInfo.setEndTime(byId.getEndTime());
+ payOrderChargingInfo.setTimeCount(payOrderChargingInfo.calculateDuration());
+ return R.ok(payOrderChargingInfo);
}
@ResponseBody
@@ -280,7 +301,11 @@
@PostMapping(value = "/pay/order/refund/list")
@ApiOperation(value = "列表", tags = {"管理后台-支付订单-退款订单"})
public R<PageInfo<TChargingOrderRefund>> refundList(@RequestBody ChargingRefundDto chargingRefundDto) {
- return chargingOrderService.getRefundList(chargingRefundDto);
+ R<PageInfo<TChargingOrderRefund>> refundList = chargingOrderService.getRefundList(chargingRefundDto);
+ for (TChargingOrderRefund record : refundList.getData().getRecords()) {
+ record.setUid(record.getId().toString());
+ }
+ return refundList;
}
@ResponseBody
@@ -307,20 +332,44 @@
}
@ResponseBody
- @PostMapping(value = "/chargingOrderInfo")
+ @GetMapping(value = "/chargingOrderInfo")
@ApiOperation(value = "充电桩订单列表查看详情", tags = {"管理后台-订单管理"})
- public AjaxResult<ChargingOrderInfoVO> chargingOrderInfo(String orderId) {
+ public AjaxResult<ChargingOrderInfoVO> chargingOrderInfo(String strategyId) {
+ TChargingOrder byId = chargingOrderService.getById(strategyId);
ChargingOrderInfoVO chargingOrderInfoVO = new ChargingOrderInfoVO();
- chargingOrderInfoVO.setCdElectronic("");
- chargingOrderInfoVO.setCdVoltage("");
- chargingOrderInfoVO.setSurplus("");
- chargingOrderInfoVO.setTotalPower("");
- chargingOrderInfoVO.setLicensePlate("");
- chargingOrderInfoVO.setVehicleBrand("");
- chargingOrderInfoVO.setVehicleModel("");
- chargingOrderInfoVO.setVehicleUse("");
- List<TChargingOrderAccountingStrategy> tChargingOrderAccountingStrategies = new ArrayList<>();
- chargingOrderInfoVO.setList(tChargingOrderAccountingStrategies);
+
+ chargingOrderInfoVO.setCdElectronic(byId.getCurrent()!=null?byId.getCurrent().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
+ chargingOrderInfoVO.setCdVoltage(byId.getVoltage()!=null?byId.getVoltage().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
+ chargingOrderInfoVO.setSurplus(byId.getTotalElectricity()!=null?byId.getTotalElectricity().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
+ chargingOrderInfoVO.setTotalPower(byId.getPower()!=null?byId.getPower().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
+ if (byId.getAppUserCarId()!=null){
+ List<TAppUserCar> data = appUserCarClient.getCarByIds(Arrays.asList(byId.getAppUserCarId())).getData();
+ if (!data.isEmpty()){
+ chargingOrderInfoVO.setLicensePlate(data.get(0).getLicensePlate());
+ chargingOrderInfoVO.setVehicleBrand(data.get(0).getVehicleBrand());
+ chargingOrderInfoVO.setVehicleModel(data.get(0).getVehicleModel());
+ chargingOrderInfoVO.setVehicleUse(data.get(0).getVehicleUse());
+ }
+ }
+ // 时段总服务费
+ BigDecimal bigDecimal = new BigDecimal("0");
+ List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, strategyId).orderByDesc(TChargingOrderAccountingStrategy::getStartTime).list();
+
+ for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : list) {
+ if (byId.getVipDiscountAmount()!=null){
+ BigDecimal multiply = byId.getVipDiscountAmount().divide(byId.getServiceCharge(), 2)
+ .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
+ tChargingOrderAccountingStrategy.setVipDiscount(multiply);
+ }
+ bigDecimal = bigDecimal.add(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
+
+ if (byId.getCouponDiscountAmount()!=null){
+ BigDecimal multiply = byId.getCouponDiscountAmount().divide(byId.getServiceCharge(), 2)
+ .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
+ tChargingOrderAccountingStrategy.setCouponDiscount(multiply);
+ }
+ }
+ chargingOrderInfoVO.setList(list);
return AjaxResult.success(chargingOrderInfoVO);
}
@@ -596,10 +645,36 @@
}
LocalDate sixBefore = PreviousSixMonths.get();
//通过siteIds进行sql查询统计
+ List<SixChargingDto> sixChargingDtos = generateLastSixMonths();
List<SixChargingDto> chargingDtos = chargingOrderService.charge(sixBefore, siteIds);
+ for (SixChargingDto sixChargingDto : sixChargingDtos) {
+ for (SixChargingDto chargingDto : chargingDtos) {
+ if (sixChargingDto.getMonth().equals(chargingDto.getMonth())){
+ BeanUtils.copyProperties(chargingDto,sixChargingDto);
+ }
+ }
- return R.ok(chargingDtos);
+ }
+ return R.ok(sixChargingDtos);
+
+ }
+
+
+ public static List<SixChargingDto> generateLastSixMonths() {
+ LocalDate today = LocalDate.now();
+ List<SixChargingDto> months = new ArrayList<>();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM");
+
+ for (int i = 5; i >= 0; i--) {
+ LocalDate date = today.minusMonths(i);
+ String month = date.format(formatter);
+ SixChargingDto sixChargingDto = new SixChargingDto();
+ sixChargingDto.setMonth(month);
+ months.add(sixChargingDto);
+ }
+
+ return months;
}
@ResponseBody
@@ -633,7 +708,33 @@
//count近6个月的数据
LocalDate sixBefore = PreviousSixMonths.get();
List<SixShopDto> sixShopDtos = shoppingOrderService.sixBefore(sixBefore,status);
- return R.ok(sixShopDtos);
+ List<SixShopDto> sixChargingDtos = generateLastSixMonths1();
+ for (SixShopDto sixChargingDto : sixChargingDtos) {
+ for (SixShopDto chargingDto : sixShopDtos) {
+ if (sixChargingDto.getMonth().equals(chargingDto.getMonth())){
+ BeanUtils.copyProperties(chargingDto,sixChargingDto);
+ }
+ }
+
+ }
+
+ return R.ok(sixChargingDtos);
+ }
+
+ public static List<SixShopDto> generateLastSixMonths1() {
+ LocalDate today = LocalDate.now();
+ List<SixShopDto> months = new ArrayList<>();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM");
+
+ for (int i = 5; i >= 0; i--) {
+ LocalDate date = today.minusMonths(i);
+ String month = date.format(formatter);
+ SixShopDto sixChargingDto = new SixShopDto();
+ sixChargingDto.setMonth(month);
+ months.add(sixChargingDto);
+ }
+
+ return months;
}
@ResponseBody
@@ -670,7 +771,9 @@
BigDecimal data2 = vipOrderService.getSumAmout(sixBefore);
map.put("vipAmount",data2);
- return R.ok(map);
+
+
+ return R.ok(map);
}
@Resource
@@ -697,16 +800,22 @@
List<UploadRealTimeMonitoringData> data1 = uploadRealTimeMonitoringDataClient.getAll(mongoChargingOrderQuery).getData();
List<ChargingOrderAndUploadRealTimeMonitoringDataDto> dtos = new ArrayList<>();
+ Map<String,ChargingOrderVO> map = new HashMap<>();
for (UploadRealTimeMonitoringData uploadRealTimeMonitoringData : data1) {
ChargingOrderAndUploadRealTimeMonitoringDataDto dataDto = new ChargingOrderAndUploadRealTimeMonitoringDataDto();
BeanUtils.copyProperties(uploadRealTimeMonitoringData,dataDto);
ChargingOrderQuery dto = new ChargingOrderQuery();
+ dto.setCode(uploadRealTimeMonitoringData.getTransaction_serial_number());
TCharingOrderVO vo = chargingOrderService.chargingOrder(dto);
- ChargingOrderVO chargingOrderVO = vo.getList().getRecords().get(0);
- if (chargingOrderVO!=null) {
- BeanUtils.copyProperties(chargingOrderVO, dataDto);
+ if (!vo.getList().getRecords().isEmpty()) {
+ ChargingOrderVO chargingOrderVO = vo.getList().getRecords().get(0);
+ if (chargingOrderVO != null) {
+ BeanUtils.copyProperties(chargingOrderVO, dataDto);
+ }
+ dtos.add(dataDto);
+ }else {
+ continue;
}
- dtos.add(dataDto);
}
@@ -761,19 +870,22 @@
LocalDate end = null;
if (statisticsQueryDto.getDayType()==1){
start = LocalDate.now();
+ end = LocalDate.now().plusDays(1);
}else if (statisticsQueryDto.getDayType()==2){
LocalDate today = LocalDate.now();
// 获取本周一的日期
LocalDate mondayThisWeek = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
-
+ start = statisticsQueryDto.getStartTime();
+ end = statisticsQueryDto.getEndTime();
System.out.println("本周一是: " + mondayThisWeek);
}
else if (statisticsQueryDto.getDayType()==3){
// 获取当前日期
LocalDate today = LocalDate.now();
-
+ start = statisticsQueryDto.getStartTime();
+ end = statisticsQueryDto.getEndTime();
// 获取本月1号的日期
YearMonth yearMonth = YearMonth.from(today);
// start = yearMonth.atDay(1);
@@ -794,6 +906,7 @@
}
List<TChargingOrder> list = chargingOrderService.lambdaQuery().ge(TChargingOrder::getStartTime, start).le(TChargingOrder::getEndTime, end).in(TChargingOrder::getSiteId, siteIds).list();
List<Long> chargingOrderIds = list.stream().map(TChargingOrder::getId).collect(Collectors.toList());
+ chargingOrderIds.add(-1L);
//上方饼图
List<Map<String,Object>> maps = chargingOrderService.getSumByType(chargingOrderIds);
@@ -930,16 +1043,18 @@
tCharingUserMapVO.setMap(dateRangeStatistics);
- List<Map<String,Object>> map1 = chargingOrderService.usersByQuery(statisticsQueryDto);
+ List<Map<String,Object>> map1 = chargingOrderService.usersByQuery1(statisticsQueryDto);
+ LocalDate startDate1 = statisticsQueryDto.getStartTime();
+ LocalDate endDate1 = statisticsQueryDto.getEndTime();
List<Map<String, Object>> dateRangeStatistics1 = new ArrayList<>();
// 遍历日期范围
- while (!startDate.isAfter(endDate)) {
- String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ while (!startDate1.isAfter(endDate1)) {
+ String formattedDate = startDate1.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
Map<String, Object> dailyStats = findMapWithDateValue(map1, formattedDate);
if (dailyStats != null) {
@@ -952,7 +1067,7 @@
}
// 移动到下一天
- startDate = startDate.plusDays(1);
+ startDate1 = startDate1.plusDays(1);
}
tCharingUserMapVO.setMap1(dateRangeStatistics1);
@@ -1136,7 +1251,15 @@
} else {
siteIds.add(statisticsQueryDto.getSiteId());
}
- List<TChargingOrder> list = chargingOrderService.lambdaQuery().in(!siteIds.isEmpty(), TChargingOrder::getSiteId, siteIds).eq(statisticsQueryDto.getSiteId() != null, TChargingOrder::getSiteId, statisticsQueryDto.getSiteId()).list();
+ LocalDateTime selectDate = statisticsQueryDto.getSelectDate();
+ LocalDateTime min = selectDate.with(LocalTime.MIN);
+ LocalDateTime max = selectDate.with(LocalTime.MAX);
+
+
+
+
+
+ List<TChargingOrder> list = chargingOrderService.lambdaQuery().in(!siteIds.isEmpty(), TChargingOrder::getSiteId, siteIds).ge( TChargingOrder::getCreateTime,min).le(BasePojo::getCreateTime,max).eq(statisticsQueryDto.getSiteId() != null, TChargingOrder::getSiteId, statisticsQueryDto.getSiteId()).list();
//当日的订单总数
int size = list.size();
//计算list中paymentAmount的总和
--
Gitblit v1.7.1