新增 查询停车优免信息列表接口

This commit is contained in:
Lemon
2026-03-20 09:21:41 +08:00
parent 89efe8b2a9
commit c14def6a39
5 changed files with 187 additions and 0 deletions

View File

@@ -1,10 +1,13 @@
package com.jsowell.api.uniapp.business;
import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.core.page.PageResponse;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.pile.dto.MerchantOrderReportDTO;
import com.jsowell.pile.dto.ParkingCouponRecordQueryDTO;
import com.jsowell.pile.service.BusinessFinancialService;
import com.jsowell.pile.vo.web.MerchantOrderReportVO;
import org.apache.commons.lang3.StringUtils;
@@ -56,4 +59,32 @@ public class BusinessFinancialController extends BaseController {
}
return response;
}
/**
* 查询停车优免记录
*
* @param dto 查询参数
* @return 优免记录列表
*/
@PostMapping("/parkingCouponRecords")
public RestApiResponse<?> queryParkingCouponRecords(@RequestBody ParkingCouponRecordQueryDTO dto) {
logger.info("查询停车优免记录 params:{}", JSONObject.toJSONString(dto));
RestApiResponse<?> response;
try {
if (dto == null) {
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
}
PageResponse result = businessFinancialService.queryParkingCouponRecords(dto);
response = new RestApiResponse<>(result);
logger.info("查询停车优免记录成功 total:{}", result.getTotal());
} catch (BusinessException e) {
logger.warn("查询停车优免记录业务异常 code:{}, message:{}", e.getCode(), e.getMessage(), e);
response = new RestApiResponse<>(e.getCode(), e.getMessage());
} catch (Exception e) {
logger.error("查询停车优免记录系统异常", e);
response = new RestApiResponse<>(e);
}
return response;
}
}

View File

@@ -1,7 +1,9 @@
package com.jsowell.pile.mapper;
import com.jsowell.pile.domain.CarCouponRecord;
import com.jsowell.pile.dto.ParkingCouponRecordQueryDTO;
import com.jsowell.pile.vo.uniapp.customer.ParkingOrderVO;
import com.jsowell.pile.vo.web.ParkingCouponRecordVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@@ -76,4 +78,12 @@ public interface CarCouponRecordMapper {
* @return
*/
List<ParkingOrderVO> queryParkingOrderList(@Param("memberId") String memberId);
/**
* 分页查询停车优免记录(联表查询站点名称和优免信息)
*
* @param queryDTO 查询条件
* @return 停车优免记录列表
*/
List<ParkingCouponRecordVO> selectParkingCouponRecordList(ParkingCouponRecordQueryDTO queryDTO);
}

View File

@@ -1,8 +1,19 @@
package com.jsowell.pile.service;
import com.jsowell.common.core.page.PageResponse;
import com.jsowell.pile.dto.MerchantOrderReportDTO;
import com.jsowell.pile.dto.ParkingCouponRecordQueryDTO;
import com.jsowell.pile.vo.web.MerchantOrderReportVO;
import com.jsowell.pile.vo.web.ParkingCouponRecordVO;
public interface BusinessFinancialService {
MerchantOrderReportVO getMyWallet(MerchantOrderReportDTO dto);
/**
* 分页查询停车优免记录
*
* @param dto 查询条件
* @return 分页结果
*/
PageResponse queryParkingCouponRecords(ParkingCouponRecordQueryDTO dto);
}

View File

