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:
@@ -1,9 +1,12 @@
|
||||
package com.jsowell.thirdparty.lianlian.service;
|
||||
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.vo.lianlian.PushStationFeeVO;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface LianLianService {
|
||||
@@ -154,6 +157,15 @@ public interface LianLianService {
|
||||
*/
|
||||
String pushPileChargeStatusChange(String orderCode);
|
||||
|
||||
|
||||
/**
|
||||
* 推送站点费率
|
||||
* @param stationId
|
||||
* @return
|
||||
*/
|
||||
String pushStationFee(String stationId);
|
||||
|
||||
|
||||
/**
|
||||
* 生成令牌
|
||||
* @param dto
|
||||
|
||||
@@ -28,13 +28,12 @@ import com.jsowell.pile.domain.*;
|
||||
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.base.MerchantInfoVO;
|
||||
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
|
||||
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
|
||||
import com.jsowell.pile.vo.base.*;
|
||||
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
|
||||
import com.jsowell.pile.vo.lianlian.PushStationFeeVO;
|
||||
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import com.jsowell.thirdparty.common.CommonService;
|
||||
@@ -57,6 +56,8 @@ import org.springframework.stereotype.Service;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -386,8 +387,8 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String dataSecret = "KnGhAb88GtUEPb0j"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO
|
||||
String dataSecretIV = "XZ4wURhuo2y8s4ZS"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR
|
||||
String signSecret = "sRjCDeokckFGpYpA"; // sRjCDeokckFGpYpA
|
||||
String dataString = "pZLkdIJdqGhgVcTEhSQXv7VBj9jRQ+Cjy49RPHeuFkHPOx+D8XLNGFhB/6ZdNDx3D3NEjNx3ua0sTLGv3bC5PnW8XjG0YslIPmPIjasXcBUTWCF83VKZ6/QrY0QgRJD4MpY3tedlj\n" +
|
||||
"icvZVFX2l7A0pH4Iy635arhR5y2k3WnPOdzLCuLDaSKItL836PGHorwOyrh4ETt+fXM/7aaDzSA8NvrzvhB6wdy7Ffob7ri8o9IXx5MQg2ddgJoIqsKxrwE2TrQzXNw5skCmXcxgPrfXyHDGEmw/wQUrxvkAX3tHXobxr8d+R2/YBWL955H+3yyK5rTMxd2xNhX80zKtt3ejBMQ45cCvda//lO2q+Rsob5qqCyAfx+1xREl37/QEPDg3CXpxe/Me4y57RvSXhKHM65lyMSBmaNNZB+KQvZ7opY=";
|
||||
String dataString = "pZLkdIJdqGhgVcTEhSQXv3cbkBYiaI4Wk0SOKEaKbzMowLZ/Qvpy1ZeMZ+yEWhkHwn8oZwQhuIUMWxYmIXgnDNRcHU6sNW8LPbQOpB1qhfFS398c+sSU2rlv/I7kqsCJntM3Sn\n" +
|
||||
"NV5SKdNtKX0gzFpsO0pl0ybHX3E6UyArdIqvhDmAbiw78/RwQRxGYsfk/cFW2PPhynTGc2ydZOb6TYFGgAh0RlHND17d3p5S4A3UJbM+mM4R4Nk2FeNJ7LESLfzDvt6RBUVOKlhl+yfzQypSSxj9X6GGAA4GZavmUUVXQwRe1fWsEqapYH2gL9mHPhg2+tNtVJlMju4iHhCftNFJBRsVpGfwJuvU0EUpo4cTm/YZ4bs5qAIC+SiLmKSmtPAL19GxPJ5hHGz2hNsCuL3rUc+cfYSfM0QKzZc6SwpikT2uwgPUy2Dq1T7POq95/4gsHu1ftW42MoG4exjtT/W74lUl3xibeLG+RqBSSWr8tDlRqQaTlz1GXYQcFG8vWREnBFuWz9NfNepN8ps0Xq7/Pzv7LHcTpAs0y1tWLo0GmYG6z32IOK9zqPd9DtAyBvW9bs5xhYVXkTzNN/g2RaGCpo3KDuq0uVRUIO0+1WVVdA6P/4jpTZ3Sc9GhtS4zYZ5YCTLbt0tEv8CUtodzmSdvbBMWUr0KGlS0lNq7ztAkJ+NprzC5Tvb4HG/pXVEwXz";
|
||||
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
@@ -1732,6 +1733,75 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送站点费率
|
||||
* @param stationId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String pushStationFee(String stationId) {
|
||||
PushStationFeeVO vo = new PushStationFeeVO();
|
||||
List<PushStationFeeVO
|
||||
.ChargeFeeDetail> chargeFeeDetailList = new ArrayList<>();
|
||||
PushStationFeeVO
|
||||
.ChargeFeeDetail chargeFeeDetail = null;
|
||||
// 根据站点 id 查询出正在使用的计费模板详情
|
||||
List<BillingPriceVO> billingPriceVOList = pileBillingTemplateService.queryBillingPrice(stationId);
|
||||
// 查询设备列表
|
||||
List<PileInfoVO> pileDetailVOS = pileBasicInfoService.queryPileDetailList(Lists.newArrayList(stationId));
|
||||
vo.setOperatorId(Constants.OPERATORID_LIANLIAN);
|
||||
vo.setStationId(stationId);
|
||||
for (PileInfoVO pileInfoVO : pileDetailVOS) {
|
||||
for (BillingPriceVO billingPriceVO : billingPriceVOList) {
|
||||
chargeFeeDetail = new PushStationFeeVO.ChargeFeeDetail();
|
||||
|
||||
chargeFeeDetail.setEquipmentType(Integer.parseInt(pileInfoVO.getSpeedType()));
|
||||
String startTime = billingPriceVO.getStartTime();
|
||||
String endTime = billingPriceVO.getEndTime();
|
||||
|
||||
chargeFeeDetail.setStartTime(startTime);
|
||||
chargeFeeDetail.setEndTime(endTime);
|
||||
chargeFeeDetail.setElectricityFee(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(2, BigDecimal.ROUND_DOWN));
|
||||
chargeFeeDetail.setServiceFee(new BigDecimal(billingPriceVO.getServicePrice()).setScale(2, BigDecimal.ROUND_DOWN));
|
||||
|
||||
chargeFeeDetailList.add(chargeFeeDetail);
|
||||
}
|
||||
}
|
||||
vo.setChargeFeeDetail(chargeFeeDetailList);
|
||||
|
||||
// 通过站点id查询相关配置信息
|
||||
ThirdPartyStationRelation relation = new ThirdPartyStationRelation();
|
||||
relation.setStationId(Long.parseLong(stationId));
|
||||
ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation);
|
||||
// ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderBasicInfo.getStationId()));
|
||||
if (relationInfo == null) {
|
||||
return null;
|
||||
}
|
||||
String operatorId = relationInfo.getOperatorId();
|
||||
String operatorSecret = relationInfo.getOperatorSecret();
|
||||
String signSecret = relationInfo.getSignSecret();
|
||||
String dataSecret = relationInfo.getDataSecret();
|
||||
String dataSecretIv = relationInfo.getDataSecretIv();
|
||||
String urlAddress = relationInfo.getUrlAddress();
|
||||
|
||||
String url = urlAddress + "notification_stationFee";
|
||||
|
||||
// 获取令牌
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("StationFee", vo);
|
||||
String jsonString = JSONObject.toJSONString(json);
|
||||
// 发送请求
|
||||
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 生成令牌
|
||||
* @param dto
|
||||
@@ -1740,9 +1810,9 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> generateToken(CommonParamsDTO dto) throws UnsupportedEncodingException {
|
||||
String operatorID = dto.getOperatorID();
|
||||
// 通过operatorID 查出 operatorSecret
|
||||
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorID);
|
||||
String operatorId = dto.getOperatorID();
|
||||
// 通过operatorId 查出 operatorSecret
|
||||
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
|
||||
if (platformConfig == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -1772,13 +1842,13 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
|
||||
// 生成token返回 eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI0MjUwMTA3NjUiLCJpYXQiOjE2ODUwOTcxMTYsInN1YiI6IjEyMzEyMzEyMzEyM2FhYWEiLCJleHAiOjY4NjkwOTcxMTZ9.NyxOUIZmgsqtfex7oiMRR2LaWePTA56WHVMXIkWWt2w
|
||||
long ttlMillis = 60 * 60 * 24 * 1000;
|
||||
String token = JWTUtils.createToken(operatorID, operatorSecret, ttlMillis);
|
||||
String token = JWTUtils.createToken(operatorId, operatorSecret, ttlMillis);
|
||||
System.out.println("生成的token:" + token);
|
||||
|
||||
// 组装返回参数
|
||||
AccessTokenVO vo = new AccessTokenVO();
|
||||
vo.setAccessToken(token);
|
||||
vo.setOperatorID(operatorID);
|
||||
vo.setOperatorID(operatorId);
|
||||
vo.setTokenAvailableTime((int) (ttlMillis / 1000));
|
||||
vo.setFailReason(0);
|
||||
vo.setSuccStat(0);
|
||||
|
||||
Reference in New Issue
Block a user