diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyBaseController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyBaseController.java new file mode 100644 index 000000000..7f348774e --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyBaseController.java @@ -0,0 +1,72 @@ +package com.jsowell.web.controller.thirdparty; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.jsowell.common.annotation.Anonymous; +import com.jsowell.common.core.controller.BaseController; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.thirdparty.lianlian.common.CommonResult; +import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.util.Cryptos; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * 内蒙古接口 + */ +@Anonymous +@RestController +public class ThirdPartyBaseController extends BaseController { + + @Autowired + @Qualifier("zhongDianLianPlatformServiceImpl") + private ThirdPartyPlatformService platformLogic; + + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + /** + * 获取token接口 + * http://localhost:8080/query_token + */ + @PostMapping("/query_token") + public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { + logger.info("平台请求令牌 params:{}", JSON.toJSONString(dto)); + try { + Map map = platformLogic.queryToken(dto); + logger.info("平台请求令牌 result:{}", JSON.toJSONString(map)); + return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("平台请求令牌接口 异常", e); + return CommonResult.failed("获取token发生异常"); + } + } + + // 解析DTO + protected T parseDto(CommonParamsDTO dto, Class targetClass) { + // 解密 + String operatorId = dto.getOperatorID(); + // 通过operatorId 查出 operatorSecret + // ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId); + ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + if (secretInfoVO == null) { + throw new BusinessException("1", "无此对接平台"); + } + + String dataSecret = secretInfoVO.getTheirDataSecret(); + String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); + + // 解密data 获取参数中的OperatorSecret + String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + return JSONObject.parseObject(decrypt, targetClass); + } + +} diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdpartySecretInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdpartySecretInfoController.java new file mode 100644 index 000000000..dfaba9266 --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdpartySecretInfoController.java @@ -0,0 +1,91 @@ +package com.jsowell.web.controller.thirdparty; + +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.page.TableDataInfo; +import com.jsowell.common.enums.BusinessType; +import com.jsowell.common.util.poi.ExcelUtil; +import com.jsowell.thirdparty.domain.ThirdpartySecretInfo; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 对接三方平台配置Controller + * + * @author jsowell + * @date 2024-04-18 + */ +@RestController +@RequestMapping("/thirdparty/secret") +public class ThirdpartySecretInfoController extends BaseController { + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + /** + * 查询对接三方平台配置列表 + */ + @PreAuthorize("@ss.hasPermi('thirdparty:secret:list')") + @GetMapping("/list") + public TableDataInfo list(ThirdpartySecretInfo thirdpartySecretInfo) { + startPage(); + List list = thirdpartySecretInfoService.selectThirdpartySecretInfoList(thirdpartySecretInfo); + return getDataTable(list); + } + + /** + * 导出对接三方平台配置列表 + */ + @PreAuthorize("@ss.hasPermi('thirdparty:secret:export')") + @Log(title = "对接三方平台配置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ThirdpartySecretInfo thirdpartySecretInfo) { + List list = thirdpartySecretInfoService.selectThirdpartySecretInfoList(thirdpartySecretInfo); + ExcelUtil util = new ExcelUtil(ThirdpartySecretInfo.class); + util.exportExcel(response, list, "对接三方平台配置数据"); + } + + /** + * 获取对接三方平台配置详细信息 + */ + @PreAuthorize("@ss.hasPermi('thirdparty:secret:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(thirdpartySecretInfoService.selectThirdpartySecretInfoById(id)); + } + + /** + * 新增对接三方平台配置 + */ + @PreAuthorize("@ss.hasPermi('thirdparty:secret:add')") + @Log(title = "对接三方平台配置", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ThirdpartySecretInfo thirdpartySecretInfo) { + return toAjax(thirdpartySecretInfoService.insertThirdpartySecretInfo(thirdpartySecretInfo)); + } + + /** + * 修改对接三方平台配置 + */ + @PreAuthorize("@ss.hasPermi('thirdparty:secret:edit')") + @Log(title = "对接三方平台配置", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ThirdpartySecretInfo thirdpartySecretInfo) { + return toAjax(thirdpartySecretInfoService.updateThirdpartySecretInfo(thirdpartySecretInfo)); + } + + /** + * 删除对接三方平台配置 + */ + @PreAuthorize("@ss.hasPermi('thirdparty:secret:remove')") + @Log(title = "对接三方平台配置", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(thirdpartySecretInfoService.deleteThirdpartySecretInfoByIds(ids)); + } +} diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/neimenggu/NMGController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/neimenggu/NMGController.java index d5fe9681c..fbafee4d2 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/neimenggu/NMGController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/neimenggu/NMGController.java @@ -1,18 +1,14 @@ package com.jsowell.web.controller.thirdparty.neimenggu; import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; import com.jsowell.common.annotation.Anonymous; -import com.jsowell.common.core.controller.BaseController; -import com.jsowell.common.exception.BusinessException; -import com.jsowell.pile.domain.ThirdPartyPlatformConfig; import com.jsowell.pile.dto.QueryOperatorInfoDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; -import com.jsowell.pile.service.ThirdPartyPlatformConfigService; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.common.CommonResult; import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; -import com.jsowell.thirdparty.platform.util.Cryptos; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import com.jsowell.web.controller.thirdparty.ThirdPartyBaseController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.web.bind.annotation.PostMapping; @@ -23,18 +19,18 @@ import org.springframework.web.bind.annotation.RestController; import java.util.Map; /** - * 内蒙古接口 + * 内蒙古自治区充电设施监测服务平台 */ @Anonymous @RestController @RequestMapping("/evcs") -public class NMGController extends BaseController { +public class NMGController extends ThirdPartyBaseController { @Autowired @Qualifier("neiMengGuPlatformServiceImpl") private ThirdPartyPlatformService platformLogic; @Autowired - private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; + private ThirdpartySecretInfoService thirdpartySecretInfoService; /** * 获取token接口 @@ -42,37 +38,17 @@ public class NMGController extends BaseController { */ @PostMapping("/v1/query_token") public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { - logger.info("海南平台请求令牌 params:{}", JSON.toJSONString(dto)); + logger.info("内蒙古平台请求令牌 params:{}", JSON.toJSONString(dto)); try { Map map = platformLogic.queryToken(dto); - logger.info("海南平台请求令牌 result:{}", JSON.toJSONString(map)); + logger.info("内蒙古平台请求令牌 result:{}", JSON.toJSONString(map)); return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("海南平台 请求令牌接口 异常", e); + logger.error("内蒙古平台 请求令牌接口 异常", e); return CommonResult.failed("获取token发生异常"); } } - // 解析DTO - private T parseDto(CommonParamsDTO dto, Class targetClass) { - // 解密 - String operatorId = dto.getOperatorID(); - // 通过operatorId 查出 operatorSecret - ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId); - if (platformConfig == null) { - throw new BusinessException("1", "无此对接平台"); - } - - String operatorSecret = platformConfig.getOperatorSecret(); - String dataSecret = platformConfig.getDataSecret(); - String dataSecretIv = platformConfig.getDataSecretIv(); - String signSecret = platformConfig.getSignSecret(); - - // 解密data 获取参数中的OperatorSecret - String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); - return JSONObject.parseObject(decrypt, targetClass); - } - /** * 查询运营商信息 * 接口名称:supervise_query_operator_info @@ -82,14 +58,14 @@ public class NMGController extends BaseController { */ @PostMapping("/v1/supervise_query_operator_info") public CommonResult queryOperatorInfo(@RequestBody CommonParamsDTO dto) { - logger.info("海南平台查询运营商信息 params:{}", JSON.toJSONString(dto)); + logger.info("内蒙古平台查询运营商信息 params:{}", JSON.toJSONString(dto)); try { QueryOperatorInfoDTO paramDTO = parseDto(dto, QueryOperatorInfoDTO.class); Map map = platformLogic.queryOperatorInfo(paramDTO); - logger.info("海南平台查询运营商信息 result:{}", JSON.toJSONString(map)); + logger.info("内蒙古平台查询运营商信息 result:{}", JSON.toJSONString(map)); return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("海南平台查询运营商信息 异常", e); + logger.error("内蒙古平台查询运营商信息 异常", e); return CommonResult.failed("查询运营商信息发生异常"); } } @@ -103,14 +79,14 @@ public class NMGController extends BaseController { */ @PostMapping("/v1/supervise_query_stations_info") public CommonResult queryStationsInfo(@RequestBody CommonParamsDTO dto) { - logger.info("海南平台查询运营商信息 params:{}", JSON.toJSONString(dto)); + logger.info("内蒙古平台查询运营商信息 params:{}", JSON.toJSONString(dto)); try { QueryStationInfoDTO paramDTO = parseDto(dto, QueryStationInfoDTO.class); Map map = platformLogic.queryStationsInfo(paramDTO); - logger.info("海南平台查询运营商信息 result:{}", JSON.toJSONString(map)); + logger.info("内蒙古平台查询运营商信息 result:{}", JSON.toJSONString(map)); return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("海南平台查询运营商信息 异常", e); + logger.error("内蒙古平台查询运营商信息 异常", e); return CommonResult.failed("查询运营商信息发生异常"); } } @@ -121,19 +97,16 @@ public class NMGController extends BaseController { */ @PostMapping("/v1/supervise_query_station_status") public CommonResult queryStationStatus(@RequestBody CommonParamsDTO dto) { - logger.info("海南平台查询充换电站状态信息 params:{}", JSON.toJSONString(dto)); + logger.info("内蒙古平台查询充换电站状态信息 params:{}", JSON.toJSONString(dto)); try { QueryStationInfoDTO paramDTO = parseDto(dto, QueryStationInfoDTO.class); Map map = platformLogic.queryStationStatus(paramDTO); - logger.info("海南平台查询充换电站状态信息 result:{}", JSON.toJSONString(map)); + logger.info("内蒙古平台查询充换电站状态信息 result:{}", JSON.toJSONString(map)); return CommonResult.success(0, "查询充换电站状态信息成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("海南平台查询充换电站状态信息异常", e); + logger.error("内蒙古平台查询充换电站状态信息异常", e); return CommonResult.failed("查询充换电站状态信息发生异常"); } } - /** - * - */ } diff --git a/jsowell-admin/src/main/resources/application-dev.yml b/jsowell-admin/src/main/resources/application-dev.yml index 63d442743..4f55bc4c1 100644 --- a/jsowell-admin/src/main/resources/application-dev.yml +++ b/jsowell-admin/src/main/resources/application-dev.yml @@ -36,10 +36,10 @@ spring: druid: # 主库数据源 master: -# url: jdbc:mysql://192.168.2.2:3306/jsowell_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 -# username: jsowell_dev - url: jdbc:mysql://192.168.2.2:3306/jsowell_prd_copy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: jsowell_prd_copy + url: jdbc:mysql://192.168.2.2:3306/jsowell_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: jsowell_dev + #url: jdbc:mysql://192.168.2.2:3306/jsowell_prd_copy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + #username: jsowell_prd_copy password: 123456 # 从库数据源 slave: diff --git a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java index e05850ce0..c27012739 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java +++ b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java @@ -36,6 +36,9 @@ public class CacheConstants { // 缓存时间 30天 public static final int cache_expire_time_30d = cache_expire_time_1d * 30; + // 第三方平台密钥配置 + public static final String THIRD_PARTY_SECRET_INFO = "third_party_secret_info:"; + // 保存order_monitor_data public static final String INSERT_ORDER_MONITOR_DATA = "insert_order_monitor_data:"; diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyPlatformConfigMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyPlatformConfigMapper.java index 410501dbf..f9f4c7479 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyPlatformConfigMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyPlatformConfigMapper.java @@ -1,6 +1,7 @@ package com.jsowell.pile.mapper; import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import org.springframework.stereotype.Repository; import java.util.List; @@ -68,4 +69,6 @@ public interface ThirdPartyPlatformConfigMapper { * @return */ ThirdPartyPlatformConfig getInfoByOperatorId(String operatorId); + + ThirdPartySecretInfoVO queryThirdPartySecretInfo(String operatorId); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartySettingInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartySettingInfoService.java index 63a6476d4..1363382d5 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartySettingInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartySettingInfoService.java @@ -1,9 +1,9 @@ package com.jsowell.pile.service; -import java.util.List; - import com.jsowell.pile.domain.ThirdPartySettingInfo; +import java.util.List; + /** * 第三方平台配置Service接口 * @@ -67,18 +67,5 @@ public interface ThirdPartySettingInfoService { */ public int deleteThirdPartySettingInfoById(Long id); - /** - * 根据站点id 查询配置列表 - * - * @param stationId - * @return - */ - public ThirdPartySettingInfo getInfoByStationId(Long stationId); - /** - * 修改站点互联互通配置 - * @param info - * @return - */ - int updateStationSettingInfo(ThirdPartySettingInfo info); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyPlatformConfigServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyPlatformConfigServiceImpl.java index f0dc96cd7..7fbb93f1b 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyPlatformConfigServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyPlatformConfigServiceImpl.java @@ -1,13 +1,14 @@ package com.jsowell.pile.service.impl; -import java.util.List; - import com.jsowell.common.util.DateUtils; +import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.mapper.ThirdPartyPlatformConfigMapper; +import com.jsowell.pile.service.ThirdPartyPlatformConfigService; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.jsowell.pile.mapper.ThirdPartyPlatformConfigMapper; -import com.jsowell.pile.domain.ThirdPartyPlatformConfig; -import com.jsowell.pile.service.ThirdPartyPlatformConfigService; + +import java.util.List; /** * 对接平台配置信息Service业务层处理 @@ -98,4 +99,12 @@ public class ThirdPartyPlatformConfigServiceImpl implements ThirdPartyPlatformCo public ThirdPartyPlatformConfig getInfoByOperatorId(String operatorId) { return thirdPartyPlatformConfigMapper.getInfoByOperatorId(operatorId); } + + /** + * 查询第三方平台配置的密钥信息 + * @return + */ + public ThirdPartySecretInfoVO queryThirdPartySecretInfo(String operatorId) { + return thirdPartyPlatformConfigMapper.queryThirdPartySecretInfo(operatorId); + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java index c1760973c..fc13ec364 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java @@ -1,13 +1,13 @@ package com.jsowell.pile.service.impl; -import java.util.List; - import com.jsowell.common.util.DateUtils; +import com.jsowell.pile.domain.ThirdPartySettingInfo; +import com.jsowell.pile.mapper.ThirdPartySettingInfoMapper; +import com.jsowell.pile.service.ThirdPartySettingInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.jsowell.pile.mapper.ThirdPartySettingInfoMapper; -import com.jsowell.pile.domain.ThirdPartySettingInfo; -import com.jsowell.pile.service.ThirdPartySettingInfoService; + +import java.util.List; /** * 第三方平台配置Service业务层处理 @@ -98,33 +98,5 @@ public class ThirdPartySettingInfoServiceImpl implements ThirdPartySettingInfoSe return thirdPartySettingInfoMapper.deleteThirdPartySettingInfoById(id); } - /** - * 根据站点id 查询配置列表 - * - * @param stationId - * @return - */ - @Override - public ThirdPartySettingInfo getInfoByStationId(Long stationId) { - return thirdPartySettingInfoMapper.getInfoByStationId(stationId); - } - /** - * 修改站点互联互通配置 - * @param info - * @return - */ - @Override - public int updateStationSettingInfo(ThirdPartySettingInfo info) { - Long stationId = info.getStationId(); - ThirdPartySettingInfo infoByStationId = getInfoByStationId(stationId); - if (infoByStationId == null) { - // 新增 - return insertThirdPartySettingInfo(info); - }else { - // 修改 - info.setId(infoByStationId.getId()); - return updateThirdPartySettingInfo(info); - } - } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/ThirdPartySecretInfoVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/ThirdPartySecretInfoVO.java new file mode 100644 index 000000000..33e8e6ffe --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/ThirdPartySecretInfoVO.java @@ -0,0 +1,44 @@ +package com.jsowell.pile.vo; + +import lombok.Getter; +import lombok.Setter; + +/** + * 第三方平台配置的密钥信息 + */ +@Getter +@Setter +public class ThirdPartySecretInfoVO { + // 我方的组织机构代码 + private String ourOperatorId; + + // 我方生成的唯一识别密钥 + private String ourOperatorSecret; + + // 我方生成的消息密钥 + private String ourDataSecret; + + // 我方生成的初始化向量 + private String ourDataSecretIv; + + // 我方生成的签名密钥 + private String ourSigSecret; + + // 对接平台的组织机构代码 + private String theirOperatorId; + + // 对接平台生成的唯一识别密钥 + private String theirOperatorSecret; + + // 对接平台生成的消息密钥 + private String theirDataSecret; + + // 对接平台的初始化向量 + private String theirDataSecretIv; + + // 对接平台生成的签名密钥 + private String theirSigSecret; + + // 对接平台接口前缀 + private String theirUrlPrefix; +} diff --git a/jsowell-pile/src/main/java/com/jsowell/thirdparty/domain/ThirdpartySecretInfo.java b/jsowell-pile/src/main/java/com/jsowell/thirdparty/domain/ThirdpartySecretInfo.java new file mode 100644 index 000000000..5c1678095 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/thirdparty/domain/ThirdpartySecretInfo.java @@ -0,0 +1,234 @@ +package com.jsowell.thirdparty.domain; + +import com.jsowell.common.annotation.Excel; +import com.jsowell.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 对接三方平台配置对象 thirdparty_secret_info + * + * @author jsowell + * @date 2024-04-18 + */ +public class ThirdpartySecretInfo extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private Long id; + + /** + * 对接平台名称 + */ + @Excel(name = "对接平台名称") + private String platformName; + + /** + * 对接平台类型 + */ + @Excel(name = "对接平台类型") + private String platformType; + + /** + * 接口地址前缀 + */ + @Excel(name = "接口地址前缀") + private String urlPrefix; + + /** + * 对接平台标识(使用组织机构代码) + */ + @Excel(name = "对接平台标识", readConverterExp = "使=用组织机构代码") + private String theirOperatorId; + + /** + * 对接平台生成的唯一识别密钥 + */ + @Excel(name = "对接平台生成的唯一识别密钥") + private String theirOperatorSecret; + + /** + * 对接平台生成的消息密钥 + */ + @Excel(name = "对接平台生成的消息密钥") + private String theirDataSecret; + + /** + * 对接平台生成的初始化向量 + */ + @Excel(name = "对接平台生成的初始化向量") + private String theirDataSecretIv; + + /** + * 对接平台生成的签名密钥 + */ + @Excel(name = "对接平台生成的签名密钥") + private String theirSigSecret; + + /** + * 我方生成的唯一识别密钥 + */ + @Excel(name = "我方生成的唯一识别密钥") + private String ourOperatorSecret; + + /** + * 我方生成的消息密钥 + */ + @Excel(name = "我方生成的消息密钥") + private String ourDataSecret; + + /** + * 我方生成的初始化向量 + */ + @Excel(name = "我方生成的初始化向量") + private String ourDataSecretIv; + + /** + * 我方生成的签名密钥 + */ + @Excel(name = "我方生成的签名密钥") + private String ourSigSecret; + + /** + * 删除标识(0-正常;1-删除) + */ + private String delFlag; + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setPlatformName(String platformName) { + this.platformName = platformName; + } + + public String getPlatformName() { + return platformName; + } + + public void setPlatformType(String platformType) { + this.platformType = platformType; + } + + public String getPlatformType() { + return platformType; + } + + public void setUrlPrefix(String urlPrefix) { + this.urlPrefix = urlPrefix; + } + + public String getUrlPrefix() { + return urlPrefix; + } + + public void setTheirOperatorId(String theirOperatorId) { + this.theirOperatorId = theirOperatorId; + } + + public String getTheirOperatorId() { + return theirOperatorId; + } + + public void setTheirOperatorSecret(String theirOperatorSecret) { + this.theirOperatorSecret = theirOperatorSecret; + } + + public String getTheirOperatorSecret() { + return theirOperatorSecret; + } + + public void setTheirDataSecret(String theirDataSecret) { + this.theirDataSecret = theirDataSecret; + } + + public String getTheirDataSecret() { + return theirDataSecret; + } + + public void setTheirDataSecretIv(String theirDataSecretIv) { + this.theirDataSecretIv = theirDataSecretIv; + } + + public String getTheirDataSecretIv() { + return theirDataSecretIv; + } + + public void setTheirSigSecret(String theirSigSecret) { + this.theirSigSecret = theirSigSecret; + } + + public String getTheirSigSecret() { + return theirSigSecret; + } + + public void setOurOperatorSecret(String ourOperatorSecret) { + this.ourOperatorSecret = ourOperatorSecret; + } + + public String getOurOperatorSecret() { + return ourOperatorSecret; + } + + public void setOurDataSecret(String ourDataSecret) { + this.ourDataSecret = ourDataSecret; + } + + public String getOurDataSecret() { + return ourDataSecret; + } + + public void setOurDataSecretIv(String ourDataSecretIv) { + this.ourDataSecretIv = ourDataSecretIv; + } + + public String getOurDataSecretIv() { + return ourDataSecretIv; + } + + public void setOurSigSecret(String ourSigSecret) { + this.ourSigSecret = ourSigSecret; + } + + public String getOurSigSecret() { + return ourSigSecret; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public String getDelFlag() { + return delFlag; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.JSON_STYLE) + .append("id", getId()) + .append("platformName", getPlatformName()) + .append("platformType", getPlatformType()) + .append("urlPrefix", getUrlPrefix()) + .append("theirOperatorId", getTheirOperatorId()) + .append("theirOperatorSecret", getTheirOperatorSecret()) + .append("theirDataSecret", getTheirDataSecret()) + .append("theirDataSecretIv", getTheirDataSecretIv()) + .append("theirSigSecret", getTheirSigSecret()) + .append("ourOperatorSecret", getOurOperatorSecret()) + .append("ourDataSecret", getOurDataSecret()) + .append("ourDataSecretIv", getOurDataSecretIv()) + .append("ourSigSecret", getOurSigSecret()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("delFlag", getDelFlag()) + .toString(); + } +} diff --git a/jsowell-pile/src/main/java/com/jsowell/thirdparty/mapper/ThirdpartySecretInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/thirdparty/mapper/ThirdpartySecretInfoMapper.java new file mode 100644 index 000000000..9d03f2f19 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/thirdparty/mapper/ThirdpartySecretInfoMapper.java @@ -0,0 +1,66 @@ +package com.jsowell.thirdparty.mapper; + +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.thirdparty.domain.ThirdpartySecretInfo; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 对接三方平台配置Mapper接口 + * + * @author jsowell + * @date 2024-04-18 + */ +@Repository +public interface ThirdpartySecretInfoMapper { + /** + * 查询对接三方平台配置 + * + * @param id 对接三方平台配置主键 + * @return 对接三方平台配置 + */ + ThirdpartySecretInfo selectThirdpartySecretInfoById(Long id); + + /** + * 查询对接三方平台配置列表 + * + * @param thirdpartySecretInfo 对接三方平台配置 + * @return 对接三方平台配置集合 + */ + List selectThirdpartySecretInfoList(ThirdpartySecretInfo thirdpartySecretInfo); + + /** + * 新增对接三方平台配置 + * + * @param thirdpartySecretInfo 对接三方平台配置 + * @return 结果 + */ + int insertThirdpartySecretInfo(ThirdpartySecretInfo thirdpartySecretInfo); + + /** + * 修改对接三方平台配置 + * + * @param thirdpartySecretInfo 对接三方平台配置 + * @return 结果 + */ + int updateThirdpartySecretInfo(ThirdpartySecretInfo thirdpartySecretInfo); + + /** + * 删除对接三方平台配置 + * + * @param id 对接三方平台配置主键 + * @return 结果 + */ + int deleteThirdpartySecretInfoById(Long id); + + /** + * 批量删除对接三方平台配置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteThirdpartySecretInfoByIds(Long[] ids); + + ThirdPartySecretInfoVO queryByOperatorId(String theirOperatorId); +} diff --git a/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/ThirdpartySecretInfoService.java b/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/ThirdpartySecretInfoService.java new file mode 100644 index 000000000..8387c1dac --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/ThirdpartySecretInfoService.java @@ -0,0 +1,64 @@ +package com.jsowell.thirdparty.service; + +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.thirdparty.domain.ThirdpartySecretInfo; + +import java.util.List; + +/** + * 对接三方平台配置Service接口 + * + * @author jsowell + * @date 2024-04-18 + */ +public interface ThirdpartySecretInfoService { + /** + * 查询对接三方平台配置 + * + * @param id 对接三方平台配置主键 + * @return 对接三方平台配置 + */ + public ThirdpartySecretInfo selectThirdpartySecretInfoById(Long id); + + /** + * 查询对接三方平台配置列表 + * + * @param thirdpartySecretInfo 对接三方平台配置 + * @return 对接三方平台配置集合 + */ + public List selectThirdpartySecretInfoList(ThirdpartySecretInfo thirdpartySecretInfo); + + /** + * 新增对接三方平台配置 + * + * @param thirdpartySecretInfo 对接三方平台配置 + * @return 结果 + */ + public int insertThirdpartySecretInfo(ThirdpartySecretInfo thirdpartySecretInfo); + + /** + * 修改对接三方平台配置 + * + * @param thirdpartySecretInfo 对接三方平台配置 + * @return 结果 + */ + public int updateThirdpartySecretInfo(ThirdpartySecretInfo thirdpartySecretInfo); + + /** + * 批量删除对接三方平台配置 + * + * @param ids 需要删除的对接三方平台配置主键集合 + * @return 结果 + */ + public int deleteThirdpartySecretInfoByIds(Long[] ids); + + /** + * 删除对接三方平台配置信息 + * + * @param id 对接三方平台配置主键 + * @return 结果 + */ + public int deleteThirdpartySecretInfoById(Long id); + + ThirdPartySecretInfoVO queryByOperatorId(String theirOperatorId); +} diff --git a/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/impl/ThirdpartySecretInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/impl/ThirdpartySecretInfoServiceImpl.java new file mode 100644 index 000000000..d30ef3cac --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/impl/ThirdpartySecretInfoServiceImpl.java @@ -0,0 +1,116 @@ +package com.jsowell.thirdparty.service.impl; + +import com.jsowell.common.constant.CacheConstants; +import com.jsowell.common.core.redis.RedisCache; +import com.jsowell.common.util.DateUtils; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.thirdparty.domain.ThirdpartySecretInfo; +import com.jsowell.thirdparty.mapper.ThirdpartySecretInfoMapper; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Objects; + +/** + * 对接三方平台配置Service业务层处理 + * + * @author jsowell + * @date 2024-04-18 + */ +@Service +public class ThirdpartySecretInfoServiceImpl implements ThirdpartySecretInfoService { + @Autowired + private ThirdpartySecretInfoMapper thirdpartySecretInfoMapper; + + @Autowired + private RedisCache redisCache; + + /** + * 查询对接三方平台配置 + * + * @param id 对接三方平台配置主键 + * @return 对接三方平台配置 + */ + @Override + public ThirdpartySecretInfo selectThirdpartySecretInfoById(Long id) { + return thirdpartySecretInfoMapper.selectThirdpartySecretInfoById(id); + } + + /** + * 查询对接三方平台配置列表 + * + * @param thirdpartySecretInfo 对接三方平台配置 + * @return 对接三方平台配置 + */ + @Override + public List selectThirdpartySecretInfoList(ThirdpartySecretInfo thirdpartySecretInfo) { + return thirdpartySecretInfoMapper.selectThirdpartySecretInfoList(thirdpartySecretInfo); + } + + /** + * 新增对接三方平台配置 + * + * @param thirdpartySecretInfo 对接三方平台配置 + * @return 结果 + */ + @Override + public int insertThirdpartySecretInfo(ThirdpartySecretInfo thirdpartySecretInfo) { + thirdpartySecretInfo.setCreateTime(DateUtils.getNowDate()); + return thirdpartySecretInfoMapper.insertThirdpartySecretInfo(thirdpartySecretInfo); + } + + /** + * 修改对接三方平台配置 + * + * @param thirdpartySecretInfo 对接三方平台配置 + * @return 结果 + */ + @Override + public int updateThirdpartySecretInfo(ThirdpartySecretInfo thirdpartySecretInfo) { + thirdpartySecretInfo.setUpdateTime(DateUtils.getNowDate()); + return thirdpartySecretInfoMapper.updateThirdpartySecretInfo(thirdpartySecretInfo); + } + + /** + * 批量删除对接三方平台配置 + * + * @param ids 需要删除的对接三方平台配置主键 + * @return 结果 + */ + @Override + public int deleteThirdpartySecretInfoByIds(Long[] ids) { + return thirdpartySecretInfoMapper.deleteThirdpartySecretInfoByIds(ids); + } + + /** + * 删除对接三方平台配置信息 + * + * @param id 对接三方平台配置主键 + * @return 结果 + */ + @Override + public int deleteThirdpartySecretInfoById(Long id) { + return thirdpartySecretInfoMapper.deleteThirdpartySecretInfoById(id); + } + + /** + * 查询第三方平台密钥配置信息 + * @param theirOperatorId 第三方平台的组织结构代码 + * @return + */ + @Override + public ThirdPartySecretInfoVO queryByOperatorId(String theirOperatorId) { + // 加缓存 + String redisKey = CacheConstants.THIRD_PARTY_SECRET_INFO + theirOperatorId; + ThirdPartySecretInfoVO result = redisCache.getCacheObject(redisKey); + if (Objects.isNull(result)) { + result = thirdpartySecretInfoMapper.queryByOperatorId(theirOperatorId); + if (Objects.nonNull(result)) { + redisCache.setCacheObject(redisKey, result, CacheConstants.cache_expire_time_1h); + } + } + return result; + } +} diff --git a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyPlatformConfigMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyPlatformConfigMapper.xml index efc7f6251..73a854726 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyPlatformConfigMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyPlatformConfigMapper.xml @@ -110,4 +110,8 @@ where del_flag = '0' and operator_id = #{operatorId,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml index 7dbd71729..a3ccf2623 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml @@ -8,7 +8,6 @@ - @@ -22,12 +21,12 @@ - select id, type, url_address, station_id, operator_id, operator_secret, sign_secret, data_secret, data_secret_IV, create_time, create_by, update_time, update_by, del_flag from thirdparty_setting_info + select id, type, url_address, operator_id, operator_secret, sign_secret, data_secret, data_secret_IV, create_time, create_by, update_time, update_by, del_flag from thirdparty_setting_info - id, type, url_address, station_id, operator_id, operator_secret, sign_secret, data_secret, data_secret_IV, create_time, create_by, update_time, update_by, del_flag + id, type, url_address, operator_id, operator_secret, sign_secret, data_secret, data_secret_IV, create_time, create_by, update_time, update_by, del_flag - select - from thirdparty_setting_info - where station_id = #{stationId,jdbcType=BIGINT} - - + + + and platform_name like concat('%', #{platformName}, '%') + and platform_type = #{platformType} + and url_prefix = #{urlPrefix} + and their_operator_id = #{theirOperatorId} + and their_operator_secret = #{theirOperatorSecret} + and their_data_secret = #{theirDataSecret} + and their_data_secret_iv = #{theirDataSecretIv} + and their_sig_secret = #{theirSigSecret} + and our_operator_secret = #{ourOperatorSecret} + and our_data_secret = #{ourDataSecret} + and our_data_secret_iv = #{ourDataSecretIv} + and our_sig_secret = #{ourSigSecret} + + + + + + + insert into thirdparty_secret_info + + platform_name, + platform_type, + url_prefix, + their_operator_id, + their_operator_secret, + their_data_secret, + their_data_secret_iv, + their_sig_secret, + our_operator_secret, + our_data_secret, + our_data_secret_iv, + our_sig_secret, + create_by, + create_time, + update_by, + update_time, + del_flag, + + + #{platformName}, + #{platformType}, + #{urlPrefix}, + #{theirOperatorId}, + #{theirOperatorSecret}, + #{theirDataSecret}, + #{theirDataSecretIv}, + #{theirSigSecret}, + #{ourOperatorSecret}, + #{ourDataSecret}, + #{ourDataSecretIv}, + #{ourSigSecret}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + + + + + update thirdparty_secret_info + + platform_name = #{platformName}, + platform_type = #{platformType}, + url_prefix = #{urlPrefix}, + their_operator_id = #{theirOperatorId}, + their_operator_secret = #{theirOperatorSecret}, + their_data_secret = #{theirDataSecret}, + their_data_secret_iv = #{theirDataSecretIv}, + their_sig_secret = #{theirSigSecret}, + our_operator_secret = #{ourOperatorSecret}, + our_data_secret = #{ourDataSecret}, + our_data_secret_iv = #{ourDataSecretIv}, + our_sig_secret = #{ourSigSecret}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + + where id = #{id} + + + + delete from thirdparty_secret_info where id = #{id} + + + + delete from thirdparty_secret_info where id in + + #{id} + + + + + \ No newline at end of file diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java index 4cb36422c..0487feee4 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java @@ -148,7 +148,7 @@ public class LianLianServiceImpl implements LianLianService { // 组装联联平台所需要的数据格式 StationInfo info = StationInfo.builder() - .stationID("LC" +dto.getStationId()) + .stationID("LC" + dto.getStationId()) .operatorID(operatorId) // .equipmentOwnerID(Constants.OPERATORID_LIANLIAN) .stationName(pileStationInfo.getStationName()) diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java index e17cc5a02..f2506e2e8 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java @@ -10,11 +10,11 @@ import com.jsowell.common.util.StringUtils; import com.jsowell.pile.dto.*; import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO; import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; +import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Encodes; import com.jsowell.thirdparty.platform.util.GBSignUtils; -import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; -import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO; import java.nio.charset.StandardCharsets; import java.util.*; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java index de0c4919d..9ff6e4816 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java @@ -820,7 +820,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { .map(PileInfoVO::getSpeedType) .collect(Collectors.toSet()); vo.setOperatorId(Constants.OPERATORID_LIANLIAN); - vo.setStationId(stationId); + vo.setStationId("LC" + stationId); for (String equipmentType : equipmentTypeList) { for (BillingPriceVO billingPriceVO : billingPriceVOList) { diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java index ffc06c67f..356691fa1 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java @@ -14,7 +14,6 @@ import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; import com.jsowell.common.util.DateUtils; -import com.jsowell.common.util.JWTUtils; import com.jsowell.common.util.PageUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.OrderBasicInfo; @@ -25,7 +24,6 @@ import com.jsowell.pile.dto.QueryEquipChargeStatusDTO; import com.jsowell.pile.dto.QueryOperatorInfoDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.service.*; -import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.pile.thirdparty.EquipmentInfo; import com.jsowell.pile.util.MerchantUtils; import com.jsowell.pile.vo.base.ConnectorInfoVO; @@ -37,7 +35,6 @@ import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo; import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; -import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.neimenggu.domain.ChargeOrderInfo; @@ -98,49 +95,49 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { * @param dto * @return */ - @Override - public Map queryToken(CommonParamsDTO dto) { - AccessTokenVO vo = new AccessTokenVO(); - // 0:成功;1:失败 - int succStat = 0; - // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 - int failReason = 0; - - String operatorId = dto.getPlatformID(); - // 通过operatorId 查出 operatorSecret - ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId); - if (platformConfig == null) { - failReason = 1; - succStat = 1; - } else { - String operatorSecret = platformConfig.getOperatorSecret(); - String dataSecret = platformConfig.getDataSecret(); - String dataSecretIv = platformConfig.getDataSecretIv(); - // 解密data 获取参数中的OperatorSecret - String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); - String inputOperatorSecret = null; - if (StringUtils.isNotBlank(decrypt)) { - inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret"); - } - // 对比密钥 - if (!StringUtils.equals(operatorSecret, inputOperatorSecret)) { - failReason = 1; - succStat = 1; - } else { - // 生成token - String token = JWTUtils.createToken(operatorId, operatorSecret, JWTUtils.ttlMillis); - vo.setAccessToken(token); - vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); - } - } - // 组装返回参数 - vo.setPlatformId(operatorId); - vo.setFailReason(failReason); - vo.setSuccStat(succStat); - - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, platformConfig); - return resultMap; - } + // @Override + // public Map queryToken(CommonParamsDTO dto) { + // AccessTokenVO vo = new AccessTokenVO(); + // // 0:成功;1:失败 + // int succStat = 0; + // // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 + // int failReason = 0; + // + // String operatorId = dto.getPlatformID(); + // // 通过operatorId 查出 operatorSecret + // ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId); + // if (platformConfig == null) { + // failReason = 1; + // succStat = 1; + // } else { + // String operatorSecret = platformConfig.getOperatorSecret(); + // String dataSecret = platformConfig.getDataSecret(); + // String dataSecretIv = platformConfig.getDataSecretIv(); + // // 解密data 获取参数中的OperatorSecret + // String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + // String inputOperatorSecret = null; + // if (StringUtils.isNotBlank(decrypt)) { + // inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret"); + // } + // // 对比密钥 + // if (!StringUtils.equals(operatorSecret, inputOperatorSecret)) { + // failReason = 1; + // succStat = 1; + // } else { + // // 生成token + // String token = JWTUtils.createToken(operatorId, operatorSecret, JWTUtils.ttlMillis); + // vo.setAccessToken(token); + // vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); + // } + // } + // // 组装返回参数 + // vo.setPlatformId(operatorId); + // vo.setFailReason(failReason); + // vo.setSuccStat(succStat); + // + // Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, platformConfig); + // return resultMap; + // } /** * 查询运营商信息 query_operator_info diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/ThirdPartyPlatformUtils.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/ThirdPartyPlatformUtils.java index 33148f288..d559a514c 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/ThirdPartyPlatformUtils.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/ThirdPartyPlatformUtils.java @@ -3,13 +3,26 @@ package com.jsowell.thirdparty.platform.util; import com.alibaba.fastjson2.JSON; import com.google.common.collect.Maps; import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import org.springframework.stereotype.Component; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +@Component public class ThirdPartyPlatformUtils { + /** + * 生成结果集 + * @param obj 需要返回的数据 + * @param secretInfo 密钥配置信息对象 + * @return 结果集 + */ + public static Map generateResultMap(Object obj, ThirdPartySecretInfoVO secretInfo) { + return generateResultMap(obj, secretInfo.getTheirOperatorSecret(), secretInfo.getTheirDataSecretIv(), secretInfo.getTheirSigSecret()); + } + /** * 生成结果集 * @param obj 需要返回的数据 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/zhongdianlian/service/ZhongDianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/zhongdianlian/service/ZhongDianLianPlatformServiceImpl.java new file mode 100644 index 000000000..619d97275 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/zhongdianlian/service/ZhongDianLianPlatformServiceImpl.java @@ -0,0 +1,78 @@ +package com.jsowell.thirdparty.platform.zhongdianlian.service; + +import com.alibaba.fastjson2.JSON; +import com.jsowell.common.util.JWTUtils; +import com.jsowell.common.util.StringUtils; +import com.jsowell.pile.service.ThirdPartyPlatformConfigService; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; +import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.util.Cryptos; +import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformService { + + @Autowired + private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; + + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + /** + * query_token 获取token,提供给第三方平台使用 + * + * @param dto + * @return + */ + @Override + public Map queryToken(CommonParamsDTO dto) { + AccessTokenVO vo = new AccessTokenVO(); + // 0:成功;1:失败 + int succStat = 0; + // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 + int failReason = 0; + + String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID(); + // 通过operatorId 查出 operatorSecret + // ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + if (thirdPartySecretInfoVO == null) { + failReason = 1; + succStat = 1; + } else { + String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String dataSecret = thirdPartySecretInfoVO.getOurDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv(); + // 解密data 获取参数中的OperatorSecret + String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + String inputOperatorSecret = null; + if (StringUtils.isNotBlank(decrypt)) { + inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret"); + } + // 对比密钥 + if (!StringUtils.equals(theirOperatorSecret, inputOperatorSecret)) { + failReason = 1; + succStat = 1; + } else { + // 生成token + String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis); + vo.setAccessToken(token); + vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); + } + } + // 组装返回参数 + vo.setPlatformId(operatorId); + vo.setFailReason(failReason); + vo.setSuccStat(succStat); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); + return resultMap; + } +} diff --git a/jsowell-ui/src/api/thirdParty/secret.js b/jsowell-ui/src/api/thirdParty/secret.js new file mode 100644 index 000000000..f14541e4d --- /dev/null +++ b/jsowell-ui/src/api/thirdParty/secret.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询对接三方平台配置列表 +export function listSecret(query) { + return request({ + url: '/thirdparty/secret/list', + method: 'get', + params: query + }) +} + +// 查询对接三方平台配置详细 +export function getSecret(id) { + return request({ + url: '/thirdparty/secret/' + id, + method: 'get' + }) +} + +// 新增对接三方平台配置 +export function addSecret(data) { + return request({ + url: '/thirdparty/secret', + method: 'post', + data: data + }) +} + +// 修改对接三方平台配置 +export function updateSecret(data) { + return request({ + url: '/thirdparty/secret', + method: 'put', + data: data + }) +} + +// 删除对接三方平台配置 +export function delSecret(id) { + return request({ + url: '/thirdparty/secret/' + id, + method: 'delete' + }) +} diff --git a/jsowell-ui/src/views/thirdParty/secret/index.vue b/jsowell-ui/src/views/thirdParty/secret/index.vue new file mode 100644 index 000000000..e65c26da1 --- /dev/null +++ b/jsowell-ui/src/views/thirdParty/secret/index.vue @@ -0,0 +1,381 @@ + + +