mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
新增 华为 请求停止充电、接收停止充电结果接口
This commit is contained in:
@@ -11,8 +11,10 @@ import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||
import com.jsowell.common.enums.thirdparty.huawei.StartFailedReasonEnum;
|
||||
import com.jsowell.common.enums.thirdparty.huawei.StopFailedReasonEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.enums.ykc.StopChargingFailedReasonEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -615,19 +617,65 @@ public class HuaweiServiceV2 {
|
||||
}
|
||||
|
||||
|
||||
public void queryStopCharge(String startChargeSeq) {
|
||||
/**
|
||||
* 请求停止充电
|
||||
* @param startChargeSeq
|
||||
*/
|
||||
public QueryStartChargeVO queryStopCharge(String startChargeSeq) {
|
||||
String requestName = "query_stop_charge";
|
||||
// 通过订单号查询订单信息
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(startChargeSeq);
|
||||
if(orderBasicInfo == null) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("StartChargeSeq", startChargeSeq);
|
||||
jsonObject.put("ConnectorID", orderBasicInfo.getPileConnectorCode());
|
||||
String jsonString = jsonObject.toJSONString();
|
||||
|
||||
// 向华为发送请求
|
||||
// 获取令牌
|
||||
String token = getHuaWeiToken();
|
||||
// 发送请求
|
||||
String result = sendMsg2HuaWei(jsonString, token, requestName);
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
// 转换成 QueryStartChargeVO 对象
|
||||
QueryStartChargeVO vo = JSON.parseObject(result, QueryStartChargeVO.class);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收华为所推送的停止充电结果
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
public String receiveStopChargeResult(ReceiveStopChargeResultVO vo) {
|
||||
String startChargeSeq = vo.getStartChargeSeq();
|
||||
Integer startChargeSeqStat = vo.getStartChargeSeqStat();
|
||||
Integer succStat = vo.getSuccStat();
|
||||
Integer failReasonCode = vo.getFailReason();
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(startChargeSeq);
|
||||
if (orderBasicInfo == null) {
|
||||
return null;
|
||||
}
|
||||
if (succStat == Constants.zero) {
|
||||
// 成功标识为 0-成功,修改订单状态为 2-待结算,具体的订单金额等详情金额,从所推送的订单信息中取
|
||||
orderBasicInfo.setOrderStatus(OrderStatusEnum.STAY_SETTLEMENT.getValue());
|
||||
|
||||
}else {
|
||||
// 若成功标识为失败,则将失败原因记录存库
|
||||
String reason = StopFailedReasonEnum.getReasonByCode(failReasonCode);
|
||||
orderBasicInfo.setReason(reason);
|
||||
}
|
||||
// 统一修改订单
|
||||
orderBasicInfoService.updateOrderBasicInfo(orderBasicInfo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取华为配置信息
|
||||
* @return
|
||||
|
||||
Reference in New Issue
Block a user