mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-06 02:50:13 +08:00
update 电单车协议
This commit is contained in:
@@ -342,8 +342,14 @@ public class OrderService {
|
||||
if (StringUtils.equals(orderInfo.getOrderStatus(), OrderStatusEnum.ORDER_COMPLETE.getValue())) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_COMPLETE_ERROR);
|
||||
}
|
||||
// 校验订单中的会员与操作会员是否一致
|
||||
if (!StringUtils.equals(orderInfo.getMemberId(), dto.getMemberId())) {
|
||||
|
||||
/*
|
||||
校验是否有权限操作该订单, 否则抛出异常
|
||||
只有会员本人, 该桩的管理员可以操作
|
||||
*/
|
||||
boolean permissionFlag = StringUtils.equals(orderInfo.getMemberId(), dto.getMemberId())
|
||||
|| UserUtils.checkStationAuth(orderInfo.getStationId()); // false无权限, true有权限
|
||||
if (!permissionFlag) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_MEMBER_NOT_MATCH_ERROR);
|
||||
}
|
||||
// 判断该桩是否推送了第三方站点(需要我方平台发送启动指令的,如:华为平台)
|
||||
@@ -361,32 +367,7 @@ public class OrderService {
|
||||
// 发送停止指令
|
||||
pileRemoteService.remoteStopCharging(orderInfo.getPileSn(), orderInfo.getConnectorCode(), orderInfo.getTransactionCode());
|
||||
}
|
||||
|
||||
// List<ThirdPartyStationRelationVO> relationInfoList = thirdPartyStationRelationService.getRelationInfoList(orderInfo.getStationId());
|
||||
//
|
||||
// if (CollectionUtils.isNotEmpty(relationInfoList)) {
|
||||
// for (ThirdPartyStationRelationVO vo : relationInfoList) {
|
||||
// String startMode = vo.getStartMode();
|
||||
// if (StringUtils.equals(Constants.ONE, startMode)) {
|
||||
// // 启动类型为 1 的即为对接了类似华为平台,需要调用第三方平台的统一停止充电接口
|
||||
// ThirdPartyCommonStopChargeDTO commonStopChargeDTO = new ThirdPartyCommonStopChargeDTO();
|
||||
// commonStopChargeDTO.setThirdPartyType(vo.getThirdPartyType());
|
||||
// commonStopChargeDTO.setOrderBasicInfo(orderInfo);
|
||||
// // 调用统一停止充电接口
|
||||
// String result = commonService.commonStopCharge(commonStopChargeDTO);
|
||||
// log.info("订单:{}调用第三方平台统一停止充电接口,调用结果 SuccStat:{}", orderInfo.getOrderCode(), result);
|
||||
// }else {
|
||||
// // 发送停止指令
|
||||
// pileRemoteService.remoteStopCharging(orderInfo.getPileSn(), orderInfo.getConnectorCode(), orderInfo.getTransactionCode());
|
||||
// }
|
||||
// }
|
||||
// }else {
|
||||
// // 发送停止指令
|
||||
// pileRemoteService.remoteStopCharging(orderInfo.getPileSn(), orderInfo.getConnectorCode(), orderInfo.getTransactionCode());
|
||||
// }
|
||||
// 发送停止指令
|
||||
// pileRemoteService.remoteStopCharging(orderInfo.getPileSn(), orderInfo.getConnectorCode(), orderInfo.getTransactionCode());
|
||||
log.info("用户停止充电, orderCode:{}, transactionCode:{}, 发送停机指令成功", dto.getOrderCode(), orderInfo.getTransactionCode());
|
||||
log.info("主动停止充电, orderCode:{}, transactionCode:{}, 发送停机指令成功", dto.getOrderCode(), orderInfo.getTransactionCode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.PileMerchantInfo;
|
||||
import com.jsowell.pile.dto.ApplyRefundDTO;
|
||||
import com.jsowell.pile.dto.ManualSettlementDTO;
|
||||
import com.jsowell.pile.dto.QueryMerchantOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.service.PileMerchantInfoService;
|
||||
import com.jsowell.pile.service.PileStationInfoService;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.util.UserUtils;
|
||||
import com.jsowell.pile.vo.web.OrderListVO;
|
||||
import com.jsowell.service.OrderService;
|
||||
@@ -26,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
@@ -203,4 +203,25 @@ public class OrderBasicInfoController extends BaseController {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后管停止充电
|
||||
* http://localhost:8080/uniapp/order/stopCharging
|
||||
*/
|
||||
@PostMapping ("/stopChargingForWeb")
|
||||
public RestApiResponse<?> stopChargingForWeb(HttpServletRequest request, @RequestBody StopChargingDTO dto) {
|
||||
logger.info("后管停止充电 param:{}", JSON.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
orderService.stopCharging(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("后管停止充电 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("后管停止充电 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_STOP_CHARGING_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ import com.jsowell.pile.service.PileStationInfoService;
|
||||
import com.jsowell.pile.vo.base.LoginUserDetailVO;
|
||||
import com.jsowell.pile.vo.base.MerchantInfoVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -33,7 +33,6 @@ import java.util.stream.Collectors;
|
||||
public class UserUtils {
|
||||
|
||||
// 2.注入想引用的对象的静态实例
|
||||
private static MemberBasicInfoService memberBasicInfoService;
|
||||
|
||||
private static PileMerchantInfoService pileMerchantInfoService;
|
||||
|
||||
@@ -43,7 +42,6 @@ public class UserUtils {
|
||||
@Autowired
|
||||
public UserUtils(MemberBasicInfoService memberBasicInfoService, PileMerchantInfoService pileMerchantInfoService,
|
||||
PileStationInfoService pileStationInfoService) {
|
||||
UserUtils.memberBasicInfoService = memberBasicInfoService;
|
||||
UserUtils.pileMerchantInfoService = pileMerchantInfoService;
|
||||
UserUtils.pileStationInfoService = pileStationInfoService;
|
||||
}
|
||||
@@ -195,4 +193,21 @@ public class UserUtils {
|
||||
LoginUserDetailVO loginUserDetail = UserUtils.getLoginUserDetail();
|
||||
return loginUserDetail.getFirstMerchantIdList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验当前登录用户是否有操作站点权限
|
||||
* @param stationId 站点id
|
||||
* @return boolean true:有权限,false:无权限
|
||||
*/
|
||||
public static boolean checkStationAuth(String stationId) {
|
||||
AuthorizedDeptVO authorizedMap = UserUtils.getAuthorizedMap();
|
||||
if (authorizedMap == null) {
|
||||
return false;
|
||||
}
|
||||
if (CollectionUtils.isEmpty(authorizedMap.getStationDeptIds())) {
|
||||
return false;
|
||||
}
|
||||
List<String> list = pileStationInfoService.queryByStationDeptIds(authorizedMap.getStationDeptIds());
|
||||
return list.contains(stationId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user