@@ -1,18 +1,28 @@
package com.jsowell.pile.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.jsowell.adapay.service.AdapayService;
import com.jsowell.adapay.vo.AdapayAccountBalanceVO;
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
import com.jsowell.common.core.page.PageResponse;
import com.jsowell.pile.dto.MerchantOrderReportDTO;
import com.jsowell.pile.dto.ParkingCouponRecordQueryDTO;
import com.jsowell.pile.mapper.CarCouponRecordMapper;
import com.jsowell.pile.service.BusinessFinancialService;
import com.jsowell.pile.service.ClearingWithdrawInfoService;
import com.jsowell.pile.service.PileStationInfoService;
import com.jsowell.pile.service.SettleOrderReportService;
import com.jsowell.pile.util.UserUtils;
import com.jsowell.pile.vo.web.MerchantOrderReportVO;
import com.jsowell.pile.vo.web.ParkingCouponRecordVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
/**
* 运营端小程序财务相关Service
@@ -30,6 +40,12 @@ public class BusinessFinancialServiceImpl implements BusinessFinancialService {
@Autowired
private ClearingWithdrawInfoService clearingWithdrawInfoService;
@Autowired
private CarCouponRecordMapper carCouponRecordMapper;
@Autowired
private PileStationInfoService pileStationInfoService;
/**
* 我的钱包查询
* @param dto
@@ -77,4 +93,59 @@ public class BusinessFinancialServiceImpl implements BusinessFinancialService {
return result;
}
/**
* 分页查询停车优免记录
*
* @param dto 查询条件
* @return 分页结果
*/
@Override
public PageResponse queryParkingCouponRecords(ParkingCouponRecordQueryDTO dto) {
// 设置默认分页参数
if (dto.getPageNum() == null || dto.getPageNum() <= 0) {
dto.setPageNum(1);
}
if (dto.getPageSize() == null || dto.getPageSize() <= 0) {
dto.setPageSize(10);
}
// 获取当前登录用户的站点权限
if (dto.getStationIds() == null || dto.getStationIds().isEmpty()) {
try {
AuthorizedDeptVO authorizedMap = UserUtils.getAuthorizedMap();
if (authorizedMap != null) {
// 判断用户角色类型
if (authorizedMap.getStationDeptIds() != null && !authorizedMap.getStationDeptIds().isEmpty()) {
// 站点管理员根据站点部门ID查询站点
dto.setStationIds(pileStationInfoService.queryByStationDeptIds(authorizedMap.getStationDeptIds()));
} else if (authorizedMap.getMerchantDeptIds() != null && !authorizedMap.getMerchantDeptIds().isEmpty()) {
// 运营商管理员根据运营商部门ID查询站点
dto.setStationIds(pileStationInfoService.getStationIdsByMerchantIds(authorizedMap.getMerchantDeptIds()));
}
// 平台账号不设置站点ID限制可查询所有站点
}
} catch (Exception e) {
log.warn("获取当前登录用户站点权限失败", e);
}
}
// 使用 PageHelper 分页
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
// 查询列表
List<ParkingCouponRecordVO> list = carCouponRecordMapper.selectParkingCouponRecordList(dto);
// 构建 PageInfo
PageInfo<ParkingCouponRecordVO> pageInfo = new PageInfo<>(list);
// 构建 PageResponse
return PageResponse.builder()
.pageNum(dto.getPageNum())
.pageSize(dto.getPageSize())
.list(pageInfo.getList())
.pages(pageInfo.getPages())
.total(pageInfo.getTotal())
.build();
}
}

View File

@@ -15,6 +15,24 @@
<result property="delFlag" column="del_flag" />
</resultMap>
<resultMap type="com.jsowell.pile.vo.web.ParkingCouponRecordVO" id="ParkingCouponRecordVOResult">
<result property="id" column="id" />
<result property="orderCode" column="order_code" />
<result property="stationId" column="station_id" />
<result property="stationName" column="station_name" />
<result property="plateNumber" column="plate_number" />
<result property="returnCode" column="return_code" />
<result property="returnMsg" column="return_msg" />
<result property="parkingPlatformId" column="parking_platform_id" />
<result property="conditionType" column="condition_type" />
<result property="conditionValue" column="condition_value" />
<result property="discountType" column="discount_type" />
<result property="discountValue" column="discount_value" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectCarCouponRecordVo">
select id, order_code, station_id, plate_number, return_code, return_msg, create_time, del_flag from car_coupon_record
</sql>
@@ -107,4 +125,50 @@
t1.del_flag = '0'
AND t2.member_id = #{memberId,jdbcType=VARCHAR}
</select>
<!-- 分页查询停车优免记录(联表查询站点名称和优免信息) -->
<select id="selectParkingCouponRecordList" parameterType="com.jsowell.pile.dto.ParkingCouponRecordQueryDTO" resultMap="ParkingCouponRecordVOResult">
SELECT
ccr.id,
ccr.order_code,
ccr.station_id,
psi.station_name,
ccr.plate_number,
ccr.return_code,
ccr.return_msg,
cpd.parking_platform_id,
cpd.condition_type,
cpd.condition_value,
cpd.discount_type,
cpd.discount_value,
cpd.start_time,
cpd.end_time,
DATE_FORMAT(ccr.create_time, '%Y-%m-%d %H:%i:%s') AS create_time
FROM
car_coupon_record ccr
INNER JOIN pile_station_info psi ON ccr.station_id = psi.id
LEFT JOIN charge_parking_discount cpd ON ccr.station_id = cpd.station_id AND cpd.del_flag = '0'
<where>
ccr.del_flag = '0'
<if test="stationId != null">
AND ccr.station_id = #{stationId}
</if>
<if test="stationIds != null and stationIds.size() > 0">
AND ccr.station_id IN
<foreach collection="stationIds" item="stationId" open="(" separator="," close=")">
#{stationId}
</foreach>
</if>
<if test="plateNumber != null and plateNumber != ''">
AND ccr.plate_number LIKE CONCAT('%', #{plateNumber}, '%')
</if>
<if test="orderCode != null and orderCode != ''">
AND ccr.order_code = #{orderCode}
</if>
<if test="merchantId != null and merchantId != ''">
AND psi.merchant_id = #{merchantId}
</if>
</where>
ORDER BY ccr.create_time DESC
</select>
</mapper>