From adf76f841a890299a4c68826b3b1716f69351dd1 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期三, 09 八月 2023 19:32:16 +0800
Subject: [PATCH] 修改bug和日志时间
---
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TOrderServiceImpl.java | 355 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 352 insertions(+), 3 deletions(-)
diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TOrderServiceImpl.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TOrderServiceImpl.java
index 75171ba..7f36fa0 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TOrderServiceImpl.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TOrderServiceImpl.java
@@ -1,10 +1,35 @@
package com.stylefeng.guns.modular.system.service.impl;
-import com.stylefeng.guns.modular.system.model.TOrder;
-import com.stylefeng.guns.modular.system.dao.TOrderMapper;
-import com.stylefeng.guns.modular.system.service.ITOrderService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.stylefeng.guns.core.shiro.ShiroKit;
+import com.stylefeng.guns.modular.system.controller.resp.DataStatisticsOrderYearResp;
+import com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp;
+import com.stylefeng.guns.modular.system.controller.resp.TOrderResp;
+import com.stylefeng.guns.modular.system.controller.resp.TOrderServerResp;
+import com.stylefeng.guns.modular.system.dao.TAppUserMapper;
+import com.stylefeng.guns.modular.system.dao.TBranchOfficeMapper;
+import com.stylefeng.guns.modular.system.dao.TDriverMapper;
+import com.stylefeng.guns.modular.system.dao.TOrderMapper;
+import com.stylefeng.guns.modular.system.enums.OrderStateEnum;
+import com.stylefeng.guns.modular.system.model.TAppUser;
+import com.stylefeng.guns.modular.system.model.TBranchOffice;
+import com.stylefeng.guns.modular.system.model.TDriver;
+import com.stylefeng.guns.modular.system.model.TOrder;
+import com.stylefeng.guns.modular.system.service.ITOrderService;
+import com.stylefeng.guns.modular.system.util.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.ui.Model;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.util.*;
/**
* <p>
@@ -17,4 +42,328 @@
@Service
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements ITOrderService {
+ @Resource
+ private TOrderMapper tOrderMapper;
+
+ @Resource
+ private TAppUserMapper tAppUserMapper;
+
+ @Resource
+ private TDriverMapper tDriverMapper;
+
+ @Resource
+ private TBranchOfficeMapper tBranchOfficeMapper;
+
+ @Override
+ public List<TOrderResp> getOrderList(String createTime, String code, Integer source, String userName, String userPhone, Integer state, String driverName,Integer isException) {
+ String startTime = null;
+ String endTime = null;
+ // 开始,结束时间
+ if(StringUtils.hasLength(createTime)){
+ String[] split = createTime.split(" - ");
+ startTime = split[0] + " 00:00:00";
+ endTime = split[1] + " 23:59:59";
+ }
+ Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType();
+ Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId();
+ return tOrderMapper.getOrderList(startTime,endTime,code,source,userName,userPhone,state,driverName,isException,roleType,objectId);
+ }
+
+ @Override
+ public void orderDetail(Integer orderId, Model model) {
+ // 订单信息
+ TOrder tOrder = tOrderMapper.selectById(orderId);
+ model.addAttribute("id", orderId);
+ model.addAttribute("createTime",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(tOrder.getCreateTime()));//下单时间
+ model.addAttribute("code",tOrder.getCode());//订单编号
+ model.addAttribute("source",tOrder.getSource());//订单来源
+ model.addAttribute("startAddress",tOrder.getStartAddress());//起点
+ model.addAttribute("startLng",tOrder.getStartLng());// 起点经度
+ model.addAttribute("startLat",tOrder.getStartLat());// 起点纬度
+ model.addAttribute("endAddress",tOrder.getEndAddress());//终点
+ model.addAttribute("endLng",tOrder.getEndLng());// 终点经度
+ model.addAttribute("endLat",tOrder.getEndLat());// 终点纬度
+
+ if(Objects.nonNull(tOrder.getStartTime())){
+ model.addAttribute("startTime",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(tOrder.getStartTime()));//乘车时间
+ }else {
+ model.addAttribute("startTime","");//乘车时间
+ }
+ if(Objects.nonNull(tOrder.getBoardingTime())){
+ model.addAttribute("boardingTime",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(tOrder.getBoardingTime()));//乘车时间
+ }else {
+ model.addAttribute("boardingTime","");//乘车时间
+ }
+ if(Objects.nonNull(tOrder.getGetoffTime())){
+ model.addAttribute("getoffTime",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(tOrder.getGetoffTime()));//乘车时间
+ }else {
+ model.addAttribute("getoffTime","");//乘车时间
+ }
+ model.addAttribute("startPrice",tOrder.getStartPrice());//起步价
+ model.addAttribute("overDrivePrice",tOrder.getOverDrivePrice());//里程费
+ model.addAttribute("waitTimePrice",tOrder.getWaitTimePrice().add(tOrder.getOutWaitTimePrice()));//等待费
+ model.addAttribute("badWeatherPrice",tOrder.getBadWeatherPrice());//恶劣天气费用
+ model.addAttribute("orderMoney",tOrder.getOrderMoney());//实际费用
+ model.addAttribute("payMoney",tOrder.getPayMoney());//实际支付费用
+ model.addAttribute("discountedPrice",tOrder.getDiscountedPrice());//优惠券抵扣费用
+ model.addAttribute("payType",tOrder.getPayType());//支付方式
+ model.addAttribute("discountAmount",tOrder.getDiscountAmount());//折扣金额
+ model.addAttribute("userId",tOrder.getUserId());//用户id
+ model.addAttribute("routeRecord",tOrder.getRouteRecord());//行程录音
+ model.addAttribute("userPhone",tOrder.getUserPhone());//用户手机号
+ model.addAttribute("userName",tOrder.getUserName());//用户名称
+
+ // 查询用户
+ TAppUser tAppUser = tAppUserMapper.selectById(tOrder.getUserId());
+ if(Objects.nonNull(tAppUser)){
+ model.addAttribute("havDiscount",tAppUser.getHavDiscount());
+ if(1 == tAppUser.getHavDiscount()){
+ BigDecimal subtract = tOrder.getOrderMoney().subtract(tOrder.getDiscountedPrice());
+ // 计算95折优惠金额
+ BigDecimal multiply = subtract.multiply(new BigDecimal("0.05"), new MathContext(2, RoundingMode.HALF_EVEN));
+ model.addAttribute("multiply",multiply);
+ }else {
+ model.addAttribute("multiply",0);
+ }
+ }else {
+ model.addAttribute("havDiscount",0);
+ model.addAttribute("multiply",0);
+ }
+
+ // 查询司机
+ TDriver tDriver = tDriverMapper.selectById(tOrder.getDriverId());
+ if(Objects.nonNull(tDriver)){
+ model.addAttribute("driverName",tDriver.getName());
+ model.addAttribute("driverPhone",tDriver.getPhone());
+ // 查询司机所属分公司
+ TBranchOffice tBranchOffice = tBranchOfficeMapper.selectById(tDriver.getBranchOfficeId());
+ if(Objects.nonNull(tBranchOffice)){
+ model.addAttribute("branchOfficeName",tBranchOffice.getPrincipal());
+ }else {
+ model.addAttribute("branchOfficeName","");
+ }
+ }else {
+ model.addAttribute("branchOfficeName","");
+ model.addAttribute("driverName","");
+ model.addAttribute("driverPhone","");
+ }
+
+ }
+
+ @Override
+ public void orderExceptionDetail(Integer orderId, Model model) {
+ this.orderDetail(orderId,model);
+ model.addAttribute("orderId",orderId);
+ }
+
+ @Override
+ public void getDataStatisticsByYear(Integer agentId,String yearDate, Model model,Map<String, Object> map) {
+
+ List<DataStatisticsOrderYearResp> data = tOrderMapper.getDataStatisticsByYear(agentId,yearDate);
+ List<DataStatisticsOrderYearResp> resps =new ArrayList<>();
+ for (int i = 1; i < 13; i++) {
+ DataStatisticsOrderYearResp dataStatisticsOrderYearResp = new DataStatisticsOrderYearResp();
+ if(i < 10){
+ dataStatisticsOrderYearResp.setMonth("0" + i);
+ }else {
+ dataStatisticsOrderYearResp.setMonth(String.valueOf(i));
+ }
+ dataStatisticsOrderYearResp.setOrderCount(0);
+ resps.add(dataStatisticsOrderYearResp);
+ }
+ if(!CollectionUtils.isEmpty(data)){
+ for (DataStatisticsOrderYearResp datum : data) {
+ for (DataStatisticsOrderYearResp resp : resps) {
+ if(resp.getMonth().equals(datum.getMonth())){
+ resp.setOrderCount(datum.getOrderCount());
+ break;
+ }
+ }
+ }
+ }
+ model.addAttribute("yearResp",resps);
+ map.put("yearResp",resps);
+ }
+
+ @Override
+ public void getDataStatisticsOrderCount(Integer agentId, String monthDate, Model model,Map<String, Object> map) {
+ List<PerformanceTableResp> list = tOrderMapper.getDataStatisticsOrderCount(agentId,monthDate);
+ model.addAttribute("performanceResp",list);
+ map.put("performanceResp",list);
+ }
+
+ @Override
+ public void getDataStatisticsCount(Integer agentId, Model model) {
+ Integer pendingOrderCount = tOrderMapper.getDataStatisticsCount(agentId, OrderStateEnum.PENDING_ORDER.getCode(), LocalDate.now());
+ Integer finishCount = tOrderMapper.getDataStatisticsCount(agentId, OrderStateEnum.FINISH.getCode(),LocalDate.now());
+ Integer cancelCount = tOrderMapper.getDataStatisticsCount(agentId, OrderStateEnum.CANCELED.getCode(),LocalDate.now());
+
+ Integer serverCount = tOrderMapper.getDataStatisticsServerCount(agentId, LocalDate.now());
+
+ model.addAttribute("pendingOrderCount",pendingOrderCount);
+ model.addAttribute("finishCount",finishCount);
+ model.addAttribute("cancelCount",cancelCount);
+ model.addAttribute("serverCount",serverCount);
+ }
+
+ @Override
+ public List<TOrderServerResp> getDataStatisticsServerList(Integer agentId) {
+ return tOrderMapper.getDataStatisticsServerList(agentId,LocalDate.now());
+ }
+
+ @Override
+ public List<TOrder> getDataStatisticsAllList(Integer agentId,Integer type) {
+ return tOrderMapper.getDataStatisticsAllList(agentId,type,LocalDate.now());
+ }
+
+ @Override
+ public void getDataStatisticsCountByIds(List<Integer> ids, Model model) {
+ Integer pendingOrderCount = tOrderMapper.getDataStatisticsCountByIds(ids, 1, LocalDate.now());
+ Integer finishCount = tOrderMapper.getDataStatisticsCountByIds(ids, 2,LocalDate.now());
+ Integer cancelCount = tOrderMapper.getDataStatisticsCountByIds(ids, 3,LocalDate.now());
+ Integer serverCount = tOrderMapper.getDataStatisticsServerCountByIds(ids, LocalDate.now());
+
+ model.addAttribute("pendingOrderCount",pendingOrderCount);
+ model.addAttribute("finishCount",finishCount);
+ model.addAttribute("cancelCount",cancelCount);
+ model.addAttribute("serverCount",serverCount);
+ }
+
+ @Override
+ public List<TOrderServerResp> getDataStatisticsServerListByIds(List<Integer> ids) {
+ return tOrderMapper.getDataStatisticsServerListByIds(ids,LocalDate.now());
+ }
+
+ @Override
+ public List<TOrder> getDataStatisticsAllListByIds(List<Integer> ids,Integer type) {
+ return tOrderMapper.getDataStatisticsAllListByIds(ids,type,LocalDate.now());
+ }
+
+ @Override
+ public void getDataStatisticsCountGetMap(Integer agentId, HashMap<String, Object> map) {
+ Integer pendingOrderCount = tOrderMapper.getDataStatisticsCount(agentId, OrderStateEnum.PENDING_ORDER.getCode(), LocalDate.now());
+ Integer finishCount = tOrderMapper.getDataStatisticsCount(agentId, OrderStateEnum.FINISH.getCode(),LocalDate.now());
+ Integer cancelCount = tOrderMapper.getDataStatisticsCount(agentId, OrderStateEnum.CANCELED.getCode(),LocalDate.now());
+
+ Integer serverCount = tOrderMapper.getDataStatisticsServerCount(agentId, LocalDate.now());
+
+ map.put("pendingOrderCount",pendingOrderCount);
+ map.put("finishCount",finishCount);
+ map.put("cancelCount",cancelCount);
+ map.put("serverCount",serverCount);
+ }
+
+ @Override
+ public void getDataStatisticsCountByIdsGetMap(List<Integer> ids, HashMap<String, Object> map) {
+ Integer pendingOrderCount = tOrderMapper.getDataStatisticsCountByIds(ids, 1, LocalDate.now());
+ Integer finishCount = tOrderMapper.getDataStatisticsCountByIds(ids, 2,LocalDate.now());
+ Integer cancelCount = tOrderMapper.getDataStatisticsCountByIds(ids, 3,LocalDate.now());
+ Integer serverCount = tOrderMapper.getDataStatisticsServerCountByIds(ids, LocalDate.now());
+
+ map.put("pendingOrderCount",pendingOrderCount);
+ map.put("finishCount",finishCount);
+ map.put("cancelCount",cancelCount);
+ map.put("serverCount",serverCount);
+ }
+
+ @Override
+ public void getDataStatisticsByYearByIds(List<Integer> ids, String yearDate, Model model, Map<String, Object> map) {
+
+ List<DataStatisticsOrderYearResp> data = tOrderMapper.getDataStatisticsByYearByIds(ids,yearDate);
+ List<DataStatisticsOrderYearResp> resps =new ArrayList<>();
+ for (int i = 1; i < 13; i++) {
+ DataStatisticsOrderYearResp dataStatisticsOrderYearResp = new DataStatisticsOrderYearResp();
+ if(i < 10){
+ dataStatisticsOrderYearResp.setMonth("0" + i);
+ }else {
+ dataStatisticsOrderYearResp.setMonth(String.valueOf(i));
+ }
+ dataStatisticsOrderYearResp.setOrderCount(0);
+ resps.add(dataStatisticsOrderYearResp);
+ }
+ if(!CollectionUtils.isEmpty(data)){
+ for (DataStatisticsOrderYearResp datum : data) {
+ for (DataStatisticsOrderYearResp resp : resps) {
+ if(resp.getMonth().equals(datum.getMonth())){
+ resp.setOrderCount(datum.getOrderCount());
+ break;
+ }
+ }
+ }
+ }
+ model.addAttribute("yearResp",resps);
+ map.put("yearResp",resps);
+ }
+
+ @Override
+ public void getDataStatisticsOrderCountByIds(List<Integer> ids, String monthDate, Model model, Map<String, Object> map) {
+ List<PerformanceTableResp> list = tOrderMapper.getDataStatisticsOrderCountByIds(ids,monthDate);
+ model.addAttribute("performanceResp",list);
+ map.put("performanceResp",list);
+ }
+
+ @Override
+ public void getStatisticsOrderByMonth(Integer agentId, String dayDate, Model model, Map<String, Object> map) {
+ List<DataStatisticsOrderYearResp> data = tOrderMapper.getStatisticsOrderByMonth(agentId,dayDate);
+ List<DataStatisticsOrderYearResp> resps =new ArrayList<>();
+ int month = DateUtil.getDaysOfMonth(new Date());
+ for (int i = 1; i <= month; i++) {
+ DataStatisticsOrderYearResp dataStatisticsOrderYearResp = new DataStatisticsOrderYearResp();
+ if(i < 10){
+ dataStatisticsOrderYearResp.setMonth("0" + i);
+ }else {
+ dataStatisticsOrderYearResp.setMonth(String.valueOf(i));
+ }
+ dataStatisticsOrderYearResp.setOrderCount(0);
+ resps.add(dataStatisticsOrderYearResp);
+ }
+ if(!CollectionUtils.isEmpty(data)){
+ for (DataStatisticsOrderYearResp datum : data) {
+ for (DataStatisticsOrderYearResp resp : resps) {
+ if(resp.getMonth().equals(datum.getMonth())){
+ resp.setOrderCount(datum.getOrderCount());
+ break;
+ }
+ }
+ }
+ }
+ model.addAttribute("monthResp",resps);
+ map.put("monthResp",resps);
+ }
+
+ @Override
+ public void getStatisticsOrderByMonthIds(List<Integer> ids, String dayDate, Model model, Map<String, Object> map) {
+ List<DataStatisticsOrderYearResp> data = tOrderMapper.getStatisticsOrderByMonthIds(ids,dayDate);
+ List<DataStatisticsOrderYearResp> resps =new ArrayList<>();
+ int month = DateUtil.getDaysOfMonth(new Date());
+ for (int i = 1; i <= month; i++) {
+ DataStatisticsOrderYearResp dataStatisticsOrderYearResp = new DataStatisticsOrderYearResp();
+ if(i < 10){
+ dataStatisticsOrderYearResp.setMonth("0" + i);
+ }else {
+ dataStatisticsOrderYearResp.setMonth(String.valueOf(i));
+ }
+ dataStatisticsOrderYearResp.setOrderCount(0);
+ resps.add(dataStatisticsOrderYearResp);
+ }
+ if(!CollectionUtils.isEmpty(data)){
+ for (DataStatisticsOrderYearResp datum : data) {
+ for (DataStatisticsOrderYearResp resp : resps) {
+ if(resp.getMonth().equals(datum.getMonth())){
+ resp.setOrderCount(datum.getOrderCount());
+ break;
+ }
+ }
+ }
+ }
+ model.addAttribute("monthResp",resps);
+ map.put("monthResp",resps);
+ }
+
+
+ @Override
+ public Integer getValidOrderCount(Integer driverId, BigDecimal orderMoney, String month) {
+ // 查询司机当月有效订单数量
+ return tOrderMapper.getValidOrderCount(driverId,orderMoney,month);
+ }
}
--
Gitblit v1.7.1