diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/ChargeParkingDiscountController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/ChargeParkingDiscountController.java new file mode 100644 index 000000000..30e3943ab --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/ChargeParkingDiscountController.java @@ -0,0 +1,46 @@ +package com.jsowell.web.controller.pile; + +import com.jsowell.common.core.controller.BaseController; +import com.jsowell.common.core.domain.AjaxResult; +import com.jsowell.pile.domain.ChargeParkingDiscount; +import com.jsowell.pile.service.ChargeParkingDiscountService; +import com.jsowell.pile.vo.web.ChargeParkingDiscountVO; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * 充电停车优惠 + * + * @author xxxxx + */ +@RestController +@RequestMapping("/pile/station") +public class ChargeParkingDiscountController extends BaseController { + + @Resource + private ChargeParkingDiscountService chargeParkingDiscountService; + + /** + * 保存充电停车优惠配置 + */ + @PostMapping("/saveChargeParkingDiscount") + public AjaxResult saveChargeParkingDiscount(@RequestBody ChargeParkingDiscount chargeParkingDiscount) { + int result = chargeParkingDiscountService.insertOrUpdateSelective(chargeParkingDiscount); + if (result > 0) { + return success(); + } else { + return error(); + } + } + + /** + * 查询站点充电停车优惠配置 + */ + @GetMapping("/getChargeParkingDiscount/{stationId}") + public AjaxResult getChargeParkingDiscount(@PathVariable("stationId") String stationId) { + ChargeParkingDiscountVO chargeParkingDiscountVO = chargeParkingDiscountService.getChargeParkingDiscount(stationId); + return AjaxResult.success(chargeParkingDiscountVO); + } + +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/domain/ChargeParkingDiscount.java b/jsowell-pile/src/main/java/com/jsowell/pile/domain/ChargeParkingDiscount.java index e0c7b87de..922f6f738 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/domain/ChargeParkingDiscount.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/domain/ChargeParkingDiscount.java @@ -1,6 +1,5 @@ package com.jsowell.pile.domain; -import java.util.Date; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -8,9 +7,12 @@ import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import lombok.experimental.SuperBuilder; +import java.time.LocalTime; +import java.util.Date; + /** - * 充电停车优惠表 - */ + * 充电停车优惠表 + */ @Data @Accessors(chain = true) @SuperBuilder @@ -19,66 +21,66 @@ import lombok.experimental.SuperBuilder; @NoArgsConstructor public class ChargeParkingDiscount { /** - * 主键 - */ + * 主键 + */ private Integer id; /** - * 站点id - */ + * 站点id + */ private String stationId; /** - * 道闸平台id - */ + * 道闸平台id + */ private Integer parkingPlatformId; /** - * 条件类型(1-固定电量;2-固定时长) - */ + * 条件类型(1-固定电量;2-固定时长) + */ private String conditionType; private String conditionValue; /** - * 优惠类型(1-减时间单位分钟; 2-减金额单位元) - */ + * 优惠类型(1-减时间单位分钟; 2-减金额单位元) + */ private String discountType; private String discountValue; /** - * 开始时间 - */ - private Date startTime; + * 开始时间 + */ + private LocalTime startTime; /** - * 结束时间 - */ - private Date endTime; + * 结束时间 + */ + private LocalTime endTime; /** - * 创建人 - */ + * 创建人 + */ private String createBy; /** - * 创建时间 - */ + * 创建时间 + */ private Date createTime; /** - * 更新人 - */ + * 更新人 + */ private String updateBy; /** - * 更新时间 - */ + * 更新时间 + */ private Date updateTime; /** - * 删除标识(0-正常; 1-删除) - */ + * 删除标识(0-正常; 1-删除) + */ private String delFlag; } \ No newline at end of file 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 aaa3c3395..a4fed62ee 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 @@ -1,10 +1,11 @@ package com.jsowell.pile.mapper; import com.jsowell.pile.domain.ChargeParkingDiscount; -import org.apache.ibatis.annotations.Param; import java.util.List; +import org.apache.ibatis.annotations.Param; + public interface ChargeParkingDiscountMapper { int deleteByPrimaryKey(Integer id); 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 41e3cb8f0..cd62a0719 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 @@ -1,6 +1,6 @@ package com.jsowell.pile.service.impl; -import com.jsowell.common.util.DateUtils; +import com.jsowell.common.util.SecurityUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.ChargeParkingDiscount; import com.jsowell.pile.mapper.ChargeParkingDiscountMapper; @@ -52,8 +52,8 @@ public class ChargeParkingDiscountServiceImpl implements ChargeParkingDiscountSe discountVO.setConditionValue(chargeParkingDiscount.getConditionValue()); discountVO.setDiscountType(chargeParkingDiscount.getDiscountType()); discountVO.setDiscountValue(chargeParkingDiscount.getDiscountValue()); - discountVO.setStartTime(DateUtils.formatDateTime(chargeParkingDiscount.getStartTime())); - discountVO.setEndTime(DateUtils.formatDateTime(chargeParkingDiscount.getEndTime())); + discountVO.setStartTime(chargeParkingDiscount.getStartTime()); + discountVO.setEndTime(chargeParkingDiscount.getEndTime()); return discountVO; } @@ -79,6 +79,11 @@ public class ChargeParkingDiscountServiceImpl implements ChargeParkingDiscountSe @Override public int insertOrUpdateSelective(ChargeParkingDiscount record) { + if (record.getId() == null) { + record.setCreateBy(SecurityUtils.getUsername()); + } else { + record.setUpdateBy(SecurityUtils.getUsername()); + } return chargeParkingDiscountMapper.insertOrUpdateSelective(record); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/ChargeParkingDiscountVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/ChargeParkingDiscountVO.java index fa98dd6b8..2d4f09f54 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/ChargeParkingDiscountVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/ChargeParkingDiscountVO.java @@ -2,6 +2,8 @@ package com.jsowell.pile.vo.web; import lombok.Data; +import java.time.LocalTime; + /** * 充电停车优惠VO */ @@ -37,10 +39,10 @@ public class ChargeParkingDiscountVO { /** * 优惠生效时间 */ - private String startTime; + private LocalTime startTime; /** * 优惠失效时间 */ - private String endTime; + private LocalTime endTime; } diff --git a/jsowell-pile/src/main/resources/mapper/pile/ChargeParkingDiscountMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ChargeParkingDiscountMapper.xml index a10f7fd56..1b22ce1bb 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/ChargeParkingDiscountMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/ChargeParkingDiscountMapper.xml @@ -11,8 +11,8 @@ - - + + @@ -146,10 +146,10 @@ discount_value = #{discountValue,jdbcType=VARCHAR}, - start_time = #{startTime,jdbcType=TIMESTAMP}, + start_time = #{startTime,jdbcType=TIME}, - end_time = #{endTime,jdbcType=TIMESTAMP}, + end_time = #{endTime,jdbcType=TIME}, create_by = #{createBy,jdbcType=VARCHAR}, @@ -218,14 +218,14 @@ - when id = #{item.id,jdbcType=INTEGER} then #{item.startTime,jdbcType=TIMESTAMP} + when id = #{item.id,jdbcType=INTEGER} then #{item.startTime,jdbcType=TIME} - when id = #{item.id,jdbcType=INTEGER} then #{item.endTime,jdbcType=TIMESTAMP} + when id = #{item.id,jdbcType=INTEGER} then #{item.endTime,jdbcType=TIME} @@ -281,7 +281,7 @@ (#{item.stationId,jdbcType=VARCHAR}, #{item.parkingPlatformId,jdbcType=INTEGER}, #{item.conditionType,jdbcType=VARCHAR}, #{item.conditionValue,jdbcType=VARCHAR}, #{item.discountType,jdbcType=VARCHAR}, #{item.discountValue,jdbcType=VARCHAR}, - #{item.startTime,jdbcType=TIMESTAMP}, #{item.endTime,jdbcType=TIMESTAMP}, #{item.createBy,jdbcType=VARCHAR}, + #{item.startTime,jdbcType=TIME}, #{item.endTime,jdbcType=TIME}, #{item.createBy,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.delFlag,jdbcType=CHAR}) @@ -337,8 +337,8 @@ condition_value = #{conditionValue,jdbcType=VARCHAR}, discount_type = #{discountType,jdbcType=VARCHAR}, discount_value = #{discountValue,jdbcType=VARCHAR}, - start_time = #{startTime,jdbcType=TIMESTAMP}, - end_time = #{endTime,jdbcType=TIMESTAMP}, + start_time = #{startTime,jdbcType=TIME}, + end_time = #{endTime,jdbcType=TIME}, create_by = #{createBy,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_by = #{updateBy,jdbcType=VARCHAR}, @@ -462,10 +462,10 @@ discount_value = #{discountValue,jdbcType=VARCHAR}, - start_time = #{startTime,jdbcType=TIMESTAMP}, + start_time = #{startTime,jdbcType=TIME}, - end_time = #{endTime,jdbcType=TIMESTAMP}, + end_time = #{endTime,jdbcType=TIME}, create_by = #{createBy,jdbcType=VARCHAR}, diff --git a/jsowell-ui/src/api/pile/station.js b/jsowell-ui/src/api/pile/station.js index 10086e2b0..c27933cc9 100644 --- a/jsowell-ui/src/api/pile/station.js +++ b/jsowell-ui/src/api/pile/station.js @@ -173,3 +173,20 @@ export function updateThirdPartyStationRelation(data) { data: data, }) } + +// 保存充电停车优惠配置 +export function saveChargeParkingDiscount(data) { + return request({ + url: '/pile/station/saveChargeParkingDiscount', + method: 'post', + data: data, + }) +} + +// 查询站点充电停车优惠配置 +export function getChargeParkingDiscount(stationId) { + return request({ + url: '/pile/station/getChargeParkingDiscount/' + stationId, + method: 'get', + }) +} diff --git a/jsowell-ui/src/utils/index.js b/jsowell-ui/src/utils/index.js index 648f75dde..1e4d5ceb6 100644 --- a/jsowell-ui/src/utils/index.js +++ b/jsowell-ui/src/utils/index.js @@ -15,6 +15,10 @@ export function formatDate(cellValue) { return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds } +export function formatTimeStr(time) { + return `${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}`; +} + /** * @param {number} time * @param {string} option diff --git a/jsowell-ui/src/views/pile/station/detail.vue b/jsowell-ui/src/views/pile/station/detail.vue index 41652151b..c287f90d0 100644 --- a/jsowell-ui/src/views/pile/station/detail.vue +++ b/jsowell-ui/src/views/pile/station/detail.vue @@ -193,92 +193,106 @@ 绑定停车平台V2(配置完成后,订单完成将自动下发优惠券) - 编辑参数 - + - - - - - - - - - - 保存 - - - - - - + + + 固定电量 + 固定时长 + - + + - - + + + 减时间(分钟) + 减金额(元) + + - + + + + + + + + 至 + + + + + + + 已跨天(次日 {{ chargeParkingDiscount.endTime }} 结束) + + + + + + + + + + 保存充电停车优惠配置 + + + + + @@ -350,11 +364,12 @@ import { getParkingInfoList, bindParkingPlatform, getRelationByStationId, - updateThirdPartyStationRelation, + updateThirdPartyStationRelation, saveChargeParkingDiscount, } from "@/api/pile/station"; import Whitelist from "@/views/pile/station/stationWhiteList"; import OrderReport from "./orderReport.vue"; import Config from "@/views/pile/station/splitConfig.vue"; +import {formatTime, formatTimeStr} from "@/utils"; export default { dicts: ["third_party_type"], @@ -378,6 +393,15 @@ export default { prefix: "", }, parkingInfo: {}, + chargeParkingDiscount:{ + stationId: "", + conditionType: "", + conditionValue: "", + discountType: "", + discountValue: "", + startTime: "", + endTime: "" + }, parkingInfoList: [], queryGroundLockQrCode: "", dialogTitle: "", @@ -410,6 +434,15 @@ export default { mounted() { this.initializeData(this.activeName); }, + computed: { + // 判断是否跨天 + isCrossDay() { + if (!this.chargeParkingDiscount.startTime || !this.chargeParkingDiscount.endTime) return false + const start = this.timeToMinutes(this.chargeParkingDiscount.startTime) + const end = this.timeToMinutes(this.chargeParkingDiscount.endTime) + return end <= start + } + }, methods: { // 更新页面title显示 updateTitle() { @@ -571,6 +604,21 @@ export default { }); }, + // 时间转换为分钟数 + timeToMinutes(time) { + const [hours, minutes] = time.split(':').map(Number) + return hours * 60 + minutes + }, + + // 保存充电停车配置 + saveChargeParkingDiscount() { + this.chargeParkingDiscount.stationId = this.stationId; + saveChargeParkingDiscount(this.chargeParkingDiscount).then((response) => { + console.log("response", response); + this.$message.success(response.msg); + }) + }, + // 绑定站点与停车平台配置 saveParkingSetting(parkingId) { console.log("parkingId", parkingId, this.stationId); @@ -618,6 +666,7 @@ export default { this.exchange.push(id); }, }, + //监听复选框状态 watch: { checkList: { @@ -644,4 +693,24 @@ export default { ::v-deep .Input .el-input--medium { width: 400px; } +.time-range-picker { + display: flex; + align-items: center; + gap: 10px; +} + +.separator { + color: #606266; + padding: 0 5px; +} + +.cross-day-tip { + color: #e6a23c; + margin-left: 10px; + font-size: 12px; + display: flex; + align-items: center; + gap: 5px; +} +