PaymentController.java
8.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package cn.com.glsx.entmicro.controller.payment;
import cn.com.glsx.entmicro.request.payment.*;
import cn.com.glsx.entmicro.service.payment.PaymentService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.platform.payment.dto.response.CreatePaymentResponseDTO;
import cn.com.glsx.platform.payment.dto.response.CreateTradeResponseDTO;
import cn.com.glsx.platform.payment.dto.response.PaymentPageResponseDTO;
import cn.com.glsx.platform.payment.model.PaymentAppInfo;
import cn.com.glsx.scrm.proxy.model.merchant.MerchantRopResponse;
import com.rop.AbstractRopRequest;
import com.rop.annotation.IgnoreSignType;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.oreframework.boot.autoconfigure.rop.metadata.RopProperty;
import org.oreframework.boot.autoconfigure.rop.util.RopClientUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.HashMap;
import java.util.List;
/**
* @author fanfr
* @Description: 支付配置
* @date 2022/12/02 13:57
*/
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
@Api("支付配置接口")
@Slf4j
public class PaymentController {
@Autowired
private PaymentService paymentService;
/**
* 上传证书文件
* @param request
* @return
*/
@ServiceMethod(method = "entmicro.api.payment.uploadCert", needInSession = NeedInSessionType.YES, ignoreSign = IgnoreSignType.YES)
@ApiOperation("上传证书文件")
public RopResponse<String> uploadCert( UploadCertFileRequest request) {
try {
String url = paymentService.uploadCert(request);
return RopResponse.success(url);
} catch (RpcServiceException e) {
log.info("=======PaymentController__invoke__uploadCert__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
@ServiceMethod(method = "entmicro.api.payment.createPayment", needInSession = NeedInSessionType.YES, ignoreSign = IgnoreSignType.YES)
@ApiOperation("创建支付账号")
public RopResponse<HashMap<String, CreatePaymentResponseDTO>> createPayment(CreatePaymentRequest request) {
try {
HashMap<String, CreatePaymentResponseDTO> response = paymentService.createPayment(request);
return RopResponse.success(response);
} catch (RpcServiceException e) {
log.info("=======PaymentController__invoke__createPayment__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
@ServiceMethod(method = "entmicro.api.payment.pageListPayment", needInSession = NeedInSessionType.YES, ignoreSign = IgnoreSignType.YES)
@ApiOperation("支付账号列表分页查询")
public RopResponse<RpcPagination<PaymentPageResponseDTO>> pageListPayment(PaymentQueryRequest request) {
try {
RpcPagination<PaymentPageResponseDTO> response = paymentService.pageListPayment(request);
return RopResponse.success(response);
} catch (RpcServiceException e) {
log.info("=======PaymentController__invoke__createPayment__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
@ServiceMethod(method = "entmicro.api.payment.deleteById", needInSession = NeedInSessionType.YES, ignoreSign = IgnoreSignType.YES)
@ApiOperation("删除支付账号")
public RopResponse<Boolean> deleteById(PaymentQueryRequest request) {
try {
Boolean aBoolean = paymentService.deleteById(request);
return RopResponse.success(aBoolean);
} catch (RpcServiceException e) {
log.info("=======PaymentController__invoke__createPayment__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
@ServiceMethod(method = "entmicro.api.payment.createWeappQrcode", needInSession = NeedInSessionType.YES, ignoreSign = IgnoreSignType.YES)
@ApiOperation("生成小程序码")
public RopResponse<String> createWeappQrcode(WeappQrcodeRequest request) {
log.info("createWeappQrcode :{}", request);
try {
String url = paymentService.createWeappQrcode(request);
return RopResponse.success(url);
} catch (RpcServiceException e) {
log.info("=======PaymentController__invoke__createWeappQrcode__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
@ServiceMethod(method = "entmicro.api.payment.getSceneById", needInSession = NeedInSessionType.NO, ignoreSign = IgnoreSignType.YES)
@ApiOperation("获取小程序码参数")
public RopResponse<String> getSceneById(SceneRequest request) {
log.info("getSceneById :{}", request);
try {
String scene = paymentService.getSceneById(request);
return RopResponse.success(scene);
} catch (RpcServiceException e) {
log.info("=======PaymentController__invoke__getSceneById__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
@ServiceMethod(method = "entmicro.api.payment.createBizQrCode", needInSession = NeedInSessionType.YES, ignoreSign = IgnoreSignType.YES)
@ApiOperation("生成公众号码")
public RopResponse<String> createBizQrCode(BizQrCodeReqeust request) {
log.info("createBizQrcode :{}", request);
String bizQrCode = paymentService.createBizQrCode(request);
if (StringUtils.isNotBlank(bizQrCode)) {
return RopResponse.success(bizQrCode);
}
return RopResponse.error(DefaultErrorEnum.SERVICE_ERROR);
}
@ServiceMethod(method = "entmicro.api.payment.createTrade", needInSession = NeedInSessionType.NO, ignoreSign = IgnoreSignType.YES)
@ApiOperation("创建交易订单")
public RopResponse<CreateTradeResponseDTO> createTrade(CreateTradeRequest request) {
try {
CreateTradeResponseDTO trade = paymentService.createTrade(request);
return RopResponse.success(trade);
} catch (RpcServiceException e) {
log.info("=======PaymentController__invoke__createTrade__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
@ServiceMethod(method = "entmicro.api.payment.listMerchant", needInSession = NeedInSessionType.YES, ignoreSign = IgnoreSignType.YES)
@ApiOperation("查询商户列表")
public RopResponse<List<MerchantRopResponse>> listMerchant(MerchantPageRequest request) {
try {
List<MerchantRopResponse> response = paymentService.listMerchant(request);
return RopResponse.success(response);
} catch (RpcServiceException e) {
log.info("=======PaymentController__invoke__listMerchant__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
@ServiceMethod(method = "entmicro.api.payment.listAppInfo", needInSession = NeedInSessionType.NO, ignoreSign = IgnoreSignType.YES)
@ApiOperation("查询App列表")
public RopResponse<List<PaymentAppInfo>> listAppInfo(AbstractRopRequest request) {
try {
List<PaymentAppInfo> response = paymentService.listAppInfo();
return RopResponse.success(response);
} catch (RpcServiceException e) {
log.info("=======PaymentController__invoke__listAppInfo__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
}