ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderStatisticsController.java
@@ -1,10 +1,12 @@ package com.stylefeng.guns.modular.system.controller.specialTrain; import com.aliyun.oss.ServiceException; import com.stylefeng.guns.core.base.controller.BaseController; import com.stylefeng.guns.modular.system.response.*; import com.stylefeng.guns.modular.system.service.TOrderStatisticsService; import com.stylefeng.guns.modular.system.util.ResultUtil; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -19,6 +21,7 @@ * @version 1.0.0 * @since 2026/6/22 11:30 */ @Slf4j @AllArgsConstructor @Controller @RequestMapping("/tOrderStatistics") @@ -31,9 +34,14 @@ */ @ResponseBody @RequestMapping(value = "/annualTrend", method = RequestMethod.GET) public ResultUtil<List<TOrderStatisticsAnnualTrendVo>> annualTrend(String year) { List<TOrderStatisticsAnnualTrendVo> annualTrendList = orderStatisticsService.annualTrendStatistics(year); return ResultUtil.success(annualTrendList); public ResultUtil annualTrend(String year) { try { List<TOrderStatisticsAnnualTrendVo> annualTrendList = orderStatisticsService.annualTrendStatistics(year); return ResultUtil.success(annualTrendList); } catch (ServiceException e) { log.error("可视化数据统计异常", e); return ResultUtil.error(e.getErrorMessage()); } } /** @@ -41,9 +49,14 @@ */ @ResponseBody @RequestMapping(value = "/totalOrder", method = RequestMethod.GET) public ResultUtil<TOrderStatisticsTotalOrderVo> totalOrder(String startDate, String endDate) { TOrderStatisticsTotalOrderVo totalOrderVo = orderStatisticsService.totalOrderStatistics(startDate, endDate); return ResultUtil.success(totalOrderVo); public ResultUtil totalOrder(String startDate, String endDate) { try { TOrderStatisticsTotalOrderVo totalOrderVo = orderStatisticsService.totalOrderStatistics(startDate, endDate); return ResultUtil.success(totalOrderVo); } catch (ServiceException e) { log.error("可视化数据统计异常", e); return ResultUtil.error(e.getErrorMessage()); } } /** @@ -51,9 +64,14 @@ */ @ResponseBody @RequestMapping(value = "/newAddPassenger", method = RequestMethod.GET) public ResultUtil<List<TOrderStatisticsCountVo>> newAddPassenger(Integer type) { List<TOrderStatisticsCountVo> countVos = orderStatisticsService.newAddPassengerStatistics(type); return ResultUtil.success(countVos); public ResultUtil newAddPassenger(Integer type) { try { List<TOrderStatisticsCountVo> countVos = orderStatisticsService.newAddPassengerStatistics(type); return ResultUtil.success(countVos); } catch (ServiceException e) { log.error("可视化数据统计异常", e); return ResultUtil.error(e.getErrorMessage()); } } /** @@ -61,9 +79,14 @@ */ @ResponseBody @RequestMapping(value = "/orderCount", method = RequestMethod.GET) public ResultUtil<List<TOrderStatisticsCountVo>> orderCount(Integer type) { List<TOrderStatisticsCountVo> countVos = orderStatisticsService.orderCountStatistics(type); return ResultUtil.success(countVos); public ResultUtil orderCount(Integer type) { try { List<TOrderStatisticsCountVo> countVos = orderStatisticsService.orderCountStatistics(type); return ResultUtil.success(countVos); } catch (ServiceException e) { log.error("可视化数据统计异常", e); return ResultUtil.error(e.getErrorMessage()); } } /** @@ -71,9 +94,14 @@ */ @ResponseBody @RequestMapping(value = "/orderDayHourCount", method = RequestMethod.GET) public ResultUtil<List<TOrderStatisticsCountVo>> orderDayHourCount(Integer startHour, Integer endHour) { List<TOrderStatisticsCountVo> countVos = orderStatisticsService.orderDayHourCount(startHour, endHour); return ResultUtil.success(countVos); public ResultUtil orderDayHourCount(Integer startHour, Integer endHour) { try { List<TOrderStatisticsCountVo> countVos = orderStatisticsService.orderDayHourCount(startHour, endHour); return ResultUtil.success(countVos); } catch (ServiceException e) { log.error("可视化数据统计异常", e); return ResultUtil.error(e.getErrorMessage()); } } /** @@ -81,9 +109,14 @@ */ @ResponseBody @RequestMapping(value = "/driverCar", method = RequestMethod.GET) public ResultUtil<List<TOrderStatisticsCarVo>> driverCar(Integer type) { List<TOrderStatisticsCarVo> countVos = orderStatisticsService.driverCarStatistics(type); return ResultUtil.success(countVos); public ResultUtil driverCar(Integer type) { try { List<TOrderStatisticsCarVo> countVos = orderStatisticsService.driverCarStatistics(type); return ResultUtil.success(countVos); } catch (ServiceException e) { log.error("可视化数据统计异常", e); return ResultUtil.error(e.getErrorMessage()); } } /** @@ -91,9 +124,14 @@ */ @ResponseBody @RequestMapping(value = "/passenger", method = RequestMethod.GET) public ResultUtil<List<TOrderStatisticsPassengerVo>> passenger(Integer type) { List<TOrderStatisticsPassengerVo> countVos = orderStatisticsService.passengerStatistics(type); return ResultUtil.success(countVos); public ResultUtil passenger(Integer type) { try { List<TOrderStatisticsPassengerVo> countVos = orderStatisticsService.passengerStatistics(type); return ResultUtil.success(countVos); } catch (ServiceException e) { log.error("可视化数据统计异常", e); return ResultUtil.error(e.getErrorMessage()); } } } ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderTaxiMapper.xml
@@ -1537,17 +1537,17 @@ AND t.insertTime < DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-%m-01'), INTERVAL 1 MONTH) </if> GROUP BY tc.carLicensePlate ORDER BY orderCount DESC ORDER BY totalCount DESC </select> <select id="passengerStatistics" resultType="com.stylefeng.guns.modular.system.response.TOrderStatisticsPassengerVo"> -- 8、今日乘客排名 SELECT t.passengersPhone as passengersPhone, COUNT(1) AS orderCount as totalCount, COUNT(1) as totalCount, SUM( CASE WHEN (source <> 'ride' AND state IN (8,9)) OR (source = 'ride' AND state = 5) THEN 1 ELSE 0 END CASE WHEN (source <> 'ride' AND state IN (8,9)) OR (source = 'ride' AND state = 5) THEN 1 ELSE 0 END ) AS finishCount FROM ( SELECT passengersPhone, insertTime, state, 'taxi' AS source @@ -1577,7 +1577,7 @@ AND t.insertTime < DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-%m-01'), INTERVAL 1 MONTH) </if> GROUP BY t.passengersPhone ORDER BY orderCount DESC ORDER BY totalCount DESC </select> </mapper> ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/response/TOrderStatisticsTotalOrderVo.java
@@ -75,6 +75,6 @@ // 计算百分比(保留两位小数) double cancelRate = (double) num / totalNum * 100; // 格式化输出,保留两位小数 return String.format("%.2f%%\n", cancelRate); return String.format("%.2f%%", cancelRate); } } ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TOrderStatisticsServiceImpl.java
@@ -9,7 +9,6 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -40,12 +39,8 @@ * 总体订单 */ public TOrderStatisticsTotalOrderVo totalOrderStatistics(String startDate, String endDate) { if(StringUtils.isNotEmpty(startDate)) { startDate = startDate+" 00:00:00"; } if(StringUtils.isNotEmpty(endDate)) { endDate = endDate+" 23:59:59"; } startDate = Optional.ofNullable(startDate).filter(StringUtils::isNotEmpty).map(s -> s +" 00:00:00").orElseThrow(() -> new ServiceException("总体订单统计,开始时间不能为空")); endDate = Optional.ofNullable(endDate).filter(StringUtils::isNotEmpty).map(e -> e +" 23:59:59").orElseThrow(() -> new ServiceException("总体订单统计,结束时间不能为空")); TOrderStatisticsTotalOrderVo totalOrderVo = orderTaxiMapper.totalOrderStatistics(startDate, endDate); return Optional.ofNullable(totalOrderVo).map(TOrderStatisticsTotalOrderVo::convert).orElse(new TOrderStatisticsTotalOrderVo()); } @@ -55,6 +50,7 @@ * @param type 1 日新增,2月新增 */ public List<TOrderStatisticsCountVo> newAddPassengerStatistics(Integer type) { Optional.ofNullable(type).orElseThrow(() -> new ServiceException("新增乘客统计,请求类型不能为空")); return orderTaxiMapper.newAddPassengerStatistics(type); } @@ -63,6 +59,7 @@ * @param type 1 日订单量,2月订单量 */ public List<TOrderStatisticsCountVo> orderCountStatistics(Integer type) { Optional.ofNullable(type).orElseThrow(() -> new ServiceException("订单量统计,请求类型不能为空")); return orderTaxiMapper.orderCountStatistics(type); } @@ -78,6 +75,7 @@ * @param type 1 今日,2本周,3本月 */ public List<TOrderStatisticsCarVo> driverCarStatistics(Integer type) { Optional.ofNullable(type).orElseThrow(() -> new ServiceException("司机接单排名统计,请求类型不能为空")); return orderTaxiMapper.driverCarStatistics(type); } @@ -86,6 +84,7 @@ * @param type 1 今日,2本周,3本月 */ public List<TOrderStatisticsPassengerVo> passengerStatistics(Integer type) { Optional.ofNullable(type).orElseThrow(() -> new ServiceException("乘客排名统计,请求类型不能为空")); return orderTaxiMapper.passengerStatistics(type); } } UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java
@@ -28,6 +28,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.InputStream; import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -1009,8 +1010,8 @@ if(null == userId){ return ResultUtil.tokenErr(); } travelCardService.travelCardExchange(userId, cardNo, cardPassword); return ResultUtil.success(); BigDecimal amount = travelCardService.travelCardExchange(userId, cardNo, cardPassword); return ResultUtil.success(amount); }catch (Exception e){ log.error("用户出行卡兑换-异常:", e); return ResultUtil.runErr(); UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/ITravelCardService.java
@@ -4,6 +4,7 @@ import com.stylefeng.guns.modular.system.model.TravelCard; import com.stylefeng.guns.modular.system.model.vo.BalanceRecordVo; import java.math.BigDecimal; import java.util.List; /** @@ -21,7 +22,7 @@ * @param cardNo 卡号 * @param cardPassword 卡密码 */ void travelCardExchange(Integer userId, String cardNo, String cardPassword); BigDecimal travelCardExchange(Integer userId, String cardNo, String cardPassword); /** * 查询用户余额变更记录 UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TravelCardServiceImpl.java
@@ -43,7 +43,7 @@ * @param cardPassword 卡密码 */ @Transactional public void travelCardExchange(Integer userId, String cardNo, String cardPassword) { public BigDecimal travelCardExchange(Integer userId, String cardNo, String cardPassword) { Optional.ofNullable(cardNo).filter(StringUtils::isNotEmpty).orElseThrow(() -> new ServiceException("出行卡兑换-卡号不能为空")); Optional.ofNullable(cardPassword).filter(StringUtils::isNotEmpty).orElseThrow(() -> new ServiceException("出行卡兑换-卡密码不能为空")); UserInfo userInfo = Optional.ofNullable(userInfoService.selectById(userId)).orElseThrow(() -> new ServiceException("出行卡兑换当前用户不存在")); @@ -64,6 +64,7 @@ // 新增余额变更记录(出行卡兑换类型) this.baseMapper.insertBalanceModifyRecord(BalanceModifyRecordVo.convert(userInfo.getId(), userInfo.getNickName(), userInfo.getPhone(), travelCard.getAmount())); } return travelCard.getAmount(); } /**