查询用户常去站点(最近半年)

This commit is contained in:
YAS\29473
2025-03-19 11:53:33 +08:00
parent 96cfa6ce6a
commit e3ce4c13bc
8 changed files with 116 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ import com.jsowell.common.response.RestApiResponse;
import com.jsowell.common.util.SMSUtil;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.MemberPlateNumberRelation;
import com.jsowell.pile.domain.UserFrquentedStationInfo;
import com.jsowell.pile.dto.*;
import com.jsowell.pile.service.MemberBasicInfoService;
import com.jsowell.pile.service.MemberPlateNumberRelationService;
@@ -603,4 +604,26 @@ public class MemberController extends BaseController {
logger.info("查询会员钱包列表 result:{}", response);
return response;
}
/**
* 查询用户常去站点(最近半年)
*/
@GetMapping("/getUserFrquentedStationList")
public RestApiResponse<?> queryUserFrquentedStation(HttpServletRequest request) {
RestApiResponse<?> response;
try {
String memberId = getMemberIdByAuthorization(request);
//查询order_basic_info表,根据member_id,对应的station_id,,然后根据station_id查询pile_station_info表中的站点名称,最后统计每个站点的次数,查询当前时间前半年的记录
List<UserFrquentedStationInfo> list = memberService.queryUserFrquentedStation(memberId);
response = new RestApiResponse<>(ImmutableMap.of("list", list));
} catch (BusinessException e) {
logger.error("查询用户常去站点(最近半年) error", e);
response = new RestApiResponse<>(e.getCode(), e.getMessage());
} catch (Exception e) {
logger.error("查询用户常去站点(最近半年) error", e);
response = new RestApiResponse<>(e);
}
logger.info("查询用户常去站点(最近半年) result:{}", response);
return response;
}
}

View File

@@ -847,4 +847,13 @@ public class MemberService {
public List<MemberWalletVO> queryMemberWalletList(String memberId) {
return memberWalletInfoService.selectByMemberWalletList(memberId);
}
/**
* 查询用户常用充电站
* @param memberId
* @return
*/
public List<UserFrquentedStationInfo> queryUserFrquentedStation(String memberId) {
return orderService.queryUserFrquentedStation(memberId);
}
}

View File

@@ -1514,4 +1514,13 @@ public class OrderService {
public static void main(String[] args) {
}
/**
* 查询用户常用站点
* @param memberId
* @return
*/
public List<UserFrquentedStationInfo> queryUserFrquentedStation(String memberId) {
return orderBasicInfoService.queryUserFrquentedStation(memberId);
}
}

View File

@@ -0,0 +1,28 @@
package com.jsowell.pile.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 用户常去站点
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class UserFrquentedStationInfo {
/**
* 站点id
*/
private String stationId;
/**
* 站点名称
*/
private String stationName;
/**
* 充电次数
*/
private int chargeNum;
}

View File

@@ -3,6 +3,7 @@ package com.jsowell.pile.mapper;
import com.alipay.api.domain.ChargeOrderInfo;
import com.jsowell.pile.domain.OrderBasicInfo;
import com.jsowell.pile.domain.OrderDetail;
import com.jsowell.pile.domain.UserFrquentedStationInfo;
import com.jsowell.pile.dto.*;
import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO;
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO;
@@ -402,4 +403,12 @@ public interface OrderBasicInfoMapper {
* @return
*/
List<OrderVO> selectThirdPartyOrderList(@Param("dto") QueryStartChargeDTO dto);
/**
* 查询用户常用站点信息
* @param memberId
* @return
*/
List<UserFrquentedStationInfo> queryUserFrquentedStation(String memberId);
}

View File

@@ -543,4 +543,11 @@ public interface OrderBasicInfoService{
List<String> tempGetOrderCodes(QueryOrderDTO dto);
void retryRefundOrderList(List<String> orderCoderList);
/**
* 查询用户常用充电站点信息
* @param memberId
* @return
*/
List<UserFrquentedStationInfo> queryUserFrquentedStation(String memberId);
}

View File

@@ -4954,5 +4954,17 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
public List<String> tempGetOrderCodes(QueryOrderDTO dto) {
return orderBasicInfoMapper.tempGetOrderCodes(dto);
}
/**
* 查询用户常用充电站
* @param memberId
* @return
*/
@Override
public List<UserFrquentedStationInfo> queryUserFrquentedStation(String memberId) {
return orderBasicInfoMapper.queryUserFrquentedStation(memberId);
}
}

View File

@@ -3118,4 +3118,23 @@
</if>
</where>
</select>
<select id="queryUserFrquentedStation" resultType="com.jsowell.pile.domain.UserFrquentedStationInfo">
SELECT
obi.station_id AS stationId,
psi.station_name AS stationName,
COUNT(obi.id) AS chargeNum
FROM
order_basic_info obi
JOIN
pile_station_info psi ON obi.station_id = psi.id
WHERE
obi.member_id = #{memberId}
AND obi.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)
GROUP BY
obi.station_id, psi.station_name
ORDER BY
chargeNum DESC;
</select>
</mapper>