提交代码

yy_dev
胡锐 1 year ago
parent 24ba0a8a2f
commit 6f3d5c3aff
  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. 4
      open-api/src/main/resources/prod-9606/application.yml
  5. 4
      open-api/src/main/resources/prod/application.yml
  6. 18
      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.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.model.ResponseData;
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.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.RequestUtils;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.common.utils.*;
import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsMer;
import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderRefund;
import com.hfkj.model.ResponseData;
import com.hfkj.obs.HuaWeiYunObs;
import com.hfkj.openapi.v1.model.*;
import com.hfkj.openapi.v1.model.request.*;
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.BsMerService;
import com.hfkj.sysenum.*;
import com.obs.services.model.PutObjectResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.util.ResourceUtils;
import org.springframework.validation.annotation.Validated;
@ -35,11 +36,9 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotBlank;
import java.io.File;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
@Controller
@Api(value = "交易订单")
@ -50,12 +49,12 @@ public class TradeController {
@Resource
private BsMerKeyService merKeyService;
@Resource
private OpenApiTradeOrderService openApiTradeOrderService;
@Resource
private BsMerService merService;
@Resource
private RedisTemplate redisTemplate;
@RequestMapping(value="/preorder",method = RequestMethod.POST)
@ResponseBody
@ -267,15 +266,18 @@ public class TradeController {
}
List<TradeBillsModel> tradeBills = openApiTradeOrderService.tradeBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE());
String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, TradeBillsModel.class)
String childPath = "temporary/";
String fileName = System.currentTimeMillis() + "" + Math.abs(new Random().nextInt() % 1000) + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + "/" + childPath + fileName, TradeBillsModel.class)
.sheet(body.getMerchantNo())
.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);
return ResponseMsgUtil.success(fileUrl);
} catch (Exception e) {
log.info("出现异常:", e);
return ResponseMsgUtil.exception(e);
@ -305,12 +307,16 @@ public class TradeController {
}
List<TradeRefundBillsModel> tradeBills = openApiTradeOrderService.tradeRefundBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE());
String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, TradeRefundBillsModel.class)
String childPath = "temporary/";
String fileName = System.currentTimeMillis() + "" + Math.abs(new Random().nextInt() % 1000) + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + "/" + childPath + fileName, TradeRefundBillsModel.class)
.sheet(body.getMerchantNo())
.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);
return ResponseMsgUtil.success(fileUrl);
@ -356,12 +362,16 @@ public class TradeController {
}
List<TradeDetailBillsModel> tradeBills = openApiTradeOrderService.tradeSettleBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE());
String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, TradeDetailBillsModel.class)
.sheet("交易结算账单")
String childPath = "temporary/";
String fileName = System.currentTimeMillis() + "" + Math.abs(new Random().nextInt() % 1000) + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + "/" + childPath + fileName, TradeDetailBillsModel.class)
.sheet(body.getMerchantNo())
.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);
return ResponseMsgUtil.success(fileUrl);

@ -9,7 +9,7 @@ debug: false
#datasource数据源设置
spring:
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
password: HF123456.
type: com.alibaba.druid.pool.DruidDataSource

@ -30,7 +30,7 @@ spring:
redis:
database: 2
host: 127.0.0.1
host: 140.210.192.36
port: 36379
password: HF123456.Redis
timeout: 1000
@ -69,7 +69,7 @@ jetcache:
remote:
default:
type: redis
host: 127.0.0.1
host: 140.210.192.36
port: 36379
password: HF123456.Redis
database: 2

@ -30,7 +30,7 @@ spring:
redis:
database: 2
host: 127.0.0.1
host: 140.210.192.36
port: 36379
password: HF123456.Redis
timeout: 1000
@ -69,7 +69,7 @@ jetcache:
remote:
default:
type: redis
host: 127.0.0.1
host: 140.210.192.36
port: 36379
password: HF123456.Redis
database: 2

@ -42,10 +42,7 @@ import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public class HttpsUtils {
@ -59,8 +56,8 @@ public class HttpsUtils {
// 设置连接池
connMgr = new PoolingHttpClientConnectionManager();
// 设置连接池大小
connMgr.setMaxTotal(1000);
connMgr.setDefaultMaxPerRoute(connMgr.getMaxTotal());
connMgr.setMaxTotal(5000);
connMgr.setDefaultMaxPerRoute(2000);
// Validate connections after 1 sec of inactivity
connMgr.setValidateAfterInactivity(1000);
RequestConfig.Builder configBuilder = RequestConfig.custom();
@ -73,7 +70,14 @@ public class HttpsUtils {
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不带输入数据
*

@ -6,6 +6,7 @@ import com.obs.services.ObsClient;
import com.obs.services.model.*;
import java.io.File;
import java.io.IOException;
/**
* 华为云obs 对象存储
@ -17,6 +18,7 @@ public class HuaWeiYunObs {
private static String endPoint = CommonSysConst.getSysConfig().getObs_end_point();
private static String accessKey = "CZVO7VAT8UV2RPYJUBD2";
private static String secretKey = "gyjrR8rYq9w2maPq9VmpRqoMqCJzQMH8vMctg7eE";
public static String bucketName = "gratia-pay";
/**
* 创建请求
@ -59,6 +61,18 @@ public class HuaWeiYunObs {
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 桶名称

@ -8,6 +8,8 @@ import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Map;
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 {
String paramStr = "{\n" +
" \"merchantNo\": \"2023051910562136809\",\n" +
" \"billDateS\": 1688140800000,\n" +
" \"billDateE\": 1690732800000,\n" +
" \"merchantNo\": \"2023041916292112804\",\n" +
" \"outTradeNo\": \"ZF1130202305051459532538970028\",\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);
/*// 创建一个线程池,设置最大线程数为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