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

This commit is contained in:
YAS\29473
2025-03-19 15:02:29 +08:00
parent e3ce4c13bc
commit c910ab609a
8 changed files with 26 additions and 36 deletions

View File

@@ -14,10 +14,11 @@ import com.jsowell.common.response.RestApiResponse;
import com.jsowell.common.util.SMSUtil; import com.jsowell.common.util.SMSUtil;
import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.MemberPlateNumberRelation; import com.jsowell.pile.domain.MemberPlateNumberRelation;
import com.jsowell.pile.domain.UserFrquentedStationInfo; import com.jsowell.pile.domain.UserFrequentedStationInfo;
import com.jsowell.pile.dto.*; import com.jsowell.pile.dto.*;
import com.jsowell.pile.service.MemberBasicInfoService; import com.jsowell.pile.service.MemberBasicInfoService;
import com.jsowell.pile.service.MemberPlateNumberRelationService; import com.jsowell.pile.service.MemberPlateNumberRelationService;
import com.jsowell.pile.service.OrderBasicInfoService;
import com.jsowell.pile.service.PileMerchantInfoService; import com.jsowell.pile.service.PileMerchantInfoService;
import com.jsowell.pile.vo.base.MemberWalletVO; import com.jsowell.pile.vo.base.MemberWalletVO;
import com.jsowell.pile.vo.uniapp.customer.InvoiceTitleVO; import com.jsowell.pile.vo.uniapp.customer.InvoiceTitleVO;
@@ -52,6 +53,8 @@ public class MemberController extends BaseController {
@Autowired @Autowired
private MemberPlateNumberRelationService memberPlateNumberRelationService; private MemberPlateNumberRelationService memberPlateNumberRelationService;
@Autowired
private OrderBasicInfoService orderBasicInfoService;
/** /**
* 下发短信接口 business * 下发短信接口 business
* http://localhost:8080/uniapp/member/sendSMS * http://localhost:8080/uniapp/member/sendSMS
@@ -609,12 +612,12 @@ public class MemberController extends BaseController {
* 查询用户常去站点(最近半年) * 查询用户常去站点(最近半年)
*/ */
@GetMapping("/getUserFrquentedStationList") @GetMapping("/getUserFrquentedStationList")
public RestApiResponse<?> queryUserFrquentedStation(HttpServletRequest request) { public RestApiResponse<?> queryUserFrequentedStation(HttpServletRequest request) {
RestApiResponse<?> response; RestApiResponse<?> response;
try { try {
String memberId = getMemberIdByAuthorization(request); String memberId = getMemberIdByAuthorization(request);
//查询order_basic_info表,根据member_id,对应的station_id,,然后根据station_id查询pile_station_info表中的站点名称,最后统计每个站点的次数,查询当前时间前半年的记录 //查询order_basic_info表,根据member_id,对应的station_id,,然后根据station_id查询pile_station_info表中的站点名称,最后统计每个站点的次数,查询当前时间前半年的记录
List<UserFrquentedStationInfo> list = memberService.queryUserFrquentedStation(memberId); List<UserFrequentedStationInfo> list = orderBasicInfoService.queryUserFrequentedStation(memberId);
response = new RestApiResponse<>(ImmutableMap.of("list", list)); response = new RestApiResponse<>(ImmutableMap.of("list", list));
} catch (BusinessException e) { } catch (BusinessException e) {
logger.error("查询用户常去站点(最近半年) error", e); logger.error("查询用户常去站点(最近半年) error", e);

View File

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

View File

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

View File

@@ -12,7 +12,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Builder @Builder
public class UserFrquentedStationInfo { public class UserFrequentedStationInfo {
/** /**
* 站点id * 站点id
*/ */

View File

@@ -3,7 +3,7 @@ package com.jsowell.pile.mapper;
import com.alipay.api.domain.ChargeOrderInfo; import com.alipay.api.domain.ChargeOrderInfo;
import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.domain.OrderBasicInfo;
import com.jsowell.pile.domain.OrderDetail; import com.jsowell.pile.domain.OrderDetail;
import com.jsowell.pile.domain.UserFrquentedStationInfo; import com.jsowell.pile.domain.UserFrequentedStationInfo;
import com.jsowell.pile.dto.*; import com.jsowell.pile.dto.*;
import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO; import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO;
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO; import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO;
@@ -408,7 +408,9 @@ public interface OrderBasicInfoMapper {
/** /**
* 查询用户常用站点信息 * 查询用户常用站点信息
* @param memberId * @param memberId
* @param startTime
* @param endTime
* @return * @return
*/ */
List<UserFrquentedStationInfo> queryUserFrquentedStation(String memberId); List<UserFrequentedStationInfo> queryUserFrequentedStation(@Param("memberId") String memberId ,@Param("startTime") LocalDateTime startTime ,@Param("endTime") LocalDateTime endTime);
} }

View File

@@ -549,5 +549,5 @@ public interface OrderBasicInfoService{
* @param memberId * @param memberId
* @return * @return
*/ */
List<UserFrquentedStationInfo> queryUserFrquentedStation(String memberId); List<UserFrequentedStationInfo> queryUserFrequentedStation(String memberId);
} }

View File

@@ -4957,13 +4957,15 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
/** /**
* 查询用户常用充电 * 查询用户常用站点信息
* @param memberId * @param memberId
* @return * @return
*/ */
@Override @Override
public List<UserFrquentedStationInfo> queryUserFrquentedStation(String memberId) { public List<UserFrequentedStationInfo> queryUserFrequentedStation(String memberId) {
return orderBasicInfoMapper.queryUserFrquentedStation(memberId); LocalDateTime endTime = LocalDateTime.now();
LocalDateTime startTime = endTime.minusMonths(6);
return orderBasicInfoMapper.queryUserFrequentedStation(memberId, startTime, endTime);
} }
} }

View File

@@ -3119,20 +3119,20 @@
</where> </where>
</select> </select>
<select id="queryUserFrquentedStation" resultType="com.jsowell.pile.domain.UserFrquentedStationInfo"> <select id="queryUserFrequentedStation" resultType="com.jsowell.pile.domain.UserFrequentedStationInfo">
SELECT SELECT
obi.station_id AS stationId, t1.station_id AS stationId,
psi.station_name AS stationName, t2.station_name AS stationName,
COUNT(obi.id) AS chargeNum COUNT(t1.id) AS chargeNum
FROM FROM
order_basic_info obi order_basic_info t1
JOIN JOIN
pile_station_info psi ON obi.station_id = psi.id pile_station_info t2 ON t1.station_id = t2.id
WHERE WHERE
obi.member_id = #{memberId} t1.member_id = #{memberId}
AND obi.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH) AND t1.create_time BETWEEN #{startTime} AND #{endTime}
GROUP BY GROUP BY
obi.station_id, psi.station_name t1.station_id, t2.station_name
ORDER BY ORDER BY
chargeNum DESC; chargeNum DESC;
</select> </select>