Commit fe32c604 authored by huangcb's avatar huangcb

增加银联获取对账单、更新公钥定时任务

parent eb656d8d
......@@ -2,6 +2,7 @@ package com.esv.freight.customer.common.unionpay;
import com.esv.freight.customer.common.constants.SDKConstants;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import java.io.*;
import java.nio.ByteBuffer;
......@@ -516,8 +517,7 @@ public class SDKUtil {
* @param encoding
* @return
*/
public static int getEncryptCert(Map<String, String> resData,
String encoding) {
public static int getEncryptCert(Map<String, String> resData, String encoding) {
String strCert = resData.get(SDKConstants.param_encryptPubKeyCert);
String certType = resData.get(SDKConstants.param_certType);
if (isEmpty(strCert) || isEmpty(certType)) {
......@@ -526,8 +526,7 @@ public class SDKUtil {
X509Certificate x509Cert = CertUtil.genCertificateByStr(strCert);
if (SDKConstants.CERTTYPE_01.equals(certType)) {
// 更新敏感信息加密公钥
if (!CertUtil.getEncryptCertId().equals(
x509Cert.getSerialNumber().toString())) {
if (!CertUtil.getEncryptCertId().equals(x509Cert.getSerialNumber().toString())) {
// ID不同时进行本地证书更新操作
String localCertPath = SDKConfig.getConfig().getEncryptCertPath();
String newLocalCertPath = genBackupName(localCertPath);
......@@ -695,10 +694,14 @@ public class SDKUtil {
int i = fileName.lastIndexOf(SDKConstants.POINT);
String leftFileName = fileName.substring(0, i);
String rightFileName = fileName.substring(i + 1);
String newFileName = leftFileName + "_backup" + SDKConstants.POINT + rightFileName;
String newFileName = leftFileName + "_backup_" + getTodayStr() + SDKConstants.POINT + rightFileName;
return newFileName;
}
public static String getTodayStr() {
DateTime dateTime = new DateTime(new Date());
return dateTime.toString("yyyyMMdd");
}
public static byte[] readFileByNIO(String filePath) {
FileInputStream in = null;
......
......@@ -121,7 +121,7 @@ public class UnionPayComponent {
throw new EException(ECode.THIRD_PARTY_ERROR.code(), "未定义异常");
}
} else {
log.error("验证签名失败");
log.error("[银联开放平台]验证签名失败");
throw new EException(ECode.THIRD_PARTY_ERROR.code(), "创建银联受理订单号失败");
}
} else {
......
package com.esv.freight.customer.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* @description: 定时任务配置
* @project: freight-customer-service
* @name: com.esv.freight.customer.config.ScheduleConfig
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/06/12 15:42
* @version:1.0
*/
@Configuration
@EnableScheduling
public class ScheduleConfig {
}
......@@ -30,7 +30,7 @@ public class DataPermHandler implements TenantHandler {
**/
private final List<String> filterTableNames = Arrays.asList(
"goods_owner_info", "goods_owner_audit_history", "goods_owner_delivery_address", "goods_owner_receive_address", "goods_owner_regularly_route",
"vehicle_audit_history", "vehicle_attachment", "driver_info", "driver_audit_history"
"vehicle_audit_history", "vehicle_attachment", "driver_info", "driver_audit_history", "unionpay_statement", "unionpay_public_cert_update"
);
@Override
......
......@@ -20,5 +20,5 @@ public interface PdfService {
* author HuangChaobin
* createTime 2020/05/28 20:17
**/
public void asyncSaveTargetFileInfo(String traceId, ContractOnlineRecordEntity entity, byte[] fileBytes);
void asyncSaveTargetFileInfo(String traceId, ContractOnlineRecordEntity entity, byte[] fileBytes);
}
......@@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
......@@ -42,6 +43,7 @@ public class PdfServiceImpl implements PdfService {
private FeignFileService feignFileService;
@Autowired
@Lazy
private ContractOnlineRecordService contractOnlineRecordService;
@Value("${font.windows.dir}")
......
package com.esv.freight.customer.module.pay.dao;
import com.esv.freight.customer.module.pay.entity.UnionpayPublicCertUpdateEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 银联加密公钥更新记录表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-06-15 13:14:21
*/
@Mapper
public interface UnionpayPublicCertUpdateDao extends BaseMapper<UnionpayPublicCertUpdateEntity> {
}
package com.esv.freight.customer.module.pay.dao;
import com.esv.freight.customer.module.pay.entity.UnionpayStatementEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 银联对账单表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-06-12 15:34:12
*/
@Mapper
public interface UnionpayStatementDao extends BaseMapper<UnionpayStatementEntity> {
}
package com.esv.freight.customer.module.pay.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 银联加密公钥更新记录表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-06-15 13:14:21
*/
@Data
@TableName("unionpay_public_cert_update")
public class UnionpayPublicCertUpdateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId
private Long id;
/**
* 更新日期(yyyyMMdd)
*/
private String updateDate;
/**
* 更新结果:0-成功、1-无更新、2-更新失败、3-更新异常
*/
private Integer updateResult;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
}
package com.esv.freight.customer.module.pay.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 银联对账单表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-06-12 15:34:12
*/
@Data
@TableName("unionpay_statement")
public class UnionpayStatementEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId
private Long id;
/**
* 账单类型:1-手机支付控件、2-在线网关支付
*/
private Integer statementCategory;
/**
* 对账单日期(yyyyMMdd)
*/
private String statementDate;
/**
* 对账单压缩包文件ID
*/
private Long zipId;
/**
* 对账单压缩包文件URL
*/
private String zipUrl;
/**
* 对账单明细文件ID
*/
private Long detailId;
/**
* 对账单明细文件URL
*/
private String detailUrl;
/**
* 对账单汇总文件ID
*/
private Long summaryId;
/**
* 对账单汇总文件URL
*/
private String summaryUrl;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
}
package com.esv.freight.customer.module.pay.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.pay.entity.UnionpayPublicCertUpdateEntity;
/**
* 银联加密公钥更新记录表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-06-15 13:14:21
*/
public interface UnionpayPublicCertUpdateService extends IService<UnionpayPublicCertUpdateEntity> {
/**
* description 保存记录
* param []
* return java.lang.Integer
* author HuangChaobin
* createTime 2020/06/15 13:19
**/
Integer saveRecord(UnionpayPublicCertUpdateEntity entity);
}
package com.esv.freight.customer.module.pay.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.pay.entity.UnionpayStatementEntity;
/**
* 银联对账单表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-06-12 15:34:12
*/
public interface UnionpayStatementService extends IService<UnionpayStatementEntity> {
/**
* description 通过对账单日期查询记录
* param [date]
* return com.esv.freight.customer.module.pay.entity.UnionpayStatementEntity
* author HuangChaobin
* createTime 2020/06/12 16:09
**/
UnionpayStatementEntity getRecordByDate(String date);
}
package com.esv.freight.customer.module.pay.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.module.pay.dao.UnionpayPublicCertUpdateDao;
import com.esv.freight.customer.module.pay.entity.UnionpayPublicCertUpdateEntity;
import com.esv.freight.customer.module.pay.service.UnionpayPublicCertUpdateService;
import org.springframework.stereotype.Service;
@Service("unionpayPublicCertUpdateService")
public class UnionpayPublicCertUpdateServiceImpl extends ServiceImpl<UnionpayPublicCertUpdateDao, UnionpayPublicCertUpdateEntity> implements UnionpayPublicCertUpdateService {
@Override
public Integer saveRecord(UnionpayPublicCertUpdateEntity entity) {
UnionpayPublicCertUpdateEntity dbEntity = this.baseMapper.selectOne(new LambdaQueryWrapper<UnionpayPublicCertUpdateEntity>()
.eq(UnionpayPublicCertUpdateEntity::getUpdateDate, entity.getUpdateDate()));
if (null == dbEntity) {
return this.baseMapper.insert(entity);
} else {
entity.setId(dbEntity.getId());
return this.baseMapper.updateById(entity);
}
}
}
\ No newline at end of file
package com.esv.freight.customer.module.pay.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.module.pay.dao.UnionpayStatementDao;
import com.esv.freight.customer.module.pay.entity.UnionpayStatementEntity;
import com.esv.freight.customer.module.pay.service.UnionpayStatementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("unionpayStatementService")
public class UnionpayStatementServiceImpl extends ServiceImpl<UnionpayStatementDao, UnionpayStatementEntity> implements UnionpayStatementService {
@Override
public UnionpayStatementEntity getRecordByDate(String date) {
return this.baseMapper.selectOne(new LambdaQueryWrapper<UnionpayStatementEntity>().eq(UnionpayStatementEntity::getStatementDate, date));
}
}
\ No newline at end of file
package com.esv.freight.customer.schedule;
import com.esv.freight.customer.common.unionpay.AcpService;
import com.esv.freight.customer.common.unionpay.DemoBase;
import com.esv.freight.customer.common.unionpay.SDKConfig;
import com.esv.freight.customer.common.util.DateUtils;
import com.esv.freight.customer.module.pay.entity.UnionpayPublicCertUpdateEntity;
import com.esv.freight.customer.module.pay.entity.UnionpayStatementEntity;
import com.esv.freight.customer.module.pay.service.UnionpayPublicCertUpdateService;
import com.esv.freight.customer.module.pay.service.UnionpayStatementService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* @description: 银联定时任务
* @project: freight-customer-service
* @name: com.esv.freight.customer.schedule.UnionpayTask
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/06/12 15:44
* @version:1.0
*/
@Component
@Slf4j
public class UnionpayTask {
@Value("${unionpay.mer-id}")
private String unionPayMerId;
@Autowired
private UnionpayStatementService unionpayStatementService;
@Autowired
private UnionpayPublicCertUpdateService unionpayPublicCertUpdateService;
/**
* 定时任务触发器:获取前1/2天对账单
* 定时策略:每天1-2点,每20分钟执行一次
**/
@Scheduled(cron = "0 0/20 1-2 * * ?")
public void getStatementTaskTrigger() {
this.initLogTraceId();
log.info("------------------- [Unionpay_Task_001]获取银联对账单开始 -------------------");
this.getStatementWork();
log.info("------------------- [Unionpay_Task_001]获取银联对账单结束 -------------------");
}
/**
* 定时任务触发器:银联加密公钥更新
* 定时策略:每天2点30执行一次
**/
@Scheduled(cron = "0 30 2 * * ?")
public void updateCertTaskTrigger() {
this.initLogTraceId();
log.info("------------------- [Unionpay_Task_002]银联加密公钥更新开始 -------------------");
this.updateCertTaskWork();
log.info("------------------- [Unionpay_Task_002]银联加密公钥更新结束 -------------------");
}
/**
* 获取对账单
**/
private void getStatementWork() {
// 生成要获取的对账单日期
List<String> dateList = new ArrayList<>(2);
dateList.add(this.getBeforeDate(1));
dateList.add(this.getBeforeDate(2));
for (int i = 0; i < dateList.size(); i++) {
String settleDate = dateList.get(i);
UnionpayStatementEntity unionpayStatementEntity = this.unionpayStatementService.getRecordByDate(settleDate);
if (null == unionpayStatementEntity) {
Map<String, String> resMap = this.reqUnionpay(settleDate);
// TODO、对账文件存储处理(当前没有有效返回数据)
} else {
continue;
}
}
}
/**
* description 请求银联获取对账单
* param [settleDate]
* return java.util.Map<java.lang.String,java.lang.String>
* author HuangChaobin
* createTime 2020/06/12 16:59
**/
private Map<String, String> reqUnionpay(String settleDate) {
Map<String, String> resMap = null;
Map<String, String> contentData = new HashMap<>(128);
/***银联全渠道系统,产品参数,除了encoding自行选择外其他不需修改***/
//版本号 全渠道默认值
contentData.put("version", DemoBase.version);
//字符集编码 可以使用UTF-8,GBK两种方式
contentData.put("encoding", DemoBase.encoding);
//签名方法
contentData.put("signMethod", SDKConfig.getConfig().getSignMethod());
//交易类型 76-对账文件下载
contentData.put("txnType", "76");
//交易子类 01-对账文件下载
contentData.put("txnSubType", "01");
//业务类型,固定
contentData.put("bizType", "000000");
/***商户接入参数***/
//接入类型,商户接入填0 ,不需修改(0:直连商户, 1: 收单机构 2:平台商户)
contentData.put("accessType", "0");
//商户代码,请替换正式商户号测试,如使用的是自助化平台注册的777开头的商户号,该商户号没有权限测文件下载接口的,
// 请使用测试参数里写的文件下载的商户号和日期测。如需777商户号的真实交易的对账文件,请使用自助化平台下载文件
contentData.put("merId", unionPayMerId);
//清算日期,如果使用正式商户号测试则要修改成自己想要获取对账文件的日期, 测试环境如果使用700000000000001商户号则固定填写0119
contentData.put("settleDate", settleDate);
//订单发送时间,取系统时间,格式为yyyyMMddHHmmss,必须取当前时间,否则会报txnTime无效
contentData.put("txnTime", DateUtils.format(DateUtils.getSysdate(), DateUtils.DATE_FORMAT4));
//文件类型,一般商户填写00即可
contentData.put("fileType", "00");
/**请求参数设置完毕,以下对请求参数进行签名并发送http post请求,接收同步应答报文------------->**/
//报文中certId,signature的值是在signData方法中获取并自动赋值的,只要证书配置正确即可
Map<String, String> reqData = AcpService.sign(contentData, DemoBase.encoding);
//获取请求银联的前台地址:对应属性文件acp_sdk.properties文件中的acpsdk.fileTransUrl
String url = SDKConfig.getConfig().getFileTransUrl();
Map<String, String> rspData = AcpService.post(reqData, url, DemoBase.encoding);
if (!rspData.isEmpty()) {
if (AcpService.validate(rspData, DemoBase.encoding)) {
String respCode = rspData.get("respCode");
if ("00".equals(respCode)) {
resMap = rspData;
} else {
//其他应答码为失败请排查原因
log.error("[银联开放平台]获取对账单失败");
}
} else {
log.error("[银联开放平台]验证签名失败");
}
} else {
//未返回正确的http状态
log.error("[银联开放平台]未获取到返回报文或返回http状态码非200");
}
return resMap;
}
/**
* description 当前日期减天数
* param [days]
* return java.lang.String
* author HuangChaobin
* createTime 2020/06/12 16:07
**/
private String getBeforeDate(int days) {
Date cur = DateUtils.getSysdate();
Date beforeDate = DateUtils.minusDays(cur, days);
return DateUtils.format(beforeDate, DateUtils.DATE_FORMAT7);
}
/**
* 银联加密公钥更新
**/
private void updateCertTaskWork() {
Map<String, String> contentData = new HashMap<>(128);
/***银联全渠道系统,产品参数,除了encoding自行选择外其他不需修改***/
//版本号 全渠道默认值
contentData.put("version", DemoBase.version);
//字符集编码 可以使用UTF-8,GBK两种方式
contentData.put("encoding", DemoBase.encoding);
//签名方法
contentData.put("signMethod", SDKConfig.getConfig().getSignMethod());
//交易类型 95-银联加密公钥更新查询
contentData.put("txnType", "95");
//交易子类型 默认00
contentData.put("txnSubType", "00");
//业务类型,固定
contentData.put("bizType", "000000");
//渠道类型
contentData.put("channelType", "07");
//01:敏感信息加密公钥(只有01可用)
contentData.put("certType", "01");
/***商户接入参数***/
//商户号码(商户号码777290058110097仅做为测试调通交易使用,该商户号配置了需要对敏感信息加密)测试时请改成自己申请的商户号,【自己注册的测试777开头的商户号不支持代收产品】
contentData.put("merId", unionPayMerId);
//接入类型,商户接入填0 ,不需修改(0:直连商户, 1: 收单机构 2:平台商户)
contentData.put("accessType", "0");
String txnTime = DateUtils.format(DateUtils.getSysdate(), DateUtils.DATE_FORMAT4);
//商户订单号,8-40位数字字母,不能含“-”或“_”,可以自行定制规则
contentData.put("orderId", "ZSGX" + txnTime);
//订单发送时间,取系统时间,格式为yyyyMMddHHmmss,必须取当前时间,否则会报txnTime无效
contentData.put("txnTime", txnTime);
/**请求参数设置完毕,以下对请求参数进行签名并发送http post请求,接收同步应答报文------------->**/
//报文中certId,signature的值是在signData方法中获取并自动赋值的,只要证书配置正确即可
Map<String, String> reqData = AcpService.sign(contentData, DemoBase.encoding);
//交易请求url从配置文件读取对应属性文件acp_sdk.properties中的 acpsdk.backTransUrl
String requestBackUrl = SDKConfig.getConfig().getBackRequestUrl();
//发送请求报文并接受同步应答(默认连接超时时间30秒,读取返回结果超时时间30秒);这里调用signData之后,调用submitUrl之前不能对submitFromData中的键值对做任何修改,如果修改会导致验签不通过
Map<String, String> rspData = AcpService.post(reqData, requestBackUrl, DemoBase.encoding);
UnionpayPublicCertUpdateEntity entity = new UnionpayPublicCertUpdateEntity();
if (!rspData.isEmpty()) {
if (AcpService.validate(rspData, DemoBase.encoding)) {
String respCode = rspData.get("respCode");
if ("00".equals(respCode)) {
int resultCode = AcpService.updateEncryptCert(rspData, "UTF-8");
if (resultCode == 1) {
entity.setUpdateResult(0);
log.info("[银联开放平台]加密公钥更新成功");
} else if (resultCode == 0) {
entity.setUpdateResult(1);
log.info("[银联开放平台]加密公钥无更新");
} else {
entity.setUpdateResult(2);
log.error("[银联开放平台]加密公钥更新失败");
}
} else {
//其他应答码为失败请排查原因
entity.setUpdateResult(3);
log.error("[银联开放平台]加密公钥更新查询失败");
}
} else {
entity.setUpdateResult(3);
log.error("[银联开放平台]验证签名失败");
}
} else {
//未返回正确的http状态
entity.setUpdateResult(3);
log.error("[银联开放平台]未获取到返回报文或返回http状态码非200");
}
// 保存更新记录
entity.setUpdateDate(DateUtils.format(DateUtils.getSysdate(), DateUtils.DATE_FORMAT2));
this.unionpayPublicCertUpdateService.saveRecord(entity);
}
/**
* description 设置日志traceId
* param []
* return void
* author HuangChaobin
* createTime 2020/06/15 14:00
**/
private void initLogTraceId() {
String traceId = MDC.get("traceId");
if (StringUtils.isBlank(traceId)) {
traceId = UUID.randomUUID().toString().replace("-", "");
MDC.put("traceId", traceId);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.esv.freight.customer.module.pay.dao.UnionpayPublicCertUpdateDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.esv.freight.customer.module.pay.entity.UnionpayPublicCertUpdateEntity" id="unionpayPublicCertUpdateMap">
<result property="id" column="id"/>
<result property="updateDate" column="update_date"/>
<result property="updateResult" column="update_result"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.esv.freight.customer.module.pay.dao.UnionpayStatementDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.esv.freight.customer.module.pay.entity.UnionpayStatementEntity" id="unionpayStatementMap">
<result property="id" column="id"/>
<result property="statementCategory" column="statement_category"/>
<result property="statementDate" column="statement_date"/>
<result property="zipId" column="zip_id"/>
<result property="zipUrl" column="zip_url"/>
<result property="detailId" column="detail_id"/>
<result property="detailUrl" column="detail_url"/>
<result property="summaryId" column="summary_id"/>
<result property="summaryUrl" column="summary_url"/>
<result property="createTime" column="create_time"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -3,14 +3,18 @@ package com.esv.freight.customer;
import com.esv.freight.customer.common.constants.CommonConstants;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import java.util.UUID;
/**
* @description:
* @project: freight-file-service
......@@ -34,6 +38,7 @@ public class BaseTestController {
@Before
public void before() {
this.initLogTraceId();
log.info("=================================== Test Start ===================================");
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
TEST_START_TIME = System.currentTimeMillis();
......@@ -61,4 +66,12 @@ public class BaseTestController {
return httpHeaders;
}
private void initLogTraceId() {
String traceId = MDC.get("traceId");
if (StringUtils.isBlank(traceId)) {
traceId = UUID.randomUUID().toString().replace("-", "");
MDC.put("traceId", traceId);
}
}
}
package com.esv.freight.customer.schedule;
import lombok.extern.slf4j.Slf4j;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.schedule.UnionpayTaskTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/06/12 17:01
* @version:1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback(false)
public class UnionpayTaskTest {
@Autowired
private UnionpayTask unionpayTask;
/**
* 对账单定时任务触发器
**/
@Test
public void a1_getStatementTaskTrigger_test() throws Exception {
unionpayTask.getStatementTaskTrigger();
}
/**
* 银联加密公钥更新
**/
@Test
public void b1_updateCertTaskTrigger_test() throws Exception {
unionpayTask.updateCertTaskTrigger();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment