From 3da837e92584933269147e8a85608f8c1880aa37 Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Wed, 21 Aug 2024 17:22:14 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E8=AE=B0=E5=BD=95=E5=BF=83=E8=B7=B3?= =?UTF-8?q?=E6=97=A5=E5=BF=97=202.=20=E7=89=88=E6=9C=AC=E6=89=B9=E6=AC=A1?= =?UTF-8?q?=E6=94=B9=E9=80=A0=203.=20=E5=AE=9A=E6=97=B6=E6=B8=85=E7=90=86o?= =?UTF-8?q?nenet=E5=BF=83=E8=B7=B3=E6=97=A5=E5=BF=97=204.=20=E8=BF=90?= =?UTF-8?q?=E8=90=A5=E6=95=B0=E6=8D=AE=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/app/AppVerifyController.java | 28 ++- .../iot/receive/ReceiveController.java | 55 ++++-- .../controller/system/AsDeviceController.java | 19 ++ .../com/ruoyi/common/utils/DateUtils.java | 21 ++- .../system/domain/EtHardwareVersion.java | 40 ++++ .../ruoyi/system/domain/EtLocationLog.java | 53 ++++++ .../system/domain/vo/OperatingDataVo2.java | 89 +++++++++ .../PrepayWithRequestPaymentResponseVo.java | 2 + .../ruoyi/system/mapper/AsDeviceMapper.java | 10 + .../system/mapper/EtCapitalFlowMapper.java | 28 +++ .../mapper/EtHardwareVersionMapper.java | 23 ++- .../system/mapper/EtLocationLogMapper.java | 79 ++++++++ .../ruoyi/system/mapper/EtOrderMapper.java | 10 + .../ruoyi/system/service/CallbackService.java | 12 ++ .../system/service/IAsDeviceService.java | 5 + .../system/service/IEtLocationLogService.java | 61 +++++++ .../ruoyi/system/service/IEtOrderService.java | 2 +- .../ruoyi/system/service/IWxPayService.java | 7 + .../service/impl/AsDeviceServiceImpl.java | 37 +++- .../service/impl/CallbackServiceImpl.java | 172 +++++++++++++++++- .../impl/EtHardwareVersionServiceImpl.java | 62 ++++++- .../impl/EtLocationLogServiceImpl.java | 95 ++++++++++ .../service/impl/EtOrderServiceImpl.java | 80 ++++---- .../system/service/impl/WxPayService.java | 87 ++++++--- .../java/com/ruoyi/system/task/EtTask.java | 21 ++- .../mapper/system/AsDeviceMapper.xml | 8 + .../mapper/system/EtCapitalFlowMapper.xml | 32 +++- .../mapper/system/EtHardwareVersionMapper.xml | 22 ++- .../mapper/system/EtLocationLogMapper.xml | 108 +++++++++++ .../resources/mapper/system/EtOrderMapper.xml | 31 ++++ 30 files changed, 1168 insertions(+), 131 deletions(-) create mode 100644 electripper-system/src/main/java/com/ruoyi/system/domain/EtLocationLog.java create mode 100644 electripper-system/src/main/java/com/ruoyi/system/domain/vo/OperatingDataVo2.java create mode 100644 electripper-system/src/main/java/com/ruoyi/system/mapper/EtLocationLogMapper.java create mode 100644 electripper-system/src/main/java/com/ruoyi/system/service/IEtLocationLogService.java create mode 100644 electripper-system/src/main/java/com/ruoyi/system/service/impl/EtLocationLogServiceImpl.java create mode 100644 electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java index 13bad29..e77e4ac 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java @@ -696,15 +696,26 @@ public class AppVerifyController extends BaseController List etParkingAreas = etParkingAreaService.allParkingArea(); return success(etParkingAreas); } +// +// /** +// * 运营数据 +// */ +// @GetMapping(value = "/operatingData") +// public AjaxResult operatingData(String timeStart,String timeEnd,String areaId) +// { +// logger.info("【运营数据】请求参数:timeStart={},timeEnd={},areaId={}", timeStart,timeEnd,areaId); +// OperatingDataVo operatingDataVo = etOrderService.getOperatingData(timeStart,timeEnd,areaId); +// return success(operatingDataVo); +// } /** * 运营数据 */ - @GetMapping(value = "/operatingData") - public AjaxResult operatingData(String timeStart,String timeEnd,String areaId) + @GetMapping(value = "/operatingData2") + public AjaxResult operatingData2(String timeStart,String timeEnd,String areaId) { logger.info("【运营数据】请求参数:timeStart={},timeEnd={},areaId={}", timeStart,timeEnd,areaId); - OperatingDataVo operatingDataVo = etOrderService.getOperatingData(timeStart,timeEnd,areaId); + OperatingDataVo2 operatingDataVo = etOrderService.getOperatingData(timeStart,timeEnd,areaId); return success(operatingDataVo); } @@ -1256,4 +1267,15 @@ public class AppVerifyController extends BaseController return error("用户"+asUser.getUserName()+"未绑定系统用户"); } + /** + * 根据订单号查询订单支付结果 + */ + @GetMapping("/queryResultByOrderNo") + public AjaxResult queryResultByOrderNo(String orderNo) + { + logger.info("根据订单号查询订单支付结果:【orderNo="+orderNo+"】"); + Boolean aBoolean = wxPayService.queryResultByOrderNo(orderNo); + return AjaxResult.success(aBoolean); + } + } diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java index 4a7ef31..e3369aa 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java @@ -16,6 +16,7 @@ import com.ruoyi.common.utils.map.GpsCoordinateUtils; import com.ruoyi.common.utils.onenet.Token; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.domain.*; +import com.ruoyi.system.mapper.EtLocationLogMapper; import com.ruoyi.system.service.*; import com.ruoyi.web.controller.iot.domain.BodyObj; import com.ruoyi.web.controller.iot.domain.LogEntry; @@ -36,6 +37,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.util.Date; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -82,6 +84,9 @@ public class ReceiveController { @Autowired private IEtOnlineLogService etOnlineLogService; + @Resource + private EtLocationLogMapper etLocationLogMapper; + private final Object lock = new Object(); // 用于记录上次发送命令的时间 @@ -171,6 +176,7 @@ public class ReceiveController { BigDecimal lat = new BigDecimal(doubles[0]).setScale(8, RoundingMode.HALF_UP); BigDecimal lon = new BigDecimal(doubles[1]).setScale(8, RoundingMode.HALF_UP); log.info("转换后的GCJ02经纬度:" + lon + "---" + lat); + asynchronousSaveLog(msg,logEntry.getAt(),devName, lon,lat,device); if(BigDecimal.ZERO.compareTo(lon) != 0 && BigDecimal.ZERO.compareTo(lat) != 0){ // 计算电量和里程后更新设备 int i = updateDevice(value, device, lon, lat); @@ -208,21 +214,42 @@ public class ReceiveController { } } + /** + * 异步保存定位 + */ + private void asynchronousSaveLog(String msg, long at,String mac,BigDecimal lon,BigDecimal lat,AsDevice device) { + //异步保存定位 + scheduledExecutorService.schedule(() -> { + EtLocationLog etLocationLog = new EtLocationLog(); + etLocationLog.setOnenetMsg(msg); + etLocationLog.setCreateTime(DateUtils.getNowDate()); + etLocationLog.setLongitude(lon.toString()); + etLocationLog.setLatitude(lat.toString()); + etLocationLog.setMac(mac); + etLocationLog.setAt(new Date(at)); + etLocationLog.setStatus(device.getStatus()); + etLocationLog.setLockStatus(device.getLockStatus()); + etLocationLogMapper.insertEtLocationLog(etLocationLog); + }, 0, TimeUnit.SECONDS); + } + /** 无定位更新设备 */ private void noLocationUpdateDevice(LogEntry logEntry, LogEntry.LocationValue value, AsDevice device) { Integer bat = value.getBat(); BigDecimal divide = new BigDecimal(bat).divide(new BigDecimal(10)); log.info("保存电压:" + divide); device.setVoltage(divide.toString());//电压 - // 根据电压计算续航里程 EtModel model = etModelService.selectEtModelByModelId(device.getModelId()); - Integer remainingMileage = 0; - if(StrUtil.isNotBlank(device.getVoltage())){ - remainingMileage = CommonUtil.getRemainingMileage(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance()); + // 根据电压计算续航里程 + if(ObjectUtil.isNotNull(model)){ + Integer remainingMileage = 0; + if(StrUtil.isNotBlank(device.getVoltage())){ + remainingMileage = CommonUtil.getRemainingMileage(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance()); + } + Integer electricQuantity = CommonUtil.getElectricQuantity(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百 + device.setRemainingMileage(remainingMileage); + device.setRemainingPower(electricQuantity.toString()); } - Integer electricQuantity = CommonUtil.getElectricQuantity(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百 - device.setRemainingMileage(remainingMileage); - device.setRemainingPower(electricQuantity.toString()); device.setLastTime(DateUtils.getNowDate()); device.setGps("0"); device.setSignalStrength(value.getCsq()); @@ -244,13 +271,15 @@ public class ReceiveController { device.setVoltage(divide.toString());//电压 // 根据电压计算续航里程 EtModel model = etModelService.selectEtModelByModelId(device.getModelId()); - Integer remainingMileage = 0; - if(StrUtil.isNotBlank(device.getVoltage())){ - remainingMileage = CommonUtil.getRemainingMileage(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance()); + if(ObjectUtil.isNotNull(model)){ + Integer remainingMileage = 0; + if(StrUtil.isNotBlank(device.getVoltage())){ + remainingMileage = CommonUtil.getRemainingMileage(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance()); + } + Integer electricQuantity = CommonUtil.getElectricQuantity(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百 + device.setRemainingMileage(remainingMileage); + device.setRemainingPower(electricQuantity.toString()); } - Integer electricQuantity = CommonUtil.getElectricQuantity(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百 - device.setRemainingMileage(remainingMileage); - device.setRemainingPower(electricQuantity.toString()); device.setLastTime(DateUtils.getNowDate()); device.setLastLocationTime(DateUtils.getNowDate()); device.setGps("1"); diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/AsDeviceController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/AsDeviceController.java index 53ac9ef..4cdaa7b 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/AsDeviceController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/AsDeviceController.java @@ -5,8 +5,10 @@ import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.AsUser; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.AsDevice; import com.ruoyi.system.service.IAsDeviceService; @@ -277,5 +279,22 @@ public class AsDeviceController extends BaseController return success(aBoolean); } + /** + * 根据时间查询车辆轨迹 + */ + @PostMapping("/trajectory") + public AjaxResult trajectory(String sn,String startTime,String endTime) + { + AjaxResult ajax = AjaxResult.success(); + if(StrUtil.isBlank(sn)){ + logger.info("没有sn号参数:【sn={}】",sn); + return error("请传sn号参数"+"【sn="+sn+"】"); + } + logger.info("【根据时间查询车辆轨迹】:{}",sn,startTime,endTime); + String trajectory = asDeviceService.trajectory(sn,startTime,endTime); + ajax.put(AjaxResult.DATA_TAG,trajectory); + return ajax; + } + } diff --git a/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java b/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java index 1cd5337..ad2c212 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java +++ b/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java @@ -1,19 +1,13 @@ package com.ruoyi.common.utils; +import org.apache.commons.lang3.time.DateFormatUtils; + import java.lang.management.ManagementFactory; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; +import java.time.*; import java.util.Calendar; import java.util.Date; -import java.util.concurrent.TimeUnit; - -import org.apache.commons.lang3.time.DateFormatUtils; /** * 时间工具类 @@ -318,4 +312,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils Date currentTime = new Date(); return currentTime.after(cooperationTime); } + + /** + * 解析带有时区偏移量的日期时间字符串 + */ + public static Date parseTime(String timeStr) { + OffsetDateTime offsetDateTime = OffsetDateTime.parse(timeStr); + ZonedDateTime zonedDateTime = offsetDateTime.toZonedDateTime(); + return Date.from(zonedDateTime.toInstant()); + } } diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/EtHardwareVersion.java b/electripper-system/src/main/java/com/ruoyi/system/domain/EtHardwareVersion.java index 9f638e6..d855b24 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/EtHardwareVersion.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/EtHardwareVersion.java @@ -3,9 +3,12 @@ package com.ruoyi.system.domain; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.domain.entity.AsArticleClassify; import lombok.Data; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * 硬件版本对象 et_hardware_version @@ -24,6 +27,12 @@ public class EtHardwareVersion extends BaseEntity{ @Excel(name = "版本号") private String version; + /** 父分类ID */ + private Long parentId; + + /** 祖级列表 */ + private String ancestors; + /** 生产时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "生产时间", width = 30, dateFormat = "yyyy-MM-dd") @@ -33,7 +42,38 @@ public class EtHardwareVersion extends BaseEntity{ @Excel(name = "数量") private Integer quantity; + /** 未录入 */ + @Excel(name = "未录入") + private Integer notEnteredNum; + + /** 已录入 */ + @Excel(name = "已录入") + private Integer entered; + + /** 已绑定 */ + @Excel(name = "已绑定") + private Integer bound; + + /** 未绑定 */ + @Excel(name = "未绑定") + private Integer unBound; + + /** 丢损 */ + @Excel(name = "丢损") + private Integer lost; + /** 版本说明 */ @Excel(name = "版本说明") private String instructions; + + /** 数量统计 备注 */ + @Excel(name = "备注") + private String remark; + + /** 子版本 */ + private List children = new ArrayList(); + +// /** 总已录入 */ +// @Excel(name = "总已录入") +// private Integer totalEntered; } diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/EtLocationLog.java b/electripper-system/src/main/java/com/ruoyi/system/domain/EtLocationLog.java new file mode 100644 index 0000000..23cb486 --- /dev/null +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/EtLocationLog.java @@ -0,0 +1,53 @@ +package com.ruoyi.system.domain; + +import com.ruoyi.common.constant.ServiceConstants; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.Date; + +/** + * 定位日志对象 et_location_log + * + * @author ruoyi + * @date 2024-08-20 + */ +@Data +public class EtLocationLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 定位id */ + private Long locationId; + + /** mac */ + @Excel(name = "mac") + private String mac; + + /** onenet接收到的消息 */ + @Excel(name = "onenet接收到的消息") + private String onenetMsg; + + /** 经度 */ + @Excel(name = "经度") + private String longitude; + + /** 纬度 */ + @Excel(name = "纬度") + private String latitude; + + @Excel(name = "onenet消息时间") + private Date at; + + /** 车辆状态 */ + @Excel(name = "车辆状态") + private String status; + + /** 锁状态 */ + @Excel(name = "锁状态") + private String lockStatus; + +} diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/OperatingDataVo2.java b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/OperatingDataVo2.java new file mode 100644 index 0000000..8109be3 --- /dev/null +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/OperatingDataVo2.java @@ -0,0 +1,89 @@ +package com.ruoyi.system.domain.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 运营数据 + * + * @author 邱贞招 + * @date 2024-05-09 + */ +@Data +public class OperatingDataVo2 { + + private Income income; + + private OrderVo order; + + /** + * 收入相关 + */ + @Data + public static class Income { + + //营业收入 + private BigDecimal operatingIncome; + + //营业收入 + private BigDecimal operatingIncome2; + + //押金余额 + private BigDecimal depositBalance; + + //账户盈余 + private BigDecimal accountSurplus; + + //总流水 = 订单金额 + 押金支付 + private BigDecimal totalFlowAmount; + + //订单支付 包含押金抵扣 + private BigDecimal orderPaid; + + //押金充值 + private BigDecimal depositPaid; + + //押金抵扣金额 + private BigDecimal deductionAmount; + + + + //总支出 + private BigDecimal totalExpenditure; + + //订单退款 + private BigDecimal orderRefund; + + //押金退款 + private BigDecimal depositRefund; + + //手续费 + private BigDecimal handlingFee; + + //平台服务费 + private BigDecimal platformServiceFee; + + + } + + /** + * 订单相关 + */ + @Data + public static class OrderVo { + //骑行中订单 + private String ridingOrder; + + //已支付订单 + private String paidOrder; + + //已退款订单 + private String refundOrder; + + //待支付订单 + private String unpaidOrder; + + } + +} diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/PrepayWithRequestPaymentResponseVo.java b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/PrepayWithRequestPaymentResponseVo.java index f9b76d2..f6839b0 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/PrepayWithRequestPaymentResponseVo.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/PrepayWithRequestPaymentResponseVo.java @@ -20,4 +20,6 @@ public class PrepayWithRequestPaymentResponseVo extends PrepayWithRequestPayment private String paySign; private String sessionId; + + private String orderNo; } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/AsDeviceMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/AsDeviceMapper.java index c70ac27..9f7b983 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/AsDeviceMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/AsDeviceMapper.java @@ -144,4 +144,14 @@ public interface AsDeviceMapper extends BaseMapper AsDevice checkSNUnique(String sn); AsDevice checkMACUnique(String mac); + + /** + * 已绑定版本数 + */ + int countBoundNum(Long id); + + /** + * 未绑定版本数 + */ + int countUnBoundNum(Long id); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtCapitalFlowMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtCapitalFlowMapper.java index a4d3db7..252d2c9 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtCapitalFlowMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtCapitalFlowMapper.java @@ -73,7 +73,35 @@ public interface EtCapitalFlowMapper */ BigDecimal getWithdrawnFee(@Param("areaId") Long areaId, @Param("status") String status); + /** + * 手续费 + * + * @param areaId 运营区id + * @return + */ BigDecimal getHandlingFee(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("sn") String sn, @Param("areaId") Long areaId); + /** + * 平台服务费 + * + * @param areaId 运营区id + * @return + */ BigDecimal getServiceFee(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("sn") String sn, @Param("areaId") Long areaId); + + /** + * 骑行订单收入 + * + * @param areaId 运营区id + * @return + */ + BigDecimal getTotalAmount(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("sn") String sn, @Param("areaId") Long areaId); + + /** + * 押金抵扣收入 + * + * @param areaId 运营区id + * @return + */ + BigDecimal getDeductionAmount(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("sn") String sn, @Param("areaId") Long areaId); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtHardwareVersionMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtHardwareVersionMapper.java index b296006..6b5d83c 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtHardwareVersionMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtHardwareVersionMapper.java @@ -5,15 +5,15 @@ import com.ruoyi.system.domain.EtHardwareVersion; /** * 硬件版本Mapper接口 - * + * * @author qiuzhenzhao * @date 2024-07-22 */ -public interface EtHardwareVersionMapper +public interface EtHardwareVersionMapper { /** * 查询硬件版本 - * + * * @param id 硬件版本主键 * @return 硬件版本 */ @@ -21,7 +21,7 @@ public interface EtHardwareVersionMapper /** * 查询硬件版本列表 - * + * * @param etHardwareVersion 硬件版本 * @return 硬件版本集合 */ @@ -29,7 +29,7 @@ public interface EtHardwareVersionMapper /** * 新增硬件版本 - * + * * @param etHardwareVersion 硬件版本 * @return 结果 */ @@ -37,7 +37,7 @@ public interface EtHardwareVersionMapper /** * 修改硬件版本 - * + * * @param etHardwareVersion 硬件版本 * @return 结果 */ @@ -45,7 +45,7 @@ public interface EtHardwareVersionMapper /** * 删除硬件版本 - * + * * @param id 硬件版本主键 * @return 结果 */ @@ -53,9 +53,16 @@ public interface EtHardwareVersionMapper /** * 批量删除硬件版本 - * + * * @param ids 需要删除的数据主键集合 * @return 结果 */ public int deleteEtHardwareVersionByIds(Long[] ids); + + /** + * 查询子节点数量 + * @param id + * @return + */ + int countChildrenNum(Long id); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtLocationLogMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtLocationLogMapper.java new file mode 100644 index 0000000..079ee04 --- /dev/null +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtLocationLogMapper.java @@ -0,0 +1,79 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.EtLocationLog; +import org.apache.ibatis.annotations.Param; + +/** + * 定位日志Mapper接口 + * + * @author ruoyi + * @date 2024-08-20 + */ +public interface EtLocationLogMapper +{ + /** + * 查询定位日志 + * + * @param locationId 定位日志主键 + * @return 定位日志 + */ + public EtLocationLog selectEtLocationLogByLocationId(Long locationId); + + /** + * 查询定位日志列表 + * + * @param etLocationLog 定位日志 + * @return 定位日志集合 + */ + public List selectEtLocationLogList(EtLocationLog etLocationLog); + + /** + * 查询定位日志列表 + * + * @param mac + * @return 定位日志集合 + */ + public List selectEtLocationLogListByCreateTime(@Param("mac") String mac, @Param("startTime") String startTime, @Param("endTime") String endTime); + + /** + * 新增定位日志 + * + * @param etLocationLog 定位日志 + * @return 结果 + */ + public int insertEtLocationLog(EtLocationLog etLocationLog); + + /** + * 修改定位日志 + * + * @param etLocationLog 定位日志 + * @return 结果 + */ + public int updateEtLocationLog(EtLocationLog etLocationLog); + + /** + * 删除定位日志 + * + * @param locationId 定位日志主键 + * @return 结果 + */ + public int deleteEtLocationLogByLocationId(Long locationId); + + /** + * 批量删除定位日志 + * + * @param locationIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEtLocationLogByLocationIds(Long[] locationIds); + + + /** + * 删除7天之前的定位日志 + * + * @return 结果 + */ + int deleteLocationLogByCreateTime(); + +} diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java index 125ca37..c82b1e2 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java @@ -235,6 +235,11 @@ public interface EtOrderMapper */ BigDecimal getRefundFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("sn") String sn, @Param("areaId") Long areaId); + /** + * 押金退款 + */ + BigDecimal getDepositRefundFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("sn") String sn, @Param("areaId") Long areaId); + /** * 收入 */ @@ -283,6 +288,11 @@ public interface EtOrderMapper */ BigDecimal getPartnerFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("areaId") Long areaId); + /** + * 押金订单收入 + */ + BigDecimal getDepositAmount(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("areaId") Long areaId); + // /** // * 平台服务费 // */ diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/CallbackService.java b/electripper-system/src/main/java/com/ruoyi/system/service/CallbackService.java index d38752e..8f3ac09 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/CallbackService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/CallbackService.java @@ -40,6 +40,18 @@ public interface CallbackService { */ public EtCapitalFlow capitalFlowRecords(EtOrder order, String type, String busType, String ownerType, SysUser user, String payType); + /** + * 新增资金流水记录 + * @param order 订单 + * @param type 类型 + * @param busType 业务类型 + * @param ownerType 所属人类型 + * @param user 合伙人对象 + * @param payType 支付方式 + * @return void + */ + public EtCapitalFlow capitalFlowRecordsByRepair(EtOrder order, String type, String busType, String ownerType, SysUser user, String payType); + /** * 新增资金流水记录 * @param order 订单 diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java index 8b7490b..a666ea7 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java @@ -377,6 +377,11 @@ public interface IAsDeviceService extends IService */ boolean updateVersion(String sn); + /** + * 根据时间查询车辆轨迹 + */ + String trajectory(String sn,String startTime,String endTime); + // /** // * 是否靠近运营区边界 // */ diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IEtLocationLogService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IEtLocationLogService.java new file mode 100644 index 0000000..156c77f --- /dev/null +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IEtLocationLogService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.EtLocationLog; + +/** + * 定位日志Service接口 + * + * @author ruoyi + * @date 2024-08-20 + */ +public interface IEtLocationLogService +{ + /** + * 查询定位日志 + * + * @param locationId 定位日志主键 + * @return 定位日志 + */ + public EtLocationLog selectEtLocationLogByLocationId(Long locationId); + + /** + * 查询定位日志列表 + * + * @param etLocationLog 定位日志 + * @return 定位日志集合 + */ + public List selectEtLocationLogList(EtLocationLog etLocationLog); + + /** + * 新增定位日志 + * + * @param etLocationLog 定位日志 + * @return 结果 + */ + public int insertEtLocationLog(EtLocationLog etLocationLog); + + /** + * 修改定位日志 + * + * @param etLocationLog 定位日志 + * @return 结果 + */ + public int updateEtLocationLog(EtLocationLog etLocationLog); + + /** + * 批量删除定位日志 + * + * @param locationIds 需要删除的定位日志主键集合 + * @return 结果 + */ + public int deleteEtLocationLogByLocationIds(Long[] locationIds); + + /** + * 删除定位日志信息 + * + * @param locationId 定位日志主键 + * @return 结果 + */ + public int deleteEtLocationLogByLocationId(Long locationId); +} diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java index 8cb3049..08371ab 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java @@ -142,7 +142,7 @@ public interface IEtOrderService /** * 运营数据 */ - OperatingDataVo getOperatingData(String timeStart,String timeEnd,String areaId); + OperatingDataVo2 getOperatingData(String timeStart,String timeEnd,String areaId); /** * 收入对账 diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IWxPayService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IWxPayService.java index 7bdfed9..70ce3f7 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IWxPayService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IWxPayService.java @@ -50,6 +50,13 @@ public interface IWxPayService { */ Transaction queryOrderByOutTradeNo(String outTradeNo); + /** + * 根据订单号查询订单支付结果 + * @param orderNo 订单号 + * @return 订单信息 + */ + Boolean queryResultByOrderNo(String orderNo); + /** * 退款 * @param etOrder 原订单对象 diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java index f65790e..44f3b8d 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java @@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.*; -import com.ruoyi.common.core.domain.entity.AsUser; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.CommonUtil; @@ -24,6 +23,7 @@ import com.ruoyi.system.domain.response.OrderResponse; import com.ruoyi.system.domain.vo.*; import com.ruoyi.system.mapper.AsDeviceMapper; import com.ruoyi.system.mapper.EtCommandLogMapper; +import com.ruoyi.system.mapper.EtLocationLogMapper; import com.ruoyi.system.mapper.EtOrderMapper; import com.ruoyi.system.service.*; import com.wechat.pay.java.service.refund.model.Refund; @@ -116,6 +116,9 @@ public class AsDeviceServiceImpl extends ServiceImpl i @Autowired private ISysConfigService sysConfigService; + @Resource + private EtLocationLogMapper etLocationLogMapper; + @Value(value = "${iot.iotUrl}") private String iotUrl; @@ -2508,6 +2511,38 @@ public class AsDeviceServiceImpl extends ServiceImpl i return false; } + /** + * 根据时间查询车辆轨迹 + */ + @Override + public String trajectory(String sn, String startTime,String endTime) { + AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn); + List etLocationLogs = etLocationLogMapper.selectEtLocationLogListByCreateTime(device.getMac(), startTime, endTime); + // 将etLocationLogs中的longitude和latitude 转换成 [[120.2534,27.1048],[120.2556,27.1051],[120.2569,27.1057]] 这样的格式 + List coordinatesList = new ArrayList<>(); + + for (EtLocationLog log : etLocationLogs) { + double longitude = Double.parseDouble(log.getLongitude()); + double latitude = Double.parseDouble(log.getLatitude()); + coordinatesList.add(new double[]{longitude, latitude}); + } + StringBuilder trajectoryStr = new StringBuilder(); + int size = coordinatesList.size(); + + trajectoryStr.append("["); // 在循环之前添加一个 "[" + + for (int i = 0; i < size; i++) { + double[] coordinate = coordinatesList.get(i); + trajectoryStr.append("[").append(coordinate[0]).append(", ").append(coordinate[1]).append("]"); + + if (i < size - 1) { + trajectoryStr.append(","); + } + } + trajectoryStr.append("]"); // 在循环之后添加一个 "]" + return trajectoryStr.toString(); + } + /** * sn和mac号绑定 diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java index ea55fcf..596dbc7 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java @@ -163,6 +163,9 @@ public class CallbackServiceImpl implements CallbackService { Notification notification = JSON.parseObject(body, Notification.class); String outTradeNo; + //异步保存回调日志 + asynchronousSaveCallbackLog(etCallbackLog); + // 支付成功通知 if (NotifyEventType.TRANSACTION_SUCCESS.getValue().equals(notification.getEventType())) { // 验签、解密并转换成 Transaction @@ -278,8 +281,6 @@ public class CallbackServiceImpl implements CallbackService { logger.error("【微信支付回调】更新用户押金失败"); throw new ServiceException("【微信支付回调】更新用户押金失败"); } - //异步保存回调日志 - asynchronousSaveCallbackLog(etCallbackLog); logger.info("=================【微信支付回调】全部结束!!!!!=================="); } } @@ -290,15 +291,11 @@ public class CallbackServiceImpl implements CallbackService { /** 发送一个短信给运营商*/ SysDept sysDept = wxPayService.getDeptObjByAreaId(order.getAreaId()); logger.info("【微信支付回调】还车拍照审核,获取到运营商:【{}】",JSON.toJSON(sysDept)); - if(ObjectUtil.isNull(sysDept.getAppUserId())){ - throw new ServiceException("该运营商【"+sysDept.getDeptName()+"】未绑定微信用户"); - } - AsUser asUser1 = asUserMapper.selectUserById(sysDept.getAppUserId()); JSONObject jsonObject = new JSONObject(); jsonObject.put("name", amount); - String phone = asUser1.getPhonenumber(); + String phone = sysDept.getPhone(); SendSmsVo sendSmsVo = new SendSmsVo(); sendSmsVo.setMobile(phone); sendSmsVo.setTemplateCode(templateCode); @@ -323,6 +320,7 @@ public class CallbackServiceImpl implements CallbackService { etMsgLog.setContent("您名下有一笔租车订单已归还,订单金额:"+ amount +"元。"); etMsgLog.setType(ServiceConstants.MSG_TYPE_VEHICLE_RETURN_AUDIT_NOTIFY); etMsgLog.setSignName(signName); + etMsgLog.setCreateTime(DateUtils.getNowDate()); etMsgLog.setTemplateCode(templateCode); int i = etMsgLogMapper.insertEtMsgLog(etMsgLog); if(i>0){ @@ -375,6 +373,7 @@ public class CallbackServiceImpl implements CallbackService { etMsgLog.setContent("您的订单:"+order.getOrderNo()+",车牌:"+asDevice.getVehicleNum()+",SN:"+order.getSn()+",用户已付款"+order.getPayFee()+"元,可在小程序管理端查看。"); etMsgLog.setType(ServiceConstants.MSG_TYPE_USER_PAYMENT_NOTIFY); etMsgLog.setSignName(signName); + etMsgLog.setCreateTime(DateUtils.getNowDate()); etMsgLog.setTemplateCode(templateCode); int i = etMsgLogMapper.insertEtMsgLog(etMsgLog); if(i>0){ @@ -743,6 +742,165 @@ public class CallbackServiceImpl implements CallbackService { return capitalFlow; } + /** + * 资金流水记录 + * */ + @Override + public EtCapitalFlow capitalFlowRecordsByRepair(EtOrder order,String type,String busType,String ownerType,SysUser user,String payType) { + EtCapitalFlow capitalFlow = new EtCapitalFlow(); + if(ownerType.equals(ServiceConstants.OWNER_TYPE_OPERATOR)){//运营商 + SysDept sysDept = wxPayService.getDeptObjByAreaId(order.getAreaId()); + String separateAccount = sysDept.getSeparateAccount(); + capitalFlow.setAreaId(order.getAreaId()); + capitalFlow.setOrderNo(order.getOrderNo()); + capitalFlow.setOutTradeNo(order.getOutTradeNo()); + capitalFlow.setType(type); + capitalFlow.setBusType(busType); + capitalFlow.setOwnerType(ownerType); + capitalFlow.setOwnerId(sysDept.getDeptId()); + capitalFlow.setOwner(sysDept.getDeptName()); + capitalFlow.setAmount(order.getPayFee()); + String handlingCharge1 = sysDept.getHandlingCharge(); + logger.info("【微信支付回调--保存资金流水记录】 获取到配置手续费==============handlingCharge=====================:"+handlingCharge1); + BigDecimal bigDecimal = new BigDecimal(handlingCharge1).divide(new BigDecimal(1000), 6, BigDecimal.ROUND_HALF_UP); + logger.info("【微信支付回调--保存资金流水记录】 转换后手续费==============bigDecimal=====================:"+bigDecimal); + BigDecimal handlingCharge = bigDecimal.multiply(order.getPayFee()).setScale(2, BigDecimal.ROUND_HALF_UP); + logger.info("【微信支付回调--保存资金流水记录】 计算出的手续费==============handlingCharge=====================:"+handlingCharge); + BigDecimal serviceFeeScale = new BigDecimal(sysDept.getPlatformServiceFee()).divide(new BigDecimal(100), 6, BigDecimal.ROUND_HALF_UP); + BigDecimal platformServiceFee = serviceFeeScale.multiply(order.getPayFee()); + logger.info("【微信支付回调--保存资金流水记录】 计算出的平台服务费==============platformServiceFee=====================:"+platformServiceFee); + capitalFlow.setPlatformServiceFee(platformServiceFee); + capitalFlow.setHandlingCharge(handlingCharge);//手续费 + if(busType.equals(ServiceConstants.ORDER_TYPE_WITHDRAW)){//提现,需要手续费,不需要平台服务费 + BigDecimal separateAccountFee = order.getPayFee(); + capitalFlow.setPartnerDividend(BigDecimal.ZERO); + capitalFlow.setAmount(order.getPayFee().subtract(handlingCharge)); + capitalFlow.setPlatformServiceFee(BigDecimal.ZERO); + capitalFlow.setOperatorDividend(separateAccountFee.negate()); + if(StrUtil.isNotBlank(separateAccount) && separateAccount.equals("N")){ + capitalFlow.setOperatorBalance(sysDept.getBalance().subtract(separateAccountFee)); + deptService.changeDeptBalance(separateAccountFee.negate(),sysDept.getDeptId()); + }else{ + capitalFlow.setOperatorBalance(BigDecimal.ZERO); + } + logger.info("【微信支付回调--保存资金流水记录】 ==============支出=====================:"); + }else if(busType.equals(ServiceConstants.ORDER_TYPE_VEHICLE_DAMAGE)){ + BigDecimal separateAccountFee = order.getPayFee(); + capitalFlow.setAmount(order.getPayFee()); + capitalFlow.setHandlingCharge(BigDecimal.ZERO);//手续费 + capitalFlow.setPartnerDividend(BigDecimal.ZERO);// 合伙人分账 + capitalFlow.setPlatformServiceFee(BigDecimal.ZERO);//平台服务费 + capitalFlow.setOperatorDividend(separateAccountFee); + if(StrUtil.isNotBlank(separateAccount) && separateAccount.equals("N")){ + capitalFlow.setOperatorBalance(sysDept.getBalance().add(separateAccountFee)); + deptService.changeDeptBalance(separateAccountFee,sysDept.getDeptId()); + }else{ + capitalFlow.setOperatorBalance(BigDecimal.ZERO); + } + }else { + logger.info("【微信支付回调--保存资金流水记录】 ==============业务类型=====================:"+busType); + BigDecimal partnerDividend = BigDecimal.ZERO; + BigDecimal separateAccountFee = order.getPayFee().subtract(handlingCharge).subtract(platformServiceFee); + logger.info("【微信支付回调--保存资金流水记录】 ==============扣掉手续费和服务费之后的金额,这个金额拿来分账=====================:"+separateAccountFee); + BigDecimal operatorDividend = separateAccountFee; +// if(sysDept.getIsProfitSharing().equals("true")){//需要分账 +// logger.info("【微信支付回调--保存资金流水记录】 ==============需要分账====================="+sysDept.getIsProfitSharing()); + //获取所有合伙人列表 + SysUser sysUser = new SysUser(); + sysUser.setUserType("03"); + sysUser.setAreaId(order.getAreaId()); + List sysUsers = userMapper.selectUserList(sysUser); + double totalDividendProportion = sysUsers.stream() + .mapToDouble(SysUser::getDividendProportion) + .sum();//算出总的分成比例 + BigDecimal decimal = new BigDecimal(totalDividendProportion).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP); + partnerDividend = operatorDividend.multiply(decimal); + operatorDividend = operatorDividend.subtract(partnerDividend); +// } + logger.info("【微信支付回调--保存资金流水记录】 ==============partnerDividend=====================:"+partnerDividend); + logger.info("【微信支付回调--保存资金流水记录】 ==============operatorDividend=====================:"+operatorDividend); + if(type.equals(ServiceConstants.FLOW_TYPE_INCOME)){ + capitalFlow.setPartnerDividend(partnerDividend); + capitalFlow.setOperatorDividend(operatorDividend); + if(StrUtil.isNotBlank(separateAccount) && separateAccount.equals("N")){ + capitalFlow.setOperatorBalance(sysDept.getBalance().add(operatorDividend)); + deptService.changeDeptBalance(operatorDividend,sysDept.getDeptId()); + }else{ + capitalFlow.setOperatorBalance(BigDecimal.ZERO); + } + logger.info("【微信支付回调--保存资金流水记录】 ==============收入=====================:"); + }else{ + capitalFlow.setPartnerDividend(partnerDividend.negate()); + capitalFlow.setOperatorDividend(operatorDividend.negate()); + if(StrUtil.isNotBlank(separateAccount) && separateAccount.equals("N")){ + capitalFlow.setOperatorBalance(sysDept.getBalance().subtract(operatorDividend)); + deptService.changeDeptBalance(operatorDividend.negate(),sysDept.getDeptId()); + }else{ + capitalFlow.setOperatorBalance(BigDecimal.ZERO); + } + logger.info("【微信支付回调--保存资金流水记录】 ==============支出=====================:"); + } + } + capitalFlow.setPayType(payType); + capitalFlow.setCreateTime(DateUtils.getNowDate()); + logger.info("【微信支付回调】保存资金流水记录对象 : " + JSON.toJSONString(capitalFlow)); + int i = etCapitalFlowService.insertEtCapitalFlow(capitalFlow); + if(i==0){ + throw new ServiceException("保存资金流水记录失败"); + }else { + logger.info("【微信支付回调】保存资金流水记录成功"); + } + }else{ + logger.info("【合伙人记录资金流水】"); + capitalFlow.setAreaId(order.getAreaId()); + capitalFlow.setOrderNo(order.getOrderNo()); + capitalFlow.setOutTradeNo(order.getOutTradeNo()); + capitalFlow.setType(type); + capitalFlow.setBusType(busType); + capitalFlow.setOwnerType(ownerType); + capitalFlow.setOwnerId(user.getUserId()); + capitalFlow.setOwner(user.getUserName()); + capitalFlow.setAmount(order.getPayFee()); + capitalFlow.setHandlingCharge(BigDecimal.ZERO);//手续费 0 + capitalFlow.setPlatformServiceFee(BigDecimal.ZERO);//平台服务费 0 + if(busType.equals(ServiceConstants.ORDER_TYPE_WITHDRAW)){//提现,需要手续费,不需要平台服务费 + BigDecimal separateAccountFee = order.getPayFee(); + capitalFlow.setPartnerDividend(BigDecimal.ZERO); + capitalFlow.setOperatorDividend(separateAccountFee.negate()); + capitalFlow.setOperatorBalance(user.getBalance().subtract(separateAccountFee)); + userMapper.changeUserBalance(separateAccountFee.negate(),user.getUserId()); + logger.info("【保存资金流水记录】 ==============支出=====================:"); + }else{ + logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============业务类型===骑行收入==================:"+busType); + BigDecimal partnerDividend = order.getPayFee(); + logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============合伙人分账partnerDividend=====================:"+partnerDividend); + if(type.equals(ServiceConstants.FLOW_TYPE_INCOME)){ + capitalFlow.setPartnerDividend(partnerDividend); + capitalFlow.setOperatorDividend(order.getPayFee()); + capitalFlow.setOperatorBalance(user.getBalance().add(partnerDividend)); + userMapper.changeUserBalance(partnerDividend,user.getUserId()); + logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============收入=====================:"); + }else{ + capitalFlow.setPartnerDividend(partnerDividend.negate()); + capitalFlow.setOperatorDividend(order.getPayFee()); + capitalFlow.setOperatorBalance(user.getBalance().subtract(partnerDividend)); + userMapper.changeUserBalance(partnerDividend.negate(),user.getUserId()); + logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============支出=====================:"); + } + } + capitalFlow.setPayType(payType); + capitalFlow.setCreateTime(order.getPayTime()); + logger.info("【微信支付回调】保存资金流水记录对象 : " + JSON.toJSONString(capitalFlow)); + int i = etCapitalFlowService.insertEtCapitalFlow(capitalFlow); + if(i==0){ + throw new ServiceException("保存资金流水记录失败"); + }else { + logger.info("【微信支付回调】保存资金流水记录成功"); + } + } + return capitalFlow; + } + /** * 资金流水记录 * */ diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtHardwareVersionServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtHardwareVersionServiceImpl.java index a23ce1e..e822845 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtHardwareVersionServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtHardwareVersionServiceImpl.java @@ -2,27 +2,33 @@ package com.ruoyi.system.service.impl; import java.util.List; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.mapper.AsDeviceMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.EtHardwareVersionMapper; import com.ruoyi.system.domain.EtHardwareVersion; import com.ruoyi.system.service.IEtHardwareVersionService; +import javax.annotation.Resource; + /** * 硬件版本Service业务层处理 - * + * * @author qiuzhenzhao * @date 2024-07-22 */ @Service -public class EtHardwareVersionServiceImpl implements IEtHardwareVersionService +public class EtHardwareVersionServiceImpl implements IEtHardwareVersionService { - @Autowired + @Resource private EtHardwareVersionMapper etHardwareVersionMapper; + @Resource + private AsDeviceMapper asDeviceMapper; + /** * 查询硬件版本 - * + * * @param id 硬件版本主键 * @return 硬件版本 */ @@ -34,19 +40,55 @@ public class EtHardwareVersionServiceImpl implements IEtHardwareVersionService /** * 查询硬件版本列表 - * + * * @param etHardwareVersion 硬件版本 * @return 硬件版本 */ @Override public List selectEtHardwareVersionList(EtHardwareVersion etHardwareVersion) { - return etHardwareVersionMapper.selectEtHardwareVersionList(etHardwareVersion); + List etHardwareVersions = etHardwareVersionMapper.selectEtHardwareVersionList(etHardwareVersion); + for (EtHardwareVersion etHardwareVersion1:etHardwareVersions) { + if(etHardwareVersion1.getParentId() != 0){ + int boundNum = asDeviceMapper.countBoundNum(etHardwareVersion1.getId());// 已绑定 + etHardwareVersion1.setBound(boundNum); + int unBoundNum = asDeviceMapper.countUnBoundNum(etHardwareVersion1.getId());// 未绑定 + etHardwareVersion1.setUnBound(unBoundNum); + int entered = boundNum+ unBoundNum;// 已录入 + etHardwareVersion1.setEntered(entered); + } + } + // 统计 parentId == 0 的对象的 totalBound, totalUnBound 和 totalEntered + for (EtHardwareVersion parentVersion : etHardwareVersions) { + if (parentVersion.getParentId() == 0) { + int totalBound = 0; + int totalUnBound = 0; + int totalEntered = 0; + + for (EtHardwareVersion childVersion : etHardwareVersions) { + if (childVersion.getParentId() == parentVersion.getId()) { + totalBound += childVersion.getBound(); + totalUnBound += childVersion.getUnBound(); + totalEntered += childVersion.getEntered(); + } + } + parentVersion.setBound(totalBound); + parentVersion.setUnBound(totalUnBound); + parentVersion.setEntered(totalEntered); + } + } + // 计算丢损数量 + for (EtHardwareVersion parentVersion : etHardwareVersions) { + if (parentVersion.getParentId() == 0) { + parentVersion.setLost(parentVersion.getQuantity()-parentVersion.getEntered()-parentVersion.getNotEnteredNum()); + } + } + return etHardwareVersions; } /** * 新增硬件版本 - * + * * @param etHardwareVersion 硬件版本 * @return 结果 */ @@ -59,7 +101,7 @@ public class EtHardwareVersionServiceImpl implements IEtHardwareVersionService /** * 修改硬件版本 - * + * * @param etHardwareVersion 硬件版本 * @return 结果 */ @@ -71,7 +113,7 @@ public class EtHardwareVersionServiceImpl implements IEtHardwareVersionService /** * 批量删除硬件版本 - * + * * @param ids 需要删除的硬件版本主键 * @return 结果 */ @@ -83,7 +125,7 @@ public class EtHardwareVersionServiceImpl implements IEtHardwareVersionService /** * 删除硬件版本信息 - * + * * @param id 硬件版本主键 * @return 结果 */ diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtLocationLogServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtLocationLogServiceImpl.java new file mode 100644 index 0000000..d1c6117 --- /dev/null +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtLocationLogServiceImpl.java @@ -0,0 +1,95 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.EtLocationLogMapper; +import com.ruoyi.system.domain.EtLocationLog; +import com.ruoyi.system.service.IEtLocationLogService; + +/** + * 定位日志Service业务层处理 + * + * @author ruoyi + * @date 2024-08-20 + */ +@Service +public class EtLocationLogServiceImpl implements IEtLocationLogService +{ + @Autowired + private EtLocationLogMapper etLocationLogMapper; + + /** + * 查询定位日志 + * + * @param locationId 定位日志主键 + * @return 定位日志 + */ + @Override + public EtLocationLog selectEtLocationLogByLocationId(Long locationId) + { + return etLocationLogMapper.selectEtLocationLogByLocationId(locationId); + } + + /** + * 查询定位日志列表 + * + * @param etLocationLog 定位日志 + * @return 定位日志 + */ + @Override + public List selectEtLocationLogList(EtLocationLog etLocationLog) + { + return etLocationLogMapper.selectEtLocationLogList(etLocationLog); + } + + /** + * 新增定位日志 + * + * @param etLocationLog 定位日志 + * @return 结果 + */ + @Override + public int insertEtLocationLog(EtLocationLog etLocationLog) + { + etLocationLog.setCreateTime(DateUtils.getNowDate()); + return etLocationLogMapper.insertEtLocationLog(etLocationLog); + } + + /** + * 修改定位日志 + * + * @param etLocationLog 定位日志 + * @return 结果 + */ + @Override + public int updateEtLocationLog(EtLocationLog etLocationLog) + { + return etLocationLogMapper.updateEtLocationLog(etLocationLog); + } + + /** + * 批量删除定位日志 + * + * @param locationIds 需要删除的定位日志主键 + * @return 结果 + */ + @Override + public int deleteEtLocationLogByLocationIds(Long[] locationIds) + { + return etLocationLogMapper.deleteEtLocationLogByLocationIds(locationIds); + } + + /** + * 删除定位日志信息 + * + * @param locationId 定位日志主键 + * @return 结果 + */ + @Override + public int deleteEtLocationLogByLocationId(Long locationId) + { + return etLocationLogMapper.deleteEtLocationLogByLocationId(locationId); + } +} diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java index 4d44746..0316a57 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java @@ -498,7 +498,7 @@ public class EtOrderServiceImpl implements IEtOrderService } } /** 押金抵扣后生成资金流水记录 */ - callbackService.capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ); + callbackService.capitalFlowRecordsByRepair(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ); } return 1; } @@ -1066,6 +1066,7 @@ public class EtOrderServiceImpl implements IEtOrderService PrepayWithRequestPaymentResponseVo responseVo = new PrepayWithRequestPaymentResponseVo(); BeanUtils.copyProperties(response,responseVo); responseVo.setSessionId(IdUtils.randomUUIDByDigit(8)); + responseVo.setOrderNo(etOrder.getOrderNo()); return responseVo; } @@ -1151,60 +1152,49 @@ public class EtOrderServiceImpl implements IEtOrderService * 运营数据 */ @Override - public OperatingDataVo getOperatingData(String timeStart,String timeEnd,String areaId) { - OperatingDataVo operatingDataVo = new OperatingDataVo(); + public OperatingDataVo2 getOperatingData(String timeStart,String timeEnd,String areaId) { + long aLong = Long.parseLong(areaId); + OperatingDataVo2 operatingDataVo = new OperatingDataVo2(); if(StrUtil.isNotBlank(timeStart) && StrUtil.isNotBlank(timeEnd)){ /*收入相关*/ - OperatingDataVo.Income income = new OperatingDataVo.Income(); - String totalUnpaid = etOrderMapper.getTotalUnpaid(timeStart, timeEnd, areaId); - income.setTotalUnpaid(totalUnpaid);//累计待支付 - String totalPaid = etOrderMapper.getTotalPaid(timeStart, timeEnd, areaId); - String totalRefund = etOrderMapper.getTotalRefund(timeStart, timeEnd, areaId);//已退款 - income.setTotalPaid(totalPaid);//已支付 - //handlingFee 手续费 = 0.0054 * 已支付金额 - SysDept sysDept = wxPayService.getDeptObjByAreaId(Long.parseLong(areaId)); - String handlingCharge = sysDept.getHandlingCharge(); - BigDecimal divide = new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 4, RoundingMode.HALF_UP); - BigDecimal handlingFee = new BigDecimal(totalPaid).multiply(divide); - income.setHandlingFee(handlingFee.setScale(2, RoundingMode.HALF_UP).toString()); - // 总营收 = 已支付 - 已退款 - 手续费 - income.setTotalIncome(new BigDecimal(totalPaid).subtract(new BigDecimal(totalRefund)).subtract(handlingFee).setScale(2, RoundingMode.HALF_UP).toString());//总收入 etOrderMapper.getTotalIncome(timeStart,timeEnd,areaId) - income.setTotalRefund(totalRefund);//已退款 - income.setTotalFee(new BigDecimal(totalUnpaid).add(new BigDecimal(totalPaid)).toString());// 订单总金额 = 已支付+待支付 - income.setTotalRidingFee(etOrderMapper.getTotalRidingFee(timeStart,timeEnd,areaId));//骑行已支付 - income.setTotalRidingRefund(etOrderMapper.getTotalRidingRefund(timeStart,timeEnd,areaId));//骑行已退款 - income.setTotalDispatchFee(etOrderMapper.getTotalDispatchFee(timeStart,timeEnd,areaId));//调度费已支付 - income.setTotalDispatchRefund(etOrderMapper.getTotalDispatchRefund(timeStart,timeEnd,areaId));//调度费已退款 - income.setTotalAppointmentFee(etOrderMapper.getTotalAppointmentFee(timeStart,timeEnd,areaId));//预约费已支付 - income.setTotalAppointmentRefund(etOrderMapper.getTotalAppointmentRefund(timeStart,timeEnd,areaId));//预约费已退款 - income.setTotalManageFee(etOrderMapper.getTotalManageFee(timeStart,timeEnd,areaId));//停车点外调度费已支付 - income.setTotalManageRefund(etOrderMapper.getTotalManageRefund(timeStart,timeEnd,areaId));//停车点外调度费已退款 + OperatingDataVo2.Income income = new OperatingDataVo2.Income(); + /** 总收入*/ + BigDecimal totalAmount = defaultIfNull(etCapitalFlowMapper.getTotalAmount(timeStart, timeEnd, null, aLong),BigDecimal.ZERO);// 骑行订单收入 + BigDecimal deductionAmount = defaultIfNull(etCapitalFlowMapper.getDeductionAmount(timeStart, timeEnd, null, aLong),BigDecimal.ZERO);// 押金抵扣金额 + BigDecimal depositAmount = defaultIfNull(etOrderMapper.getDepositAmount(timeStart, timeEnd, aLong),BigDecimal.ZERO);// 押金收入 + BigDecimal totalFlowAmount = totalAmount.add(depositAmount).add(deductionAmount);// 总流水 + income.setTotalFlowAmount(totalFlowAmount); + income.setDeductionAmount(deductionAmount); + income.setOrderPaid(totalAmount.add(deductionAmount));//订单支付 + income.setDepositPaid(depositAmount); + + /** 总支出*/ + BigDecimal refundFee = defaultIfNull(etOrderMapper.getRefundFee(timeStart, timeEnd, null, aLong), BigDecimal.ZERO);//订单退款 + BigDecimal depositRefundFee = defaultIfNull(etOrderMapper.getDepositRefundFee(timeStart, timeEnd, null, aLong), BigDecimal.ZERO);//押金退款 + BigDecimal serviceFee = defaultIfNull(etCapitalFlowMapper.getHandlingFee(timeStart, timeEnd, null, Long.parseLong(areaId)),BigDecimal.ZERO);//手续费,扣除掉退款部分的 + BigDecimal platformServiceFee = defaultIfNull(etCapitalFlowMapper.getServiceFee(timeStart, timeEnd, null,Long.parseLong(areaId)),BigDecimal.ZERO);//平台服务费 ,扣除掉退款部分的 + BigDecimal totalExpenditure = defaultIfNull(refundFee.add(depositRefundFee).add(serviceFee).add(platformServiceFee), BigDecimal.ZERO); + + income.setOrderRefund(refundFee); + income.setDepositRefund(depositRefundFee); + income.setHandlingFee(serviceFee); + income.setPlatformServiceFee(platformServiceFee); + income.setTotalExpenditure(totalExpenditure); + operatingDataVo.setIncome(income); + BigDecimal depositBalance = depositAmount.subtract(depositRefundFee).subtract(deductionAmount); + income.setOperatingIncome(totalFlowAmount.subtract(totalExpenditure).subtract(depositBalance)); + income.setOperatingIncome2(totalAmount.add(deductionAmount).subtract(refundFee).subtract(serviceFee).subtract(platformServiceFee).add(deductionAmount)); + income.setDepositBalance(depositBalance);// 押金余额 + income.setAccountSurplus(totalFlowAmount.subtract(totalExpenditure));// 账户盈余=总流水-总支出 = 营业收入+押金余额 /*订单相关*/ - OperatingDataVo.OrderVo orderVo = new OperatingDataVo.OrderVo(); + OperatingDataVo2.OrderVo orderVo = new OperatingDataVo2.OrderVo(); orderVo.setPaidOrder(etOrderMapper.getPaidOrder(timeStart,timeEnd,areaId));//已支付订单 orderVo.setRidingOrder(etOrderMapper.getRidingOrder(timeStart,timeEnd,areaId));//骑行中订单 orderVo.setRefundOrder(etOrderMapper.getRefundOrder(timeStart,timeEnd,areaId));//退款订单 orderVo.setUnpaidOrder(etOrderMapper.getUnpaidOrder(timeStart,timeEnd,areaId));//待支付订单 operatingDataVo.setOrder(orderVo); - - /*设备相关*/ - OperatingDataVo.DeviceVo deviceVo = new OperatingDataVo.DeviceVo(); - String inOperationDevice = deviceService.getInOperationDevice(timeStart, timeEnd, areaId); - String inOrderDevice = deviceService.getInOrderDevice(timeStart, timeEnd, areaId); - deviceVo.setInOperationDevice(inOperationDevice);//运营中车辆 - deviceVo.setInOrderDevice(inOrderDevice);//有订单车辆 - int i = Integer.parseInt(inOperationDevice) - Integer.parseInt(inOrderDevice); - deviceVo.setNoOrderDevice( i+"");//无订单车辆 - operatingDataVo.setDevice(deviceVo); - - /*用户相关*/ - OperatingDataVo.UserVo userVo = new OperatingDataVo.UserVo(); - userVo.setTotalUser(asUserService.getTotalUser(areaId));//总用户 - userVo.setNewUser(asUserService.getNewUser(timeStart,timeEnd,areaId));//新增用户 - userVo.setLeaseUser(asUserService.getLeaseUser(timeStart,timeEnd,areaId));//租赁用户 - operatingDataVo.setUser(userVo); return operatingDataVo; }else{ throw new ServiceException("请选择时间"); diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java index f50f7c1..988b0b2 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java @@ -4,15 +4,19 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.core.domain.entity.AsUser; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.redis.RedisLock; import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.domain.EtAreaDept; import com.ruoyi.system.domain.EtOrder; import com.ruoyi.system.domain.vo.AttachVo; +import com.ruoyi.system.mapper.AsUserMapper; import com.ruoyi.system.mapper.EtAreaDeptMapper; import com.ruoyi.system.service.IAsUserService; import com.ruoyi.system.service.IEtOrderService; @@ -52,27 +56,12 @@ import java.util.List; @Slf4j public class WxPayService implements IWxPayService { -// @Autowired -// private JsapiService jsapiService; - -// @Autowired -// private JsapiServiceExtension jsapiServiceExtension; - @Autowired private IEtOrderService etOrderService; @Autowired private IAsUserService asUserService; -// @Autowired -// private NotificationParser notificationParser; - -// @Autowired -// public RefundService refundService2; - -// @Autowired -// public ProfitsharingService profitsharingService; - @Autowired private RedisLock redisLock; @@ -82,6 +71,12 @@ public class WxPayService implements IWxPayService { @Autowired private ISysDeptService deptService; + @Resource + private AsUserMapper asUserMapper; + + @Autowired + private IEtOrderService orderService; + private static final String CNY = "CNY"; private static final String PREPAY_LOCK = "prepay:"; @@ -105,12 +100,15 @@ public class WxPayService implements IWxPayService { // 获取JSAPI所需参数 PrepayRequest request = new PrepayRequest(); request.setAmount(getAmount(order.getPayFee())); -// String outTradeNo; -// if(StrUtil.isBlank(order.getOutTradeNo())){ -// outTradeNo = IdUtils.getOrderNo("wx"); -// }else{ -// outTradeNo = order.getOutTradeNo(); -// } + JsapiServiceExtension jsapiServiceExtension = getJsapiServiceExtension(sysDept); + if(StrUtil.isNotBlank(order.getOutTradeNo())){ + String tradeNo = order.getOutTradeNo(); + // 关闭订单 + CloseOrderRequest closeOrderRequest = new CloseOrderRequest(); + closeOrderRequest.setMchid(sysDept.getMerchantId()); + closeOrderRequest.setOutTradeNo(tradeNo); + jsapiServiceExtension.closeOrder(closeOrderRequest); + } String outTradeNo = IdUtils.getOrderNo("wx"); order.setOutTradeNo(outTradeNo); order.setLocking("1"); @@ -133,7 +131,7 @@ public class WxPayService implements IWxPayService { settleInfo.setProfitSharing(false);//暂时关闭分账 // settleInfo.setProfitSharing( "true".equalsIgnoreCase(isProfitSharing)); request.setSettleInfo(settleInfo); - JsapiServiceExtension jsapiServiceExtension = getJsapiServiceExtension(sysDept); +// JsapiServiceExtension jsapiServiceExtension = getJsapiServiceExtension(sysDept); PrepayWithRequestPaymentResponse res = jsapiServiceExtension.prepayWithRequestPayment(request); return res; }else{ @@ -186,6 +184,51 @@ public class WxPayService implements IWxPayService { } } + /** + * 根据订单号查询订单 + * @param orderNo 商户订单号 + * @return + */ + @Override + public Boolean queryResultByOrderNo(String orderNo) { + EtOrder order = etOrderService.selectEtOrderByOrderNo(orderNo); + SysDept sysDept = getDeptObjByAreaId(order.getAreaId()); + log.info("获取到运营商对象:【{}】",JSON.toJSON(sysDept)); + QueryOrderByOutTradeNoRequest request = new QueryOrderByOutTradeNoRequest(); + request.setMchid(sysDept.getMerchantId()); + request.setOutTradeNo(order.getOutTradeNo()); + JsapiService jsapiService = getJsapiService(sysDept); + Transaction transaction = jsapiService.queryOrderByOutTradeNo(request); + // 订单未支付并且微信支付结果是成功的情况下,更新订单状态和用户余额 + if(transaction.getTradeState().equals(Transaction.TradeStateEnum.SUCCESS)){ + if(order.getPaid().equals(ServiceConstants.ORDER_PAY_STATUS_NON_PAYMENT)){ + order.setPaid("1"); + order.setPayTime(DateUtils.parseTime(transaction.getSuccessTime())); + order.setPayType(ServiceConstants.PAY_TYPE_WX); + log.info("【主动查询】押金支付"); + order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); + order.setMark("押金支付"); + + // 更新用户余额 + AsUser asUser = asUserMapper.selectUserById(order.getUserId()); + asUser.setBalance(order.getTotalFee()); + int updateUser = asUserMapper.updateUser(asUser); + if(updateUser==0){ + log.error("【微信支付回调】更新用户押金失败"); + throw new ServiceException("【微信支付回调】更新用户押金失败"); + } + + int updateEtOrder = orderService.updateEtOrder(order); + if(updateEtOrder==0){ + log.error("【微信支付回调】更新订单信息失败"); + throw new ServiceException("【微信支付回调】更新订单信息失败"); + } + } + return true; + } + return false; + } + private JsapiService getJsapiService(SysDept sysDept) { // 初始化商户配置 Config config = new RSAAutoCertificateConfig.Builder() diff --git a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java index 37cfdc9..e217250 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java +++ b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java @@ -13,12 +13,8 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.map.GeoUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.domain.*; -import com.ruoyi.system.mapper.AsDeviceMapper; -import com.ruoyi.system.mapper.AsUserMapper; -import com.ruoyi.system.mapper.EtOrderMapper; -import com.ruoyi.system.mapper.SysUserMapper; +import com.ruoyi.system.mapper.*; import com.ruoyi.system.service.*; -import com.wechat.pay.java.service.payments.model.Transaction; import com.wechat.pay.java.service.refund.model.Refund; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -86,6 +82,9 @@ public class EtTask { @Autowired private CallbackService callbackService; + @Resource + private EtLocationLogMapper etLocationLogMapper; + /** @@ -396,4 +395,16 @@ public class EtTask { } } + /** + * 一个星期删除一次onenet心跳日志 + * cron: 0 5 0 * * ? + * + * DELETE FROM et_location_log + * WHERE create_time < NOW() - INTERVAL 7 DAY; + */ + public void deleteLocationLog(){ + log.info("-------------------【定时任务】删除onenet心跳日志-------------------"); + etLocationLogMapper.deleteLocationLogByCreateTime(); + } + } diff --git a/electripper-system/src/main/resources/mapper/system/AsDeviceMapper.xml b/electripper-system/src/main/resources/mapper/system/AsDeviceMapper.xml index b5472c5..8240288 100644 --- a/electripper-system/src/main/resources/mapper/system/AsDeviceMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/AsDeviceMapper.xml @@ -163,6 +163,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select device_id, sn, device_name from et_device where mac = #{mac} limit 1 + + + + insert into et_device diff --git a/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml b/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml index 34af720..cecb744 100644 --- a/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml @@ -112,11 +112,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select - COALESCE(SUM(CASE WHEN f.type = '1' THEN platform_service_fee ELSE 0 END), 0) - - COALESCE(SUM(CASE WHEN f.type = '2' THEN platform_service_fee ELSE 0 END), 0) AS net_fee + COALESCE(SUM(platform_service_fee), 0) AS net_fee from et_capital_flow f LEFT JOIN et_order o on o.order_no = f.order_no - where f.area_id != 14 + where f.area_id != 14 and f.type = 1 and o.sn = #{sn} AND date_format(f.create_time,'%y%m%d') >= date_format(#{timeStart},'%y%m%d') @@ -144,6 +142,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and f.area_id = #{areaId} + + + + insert into et_capital_flow diff --git a/electripper-system/src/main/resources/mapper/system/EtHardwareVersionMapper.xml b/electripper-system/src/main/resources/mapper/system/EtHardwareVersionMapper.xml index 1df2002..faa3699 100644 --- a/electripper-system/src/main/resources/mapper/system/EtHardwareVersionMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtHardwareVersionMapper.xml @@ -9,12 +9,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + - select id, version, production_time, quantity, instructions, create_time from et_hardware_version + select id, version, production_time, quantity, not_entered_num, instructions, create_time, parent_id, ancestors, remark from et_hardware_version + + insert into et_hardware_version @@ -39,16 +47,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" version, production_time, quantity, + not_entered_num, instructions, create_time, + parent_id, + ancestors, + remark, #{id}, #{version}, #{productionTime}, #{quantity}, + #{notEnteredNum}, #{instructions}, #{createTime}, + #{parentId}, + #{ancestors}, + #{remark}, @@ -58,8 +74,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" version = #{version}, production_time = #{productionTime}, quantity = #{quantity}, + not_entered_num = #{notEnteredNum}, instructions = #{instructions}, create_time = #{createTime}, + parent_id = #{parentId}, + ancestors = #{ancestors}, + remark = #{remark}, where id = #{id} diff --git a/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml b/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml new file mode 100644 index 0000000..10a7ff3 --- /dev/null +++ b/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + select location_id, mac, onenet_msg, longitude, latitude, create_time, at, status, lock_status from et_location_log + + + + + + + + + + insert into et_location_log + + mac, + onenet_msg, + longitude, + latitude, + create_time, + at, + status, + lock_status, + + + #{mac}, + #{onenetMsg}, + #{longitude}, + #{latitude}, + #{createTime}, + #{at}, + #{status}, + #{lockStatus}, + + + + + update et_location_log + + mac = #{mac}, + onenet_msg = #{onenetMsg}, + longitude = #{longitude}, + latitude = #{latitude}, + create_time = #{createTime}, + at = #{at}, + status = #{status}, + lock_status = #{lockStatus}, + + where location_id = #{locationId} + + + + delete from et_location_log where location_id = #{locationId} + + + + delete from et_location_log where location_id in + + #{locationId} + + + + + delete from et_location_log + where create_time <= now() - INTERVAL 7 DAY + + + diff --git a/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml b/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml index cdf6cdd..bb43de9 100644 --- a/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml @@ -497,6 +497,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + +