Merge branch 'pre' into sxf

yy_dev
胡锐 1 year ago
commit c85be0e647
  1. 14
      open-api/src/main/java/com/api/controller/v1/AuthController.java
  2. 50
      open-api/src/main/java/com/api/controller/v1/TradeController.java
  3. 2
      open-api/src/main/resources/dev/application.yml
  4. 10
      open-api/src/main/resources/prod-9606/application.yml
  5. 10
      open-api/src/main/resources/prod/application.yml
  6. 16
      service/src/main/java/com/hfkj/common/utils/HttpsUtils.java
  7. 14
      service/src/main/java/com/hfkj/obs/HuaWeiYunObs.java
  8. 51
      service/src/main/java/com/hfkj/openapi/v1/utils/SignatureUtil.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.openapi.v1.model.TokenGrantType; import com.hfkj.openapi.v1.model.TokenGrantType;
@ -109,4 +110,17 @@ public class AuthController {
} }
} }
@RequestMapping(value="/getHttpStats",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "getHttpStats")
public ResponseData getHttpStats() {
try {
return ResponseMsgUtil.success(HttpsUtils.getHttpStats());
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -5,14 +5,13 @@ import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.*;
import com.hfkj.common.utils.RequestUtils;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.config.CommonSysConst; import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsMer; import com.hfkj.entity.BsMer;
import com.hfkj.entity.BsTradeOrder; import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderRefund; import com.hfkj.entity.BsTradeOrderRefund;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.obs.HuaWeiYunObs;
import com.hfkj.openapi.v1.model.*; import com.hfkj.openapi.v1.model.*;
import com.hfkj.openapi.v1.model.request.*; import com.hfkj.openapi.v1.model.request.*;
import com.hfkj.openapi.v1.model.response.ResponseQueryTradeModel; import com.hfkj.openapi.v1.model.response.ResponseQueryTradeModel;
@ -22,11 +21,13 @@ import com.hfkj.openapi.v1.utils.SignatureUtil;
import com.hfkj.service.BsMerKeyService; import com.hfkj.service.BsMerKeyService;
import com.hfkj.service.BsMerService; import com.hfkj.service.BsMerService;
import com.hfkj.sysenum.*; import com.hfkj.sysenum.*;
import com.obs.services.model.PutObjectResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.ResourceUtils; import org.springframework.util.ResourceUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -35,11 +36,9 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Controller @Controller
@Api(value = "交易订单") @Api(value = "交易订单")
@ -50,12 +49,12 @@ public class TradeController {
@Resource @Resource
private BsMerKeyService merKeyService; private BsMerKeyService merKeyService;
@Resource @Resource
private OpenApiTradeOrderService openApiTradeOrderService; private OpenApiTradeOrderService openApiTradeOrderService;
@Resource @Resource
private BsMerService merService; private BsMerService merService;
@Resource
private RedisTemplate redisTemplate;
@RequestMapping(value="/preorder",method = RequestMethod.POST) @RequestMapping(value="/preorder",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ -267,15 +266,18 @@ public class TradeController {
} }
List<TradeBillsModel> tradeBills = openApiTradeOrderService.tradeBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE()); List<TradeBillsModel> tradeBills = openApiTradeOrderService.tradeBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE());
String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx"; String childPath = "temporary/";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, TradeBillsModel.class) String fileName = System.currentTimeMillis() + "" + Math.abs(new Random().nextInt() % 1000) + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + "/" + childPath + fileName, TradeBillsModel.class)
.sheet(body.getMerchantNo()) .sheet(body.getMerchantNo())
.doWrite(tradeBills); .doWrite(tradeBills);
String fileUrl = CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + fileName; // 上传华为云 OBS
HuaWeiYunObs.obsUtilPutObject(CommonSysConst.getSysConfig().getFilesystem() + "/" + childPath + fileName, HuaWeiYunObs.bucketName, childPath + fileName);
String fileUrl = CommonSysConst.getSysConfig().getObs_url() + "/"+ childPath + fileName;
log.info("返回参数:" + fileUrl); log.info("返回参数:" + fileUrl);
return ResponseMsgUtil.success(fileUrl); return ResponseMsgUtil.success(fileUrl);
} catch (Exception e) { } catch (Exception e) {
log.info("出现异常:", e); log.info("出现异常:", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
@ -305,12 +307,16 @@ public class TradeController {
} }
List<TradeRefundBillsModel> tradeBills = openApiTradeOrderService.tradeRefundBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE()); List<TradeRefundBillsModel> tradeBills = openApiTradeOrderService.tradeRefundBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE());
String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx"; String childPath = "temporary/";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, TradeRefundBillsModel.class) String fileName = System.currentTimeMillis() + "" + Math.abs(new Random().nextInt() % 1000) + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + "/" + childPath + fileName, TradeRefundBillsModel.class)
.sheet(body.getMerchantNo()) .sheet(body.getMerchantNo())
.doWrite(tradeBills); .doWrite(tradeBills);
String fileUrl = CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + fileName; // 上传华为云 OBS
HuaWeiYunObs.obsUtilPutObject(CommonSysConst.getSysConfig().getFilesystem() + "/" + childPath + fileName, HuaWeiYunObs.bucketName, childPath + fileName);
String fileUrl = CommonSysConst.getSysConfig().getObs_url() + "/"+ childPath + fileName;
log.info("返回参数:" + fileUrl); log.info("返回参数:" + fileUrl);
return ResponseMsgUtil.success(fileUrl); return ResponseMsgUtil.success(fileUrl);
@ -356,12 +362,16 @@ public class TradeController {
} }
List<TradeDetailBillsModel> tradeBills = openApiTradeOrderService.tradeSettleBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE()); List<TradeDetailBillsModel> tradeBills = openApiTradeOrderService.tradeSettleBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE());
String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx"; String childPath = "temporary/";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, TradeDetailBillsModel.class) String fileName = System.currentTimeMillis() + "" + Math.abs(new Random().nextInt() % 1000) + ".xlsx";
.sheet("交易结算账单") EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + "/" + childPath + fileName, TradeDetailBillsModel.class)
.sheet(body.getMerchantNo())
.doWrite(tradeBills); .doWrite(tradeBills);
String fileUrl = CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + fileName; // 上传华为云 OBS
HuaWeiYunObs.obsUtilPutObject(CommonSysConst.getSysConfig().getFilesystem() + "/" + childPath + fileName, HuaWeiYunObs.bucketName, childPath + fileName);
String fileUrl = CommonSysConst.getSysConfig().getObs_url() + "/"+ childPath + fileName;
log.info("返回参数:" + fileUrl); log.info("返回参数:" + fileUrl);
return ResponseMsgUtil.success(fileUrl); return ResponseMsgUtil.success(fileUrl);

@ -9,7 +9,7 @@ debug: false
#datasource数据源设置 #datasource数据源设置
spring: spring:
datasource: datasource:
url: jdbc:mysql://139.9.154.68:3306/gratia_pay?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false url: jdbc:mysql://139.9.154.68:3306/gratia_pay_prod?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root username: root
password: HF123456. password: HF123456.
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource

@ -15,10 +15,10 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
filters: stat filters: stat
maxActive: 10 maxActive: 200
initialSize: 5 initialSize: 20
maxWait: 60000 maxWait: 60000
minIdle: 5 minIdle: 20
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
validationQuery: select 'x' validationQuery: select 'x'
@ -30,7 +30,7 @@ spring:
redis: redis:
database: 2 database: 2
host: 127.0.0.1 host: 140.210.192.36
port: 36379 port: 36379
password: HF123456.Redis password: HF123456.Redis
timeout: 1000 timeout: 1000
@ -69,7 +69,7 @@ jetcache:
remote: remote:
default: default:
type: redis type: redis
host: 127.0.0.1 host: 140.210.192.36
port: 36379 port: 36379
password: HF123456.Redis password: HF123456.Redis
database: 2 database: 2

@ -15,10 +15,10 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
filters: stat filters: stat
maxActive: 10 maxActive: 200
initialSize: 5 initialSize: 20
maxWait: 60000 maxWait: 60000
minIdle: 5 minIdle: 20
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
validationQuery: select 'x' validationQuery: select 'x'
@ -30,7 +30,7 @@ spring:
redis: redis:
database: 2 database: 2
host: 127.0.0.1 host: 140.210.192.36
port: 36379 port: 36379
password: HF123456.Redis password: HF123456.Redis
timeout: 1000 timeout: 1000
@ -69,7 +69,7 @@ jetcache:
remote: remote:
default: default:
type: redis type: redis
host: 127.0.0.1 host: 140.210.192.36
port: 36379 port: 36379
password: HF123456.Redis password: HF123456.Redis
database: 2 database: 2

@ -42,10 +42,7 @@ import java.security.GeneralSecurityException;
import java.security.KeyStore; import java.security.KeyStore;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HttpsUtils { public class HttpsUtils {
@ -59,8 +56,8 @@ public class HttpsUtils {
// 设置连接池 // 设置连接池
connMgr = new PoolingHttpClientConnectionManager(); connMgr = new PoolingHttpClientConnectionManager();
// 设置连接池大小 // 设置连接池大小
connMgr.setMaxTotal(1000); connMgr.setMaxTotal(5000);
connMgr.setDefaultMaxPerRoute(connMgr.getMaxTotal()); connMgr.setDefaultMaxPerRoute(2000);
// Validate connections after 1 sec of inactivity // Validate connections after 1 sec of inactivity
connMgr.setValidateAfterInactivity(1000); connMgr.setValidateAfterInactivity(1000);
RequestConfig.Builder configBuilder = RequestConfig.custom(); RequestConfig.Builder configBuilder = RequestConfig.custom();
@ -74,6 +71,13 @@ public class HttpsUtils {
requestConfig = configBuilder.build(); requestConfig = configBuilder.build();
} }
public static Object getHttpStats() {
Map<String,Object> param = new LinkedHashMap<>();
param.put("totalStats", connMgr.getTotalStats());
param.put("routes", connMgr.getRoutes());
return param;
}
/** /**
* 发送 GET 请求HTTP不带输入数据 * 发送 GET 请求HTTP不带输入数据
* *

@ -6,6 +6,7 @@ import com.obs.services.ObsClient;
import com.obs.services.model.*; import com.obs.services.model.*;
import java.io.File; import java.io.File;
import java.io.IOException;
/** /**
* 华为云obs 对象存储 * 华为云obs 对象存储
@ -17,6 +18,7 @@ public class HuaWeiYunObs {
private static String endPoint = CommonSysConst.getSysConfig().getObs_end_point(); private static String endPoint = CommonSysConst.getSysConfig().getObs_end_point();
private static String accessKey = "CZVO7VAT8UV2RPYJUBD2"; private static String accessKey = "CZVO7VAT8UV2RPYJUBD2";
private static String secretKey = "gyjrR8rYq9w2maPq9VmpRqoMqCJzQMH8vMctg7eE"; private static String secretKey = "gyjrR8rYq9w2maPq9VmpRqoMqCJzQMH8vMctg7eE";
public static String bucketName = "gratia-pay";
/** /**
* 创建请求 * 创建请求
@ -59,6 +61,18 @@ public class HuaWeiYunObs {
return null; return null;
} }
/**
* 上传文件
* @param fileUrl 文件路径
* @param bucketName 桶名称
* @param objectName 对象路径名称 例如temporary/1.jpg
* @return
*/
public static void obsUtilPutObject(String fileUrl,String bucketName,String objectName) throws IOException {
// 执行上传命令
new ProcessBuilder("/bin/bash", "-c", "obsutil cp "+ fileUrl + " obs://"+bucketName +"/"+ objectName).start();
}
/** /**
* 获取图片临时路径 * 获取图片临时路径
* @param bucketName 桶名称 * @param bucketName 桶名称

@ -8,6 +8,8 @@ import java.security.MessageDigest;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/** /**
* 签名工具类 * 签名工具类
@ -82,11 +84,52 @@ public class SignatureUtil {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String paramStr = "{\n" + String paramStr = "{\n" +
" \"merchantNo\": \"2023051910562136809\",\n" + " \"merchantNo\": \"2023041916292112804\",\n" +
" \"billDateS\": 1688140800000,\n" + " \"outTradeNo\": \"ZF1130202305051459532538970028\",\n" +
" \"billDateE\": 1690732800000,\n" + " \"payMode\": \"ALIPAY\",\n" +
" \"totalAmount\": 0.01,\n" +
" \"transType\": \"NATIVE\",\n" +
" \"profitSharing\": 0,\n" +
" \"specialField\": \"测试\"" +
"}"; "}";
String sign = createSign(JSONObject.parseObject(paramStr), "NGixVhkzVYFFMj8tjj4zOkYQtUiU3bd4"); String sign = createSign(JSONObject.parseObject(paramStr), "2jLO2WjXcSRSzTCaca0Kmv0OFrfYBbrA");
System.out.println(sign); System.out.println(sign);
/*// 创建一个线程池,设置最大线程数为10
ExecutorService executor = Executors.newFixedThreadPool(10);
// 提交10个查询任务
for (int i = 0; i < 10; i++) {
executor.submit(new QueryTask(i));
}
// 关闭线程池
executor.shutdown();*/
}
static class QueryTask implements Runnable {
private int taskId;
public QueryTask(int taskId) {
this.taskId = taskId;
}
@Override
public void run() {
// 执行查询任务
String result = queryData(taskId);
System.out.println("Task " + taskId + " result: " + result);
}
private String queryData(int taskId) {
// 模拟查询数据的过程
/*try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}*/
return "data " + taskId;
}
} }
} }

Loading…
Cancel
Save