diff --git a/lib/access_token1.1.jar b/lib/access_token1.1.jar
new file mode 100644
index 0000000..ca28bb3
Binary files /dev/null and b/lib/access_token1.1.jar differ
diff --git a/lib/access_token1.3.jar b/lib/access_token1.3.jar
new file mode 100644
index 0000000..dc162fc
Binary files /dev/null and b/lib/access_token1.3.jar differ
diff --git a/pom.xml b/pom.xml
index 80857ba..31bcbf8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
uboot-core
0.0.1-SNAPSHOT
-
+
com.chinaunicom.ebtp
mall-ebtp-cloud-attachment-sdk
@@ -94,6 +94,15 @@
${basedir}/lib/aspose-words-16.8.0-jdk16.jar
+
+
+ cryp.access
+ accessToken
+ 1.3
+ system
+ ${basedir}/lib/access_token1.3.jar
+
+
org.apache.velocity
velocity-tools
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java
index 58a2b47..05651ce 100644
--- a/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java
@@ -16,6 +16,7 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
+import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class})
@EnableFeignClients
@@ -23,6 +24,7 @@ import org.springframework.context.annotation.ComponentScan;
@MapperScan({"com.chinaunicom.mall.ebtp.extend.**.dao"})
@ComponentScan("com.chinaunicom.mall.ebtp.*")
@EnableApolloConfig
+@EnableAsync
public class BizServiceEbtpExtendApplication {
public static void main(String[] args) {
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/controller/BlockChainLogController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/controller/BlockChainLogController.java
new file mode 100644
index 0000000..815bc73
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/controller/BlockChainLogController.java
@@ -0,0 +1,58 @@
+package com.chinaunicom.mall.ebtp.extend.blockchain.controller;
+
+
+import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
+import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
+import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog;
+import com.chinaunicom.mall.ebtp.extend.blockchain.service.IBlockChainLogService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+
+@RestController
+@Api(tags = "供应链+区块链接口调用日志")
+@RequestMapping("/v1/blockchainlog")
+public class BlockChainLogController {
+
+ @Resource
+ private IBlockChainLogService iBlockChainLogService;
+
+ /**
+ * 插入新数据
+ *
+ * @param blockChainLog
+ *
+ * @return
+ */
+ @ApiOperation("插入新数据")
+ @PostMapping("")
+ public BaseResponse insert(@ApiParam(value = "对象数据", required = true) @RequestBody @Valid BlockChainLog blockChainLog){
+ blockChainLog.setId(PropertyUtils.getSnowflakeId());
+ boolean save = iBlockChainLogService.save(blockChainLog);
+ return BaseResponse.success(save);
+ }
+
+
+
+ /**
+ * 查询数据
+ *
+ * @param id
+ *
+ * @return
+ */
+ @ApiOperation("查询数据")
+ @GetMapping("/{id}")
+ public BaseResponse get(@ApiParam(value = "主键id", required = true) @PathVariable String id){
+
+ BlockChainLog blockChainLog = iBlockChainLogService.getById(id);
+
+ return BaseResponse.success(blockChainLog);
+ }
+
+
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/dao/BlockChainLogMapper.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/dao/BlockChainLogMapper.java
new file mode 100644
index 0000000..22c42f1
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/dao/BlockChainLogMapper.java
@@ -0,0 +1,13 @@
+package com.chinaunicom.mall.ebtp.extend.blockchain.dao;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog;
+
+/**
+* @auto.generated
+ */
+public interface BlockChainLogMapper extends BaseMapper {
+
+
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/dao/mapper/BlockChainLogMapper.xml b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/dao/mapper/BlockChainLogMapper.xml
new file mode 100644
index 0000000..6b0433a
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/dao/mapper/BlockChainLogMapper.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ update supply_block_chain_log
+ set
+ delete_flag="deleted"
+ where ID=#{id,jdbcType=BIGINT}
+
+
\ No newline at end of file
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/entity/BlockChainLog.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/entity/BlockChainLog.java
new file mode 100644
index 0000000..c099bbd
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/entity/BlockChainLog.java
@@ -0,0 +1,93 @@
+package com.chinaunicom.mall.ebtp.extend.blockchain.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.chinaunicom.mall.ebtp.common.config.CustomLocalDateTimeTypeHandler;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 实体类 BlockChainLog
+ *
+ * @auto.generated
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel
+@EqualsAndHashCode(callSuper = false)
+@TableName(value = "block_chain_log", autoResultMap = true)
+public class BlockChainLog implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ @ApiModelProperty(value = "")
+ private String id;
+
+ /**
+ *
+ */
+ @ApiModelProperty(value = "")
+ private String tpId;
+
+ /**
+ *
+ */
+ @ApiModelProperty(value = "")
+ private String sectionId;
+
+ /**
+ *
+ */
+ @ApiModelProperty(value = "")
+ private String assessRoomId;
+
+ /**
+ *
+ */
+ @ApiModelProperty(value = "")
+ private String turnId;
+ /**
+ *
+ */
+ @ApiModelProperty(value = "调用接口的地址")
+ private String interfaceUrl;
+
+ /**
+ * 传参
+ */
+ @ApiModelProperty(value = "传参")
+ private String param;
+
+ /**
+ * 返回的结果或异常
+ */
+ @ApiModelProperty(value = "返回的结果或异常")
+ private String result;
+
+ /**
+ * 0-成功 1-失败
+ */
+ @ApiModelProperty(value = "0-成功 1-失败")
+ private Integer status;
+ @TableField(fill = FieldFill.INSERT,typeHandler = CustomLocalDateTimeTypeHandler.class)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @ApiModelProperty("创建时间")
+ private LocalDateTime createDate;
+
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/service/IBlockChainLogService.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/service/IBlockChainLogService.java
new file mode 100644
index 0000000..286128f
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/service/IBlockChainLogService.java
@@ -0,0 +1,16 @@
+package com.chinaunicom.mall.ebtp.extend.blockchain.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog;
+
+/**
+ * 对数据表 supply_block_chain_log 操作的 service
+ * @author Auto create
+ *
+ */
+public interface IBlockChainLogService extends IService {
+
+
+
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/service/impl/BlockChainLogServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/service/impl/BlockChainLogServiceImpl.java
new file mode 100644
index 0000000..d990d97
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/service/impl/BlockChainLogServiceImpl.java
@@ -0,0 +1,17 @@
+package com.chinaunicom.mall.ebtp.extend.blockchain.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chinaunicom.mall.ebtp.extend.blockchain.dao.BlockChainLogMapper;
+import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog;
+import com.chinaunicom.mall.ebtp.extend.blockchain.service.IBlockChainLogService;
+import org.springframework.stereotype.Service;
+/**
+ * 对数据表 supply_block_chain_log 操作的 serviceImpl
+ * blockchain
+ *
+ */
+@Service
+public class BlockChainLogServiceImpl extends ServiceImpl implements IBlockChainLogService {
+
+
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/controller/CrypConfigureController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/controller/CrypConfigureController.java
new file mode 100644
index 0000000..35e5449
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/controller/CrypConfigureController.java
@@ -0,0 +1,161 @@
+package com.chinaunicom.mall.ebtp.extend.crypconfigure.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.chinaunicom.baas.util.AccessToken;
+import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.List;
+
+@RestController
+@Api(value = "区块链参数配置表")
+@RequestMapping("/v1/crypconfigure")
+public class CrypConfigureController{
+
+ @Resource
+ private ICrypConfigureService iCrypConfigureService;
+
+// /**
+// * 插入新数据
+// *
+// * @param crypConfigure
+// *
+// * @return
+// */
+// @ApiOperation("插入新数据")
+// @PostMapping
+// public BaseResponse insert(@ApiParam(value = "对象数据", required = true) @RequestBody @Valid CrypConfigure crypConfigure){
+//
+// int i = iCrypConfigureService.insert(crypConfigure);
+//
+// return BaseResponse.success(i);
+// }
+//
+// /**
+// * 修改数据
+// *
+// * @param crypConfigure
+// *
+// * @return
+// */
+// @ApiOperation("修改数据")
+// @PutMapping
+// public BaseResponse update(@ApiParam(value = "对象数据", required = true) @RequestBody CrypConfigure crypConfigure){
+//
+// Boolean i = iCrypConfigureService.updateCrypConfigureById(crypConfigure);
+//
+// return BaseResponse.success(i);
+// }
+//
+// /**
+// * 查询数据
+// *
+// * @param id
+// *
+// * @return
+// */
+// @ApiOperation("根据id查询数据")
+// @GetMapping("/{id}")
+// public BaseResponse get(@ApiParam(value = "主键id", required = true) @PathVariable String id){
+//
+// CrypConfigure crypConfigure = iCrypConfigureService.getById(id);
+//
+// return BaseResponse.success(crypConfigure);
+// }
+//
+// /**
+// * 删除数据
+// * @param id 主键id
+// * @return BaseResponse
+// * @author dino
+// * @date 2020/10/21 14:56
+// */
+// @ApiOperation(value = "delete",notes = "删除数据")
+// @DeleteMapping("/{id}")
+// public BaseResponse delete(@ApiParam(value = "主键id", required = true) @PathVariable Long id) {
+// int i = iCrypConfigureService.deleteById(id);
+// return BaseResponse.success(i);
+// }
+
+ /**
+ * 查询数据
+ *
+ * @param param
+ * @return
+ */
+ @ApiOperation("查询列表数据")
+ @GetMapping("/list")
+ public BaseResponse> list(@ApiParam(value = "查询对象数据", required = false) CrypConfigure param) {
+ //查询
+ LambdaQueryWrapper query = Wrappers.lambdaQuery(param);
+ List list = iCrypConfigureService.list(query);
+ //异常处理
+ //RespsExceptionEnum.FRAME_EXCEPTION_DEMO_NOT_FIND.customValid(list.isEmpty());
+ return BaseResponse.success(list);
+ }
+
+ /**
+ * 调用天擎接口
+ *
+ * @param bean
+ * @return
+ */
+ @ApiOperation("调用天擎接口")
+ @PostMapping("/callUniInterface")
+ public BaseResponse callUniInterface(@RequestBody CrypBean bean) {
+
+ return BaseResponse.success(this.iCrypConfigureService.callUniInterface(bean));
+ }
+
+ /**
+ * 区块链数据加密
+ *
+ * @param object
+ * @return
+ */
+ @ApiOperation("区块链数据加密")
+ @PostMapping("/signObject")
+ public BaseResponse signObject(@RequestBody Object object) {
+
+ return BaseResponse.success(this.iCrypConfigureService.signObject(object));
+ }
+
+ /**
+ * 区块链数据解密
+ *
+ * @param bean
+ * @return
+ */
+ @ApiOperation("区块链数据解密")
+ @PostMapping("/verifyObject")
+ public BaseResponse verifyObject(@RequestBody CrypBean bean) {
+
+ return BaseResponse.success(this.iCrypConfigureService.verifyObject(bean));
+ }
+
+ /**
+ * accessToken获取
+ *
+ * @param
+ * @return
+ */
+ @ApiOperation("accessToken获取")
+ @GetMapping("/getAccessToken")
+ public BaseResponse getAccessToken() {
+
+ return BaseResponse.success( AccessToken.tokenCreate("bidding"));
+ }
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/dao/CrypConfigureMapper.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/dao/CrypConfigureMapper.java
new file mode 100644
index 0000000..16f76f1
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/dao/CrypConfigureMapper.java
@@ -0,0 +1,10 @@
+package com.chinaunicom.mall.ebtp.extend.crypconfigure.dao;
+
+
+import com.chinaunicom.mall.ebtp.common.base.dao.IBaseMapper;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface CrypConfigureMapper extends IBaseMapper {
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/dao/mapper/CrypConfigureMapper.xml b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/dao/mapper/CrypConfigureMapper.xml
new file mode 100644
index 0000000..605fa81
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/dao/mapper/CrypConfigureMapper.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ update biz_bid_cryp_configure
+ set
+ delete_flag="1"
+ where ID=#{id }
+
+
\ No newline at end of file
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/entity/CrypBean.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/entity/CrypBean.java
new file mode 100644
index 0000000..10a6833
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/entity/CrypBean.java
@@ -0,0 +1,35 @@
+package com.chinaunicom.mall.ebtp.extend.crypconfigure.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+* 实体类 CrypConfigure-区块链参数配置表
+*
+* @author yss
+*/
+@Data
+public class CrypBean {
+ /**
+ * 能力req名称
+ * BIDDING_PUBLISH_REQ 发标
+ */
+ @ApiModelProperty(value = "能力req名称")
+ public String reqName;
+ /**
+ * 签名
+ */
+ @ApiModelProperty(value = "签名")
+ public String sign;
+ /**
+ * 待签名参数 Map
+ */
+ @ApiModelProperty(value = "待签名参数")
+ public Object object;
+ /**
+ * 天擎接口地址
+ */
+ @ApiModelProperty(value = "天擎接口地址")
+ public String url;
+
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/entity/CrypConfigure.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/entity/CrypConfigure.java
new file mode 100644
index 0000000..bcb83cc
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/entity/CrypConfigure.java
@@ -0,0 +1,73 @@
+package com.chinaunicom.mall.ebtp.extend.crypconfigure.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+* 实体类 CrypConfigure-区块链参数配置表
+*
+* @author yss
+*/
+@Data
+@Accessors(chain = true)
+@TableName(value = "biz_bid_cryp_configure", autoResultMap = true)
+@ApiModel(value = "CrypConfigure对象", description = "区块链参数配置表")
+public class CrypConfigure extends BaseEntity implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @TableId
+ @ApiModelProperty(value = "主键ID")
+ private String id;
+
+ @ApiModelProperty(value = "配置标识")
+ private String cCode;
+
+ @ApiModelProperty(value = "配置说明")
+ private String cShow;
+
+ @ApiModelProperty(value = "配置类型 1-区块链")
+ private Integer type;
+
+ @ApiModelProperty(value = "值")
+ private String cValue;
+
+ @ApiModelProperty(value = "备注")
+ private String remarks;
+
+ @ApiModelProperty(value = "状态 0-失效 1-生效")
+ private Integer state;
+
+
+
+
+
+ @ApiModelProperty(value = "租户ID")
+ private String tenantId;
+
+ @ApiModelProperty(value = "租户名称")
+ private String tenantName;
+
+ @ApiModelProperty(value = "删除标识")
+ private String deleteFlag;
+
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ @ApiModelProperty(value = "删除标识")
+ private LocalDateTime lastUpdateTime;
+
+ @ApiModelProperty(value = "割接状态;0-割接数据,1-新数据")
+ private Integer cutoverStatus;
+
+
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/ICrypConfigureService.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/ICrypConfigureService.java
new file mode 100644
index 0000000..865ffe8
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/ICrypConfigureService.java
@@ -0,0 +1,34 @@
+package com.chinaunicom.mall.ebtp.extend.crypconfigure.service;
+
+
+import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
+
+/**
+ * 对数据表 biz_bid_cryp_configure 操作的 service
+ * @author yss
+ *
+ */
+public interface ICrypConfigureService extends IBaseService {
+ /**
+ * 调用天擎接口
+ * @param bean
+ * @return
+ */
+ Boolean callUniInterface(CrypBean bean);
+
+ /**
+ * 加密
+ * @param object
+ * @return
+ */
+ CrypBean signObject(Object object);
+
+ /**
+ * 解密
+ * @param bean
+ * @return
+ */
+ Boolean verifyObject(CrypBean bean);
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/impl/CrypConfigureServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/impl/CrypConfigureServiceImpl.java
new file mode 100644
index 0000000..bd794c0
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/impl/CrypConfigureServiceImpl.java
@@ -0,0 +1,348 @@
+package com.chinaunicom.mall.ebtp.extend.crypconfigure.service.impl;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.chinaunicom.baas.util.AccessToken;
+import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
+import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
+import com.chinaunicom.mall.ebtp.common.constant.CommonConstants;
+import com.chinaunicom.mall.ebtp.common.crypto.service.CrypServiceImpl;
+import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum;
+import com.chinaunicom.mall.ebtp.common.uniBss.constant.UniBssConstant;
+import com.chinaunicom.mall.ebtp.common.uniBss.entity.*;
+import com.chinaunicom.mall.ebtp.common.uniBss.service.UniBssServiceImpl;
+import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
+import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog;
+import com.chinaunicom.mall.ebtp.extend.blockchain.service.IBlockChainLogService;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.dao.CrypConfigureMapper;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static com.chinaunicom.mall.ebtp.common.uniBss.service.UniBssServiceImpl.MD5min;
+
+/**
+ * 对数据表 biz_bid_cryp_configure 操作的 serviceImpl
+ * @author yss
+ *
+ */
+@Slf4j
+@Service
+public class CrypConfigureServiceImpl extends BaseServiceImpl implements ICrypConfigureService {
+
+ @Autowired
+ private IBlockChainLogService iBlockChainLogService;
+
+ private @Autowired
+ IBaseCacheUserService service;
+
+ // 测试 PEM_PATH = "admin_certPrivateNew.pem" CRT_PATH = "adminNew.crt"
+ // 生产 PEM_PATH = "bidding_certPrivate.pem" CRT_PATH = "bidding.crt"
+ // 私钥文件路径 - 加密
+ private static String PEM_PATH = "bidding_certPrivate.pem";
+ // 证书文件路径 - 解密
+ private static String CRT_PATH = "bidding.crt";
+
+ @Value("${mconfig.bss.app-id}")
+ private String app_id;
+ @Value("${mconfig.bss.app-secret}")
+ private String app_secret;
+ @Value("${mconfig.bss.app-url-test}")
+ private String app_url_test;
+ @Value("${mconfig.bss.app-url}")
+ private String app_url;
+
+ /**
+ * 调用天擎接口
+ * @param bean
+ * @return
+ */
+ @Override
+ @Async
+ public Boolean callUniInterface(CrypBean bean){
+ log.info("区块链------callUniInterface:---入参-----"+JSON.toJSONString(bean));
+ BlockChainLog blockChainLog = new BlockChainLog();
+ blockChainLog.setId(PropertyUtils.getSnowflakeId());
+ //天擎地址
+ if(app_secret.equals("1mb6n6635cJkDb3pEQPUFXc2nRJ8RPaS")){
+ //测试环境
+ bean.setUrl(bean.getUrl().replace(app_url,app_url_test));
+ PEM_PATH = "admin_certPrivateNew.pem";
+ CRT_PATH = "adminNew.crt";
+ }else{
+ PEM_PATH = "bidding_certPrivate.pem";
+ CRT_PATH = "bidding.crt";
+ //生产环境
+ bean.setUrl(bean.getUrl().replace(app_url_test,app_url));
+ }
+ log.info("加密文件:"+PEM_PATH);
+ log.info("解密文件:"+CRT_PATH);
+ log.info("请求路径:"+bean.getUrl());
+ blockChainLog.setInterfaceUrl(bean.getUrl());
+
+ try {
+ Map map = JSONArray.parseObject(JSONArray.toJSONString(bean.getObject()), Map.class);
+
+ //传入数据解密
+ String sign = getSignValue(map);
+
+ map.put("SIGN", sign);
+
+ String json = getUniBss(bean.getReqName(),map);
+
+ blockChainLog.setParam(json);//请求参数
+ String str = UniBssServiceImpl.uniBssHttpPost(bean.getUrl(), json);
+ blockChainLog.setResult(str);//返回参数
+ UniBss uniBssRsp = JSONArray.parseObject(str, UniBss.class);
+ if (uniBssRsp != null && UniBssConstant.RESP_CODE_00000.equals(uniBssRsp.getUniBssHead().getRespCode())) {
+ System.out.println("返回接口:"+uniBssRsp);
+
+ if(str!=null&&!"".equals(str)&&str.indexOf("_RSP\":{\"Code\":200,")>=0){
+ blockChainLog.setStatus(0);//成功
+ this.iBlockChainLogService.save(blockChainLog);
+ return true;
+ }else{
+ blockChainLog.setStatus(1);//失败
+ }
+ } else {
+ blockChainLog.setStatus(1);//失败
+ CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.assertStringNotNullByKey("天擎接口调用错误," +
+ "RESP_CODE:" + uniBssRsp.getUniBssHead().getRespCode() + "" +
+ "(" + UniBssConstant.getRESP_CODE_Map(uniBssRsp.getUniBssHead().getRespCode()) + ")。" +
+ "RESP_DESC:" + uniBssRsp.getUniBssHead().getRespDesc(), bean);
+ }
+ }catch (Exception e){
+ blockChainLog.setStatus(1);
+ blockChainLog.setResult(e.getMessage());
+ }
+
+ this.iBlockChainLogService.save(blockChainLog);
+
+ return false;
+ }
+ /**
+ * 加密
+ * @param object
+ * @return
+ */
+ @Override
+ public CrypBean signObject(Object object){
+ CrypBean bean = new CrypBean();
+ try{
+ bean.setObject(object);
+
+ String signValue = getSignValue(bean.getObject());
+
+ bean.setSign(signValue);
+
+ return bean;
+ }catch (Exception e){
+ log.error("加密异常:"+e);
+ }
+
+ return bean;
+ }
+
+ /**
+ * 获取加密签名
+ * @param object
+ * @return
+ */
+ private String getSignValue(Object object){
+ String signValue = "";
+ try{
+
+ log.info("加密参数1:"+object);
+ String json = JSONArray.toJSONString(object);
+ Map jsonMap = JSONArray.parseObject(json);
+ Object signObject = new Object();
+
+ if(jsonMap.get("BODY_LIST")!=null){
+ List jsonList = (List)jsonMap.get("BODY_LIST");
+ log.info("加密参数2:"+jsonList);
+ InputStream is = CrypConfigureServiceImpl.class.getClassLoader().getResourceAsStream(PEM_PATH);
+ signValue = CrypServiceImpl.signObject2(jsonList,IOUtils.toString(is));
+ }else{
+ log.info("加密参数2:"+jsonMap);
+ InputStream is = CrypConfigureServiceImpl.class.getClassLoader().getResourceAsStream(PEM_PATH);
+ signValue = CrypServiceImpl.signObject2(jsonMap,IOUtils.toString(is));
+ }
+
+
+ log.info("加密结果:"+signValue);
+ }catch (Exception e){
+ log.info("---------加密异常-"+e.getMessage());
+ }
+ return signValue;
+ }
+
+ /**
+ * 获取加密签名
+ * @param map
+ * @return
+ */
+ private String getUniBss(String reqName, Map map){
+ //获取token
+ Date date = new Date();
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
+ SimpleDateFormat format2 = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+ String TIMESTAMP = format.format(date);
+ String TRANS_ID = format2.format(date) + (int) ((Math.random() * 9 + 1) * 100000);
+ String s = "APP_ID" + app_id + "TIMESTAMP" + TIMESTAMP + "TRANS_ID" + TRANS_ID + app_secret;
+ String token = MD5min(s);
+ UniBss uniBss = new UniBss();
+ uniBss.setUniBssAttached(new UniBssAttached().setMediaInf(""));
+ //天擎部分head
+ UniBssHead head = new UniBssHead();
+ head.setAppId(app_id);
+ head.setTimeStamp(TIMESTAMP);
+ head.setTransId(TRANS_ID);
+ head.setToken(token);
+ uniBss.setUniBssHead(head);
+
+ UniReqHead reqhead = new UniReqHead();
+ //测试写死
+ String accessToken = "MQjkzVoYoSHe6r/3uZm0MV/TLx+n8PS9ivfPhgY4bWmh+8DVxj7vTC15xbBkuV8oujD3XBZPP7PhcWag9UU5IzsUBT7PSwPhqi/fUqa+iAWhCWpvyihG/23BAY3rJyaoa3OdMNSnIh8woPDCJQTzCTpNtg0toKwdWnuc2mig7vI0Lm9lePvrx3XxFLSaFr+jB5C3qnAX4uUBioZzithSjtra1QUK6S1cb9DCmpj6NRI=";
+//SystemId测试环境 990001 生产环境 74
+ if(app_secret.equals("1mb6n6635cJkDb3pEQPUFXc2nRJ8RPaS")){
+ //测试环境
+ reqhead.setSystemId("990001");
+ }else{
+ //生产环境
+ reqhead.setSystemId("74");
+ accessToken = AccessToken.tokenCreate("bidding");
+ accessToken = accessToken.replaceAll("\n","");
+ log.info("获取token:"+accessToken);
+ }
+ reqhead.setSystemName("bidding");
+ reqhead.setUserId(service.getCacheUser().getUserId()!=null?service.getCacheUser().getUserId():"dzztb");
+ reqhead.setUserName(service.getCacheUser().getUserId()!=null?service.getCacheUser().getUserId():"dzztb");
+
+ reqhead.setAccessToken(accessToken);
+
+
+ log.info("业务参数封装前:"+map);
+ UniCrpyReq req = new UniCrpyReq();
+ req.setBody(map);
+ req.setHead(reqhead);
+ log.info("业务参数封装中:"+req);;
+ Map reqMap = new HashMap();
+ reqMap.put(reqName,req);
+ uniBss.setUniBssBodyMap(reqMap);
+ log.info("业务参数封装后:"+reqMap);
+ log.info("业务参数封装后uniBss:"+uniBss);
+
+ return JSON.toJSONString(uniBss);
+ }
+ /**
+ * 解密
+ * @param bean
+ * @return
+ */
+ @Override
+ public Boolean verifyObject(CrypBean bean){
+
+ try{
+ log.info("解密参数1:" + bean);
+ String json = JSONArray.toJSONString(bean.getObject());
+ Map jsonMap = JSONArray.parseObject(json, Map.class);
+ if(jsonMap.get("BODY_LIST")!=null){
+ List jsonList = (List)jsonMap.get("BODY_LIST");
+ log.info("解密参数2:"+jsonList);
+ InputStream is = CrypConfigureServiceImpl.class.getClassLoader().getResourceAsStream(CRT_PATH);
+ Boolean b = CrypServiceImpl.verifyValue(bean.getSign(), jsonList, IOUtils.toString(is));
+
+ return b;
+ }else {
+ log.info("解密参数2:" + bean);
+ InputStream is = CrypConfigureServiceImpl.class.getClassLoader().getResourceAsStream(CRT_PATH);
+ Boolean b = CrypServiceImpl.verifyValue(bean.getSign(), jsonMap, IOUtils.toString(is));
+ return b;
+ }
+
+ }catch (Exception e){
+ log.info("-----------解密失败"+e.getMessage());
+ }
+
+ return false;
+ }
+
+ public static Map parseJSON2Map(String jsonStr){
+ Map map = new HashMap();
+ Map strmap = JSONArray.parseObject(jsonStr,Map.class);
+ for(Object k : strmap.keySet()){
+ Object v = strmap.get(k);
+ if(v instanceof JSONArray){
+ List