Commit c86ad540 authored by david.zhong's avatar david.zhong

first 提交

parent cc7ad27b
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/
# pay-provider
资质供应商
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>micro-as</artifactId>
<groupId>com.ost.micro</groupId>
<version>1.0.0-alpha</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<artifactId>pay-provider</artifactId>
<name>Micro :: Project :: As :: Provider</name>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.ost.micro;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnableDiscoveryClient
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class PayProviderApplication {
public static void main(String[] args) {
SpringApplication.run(PayProviderApplication.class, args);
}
}
package com.ost.micro.provider.common;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.export.ExcelExportService;
import com.google.gson.Gson;
import com.ost.micro.core.pay.modules.sys.dto.BizTradeDetailDto;
import com.ost.micro.core.pay.modules.sys.excel.BizTradeDetailBean;
import com.ost.micro.core.utils.CopyDataUtil;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* excel工具类
*
* @author Mark sunlightcs@gmail.com
* @since 2018-03-24
*/
public class ExcelBigUtils {
private static final Integer MAX_SIZE = 10000;
/**
* Excel导出
* 20W数据没问题,再多会卡死,需要继续优化
*
* @param response response
* @param list 数据List
*/
public static void exportExcel(HttpServletResponse response, String fileName, Collection<?> list) {
try {
List<String> fileNames = new ArrayList<>(); //存放生成的文件名称
String filePath = "D:/excel/"; //上线后切换成linux服务器地址
if (!new File(filePath).exists()) {
new File(filePath).mkdirs();
}
File zip = new File(filePath + fileName + ".zip"); //压缩文件路径
List lists = (List) list;
Integer pageNumeber = (lists.size() % MAX_SIZE == 0) ? lists.size() / MAX_SIZE : lists.size() / MAX_SIZE + 1;
Gson gson = new Gson();
List<BizTradeDetailBean> bizTradeDetailDtos = new ArrayList<>(10000);
for (int i = 0; i < pageNumeber; i++) {
String tempExcelFile = filePath + fileName + "[" + (i + 1) + "].xlsx";
fileNames.add(tempExcelFile);
FileOutputStream fos = new FileOutputStream(tempExcelFile);
//int rowMemory = 100;
SXSSFWorkbook workbook = new SXSSFWorkbook(100);
ExportParams exportParams = new ExportParams();
exportParams.setMaxNum(10000);
exportParams.setType(ExcelType.XSSF);
int minNum = i * MAX_SIZE;
int maxNum = (i + 1) * MAX_SIZE;
for (int j = minNum; j < (maxNum > lists.size() ? lists.size() : maxNum); j++) {
BizTradeDetailBean history = CopyDataUtil.copyObject(gson.fromJson(gson.toJson(lists.get(j)), BizTradeDetailDto.class), BizTradeDetailBean.class);
bizTradeDetailDtos.add(history);
}
//Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), BizTradeDetailDto.class, bizTradeDetailDtos);
new ExcelExportService().createSheet(workbook, exportParams, BizTradeDetailBean.class, bizTradeDetailDtos);
try {
workbook.write(fos);
fos.flush();
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
bizTradeDetailDtos.clear();
}
exportZip(response, fileName, fileNames, zip);
} catch (IOException e) {
e.printStackTrace();
}
}
private static void exportZip(HttpServletResponse response, String fileName, List<String> fileNames, File zip)
throws IOException {
response.reset();
response.setContentType("application/octet-stream;charset=UTF-8");
response.addHeader("pargam", "no-cache");
response.addHeader("Cache-Control", "no-cache");
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".zip");
OutputStream outPut = response.getOutputStream();
//1.压缩文件
File srcFile[] = new File[fileNames.size()];
for (int i = 0; i < fileNames.size(); i++) {
srcFile[i] = new File(fileNames.get(i));
}
byte[] byt = new byte[1024];
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zip));
//out.setEncoding("UTF-8");
for (int i = 0; i < srcFile.length; i++) {
FileInputStream in = new FileInputStream(srcFile[i]);
out.putNextEntry(new ZipEntry(srcFile[i].getName()));
int length;
while ((length = in.read(byt)) > 0) {
out.write(byt, 0, length);
}
out.closeEntry();
in.close();
}
out.close();
//2.删除服务器上的临时文件(excel)
for (int i = 0; i < srcFile.length; i++) {
File temFile = srcFile[i];
if (temFile.exists() && temFile.isFile()) {
temFile.delete();
}
}
//3.返回客户端压缩文件
FileInputStream inStream = new FileInputStream(zip);
byte[] buf = new byte[4096];
int readLenght;
while ((readLenght = inStream.read(buf)) != -1) {
outPut.write(buf, 0, readLenght);
}
inStream.close();
outPut.close();
//4.删除压缩文件
if (zip.exists() && zip.isFile()) {
zip.delete();
}
}
}
package com.ost.micro.provider.common;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.LongSerializationPolicy;
import com.ost.micro.common.utils.Result;
import com.ost.micro.core.configuration.SpringfoxJsonToGsonAdapter;
import com.ost.micro.core.context.model.response.DataResponse;
import com.ost.micro.core.utils.GsonUtil;
import com.ost.micro.core.utils.MapUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.*;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.GsonHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Service;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.client.RestTemplate;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author david.zhong
* @Title: PaymentServiceClient
* @ProjectName micro-root
* @Description: 远程调用底层逻辑
* @date 2018/9/3011:03
*/
@Service
@Slf4j
public class PaymentServiceClient<T> {
private Gson gson = new Gson();
private RestTemplate restTemplate;
public PaymentServiceClient() {
restTemplate = new RestTemplate();
List<HttpMessageConverter<?>> converters = restTemplate.getMessageConverters();
// 删除MappingJackson2HttpMessageConverter
converters.removeIf(httpMessageConverter -> httpMessageConverter instanceof MappingJackson2HttpMessageConverter);
// 添加GsonHttpMessageConverter
converters.add(new GsonHttpMessageConverter(new GsonBuilder().enableComplexMapKeySerialization().setLongSerializationPolicy(LongSerializationPolicy.STRING)
.serializeNulls().registerTypeAdapter(JsonElement.class, new SpringfoxJsonToGsonAdapter()).create()));
}
/**
* @param url
* @param param
* @return
*/
// @HystrixCommand(fallbackMethod = "selectPayChannelFallback") 熔断机制
public DataResponse get(String url, Map param) {
String urlParams = MapUtil.getUrlParamsByMap(param);
if (!StringUtils.isEmpty(urlParams)) {
url = url + "?" + urlParams;
}
log.info("get url is :" + url);
return restTemplate.getForEntity(url, DataResponse.class).getBody();
}
/**
* 包含敏感信息(身份信息、权限信息),用此方法做脱敏处理
*
* @param url
* @param param
* @return
*/
public Result _get(String url, Map param) {
String urlParams = MapUtil.getUrlParamsByMap(param);
if (!StringUtils.isEmpty(urlParams)) {
url = url + "?" + urlParams;
}
log.info("get url is :" + url.split("[?]")[0] + "?****");
return restTemplate.getForEntity(url, Result.class).getBody();
}
/**
* 通过id去获取
*
* @param url
* @param id
* @return
*/
public DataResponse get(String url, Long id) {
url = url + "/" + id;
log.info("get url is :" + url);
DataResponse model = restTemplate.getForEntity(url, DataResponse.class).getBody();
String json = gson.toJson(model.getData());
Map<String, Object> data = gson.fromJson(json, HashMap.class);
if (null != data) {
data.put("id", id);
}
return model;
}
/**
* post 请求
*
* @param url
* @param t
* @return
*/
public DataResponse post(String url, T t) {
log.info("post url is :" + url);
log.info("request params is :" + gson.toJson(t));
return restTemplate.postForEntity(url, t, DataResponse.class).getBody();
}
/**
* post 请求
*
* @param url
* @param t
* @return
*/
public DataResponse postForObject(String url, MediaType mediaType, T t) {
log.info("post url is :" + url);
log.info("request params is :" + gson.toJson(t));
//return restTemplate.postForEntity(url, t, DataResponse.class).getBody();
HttpHeaders header = new HttpHeaders();
// 需求需要传参为application/json格式
header.setContentType(mediaType);
HttpEntity<String> httpEntity = new HttpEntity<>(GsonUtil.toJson(t, false), header);
String response = restTemplate.postForObject(url, httpEntity, String.class);
log.info("response is {}", response);
DataResponse dataResponse = GsonUtil.fromJson(response, DataResponse.class);
return dataResponse;
}
/**
* put请求
*
* @param url
* @param t
* @return
*/
public void put(String url, T t) {
log.info("put url is :" + url);
log.info("request params is :" + gson.toJson(t));
restTemplate.put(url, t);
}
/**
* put请求
*
* @param url
* @param t
* @return
*/
public DataResponse putForEntity(String url, T t) {
log.info("put url is :" + url);
log.info("request params is :" + gson.toJson(t));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<T> entity = new HttpEntity<T>(t, headers);
ResponseEntity<DataResponse> result = restTemplate.exchange(url,
HttpMethod.PUT, entity, DataResponse.class);
return result.getBody();
}
/**
* delete 请求
*
* @param url
* @param id
*/
public void delete(String url, Long id) {
url = url + "/" + id;
log.info("request params is :" + url);
restTemplate.delete(url, id);
}
/**
* delete
*
* @param url
* @param t
* @return
*/
public DataResponse deleteForEntity(String url, T t) {
log.info("delete url is :" + url);
log.info("request params is :" + gson.toJson(t));
//restTemplate.put(url, t);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<T> entity = new HttpEntity<T>(t, headers);
ResponseEntity<DataResponse> result = restTemplate.exchange(url,
HttpMethod.DELETE, entity, DataResponse.class, t);
return result.getBody();
}
/**
* 发送/获取 服务端数据(主要用于解决发送put,delete方法无返回值问题).
*
* @param url 绝对地址
* @param method 请求方式
* @param bodyType 返回类型
* @param <T> 返回类型
* @return 返回结果(响应体)
*/
public <T> T exchange(String url, HttpMethod method, Class<T> bodyType, Map<String, Object> params) {
// 请求头
HttpHeaders headers = new HttpHeaders();
MimeType mimeType = MimeTypeUtils.parseMimeType("application/json");
MediaType mediaType = new MediaType(mimeType.getType(), mimeType.getSubtype(), Charset.forName("UTF-8"));
// 请求体
headers.setContentType(mediaType);
//提供json转化功能
ObjectMapper mapper = new ObjectMapper();
String str = null;
try {
if (!params.isEmpty()) {
str = mapper.writeValueAsString(params);
}
} catch (JsonProcessingException e) {
e.printStackTrace();
}
// 发送请求
HttpEntity<String> entity = new HttpEntity<>(str, headers);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<T> resultEntity = restTemplate.exchange(url, method, entity, bodyType);
return resultEntity.getBody();
}
public RestTemplate getRestTemplate() {
return restTemplate;
}
}
package com.ost.micro.provider.common;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryClient;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
/**
* @author Yubo
*/
@Slf4j
@Component
public class ServiceUrl {
@Value("${spring.profiles.active}")
private String environmentValue;
/**
* 开发环境和测试环境时使用
* 远程调用as-service
*/
public static final String LOCAL_DEV_URL_AS_SERVICE = "http://localhost:6020";
@Value("${services.as-service}")
private String asService;
public static final ServiceUrl INSTANCE = new ServiceUrl();
private ServiceUrl() {
}
/**
* 远程调用as-service
*
* @param consulDiscoveryClient
* @return
*/
public String getAsServiceUrl(ConsulDiscoveryClient consulDiscoveryClient) {
String serviceUrl = null;
switch (environmentValue) {
case "dev":
case "test":
case "sit":
serviceUrl = LOCAL_DEV_URL_AS_SERVICE;
break;
// formal
default:
List<ServiceInstance> serviceInstanceList = consulDiscoveryClient.getInstances(asService);
if (CollectionUtils.isEmpty(serviceInstanceList)) {
log.error("未找到服务========>" + asService);
return "";
}
ServiceInstance serviceInstance = serviceInstanceList.get(0);
serviceUrl = serviceInstance.getUri().toString();
log.info("as-service 服务地址为:========>{}", serviceUrl);
}
return serviceUrl;
}
}
package com.ost.micro.provider.controller;
import com.ost.micro.core.aop.DataToUnderline;
import com.ost.micro.core.context.model.response.DataResponse;
import com.ost.micro.core.pay.form.EditForm;
import com.ost.micro.core.pay.modules.sys.dto.BizAuditmpDto;
import com.ost.micro.core.pay.modules.sys.dto.BizDto;
import com.ost.micro.core.pay.modules.sys.dto.BizParamsDto;
import com.ost.micro.core.pay.modules.sys.dto.EditBizPsgDto;
import com.ost.micro.core.utils.GsonUtil;
import com.ost.micro.core.utils.RSAPublicKeyEncodeUtil;
import com.ost.micro.core.utils.ResponseUtils;
import com.ost.micro.provider.common.PaymentServiceClient;
import com.ost.micro.provider.common.ServiceUrl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryClient;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/**
* 商家管理
*
* @author yubo
*/
@RestController
@Slf4j
@RequestMapping("/mch/biz")
@Api(tags = "商家管理接口")
public class BizController {
@Autowired
private PaymentServiceClient paymentServiceClient;
@Autowired
private ConsulDiscoveryClient consulDiscoveryClient;
@Autowired
private ServiceUrl serviceUrl;
private String bizUrl = null;// 商家
private String certiUrl = null;// 商家交易详情
private String orderUrl = null;// 商家交易详情
private String psgUrl = null;// 商家设置支付通道
private String psgGroupUrl = null;// 商家设置支付通道组
private String transactionUrl = null;// 商家交易流水记录
@GetMapping("")
@ApiOperation("查询商家列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "keyword", value = "关键字,如:商家编号/法人姓名/手机号码/公司名称", required = false, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "audit_status", value = "资料认证状态", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "status", value = "启用状态", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "comp_id", value = "签约公司id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = true, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse searchBiz(@RequestParam(required = false, name = "keyword") String keyword,
@RequestParam(required = false, name = "status") Integer status,
@RequestParam(required = false, name = "audit_status") Integer auditStatus,
@RequestParam(required = false, name = "comp_id") Long compId,
@RequestParam(name = "page_index") Integer pageIndex,
@RequestParam(name = "page_size") Integer pageSize) {
if (bizUrl == null) {
bizUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz";
}
Map params = new HashMap();
params.put("keyword", keyword);
params.put("auditStatus", auditStatus);
params.put("status", status);
params.put("compId", compId);
params.put("pageIndex", pageIndex);
params.put("pageSize", pageSize);
return paymentServiceClient.get(bizUrl, params);
}
@PostMapping("")
@ApiOperation("添加商家")
@DataToUnderline()
public DataResponse add(@RequestBody(required = false) BizDto dto) {
if (bizUrl == null) {
bizUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz";
}
return paymentServiceClient.post(bizUrl, dto);
}
@PutMapping("")
@ApiOperation("编辑商家信息")
@DataToUnderline()
public DataResponse edit(@RequestBody EditForm bizForm) {
if (bizUrl == null) {
bizUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz";
}
paymentServiceClient.put(bizUrl, bizForm);
return ResponseUtils.getInstance().success(null);
}
@GetMapping("{biz_id}")
@ApiOperation("商家详情")
@ApiImplicitParam(paramType = "path", name = "biz_id", value = "商家id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse bizDetail(@PathVariable("biz_id") Long bizId) {
if (bizUrl == null) {
bizUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz";
}
return paymentServiceClient.get(bizUrl, bizId);
}
@GetMapping("order/page")
@ApiOperation("商家详情订单列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = true, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = true, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse bizDetailOrderList(@RequestParam(name = "biz_id") Long bizId,
@RequestParam(name = "page_index") Integer pageIndex,
@RequestParam(name = "page_size") Integer pageSize) {
if (orderUrl == null) {
orderUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/order/page";
}
Map<String, Object> params = new HashMap<>();
params.put("bizId", bizId);
params.put("pageIndex", pageIndex);
params.put("pageSize", pageSize);
return paymentServiceClient.get(orderUrl, params);
}
@GetMapping("psg")
@ApiOperation("查询商家支付通道")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = true, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "plat", value = "商家平台类型id", required = false, dataType = "long")})
@DataToUnderline()
public DataResponse getPassage(@RequestParam(name = "biz_id") Long bizId,
@RequestParam Integer plat) {
if (psgUrl == null) {
psgUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/psg";
}
Map<String, Object> params = new HashMap<>();
params.put("bizId", bizId);
params.put("plat", plat);
DataResponse dataResponse = paymentServiceClient.get(psgUrl, params);
return dataResponse;
}
@PutMapping("psg")
@ApiOperation("编辑商家支付通道")
@DataToUnderline()
public DataResponse editBizPassage(@RequestBody EditBizPsgDto editBizPsgForm) {
if (psgUrl == null) {
psgUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/psg";
}
paymentServiceClient.put(psgUrl, editBizPsgForm);
return ResponseUtils.getInstance().success(null);
}
@PostMapping("psg")
@ApiOperation("添加商家支付通道")
@DataToUnderline()
public DataResponse addBizPassage(@RequestBody EditBizPsgDto editBizPsgForm) {
if (psgUrl == null) {
psgUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/psg";
}
paymentServiceClient.post(psgUrl, editBizPsgForm);
return ResponseUtils.getInstance().success(null);
}
@DeleteMapping("psg/{biz_id}")
@ApiOperation("重置商家支付通道")
@ApiImplicitParam(paramType = "path", name = "biz_id", value = "商家id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse restBizPassage(@PathVariable("biz_id") Long bizId) {
if (psgUrl == null) {
psgUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/psg";
}
Map<String, Object> params = new HashMap<>();
params.put("bizId", bizId);
paymentServiceClient.delete(psgUrl, bizId);
return ResponseUtils.getInstance().success(null);
}
@GetMapping("psg/group/{biz_id}")
@ApiOperation("获取支付通道组")
@ApiImplicitParam(paramType = "path", name = "biz_id", value = "商家id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse getPsgGroup(@PathVariable("biz_id") Long bizId) {
if (psgGroupUrl == null) {
psgGroupUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/psg/group";
}
return paymentServiceClient.get(psgGroupUrl, bizId);
}
@PostMapping("certifile")
@ApiOperation("添加认证资料")
@DataToUnderline()
public DataResponse addCertiFile(@RequestBody BizAuditmpDto dto) {
if (certiUrl == null) {
certiUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/certifile";
}
return paymentServiceClient.post(certiUrl, dto);
}
@GetMapping("certifile/{biz_id}")
@ApiOperation("根据商家id获取认证资料")
@ApiImplicitParam(paramType = "path", name = "biz_id", value = "商家id", required = true, dataType = "long")
@DataToUnderline()
public DataResponse getCertiFile(@PathVariable("biz_id") Long bizId) {
if (certiUrl == null) {
certiUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/certifile";
}
return paymentServiceClient.get(certiUrl, bizId);
}
@PutMapping("certifile")
@ApiOperation("编辑认证资料")
@DataToUnderline()
public DataResponse editCertiFile(@RequestBody EditForm editForm) {
if (certiUrl == null) {
certiUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/certifile";
}
paymentServiceClient.put(certiUrl, editForm);
return ResponseUtils.getInstance().success(null);
}
@GetMapping("params/{biz_id}")
@ApiOperation("获取交易参数")
@ApiImplicitParam(paramType = "path", name = "biz_id", value = "商家id", required = true, dataType = "long")
@DataToUnderline()
public DataResponse getParams(@PathVariable("biz_id") Long bizId) {
String paramsUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/params";
return paymentServiceClient.get(paramsUrl, bizId);
}
@PostMapping("/params")
@ApiOperation("添加交易参数")
@DataToUnderline()
public DataResponse addParams(@RequestBody BizParamsDto bizParamsDto) {
String paramsUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/params";
//调用as-service服务
DataResponse backResponse = paymentServiceClient.post(paramsUrl, bizParamsDto);
log.info("添加交易参数 as-service 响应结果为:", GsonUtil.toJson(backResponse, true));
return backResponse;
}
@PutMapping("params")
@ApiOperation("编辑交易参数")
@DataToUnderline()
public DataResponse editParams(@RequestBody EditForm editForm) {
//调用as-service服务
String paramsUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/params";
DataResponse backResponse = paymentServiceClient.putForEntity(paramsUrl, editForm);
log.info("编辑交易参数 as-service 响应结果为:", GsonUtil.toJson(backResponse, true));
return backResponse;
}
@GetMapping("transaction/{id}")
@ApiOperation("获取交易详情")
@ApiImplicitParam(paramType = "path", name = "id", value = "id", required = true, dataType = "long")
@DataToUnderline()
public DataResponse getTradeDetail(@PathVariable Long id) {
if (transactionUrl == null) {
transactionUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/biz/transaction";
}
return paymentServiceClient.get(transactionUrl, id);
}
@GetMapping("/ras")
@ApiOperation("获取公钥与私钥")
@DataToUnderline()
public DataResponse crateRas() {
Map<String, String> dataMap = RSAPublicKeyEncodeUtil.generateKeyPair();
return ResponseUtils.getInstance().success(dataMap);
}
}
package com.ost.micro.provider.controller;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.ost.micro.core.aop.DataToUnderline;
import com.ost.micro.core.context.model.response.DataResponse;
import com.ost.micro.core.pay.modules.sys.dto.BizTradeDetailDto;
import com.ost.micro.core.pay.modules.sys.dto.BizTradeStatisticsDto;
import com.ost.micro.core.pay.modules.sys.excel.BizTradeDetailStaticBean;
import com.ost.micro.core.pay.modules.sys.excel.BizTradeStatisticsBean;
import com.ost.micro.core.utils.DateUtil;
import com.ost.micro.core.utils.ExcelUtils;
import com.ost.micro.provider.common.PaymentServiceClient;
import com.ost.micro.provider.common.ServiceUrl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/mch/trade/calculate")
@Api(tags = "交易统计")
@Slf4j
public class BizTradeStaticsController {
@Autowired
private PaymentServiceClient paymentServiceClient;
@Autowired
private ConsulDiscoveryClient consulDiscoveryClient;
@Autowired
private ServiceUrl serviceUrl;
private String staticUrl = null;
@GetMapping("")
@ApiOperation("交易统计查询")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "商家id", required = false, allowMultiple = true, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "comp_id", value = "签约公司id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "supplier_id", value = "支付供应商id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "mch_id", value = "商户id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "currency", value = "0人民币1美元", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "begin_time", value = "开始时间", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "end_time", value = "结束时间", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = true, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse search(
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_ids") String[] bizIds,
@RequestParam(required = false, name = "comp_id") Long compId,
@RequestParam(required = false, name = "supplier_id") Long supplierId,
@RequestParam(required = false, name = "mch_id") Long mchId,
@RequestParam(required = false, name = "begin_time") Long beginTime,
@RequestParam(required = false, name = "end_time") Long endTime,
@RequestParam(required = false) Integer currency,
@RequestParam(name = "page_index") Integer pageIndex,
@RequestParam(name = "page_size") Integer pageSize) {
staticUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/statics";
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append("/api/statics");
urlBuilder.append("?bizId={bizId}");
urlBuilder.append("&bizIds={bizIds}");
urlBuilder.append("&compId={compId}");
urlBuilder.append("&supplierId={supplierId}");
urlBuilder.append("&mchId={mchId}");
urlBuilder.append("&beginTime={beginTime}");
urlBuilder.append("&endTime={endTime}");
urlBuilder.append("&currency={currency}");
urlBuilder.append("&pageIndex={pageIndex}");
urlBuilder.append("&pageSize={pageSize}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, bizId, bizIds, compId, supplierId, mchId, beginTime, endTime, currency, pageIndex, pageSize);
return result.getBody();
}
/**
* 交易明细
*
* @param bizId
* @param mchId
* @return
*/
@GetMapping("/tradePage")
@ApiOperation("交易统计明细")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "keyword", value = "商家id", required = false, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "trade_type", value = "交易类型", required = false, dataType = "Integer"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = true, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "mch_id", value = "商户id", required = true, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "begin_time", value = "开始时间", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "end_time", value = "结束时间", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "currency", value = "0人民币1美元", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = true, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse tradePage(@RequestParam(required = false) String keyword,
@RequestParam(required = false, name = "trade_type") Integer tradeType,
@RequestParam(name = "biz_id") Long bizId,
@RequestParam(name = "mch_id") Long mchId,
@RequestParam(required = false, name = "begin_time") Long beginTime,
@RequestParam(required = false, name = "end_time") Long endTime,
@RequestParam(required = false) Integer currency,
@RequestParam(name = "page_index") Integer pageIndex,
@RequestParam(name = "page_size") Integer pageSize) {
staticUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/statics/tradePage";
Map<String, Object> params = new HashMap<>();
params.put("keyword", keyword);
params.put("tradeType", tradeType);
params.put("bizId", bizId);
params.put("mchId", mchId);
params.put("beginTime", beginTime);
params.put("endTime", endTime);
params.put("currency", currency);
params.put("pageIndex", pageIndex);
params.put("pageSize", pageSize);
return paymentServiceClient.get(staticUrl, params);
}
@GetMapping("/exportTradeStatic")
@ApiOperation("导出交易统计")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "商家id", required = false, allowMultiple = true, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "comp_id", value = "公司id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "supplier_id", value = "支付供应商", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "mch_id", value = "商户id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "begin_time", value = "开始时间", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "end_time", value = "结束时间", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "currency", value = "0人民币1美元", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = false, dataType = "int")})
public void exportTradeStatic(@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_ids") String[] bizIds,
@RequestParam(required = false, name = "comp_id") Long compId,
@RequestParam(required = false, name = "supplier_id") Long supplierId,
@RequestParam(required = false, name = "mch_id") Long mchId,
@RequestParam(required = false, name = "begin_time") Long beginTime,
@RequestParam(required = false, name = "end_time") Long endTime,
@RequestParam(required = false) Integer currency,
@RequestParam(required = false, name = "page_index") Integer pageIndex,
@RequestParam(required = false, name = "page_size") Integer pageSize,
HttpServletResponse response) {
staticUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/statics/exportTradeStatic";
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append("/api/statics/exportTradeStatic");
urlBuilder.append("?bizId={bizId}");
urlBuilder.append("&bizIds={bizIds}");
urlBuilder.append("&compId={compId}");
urlBuilder.append("&supplierId={supplierId}");
urlBuilder.append("&mchId={mchId}");
urlBuilder.append("&beginTime={beginTime}");
urlBuilder.append("&endTime={endTime}");
urlBuilder.append("&currency={currency}");
urlBuilder.append("&pageIndex={pageIndex}");
urlBuilder.append("&pageSize={pageSize}");
log.info("bizId={},bizIds={},compId={},supplierId={},mchId={},beginTime={},endTime={},pageIndex={},pageSize={}", bizId, bizIds, compId, supplierId, mchId, beginTime, endTime, pageIndex, pageSize);
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, bizId, bizIds, compId, supplierId, mchId, beginTime, endTime, currency, pageIndex, pageSize);
DataResponse dataResponse = result.getBody();
if (null != dataResponse && null != dataResponse.getData()) {
Object obj = dataResponse.getData().getList();
Gson gson = new Gson();
if (null != obj && obj instanceof List) {
List<BizTradeStatisticsDto> dataList = gson.fromJson(gson.toJson(obj), new TypeToken<List<BizTradeStatisticsDto>>() {
}.getType());
try {
ExcelUtils.exportExcelToTarget(response, "交易统计_" + DateUtil.format(new Date(), "yyyyMMddHHmmss"), dataList, BizTradeStatisticsBean.class);
} catch (Exception e) {
log.error("export 导出交易流水 error", e);
}
}
}
}
@GetMapping("/exportTradePage")
@ApiOperation("导出交易明细")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "keyword", value = "商家id", required = false, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "trade_type", value = "交易类型", required = false, dataType = "Integer"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = true, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "mch_id", value = "商户id", required = true, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "begin_time", value = "开始时间", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "end_time", value = "结束时间", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "currency", value = "0人民币1美元", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = false, dataType = "int")})
public void exportTradePage(@RequestParam(required = false) String keyword,
@RequestParam(required = false, name = "trade_type") Integer tradeType,
@RequestParam(name = "biz_id") Long bizId,
@RequestParam(name = "mch_id") Long mchId,
@RequestParam(required = false, name = "begin_time") Long beginTime,
@RequestParam(required = false, name = "end_time") Long endTime,
@RequestParam(required = false) Integer currency,
@RequestParam(required = false, name = "page_index") Integer pageIndex,
@RequestParam(required = false, name = "page_size") Integer pageSize,
HttpServletResponse response) {
staticUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/statics/exportTradePage";
Map<String, Object> params = new HashMap<>();
params.put("keyword", keyword);
params.put("tradeType", tradeType);
params.put("bizId", bizId);
params.put("mchId", mchId);
params.put("beginTime", beginTime);
params.put("endTime", endTime);
params.put("currency", currency);
params.put("pageIndex", pageIndex);
params.put("pageSize", pageSize);
DataResponse dataResponse = paymentServiceClient.get(staticUrl, params);
if (null != dataResponse && null != dataResponse.getData()) {
Object obj = dataResponse.getData().getList();
Gson gson = new Gson();
if (null != obj && obj instanceof List) {
List<BizTradeDetailDto> dataList = gson.fromJson(gson.toJson(obj), new TypeToken<List<BizTradeDetailDto>>() {
}.getType());
try {
ExcelUtils.exportExcelToTarget(response, "统计明细_" + DateUtil.format(new Date(), "yyyyMMddHHmmss"), dataList, BizTradeDetailStaticBean.class);
} catch (Exception e) {
log.error("export 导出交易明细 error", e);
}
}
}
}
}
package com.ost.micro.provider.controller;
import com.ost.micro.core.aop.DataToUnderline;
import com.ost.micro.core.context.model.response.DataResponse;
import com.ost.micro.core.pay.modules.sys.dto.MchPlatDto;
import com.ost.micro.core.utils.ResponseUtils;
import com.ost.micro.provider.common.PaymentServiceClient;
import com.ost.micro.provider.common.ServiceUrl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryClient;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/mch/common")
@Api(tags = "通用接口")
@Slf4j
public class CommonController {
@Autowired
private ConsulDiscoveryClient consulDiscoveryClient;
@Autowired
private PaymentServiceClient paymentServiceClient;
@Autowired
private ServiceUrl serviceUrl;
private static final String BASE_URL = "/api/common";
@GetMapping("supplier")
@ApiOperation("获取供应商列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "is_entry_info", value = "是否是资质录入员", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "is_filter_by_biz_id", value = "是否根据商家过滤", required = false, dataType = "boolean"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "所属商家", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "所属商家", required = false, allowMultiple = true, dataType = "String"),
})
@DataToUnderline()
public DataResponse getSupplier(
@RequestParam(required = false, name = "is_entry_info") Integer isEntryInfo,
@RequestParam(required = false, name = "is_filter_by_biz_id") Boolean isFilterByBizId,
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_ids") String[] bizIds) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/supplier?bizId={bizId}&bizIds={bizIds}&isFilterByBizId={isFilterByBizId}&isEntryInfo={isEntryInfo}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, bizId, bizIds, isFilterByBizId, isEntryInfo);
return result.getBody();
}
@GetMapping("biz")
@ApiOperation("获取商家列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "is_entry_info", value = "是否是资质录入员", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "sup_id", value = "供应商id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "商家id列表", required = false, allowMultiple = true, dataType = "String")
})
@DataToUnderline()
public DataResponse getBiz(@RequestParam(required = false, name = "sup_id") Long supId,
@RequestParam(required = false, name = "is_entry_info") Integer isEntryInfo,
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_ids") String[] bizIds) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/biz?supId={supId}&bizId={bizId}&bizIds={bizIds}&isEntryInfo={isEntryInfo}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, supId, bizId, bizIds, isEntryInfo);
return result.getBody();
}
@GetMapping("psg")
@ApiOperation("查询通道列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "is_entry_info", value = "是否是资质录入员", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "商家id集合", required = false, allowMultiple = true, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "supplier_id", value = "支付供应商", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "pay_api_id", value = "支付接口id", required = false, dataType = "long")
})
@DataToUnderline()
public DataResponse psg(@RequestParam(required = false, name = "is_entry_info") Integer isEntryInfo,
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_ids") String[] bizIds,
@RequestParam(required = false, name = "supplier_id") Long supplierId,
@RequestParam(required = false, name = "pay_api_id") Long payApiId) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/psg?bizId={bizId}&bizIds={bizIds}&supplierId={supplierId}&payApiId={payApiId}&isEntryInfo={isEntryInfo}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, bizId, bizIds, supplierId, payApiId, isEntryInfo);
return result.getBody();
}
@GetMapping("biz/comp")
@ApiOperation("获取签约公司商家列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "comp_id", value = "商家id", required = false, dataType = "long")
})
@DataToUnderline()
public DataResponse getBizByCompId(@RequestParam(required = false, name = "comp_id") Long compId) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/biz/comp?compId={compId}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, compId);
return result.getBody();
}
@GetMapping("bizscopes")
@ApiOperation("获取经营范围列表")
@DataToUnderline()
public DataResponse getBizScopes() {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/bizscopes");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class);
return result.getBody();
}
@GetMapping("company")
@ApiOperation("获取签约公司列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "is_biz_id_from_permission", value = "bizId是否是权限系统中", required = false, dataType = "boolean"),
@ApiImplicitParam(paramType = "query", name = "is_entry_info", value = "是否是资质录入员", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "biz_Id", value = "所属商家", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "所属商家集合", required = false, allowMultiple = true, dataType = "String")
})
@DataToUnderline()
public DataResponse getCompany(@RequestParam(required = false, name = "is_entry_info") Integer isEntryInfo,
@RequestParam(required = false, name = "is_biz_id_from_permission") Boolean isBizIdFromPermission,
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_ids") String[] bizIds) {
log.info("isEntryInfo ={}, isBizIdFromPermission = {},bizId ={},bizIds={}", isEntryInfo, isBizIdFromPermission, bizId, bizIds);
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/company?bizId={bizId}&bizIds={bizIds}&isEntryInfo={isEntryInfo}&isBizIdFromPermission={isBizIdFromPermission}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, bizId, bizIds, isEntryInfo, isBizIdFromPermission);
return result.getBody();
}
@GetMapping("merchant")
@ApiOperation("通过商家和供应商获取商户列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "sup_id", value = "供应商id", required = true, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "biz_id_admin", value = "商户商家id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "is_entry_info", value = "是否是资质录入员", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "商家id列表", required = false, allowMultiple = true, dataType = "String")
})
@DataToUnderline()
public DataResponse getMerchants(@RequestParam(name = "sup_id") Long supId,
@RequestParam(required = false, name = "is_entry_info") Integer isEntryInfo,
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_id_admin") Long bizIdAdmin,
@RequestParam(required = false, name = "biz_ids") String[] bizIds) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/merchant?supId={supId}&bizId={bizId}&bizIds={bizIds}&isEntryInfo={isEntryInfo}&bizIdAdmin={bizIdAdmin}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, supId, bizId, bizIds, isEntryInfo, bizIdAdmin);
return result.getBody();
}
@GetMapping("payapi")
@ApiOperation("获取商户的接口及接口类型")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "sup_id", value = "供应商id", required = true, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "type", value = "类型(0支付1代付)", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse getApiList(@RequestParam(name = "sup_id") Long supId,
@RequestParam(name = "type") Integer type) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/payapi");
Map requestMap = new HashMap();
requestMap.put("supId", supId);
requestMap.put("type", type);
return paymentServiceClient.get(urlBuilder.toString(), requestMap);
}
@GetMapping("type/{mch_id}")
@ApiOperation("获取商户的支付类型,已废弃,从“获取支付接口”中获取")
@ApiImplicitParam(paramType = "path", name = "mch_id", value = "商户id", required = true, dataType = "long")
@DataToUnderline()
@Deprecated
public DataResponse getTypeList(@PathVariable("mch_id") Long mchId) {
return ResponseUtils.getInstance().success(null);
}
@GetMapping("group")
@ApiOperation("获取通道分组列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "is_biz_id_from_permission", value = "bizId是否是权限系统中", required = false, dataType = "boolean"),
@ApiImplicitParam(paramType = "query", name = "is_entry_info", value = "是否是资质录入员", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "Long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "商家id列表", required = false, allowMultiple = true, dataType = "String")
})
@DataToUnderline()
public DataResponse getGroupList(@RequestParam(required = false, name = "is_entry_info") Integer isEntryInfo,
@RequestParam(required = false, name = "is_biz_id_from_permission") Boolean isBizIdFromPermission,
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_ids") String[] bizIds) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/group?bizId={bizId}&bizIds={bizIds}&isEntryInfo={isEntryInfo}&isBizIdFromPermission={isBizIdFromPermission}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, bizId, bizIds, isEntryInfo, isBizIdFromPermission);
return result.getBody();
}
@PostMapping("plat")
@ApiOperation("添加平台")
@DataToUnderline()
//public DataResponse addPlat(@RequestBody AddMchPlatForm addMchPlatForm) {
public DataResponse addPlat(@RequestBody MchPlatDto addMchPlatForm) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/plat");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate()
.postForEntity(urlBuilder.toString(), addMchPlatForm, DataResponse.class);
return result.getBody();
}
@DeleteMapping("plat")
@ApiOperation("删除平台")
@ApiImplicitParam(paramType = "query", name = "plat_id", value = "平台id", required = true, dataType = "long")
@DataToUnderline()
public DataResponse delPlat(@RequestParam(name = "plat_id") Long platId) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Long> entity = new HttpEntity<Long>(platId, headers);
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/plat");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().exchange(urlBuilder.toString(),
HttpMethod.DELETE, entity, DataResponse.class);
return result.getBody();
}
@GetMapping("plat")
@ApiOperation("获取平台列表")
@ApiImplicitParam(paramType = "query", name = "pay_api_id", value = "接口id", required = false, dataType = "long")
@DataToUnderline()
public DataResponse getPlatList(@RequestParam(required = false, name = "pay_api_id") Long payApiId) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/plat?payApiId={payApiId}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, payApiId);
return result.getBody();
}
@GetMapping("platAll")
@ApiOperation("获取所有的平台列表")
@DataToUnderline()
public DataResponse getPlatList() {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/platAll");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class);
return result.getBody();
}
@GetMapping("tmpl")
@ApiOperation("查询模板列表")
@DataToUnderline()
public DataResponse getTmplList() {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/tmpl");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class);
return result.getBody();
}
@GetMapping("api/type")
@ApiOperation("查询接口类型")
@DataToUnderline()
public DataResponse getApiType() {
String url = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/common/api/type";
return paymentServiceClient.get(url, new HashMap());
}
}
package com.ost.micro.provider.controller;
import com.ost.micro.core.aop.DataToUnderline;
import com.ost.micro.core.context.model.response.DataResponse;
import com.ost.micro.core.pay.form.EditForm;
import com.ost.micro.core.pay.modules.sys.dto.BizCompMapDto;
import com.ost.micro.core.pay.modules.sys.dto.BizSignCompExtDto;
import com.ost.micro.provider.common.PaymentServiceClient;
import com.ost.micro.provider.common.ServiceUrl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryClient;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
/**
* @author Yubo
*/
@RestController
@RequestMapping("/mch/company")
@Api(tags = "签约公司接口")
@Slf4j
public class CompanyController {
@Autowired
private ConsulDiscoveryClient consulDiscoveryClient;
@Autowired
private PaymentServiceClient paymentServiceClient;
@Autowired
private ServiceUrl serviceUrl;
private static final String BASE_URL = "/api/company";
private static final String CASHIER_BASE_URL = "/cashier/company";
@GetMapping("")
@ApiOperation("查询公司列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "keyword", value = "关键字", required = false, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "is_entry_info", value = "是否是资质录入员", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "Long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "商家id列表", required = false, dataType = "List"),
@ApiImplicitParam(paramType = "query", name = "enable", value = "启用状态", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = true, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse search(@RequestParam(required = false) String keyword,
@RequestParam(required = false) Integer enable,
@RequestParam(required = false, name = "is_entry_info") Integer isEntryInfo,
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_ids") String[] bizIds,
@RequestParam(name = "page_index") Integer pageIndex,
@RequestParam(name = "page_size") Integer pageSize) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("?keyword={keyword}");
urlBuilder.append("&isEntryInfo={isEntryInfo}");
urlBuilder.append("&bizId={bizId}");
urlBuilder.append("&bizIds={bizIds}");
urlBuilder.append("&enable={enable}");
urlBuilder.append("&pageIndex={pageIndex}");
urlBuilder.append("&pageSize={pageSize}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate()
.getForEntity(urlBuilder.toString(), DataResponse.class, keyword, isEntryInfo, bizId, bizIds, enable, pageIndex, pageSize);
return result.getBody();
}
@PostMapping("")
@ApiOperation("添加签约公司")
@DataToUnderline()
//public DataResponse add(@RequestBody AddCompanyForm addCompanyForm) {
public DataResponse add(@RequestBody BizSignCompExtDto addCompanyForm) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate()
.postForEntity(urlBuilder.toString(), addCompanyForm, DataResponse.class);
DataResponse dataResponse = result.getBody();
return dataResponse;
}
@GetMapping("/info")
@ApiOperation("获取签约公司信息")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "id", value = "公司id", required = true, dataType = "Long"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "Long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "所属商家集合", required = false, allowMultiple = true, dataType = "String")
})
@DataToUnderline()
public DataResponse companyInfo(@RequestParam("id") Long id,
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_ids") String[] bizIds) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/info?id={id}&bizId={bizId}&bizIds={bizIds}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate()
.getForEntity(urlBuilder.toString(), DataResponse.class, id, bizId, bizIds);
return result.getBody();
}
@PutMapping("")
@ApiOperation("编辑公司信息")
@DataToUnderline()
public DataResponse edit(@RequestBody EditForm editForm) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<EditForm> entity = new HttpEntity<EditForm>(editForm, headers);
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate()
.exchange(urlBuilder.toString(), HttpMethod.PUT, entity, DataResponse.class);
DataResponse dataResponse = result.getBody();
return dataResponse;
}
@GetMapping("scope")
@ApiOperation("获取经营范围列表")
@DataToUnderline()
public DataResponse scores() {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
urlBuilder.append("/scope");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate()
.getForEntity(urlBuilder.toString(), DataResponse.class);
return result.getBody();
}
@DeleteMapping("biz")
@ApiOperation("删除公司对应的商家记录")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = true, dataType = "Long"),
@ApiImplicitParam(paramType = "query", name = "comp_id", value = "公司id", required = true, dataType = "Long")})
@DataToUnderline()
public DataResponse compBizDelete(@RequestParam("biz_id") Long bizId,
@RequestParam("comp_id") Long compId) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
ResponseEntity<DataResponse> resp = paymentServiceClient.getRestTemplate().exchange(urlBuilder + "/biz?bizId={bizId}&compId={compId}", HttpMethod.DELETE, null, DataResponse.class, bizId, compId);
return resp.getBody();
}
@PostMapping("/biz")
@ApiOperation("添加公司对应的商家记录")
@DataToUnderline()
public DataResponse compBizAdd(@RequestBody BizCompMapDto dto) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
DataResponse dataResponse = paymentServiceClient.post(urlBuilder + "/biz", dto);
return dataResponse;
}
@DeleteMapping("")
@ApiOperation("删除签约公司")
@ApiImplicitParam(paramType = "query", name = "comp_id", value = "公司id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse delCompany(@RequestParam("comp_id") Long compId) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append(BASE_URL);
ResponseEntity<DataResponse> resp = paymentServiceClient.getRestTemplate().exchange(urlBuilder + "?compId={compId}", HttpMethod.DELETE, null, DataResponse.class, compId);
return resp.getBody();
}
@GetMapping("download")
@ApiOperation("签约公司配置文件下载")
public void download(@RequestParam(name = "cashier_url") String cashierUrl, HttpServletRequest request, HttpServletResponse response) {
BufferedOutputStream buff = null;
ServletOutputStream outSTr = null;
try {
ResourceLoader resourceLoader = new DefaultResourceLoader();
Resource resource = resourceLoader.getResource("classpath:template/pay_cashier.conf");
//Resource resource = new ClassPathResource("classpath:template/pay_cashier.conf");
File file = resource.getFile();
//File file = ResourceUtils.getFile("classpath:template/pay_cashier.conf")
FileInputStream keyStoreIn = new FileInputStream(file);
InputStreamReader in = new InputStreamReader(keyStoreIn, "UTF-8");
BufferedReader br = new BufferedReader(in);
StringBuffer content = new StringBuffer();
String s = "";
while ((s = br.readLine()) != null) {
String line = String.format(s, cashierUrl);
content.append(line).append(System.lineSeparator());
}
//使用占位符
String outContext = String.format(content.toString(), cashierUrl);
// 导出文件
response.setContentType("text/plain");
String fileName = "phone-list";
response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".txt");
outSTr = response.getOutputStream(); // 建立
buff = new BufferedOutputStream(outSTr);
// 把内容写入文件
buff.write(outContext.getBytes("UTF-8"));
buff.flush();
buff.close();
} catch (IOException e) {
log.error("读取签约公司配置文件失败,error is {}", e);
} finally {
try {
buff.close();
outSTr.close();
} catch (Exception e) {
log.error("输入流关闭失败,error is {}", e);
}
}
}
}
package com.ost.micro.provider.controller;
import com.ost.micro.core.aop.DataToUnderline;
import com.ost.micro.core.context.model.response.DataResponse;
import com.ost.micro.core.pay.form.EditForm;
import com.ost.micro.core.pay.form.EditPayApiRateForm;
import com.ost.micro.core.pay.modules.sys.dto.MchPayApiDto;
import com.ost.micro.core.pay.modules.sys.dto.MchPayApiTmplDto;
import com.ost.micro.core.pay.modules.sys.dto.MchPayDto;
import com.ost.micro.core.pay.modules.sys.dto.MchPaySupplierDto;
import com.ost.micro.core.pay.modules.sys.request.EditPayApiRateDto;
import com.ost.micro.core.pay.modules.sys.request.MchPayBankDtoExt;
import com.ost.micro.core.utils.ResponseUtils;
import com.ost.micro.provider.common.PaymentServiceClient;
import com.ost.micro.provider.common.ServiceUrl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryClient;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/mch/supplier")
@Api(tags = "支付供应商接口")
public class SupplierController {
@Autowired
private PaymentServiceClient paymentServiceClient;
@Autowired
private ConsulDiscoveryClient consulDiscoveryClient;
@Autowired
private ServiceUrl serviceUrl;
private String url = null;// 支付供应商上
private String merchantUrl = null;// 商户
private String payCashierMerchantUrl = null;// 商户
// private String merchantPayInfoUrl =
// ServiceUrl.INSTACE.getUrl(consulDiscoveryClient)+"/api/supplier/merchant/payinfo";//商户详情
private String bankUrl = null;// 银行
private String tmlpUrl = null;// 支付接口模板
private String payapiUrl = null;// 支付接口模板
private String cashierPayapiUrl = null;// 支付接口模板
@GetMapping("")
@ApiOperation("查询供应商列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "comp_id", value = "签约公司", required = false, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "name", value = "关键字", required = false, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "type", value = "供应商类型", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "status", value = "启用状态", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = true, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse search(@RequestParam(required = false) String name,
@RequestParam(required = false, name = "comp_id") String compId,
@RequestParam(required = false) Integer type,
@RequestParam(required = false) Integer status,
@RequestParam(name = "page_index") Integer pageIndex,
@RequestParam(name = "page_size") Integer pageSize) {
if (url == null) {
url = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier";
}
Map params = new HashMap();
params.put("name", name);
params.put("type", type);
params.put("status", status);
params.put("pageIndex", pageIndex);
params.put("pageSize", pageSize);
params.put("compId", compId);
return paymentServiceClient.get(url, params);
}
@PostMapping("")
@ApiOperation("添加支付供应商")
@DataToUnderline()
public DataResponse add(@RequestBody(required = false) MchPaySupplierDto params) {
if (url == null) {
url = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier";
}
return paymentServiceClient.post(url, params);
}
@GetMapping("{id}")
@ApiOperation("支付供应商详情")
@ApiImplicitParam(paramType = "path", name = "id", value = "支付供应商_id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse detail(@PathVariable Long id) {
if (url == null) {
url = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier";
}
return paymentServiceClient.get(url, id);
}
@DeleteMapping("{id}")
@ApiOperation("删除支付供应商")
@ApiImplicitParam(paramType = "path", name = "id", value = "支付供应商_id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse delete(@PathVariable Long id) {
if (url == null) {
url = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier";
}
paymentServiceClient.delete(url, id);
return ResponseUtils.getInstance().success(null);
}
@PutMapping("")
@ApiOperation("编辑支付供应商")
@DataToUnderline()
public DataResponse edit(@RequestBody EditForm editForm) {
if (url == null) {
url = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier";
}
return paymentServiceClient.putForEntity(url, editForm);
// return ResponseUtils.getInstance().success(null);
}
@GetMapping("merchant")
@ApiOperation("查询商户列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "sup_id", value = "供应商id", required = false, dataType = "Long"),
@ApiImplicitParam(paramType = "query", name = "keyword", value = "关键字", required = false, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "is_entry_info", value = "是否是资质录入员", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "biz_id_admin", value = "商户商家id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "is_biz_id_from_permission", value = "bizId是否是权限系统中", required = false, dataType = "boolean"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "Long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "商家id", required = false, allowMultiple = true, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "enable", value = "启用状态", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = true, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse searchMerchant(@RequestParam(required = false, name = "sup_id") Long supId,
@RequestParam(required = false) String keyword,
@RequestParam(required = false, name = "is_entry_info") Integer isEntryInfo,
@RequestParam(required = false, name = "is_biz_id_from_permission") Boolean isBizIdFromPermission,
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_id_admin") Long bizIdAdmin,
@RequestParam(required = false, name = "biz_ids") String[] bizIds,
@RequestParam(required = false) Integer enable,
@RequestParam(name = "page_index") Integer pageIndex,
@RequestParam(name = "page_size") Integer pageSize) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append("/api/supplier/merchant");
urlBuilder.append("?supId={supId}");
urlBuilder.append("&keyword={keyword}");
urlBuilder.append("&isEntryInfo={isEntryInfo}");
urlBuilder.append("&isBizIdFromPermission={isBizIdFromPermission}");
urlBuilder.append("&bizId={bizId}");
urlBuilder.append("&bizIdAdmin={bizIdAdmin}");
urlBuilder.append("&bizIds={bizIds}");
urlBuilder.append("&enable={enable}");
urlBuilder.append("&pageIndex={pageIndex}");
urlBuilder.append("&pageSize={pageSize}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, supId, keyword, isEntryInfo, isBizIdFromPermission, bizId, bizIdAdmin, bizIds, enable, pageIndex, pageSize);
return result.getBody();
}
@GetMapping("merchant/info")
@ApiOperation("获取商户详情")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "is_entry_info", value = "是否是资质录入员", required = false, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "id", value = "商户id", required = true, dataType = "Long"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "Long"),
@ApiImplicitParam(paramType = "query", name = "biz_ids", value = "商家id集合", required = false, allowMultiple = true, dataType = "String")
})
@DataToUnderline()
public DataResponse getMerchant(@RequestParam Long id,
@RequestParam(required = false, name = "is_entry_info") Integer isEntryInfo,
@RequestParam(required = false, name = "biz_id") Long bizId,
@RequestParam(required = false, name = "biz_ids") String[] bizIds) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append("/api/supplier/merchant/info");
urlBuilder.append("?id={id}");
urlBuilder.append("&bizId={bizId}");
urlBuilder.append("&bizIds={bizIds}");
urlBuilder.append("&isEntryInfo={isEntryInfo}");
ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate().getForEntity(urlBuilder.toString(),
DataResponse.class, id, bizId, bizIds, isEntryInfo);
return result.getBody();
}
@PostMapping("merchant")
@ApiOperation("添加商户")
@DataToUnderline()
public DataResponse add(@RequestBody(required = false) MchPayDto params, @RequestParam(required = false, name = "biz_id") Long bizId) {
if (merchantUrl == null) {
merchantUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/merchant";
}
params.setCreateBy(bizId + "");
DataResponse dataResponse = paymentServiceClient.post(merchantUrl, params);
return dataResponse;
}
@DeleteMapping("/delMerchant")
@ApiOperation("删除商户")
@ApiImplicitParam(paramType = "query", name = "mch_id", value = "商户id", required = true, dataType = "long")
public DataResponse delMerchant(@RequestParam("mch_id") Long id) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append("/api/supplier");
ResponseEntity<DataResponse> resp = paymentServiceClient.getRestTemplate().exchange(urlBuilder + "/delMerchant?mchId={id}", HttpMethod.DELETE, null, DataResponse.class, id);
DataResponse dataResponse = resp.getBody();
return dataResponse;
}
@PutMapping("merchant")
@ApiOperation("编辑商户详情")
@DataToUnderline()
public DataResponse editMerchant(@RequestBody EditForm editForm) {
if (merchantUrl == null) {
merchantUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/merchant";
}
DataResponse dataResponse = paymentServiceClient.putForEntity(merchantUrl, editForm);
return dataResponse;
}
@DeleteMapping("merchant/{id}")
@ApiOperation("删除支付供应商户详情表")
@ApiImplicitParam(paramType = "path", name = "id", value = "支付供应商户详情表_id", required = true, dataType = "Long")
@RequiresPermissions("supplier:merchant:delete")
public DataResponse merchantDelete(@PathVariable Long id) {
if (merchantUrl == null) {
merchantUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/merchant";
}
paymentServiceClient.delete(merchantUrl, id);
return ResponseUtils.getInstance().success(null);
}
@GetMapping("payapi")
@ApiOperation("查询支付接口列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "sup_id", value = "供应商id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "api_name", value = "接口名", required = false, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = true, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse searchPayapi(@RequestParam(required = false, name = "sup_id") Long supId,
@RequestParam(required = false, name = "api_name") String apiName,
@RequestParam(name = "page_index") Integer pageIndex,
@RequestParam(name = "page_size") Integer pageSize) {
if (payapiUrl == null) {
payapiUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/payapi";
}
Map params = new HashMap();
params.put("supId", supId);
params.put("apiName", apiName);
params.put("pageIndex", pageIndex);
params.put("pageSize", pageSize);
return paymentServiceClient.get(payapiUrl, params);
}
@GetMapping("payapi/{id}")
@ApiOperation("获取支付接口详情")
@ApiImplicitParam(paramType = "path", name = "id", value = "支付接口id", required = true, dataType = "long")
@DataToUnderline()
public DataResponse getPayapi(@PathVariable Long id) {
if (payapiUrl == null) {
payapiUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/payapi";
}
return paymentServiceClient.get(payapiUrl, id);
}
@PutMapping("/payapi")
@ApiOperation("编辑支付接口详情")
@RequiresPermissions("supplier:payapi:edit")
public DataResponse editPayapi(@RequestBody MchPayApiDto mchPayApiFrom) {
if (payapiUrl == null) {
payapiUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/payapi";
}
paymentServiceClient.put(payapiUrl, mchPayApiFrom);
return ResponseUtils.getInstance().success(null);
}
@PostMapping("/payapi")
@ApiOperation("添加支付接口详情")
@DataToUnderline()
public DataResponse add(@RequestBody(required = false) MchPayApiDto params) {
if (payapiUrl == null) {
payapiUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/payapi";
}
DataResponse dataResponse = paymentServiceClient.post(payapiUrl, params);
return dataResponse;
}
@DeleteMapping("payapi/{id}")
@ApiOperation("删除支付接口")
@ApiImplicitParam(paramType = "path", name = "id", value = "支付接口_id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse payapiDelete(@PathVariable Long id) {
if (payapiUrl == null) {
payapiUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/payapi";
}
paymentServiceClient.delete(payapiUrl, id);
return ResponseUtils.getInstance().success(null);
}
@GetMapping("paytmpl")
@ApiOperation("获取全部支付接口模板")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = true, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse allPaytmpl(@RequestParam(name = "page_index") Integer pageIndex, @RequestParam(name = "page_size") Integer pageSize) {
if (tmlpUrl == null) {
tmlpUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/paytmpl";
}
Map params = new HashMap();
params.put("pageIndex", pageIndex);
params.put("pageSize", pageSize);
return paymentServiceClient.get(tmlpUrl, params);
/*Page page = paymentServiceClient.getPage(tmlpUrl, params);
DataPager dataPager = new DataPager(pageIndex, pageSize, page.getTotal(), page.getPages());
return ResponseUtils.getInstance().success(page.getRecords(), dataPager);*/
}
@PostMapping("paytmpl")
@ApiOperation("添加支付接口模板")
@DataToUnderline()
public DataResponse addPaytmpl(@RequestBody(required = false) MchPayApiTmplDto params) {
if (tmlpUrl == null) {
tmlpUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/paytmpl";
}
return paymentServiceClient.post(tmlpUrl, params);
}
@GetMapping("/paytmpl/{id}")
@ApiOperation("支付接口模板详情")
@ApiImplicitParam(paramType = "path", name = "id", value = "支付接口模板_id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse getPaytmpl(@PathVariable Long id) {
if (tmlpUrl == null) {
tmlpUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/paytmpl";
}
return paymentServiceClient.get(tmlpUrl, id);
}
@DeleteMapping("/paytmpl/{id}")
@ApiOperation("删除支付接口模板")
@ApiImplicitParam(paramType = "path", name = "id", value = "支付接口模板_id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse deletePaytmpl(@PathVariable Long id) {
if (tmlpUrl == null) {
tmlpUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/paytmpl";
}
paymentServiceClient.delete(tmlpUrl, id);
return ResponseUtils.getInstance().success(null);
}
@PutMapping("/paytmpl")
@ApiOperation("编辑支付接口模板")
@DataToUnderline()
public DataResponse editPaytmpl(@RequestBody MchPayApiTmplDto form) {
if (tmlpUrl == null) {
tmlpUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/paytmpl";
}
paymentServiceClient.put(tmlpUrl, form);
return ResponseUtils.getInstance().success(null);
}
@GetMapping("bank")
@ApiOperation("查询银行列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "supplier_id", value = "供应商id", required = false, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "bank_name", value = "银行名", required = false, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "enable", value = "启用状态", required = false, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "page_index", value = "页码", required = true, dataType = "int"),
@ApiImplicitParam(paramType = "query", name = "page_size", value = "每页数码条数", required = true, dataType = "int")})
@DataToUnderline()
public DataResponse searchBank(@RequestParam(required = false, name = "supplier_id") Long supplierId,
@RequestParam(required = false, name = "bank_name") String bankName,
@RequestParam(required = false, name = "enable") Integer enable,
@RequestParam(name = "page_index") Integer pageIndex,
@RequestParam(name = "page_size") Integer pageSize) {
if (bankUrl == null) {
bankUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/bank";
}
Map params = new HashMap();
params.put("supplierId", supplierId);
params.put("bankName", bankName);
params.put("enable", enable);
params.put("pageIndex", pageIndex);
params.put("pageSize", pageSize);
return paymentServiceClient.get(bankUrl, params);
}
@PostMapping("bank")
@ApiOperation("添加银行")
@DataToUnderline()
public DataResponse addBank(@RequestBody MchPayBankDtoExt params) {
if (bankUrl == null) {
bankUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/bank";
}
return paymentServiceClient.post(bankUrl, params);
}
@GetMapping("bank/{id}")
@ApiOperation("获取银行详情")
@ApiImplicitParam(paramType = "path", name = "id", value = "银行id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse getBank(@PathVariable Long id) {
if (bankUrl == null) {
bankUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/bank";
}
return paymentServiceClient.get(bankUrl, id);
}
@PutMapping("/bank")
@ApiOperation("编辑银行详情")
@DataToUnderline()
public DataResponse editBank(@RequestBody MchPayBankDtoExt editForm) {
if (bankUrl == null) {
bankUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/bank";
}
paymentServiceClient.put(bankUrl, editForm);
return ResponseUtils.getInstance().success(null);
}
@DeleteMapping("/bank/{id}")
@ApiOperation("删除 支付通道支持的银行")
@ApiImplicitParam(paramType = "path", name = "id", value = " 支付通道支持的银行_id", required = true, dataType = "Long")
@DataToUnderline()
public DataResponse deleteBank(@PathVariable Long id) {
if (bankUrl == null) {
bankUrl = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/bank";
}
paymentServiceClient.delete(bankUrl, id);
return ResponseUtils.getInstance().success(null);
}
/**
* 设置接口费率
*
* @return
*/
@PostMapping("api/rate")
@ApiOperation("支付接口费率设置")
@DataToUnderline()
public DataResponse postPayApiRate(@RequestBody EditPayApiRateDto editPayApiRateForm) {
String url = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/api/rate";
return paymentServiceClient.post(url, editPayApiRateForm);
}
/**
* 获取接口费率
*
* @param payApiId
* @param rentType
* @return
*/
@GetMapping("api/rate")
@ApiOperation("获取支付接口费率")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "pay_api_id", value = "支付接口id", required = true, dataType = "long"),
@ApiImplicitParam(paramType = "query", name = "rent_type", value = "租用方式", required = true, dataType = "int")
})
@DataToUnderline()
public DataResponse getPayApiRate(@RequestParam(name = "pay_api_id") Long payApiId, @RequestParam(name = "rent_type") Integer rentType) {
String url = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/api/rate";
Map params = new HashMap();
params.put("payApiId", payApiId);
params.put("rentType", rentType);
return paymentServiceClient.get(url, params);
}
/**
* 编辑接口费率
*
* @param
* @return
*/
@PutMapping("api/rate")
@ApiOperation("编辑支付接口费率")
@DataToUnderline()
public DataResponse edit(@RequestBody(required = false) EditPayApiRateForm entity) {
String url = serviceUrl.getAsServiceUrl(consulDiscoveryClient) + "/api/supplier/api/rate";
return paymentServiceClient.putForEntity(url, entity);
}
}
package com.ost.micro.provider.controller;
import com.ost.micro.core.aop.DataToUnderline;
import com.ost.micro.core.context.model.response.DataResponse;
import com.ost.micro.core.pay.modules.sys.excel.BizBean;
import com.ost.micro.core.utils.ResponseUtils;
import com.ost.micro.provider.common.PaymentServiceClient;
import com.ost.micro.provider.common.ServiceUrl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/mch/tool")
@Api(tags = "查询工具接口")
public class ToolController {
@Autowired
private ConsulDiscoveryClient consulDiscoveryClient;
@Autowired
private PaymentServiceClient paymentServiceClient;
@Autowired
private ServiceUrl serviceUrl;
@GetMapping("payorder")
@ApiOperation("查询某条支付订单")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "order_no", value = "订单号", required = true, dataType = "String"),
@ApiImplicitParam(paramType = "query", name = "biz_id", value = "商家id", required = false, dataType = "Long")
})
@DataToUnderline()
public DataResponse queryPayOrder(@RequestParam(name = "order_no") String orderNo, @RequestParam(required = false, name = "biz_id") Long bizId) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append("/api/tool/payorder");
Map<String, Object> params = new HashMap<>();
params.put("orderNo", orderNo);
return paymentServiceClient.get(urlBuilder.toString(), params);
/*ResponseEntity<DataResponse> result = paymentServiceClient.getRestTemplate()
.getForEntity(urlBuilder.toString(), DataResponse.class, orderNo);
return result.getBody();*/
}
@GetMapping("idcard")
@ApiOperation("查询身份证")
@ApiImplicitParam(paramType = "query", name = "id_no", value = "身份证号", required = true, dataType = "String")
@DataToUnderline()
public DataResponse queryIdCard(@RequestParam(name = "id_no") String idNo) {
return ResponseUtils.getInstance().success(new BizBean());
}
@GetMapping("bankcard")
@ApiOperation("查询银行卡")
@ApiImplicitParam(paramType = "query", name = "card_no", value = "银行卡号", required = true, dataType = "String")
@DataToUnderline()
public DataResponse queryBankCard(@RequestParam(name = "card_no") String cardNo) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serviceUrl.getAsServiceUrl(consulDiscoveryClient));
urlBuilder.append("/api/tool/bankcard");
Map<String, Object> params = new HashMap<>();
params.put("cardNo", cardNo);
return paymentServiceClient.get(urlBuilder.toString(), params);
}
}
applications: ${spring.application.name}
\ No newline at end of file
applications: ${spring.application.name}
\ No newline at end of file
applications: ${spring.application.name}
\ No newline at end of file
applications: ${spring.application.name}
\ No newline at end of file
applications: ${spring.application.name}
\ No newline at end of file
applications: ${spring.application.name}
\ No newline at end of file
applications: ${spring.application.name}
\ No newline at end of file
server:
port: 6019
tomcat:
basedir: /web/temp_upload
spring:
profiles:
#active: prod
active: devv2
application:
name: micro-project.as.pay-provider-v2
cloud:
consul:
#host: 10.113.8.24
host: 172.30.10.176
port: 8500
\ No newline at end of file
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