From 4986239cd404e0e66dbfb2033335f0c3b6697622 Mon Sep 17 00:00:00 2001
From: jsowell <123@jsowell.com>
Date: Wed, 8 Jul 2026 16:41:15 +0800
Subject: [PATCH] =?UTF-8?q?update=20=E5=81=9C=E8=BD=A6=E4=BC=98=E6=83=A0?=
=?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../mapper/ChargeParkingDiscountMapper.java | 7 +++++-
.../ChargeParkingDiscountServiceImpl.java | 25 +++++++++++++++----
.../pile/ChargeParkingDiscountMapper.xml | 14 ++++++++++-
3 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ChargeParkingDiscountMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ChargeParkingDiscountMapper.java
index a4fed62ee..f39b74921 100644
--- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ChargeParkingDiscountMapper.java
+++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ChargeParkingDiscountMapper.java
@@ -24,4 +24,9 @@ public interface ChargeParkingDiscountMapper {
int insertOrUpdateSelective(ChargeParkingDiscount record);
ChargeParkingDiscount selectByStationId(String stationId);
-}
\ No newline at end of file
+
+ int logicDeleteByStationIdExcludeId(@Param("stationId") String stationId,
+ @Param("keepId") Integer keepId,
+ @Param("updateBy") String updateBy,
+ @Param("updateTime") java.util.Date updateTime);
+}
diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ChargeParkingDiscountServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ChargeParkingDiscountServiceImpl.java
index 55abe886f..cbc3361ea 100644
--- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ChargeParkingDiscountServiceImpl.java
+++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ChargeParkingDiscountServiceImpl.java
@@ -9,6 +9,7 @@ import com.jsowell.pile.vo.web.ChargeParkingDiscountVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import java.util.Date;
import java.util.List;
@Service
public class ChargeParkingDiscountServiceImpl implements ChargeParkingDiscountService{
@@ -81,12 +82,26 @@ public class ChargeParkingDiscountServiceImpl implements ChargeParkingDiscountSe
@Override
public int insertOrUpdateSelective(ChargeParkingDiscount record) {
- if (record.getId() == null) {
- record.setCreateBy(SecurityUtils.getUsername());
- } else {
- record.setUpdateBy(SecurityUtils.getUsername());
+ if (record == null || StringUtils.isBlank(record.getStationId())) {
+ return 0;
}
- return chargeParkingDiscountMapper.insertOrUpdateSelective(record);
+ String username = SecurityUtils.getUsername();
+ Date now = new Date();
+ record.setDelFlag("0");
+
+ ChargeParkingDiscount latestRecord = this.selectByStationId(record.getStationId());
+ if (latestRecord == null) {
+ record.setCreateBy(username);
+ record.setCreateTime(now);
+ return chargeParkingDiscountMapper.insertSelective(record);
+ }
+
+ record.setId(latestRecord.getId());
+ record.setUpdateBy(username);
+ record.setUpdateTime(now);
+ int result = chargeParkingDiscountMapper.updateByPrimaryKeySelective(record);
+ chargeParkingDiscountMapper.logicDeleteByStationIdExcludeId(record.getStationId(), latestRecord.getId(), username, now);
+ return result;
}
}
diff --git a/jsowell-pile/src/main/resources/mapper/pile/ChargeParkingDiscountMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ChargeParkingDiscountMapper.xml
index 1b22ce1bb..5721a86fc 100644
--- a/jsowell-pile/src/main/resources/mapper/pile/ChargeParkingDiscountMapper.xml
+++ b/jsowell-pile/src/main/resources/mapper/pile/ChargeParkingDiscountMapper.xml
@@ -485,11 +485,23 @@
+
+ update charge_parking_discount
+ set del_flag = '1',
+ update_by = #{updateBy,jdbcType=VARCHAR},
+ update_time = #{updateTime,jdbcType=TIMESTAMP}
+ where station_id = #{stationId,jdbcType=VARCHAR}
+ and del_flag = '0'
+ and id != #{keepId,jdbcType=INTEGER}
+
+
-
\ No newline at end of file
+