配置充电停车优惠

This commit is contained in:
Guoqs
2025-02-17 16:15:54 +08:00
parent f7057f925f
commit bf673bc5bf
9 changed files with 252 additions and 106 deletions

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -11,8 +11,8 @@
<result column="condition_value" jdbcType="VARCHAR" property="conditionValue" />
<result column="discount_type" jdbcType="VARCHAR" property="discountType" />
<result column="discount_value" jdbcType="VARCHAR" property="discountValue" />
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
<result column="start_time" jdbcType="TIME" property="startTime" />
<result column="end_time" jdbcType="TIME" property="endTime" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
@@ -146,10 +146,10 @@
discount_value = #{discountValue,jdbcType=VARCHAR},
</if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIMESTAMP},
start_time = #{startTime,jdbcType=TIME},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIMESTAMP},
end_time = #{endTime,jdbcType=TIME},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
@@ -218,14 +218,14 @@
<trim prefix="start_time = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.startTime != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.startTime,jdbcType=TIMESTAMP}
when id = #{item.id,jdbcType=INTEGER} then #{item.startTime,jdbcType=TIME}
</if>
</foreach>
</trim>
<trim prefix="end_time = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.endTime != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.endTime,jdbcType=TIMESTAMP}
when id = #{item.id,jdbcType=INTEGER} then #{item.endTime,jdbcType=TIME}
</if>
</foreach>
</trim>
@@ -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})
</foreach>
@@ -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},
</if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIMESTAMP},
start_time = #{startTime,jdbcType=TIME},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIMESTAMP},
end_time = #{endTime,jdbcType=TIME},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},

View File

@@ -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',
})
}

View File

@@ -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

View File

@@ -193,92 +193,106 @@
<el-card style="margin-bottom: 10px">
<h2>绑定停车平台V2(配置完成后订单完成将自动下发优惠券)</h2>
<el-button
icon="el-icon-edit"
size="big"
@click="parkingOpenEdit"
v-has-permi="['pile:station:edit']"
>编辑参数
</el-button>
<el-form
ref="parkingForm"
:model="parkingInfo"
:model="chargeParkingDiscount"
label-position="right"
label-width="200px"
style="margin-top: 10px"
>
<!-- 新增规则配置部分 -->
<el-row>
<el-col :span="5">
<el-form-item label="停车平台名称:" prop="type">
<el-select
v-model="parkingInfo.parkingName"
placeholder="请选择停车平台名称"
clearable
filterable
style="width: 220px"
:disabled="parkingDisableFlag"
@change="getParkingInfo($event)"
>
<el-option
v-for="item in parkingInfoList"
:key="item.id"
:label="item.parkingName"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item>
<el-button
size="big"
@click="saveParkingSetting(parkingInfo.id)"
v-has-permi="['pile:station:edit']"
>
保存
</el-button>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="停车场库secretKey:" prop="secretKey">
<el-input
placeholder="请输入"
v-model="parkingInfo.secretKey"
:disabled="true"
/>
<el-form-item label="条件类型:" prop="conditionType">
<el-radio-group v-model="chargeParkingDiscount.conditionType">
<el-radio :label="1">固定电量</el-radio>
<el-radio :label="2">固定时长</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="停车场库appId:" prop="appId">
<el-form-item label="条件值:" prop="conditionValue">
<el-input
placeholder="请输入"
v-model="parkingInfo.appId"
:disabled="true"
v-model="chargeParkingDiscount.conditionValue"
placeholder="请输入数值"
type="number"
min="0"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="票券id:" prop="couponId">
<el-input
placeholder="请输入"
v-model="parkingInfo.couponId"
:disabled="false"
/>
<el-form-item label="优惠类型:" prop="discountType">
<el-radio-group v-model="chargeParkingDiscount.discountType">
<el-radio :label="1">减时间(分钟)</el-radio>
<el-radio :label="2">减金额()</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="停车场库商户id:" prop="parkingMerchantId">
<el-form-item label="优惠值:" prop="discountValue">
<el-input
placeholder="请输入"
v-model="parkingInfo.parkingMerchantId"
:disabled="false"
v-model="chargeParkingDiscount.discountValue"
placeholder="请输入数值"
type="number"
min="0"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="生效时间:" prop="timeRange">
<!-- 开始时间 -->
<el-time-select
v-model="chargeParkingDiscount.startTime"
placeholder="起始时间"
:picker-options="{
start: '00:00',
step: '00:30',
end: '23:59'
}"
/>
<span class="separator"></span>
<!-- 结束时间 -->
<el-time-select
v-model="chargeParkingDiscount.endTime"
placeholder="结束时间"
:picker-options="{
start: '00:00',
step: '00:30',
end: '23:59',
}"
/>
<!-- 跨天提示 -->
<div v-if="isCrossDay" class="cross-day-tip">
<i class="el-icon-warning"></i>
已跨天次日 {{ chargeParkingDiscount.endTime }} 结束
</div>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item>
<el-button
size="big"
@click="saveChargeParkingDiscount"
v-has-permi="['pile:station:edit']"
>
保存充电停车优惠配置
</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
@@ -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;
}
</style>