update 停车优惠配置接口

This commit is contained in:
jsowell
2026-07-08 16:41:15 +08:00
parent cace7f692f
commit 4986239cd4
3 changed files with 39 additions and 7 deletions

View File

@@ -24,4 +24,9 @@ public interface ChargeParkingDiscountMapper {
int insertOrUpdateSelective(ChargeParkingDiscount record); int insertOrUpdateSelective(ChargeParkingDiscount record);
ChargeParkingDiscount selectByStationId(String stationId); ChargeParkingDiscount selectByStationId(String stationId);
int logicDeleteByStationIdExcludeId(@Param("stationId") String stationId,
@Param("keepId") Integer keepId,
@Param("updateBy") String updateBy,
@Param("updateTime") java.util.Date updateTime);
} }

View File

@@ -9,6 +9,7 @@ import com.jsowell.pile.vo.web.ChargeParkingDiscountVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date;
import java.util.List; import java.util.List;
@Service @Service
public class ChargeParkingDiscountServiceImpl implements ChargeParkingDiscountService{ public class ChargeParkingDiscountServiceImpl implements ChargeParkingDiscountService{
@@ -81,12 +82,26 @@ public class ChargeParkingDiscountServiceImpl implements ChargeParkingDiscountSe
@Override @Override
public int insertOrUpdateSelective(ChargeParkingDiscount record) { public int insertOrUpdateSelective(ChargeParkingDiscount record) {
if (record.getId() == null) { if (record == null || StringUtils.isBlank(record.getStationId())) {
record.setCreateBy(SecurityUtils.getUsername()); return 0;
} else {
record.setUpdateBy(SecurityUtils.getUsername());
} }
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;
} }
} }

View File

@@ -485,11 +485,23 @@
</trim> </trim>
</insert> </insert>
<update id="logicDeleteByStationIdExcludeId">
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}
</update>
<select id="selectByStationId" resultMap="BaseResultMap"> <select id="selectByStationId" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from charge_parking_discount from charge_parking_discount
where del_flag = '0' where del_flag = '0'
and station_id = #{stationId,jdbcType=VARCHAR} and station_id = #{stationId,jdbcType=VARCHAR}
order by ifnull(update_time, create_time) desc, id desc
limit 1
</select> </select>
</mapper> </mapper>