MerchantStaffWithdrawalService.java
7.69 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
package cn.com.glsx.merchants.service;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.merchants.convert.ConvertRequest;
import cn.com.glsx.merchants.convert.ConvertResponse;
import cn.com.glsx.merchants.request.withdrawal.MerchantStaffFailBatchRopRequest;
import cn.com.glsx.merchants.request.withdrawal.MerchantStaffWithdrawalSearchRopRequest;
import cn.com.glsx.merchants.request.withdrawal.MerchantStaffWithdrawalUpdateRopRequest;
import cn.com.glsx.merchants.request.withdrawal.StaffWithdrawalImportRopRequest;
import cn.com.glsx.merchants.response.withdrawal.MerchantStaffWithdrawalListRopResponse;
import cn.com.glsx.merchants.response.withdrawal.StaffImportWithdrawalRopResponse;
import cn.com.glsx.merchants.response.withdrawal.StaffWithdrawalUrlRopResponse;
import cn.com.glsx.merchants.util.WithdrawalPagination;
import cn.com.glsx.stoassistant.model.request.withdrawal.MerchantStaffFailBatchRpcRequest;
import cn.com.glsx.stoassistant.model.request.withdrawal.MerchantStaffWithdrawalInsertRpcRequest;
import cn.com.glsx.stoassistant.model.request.withdrawal.MerchantStaffWithdrawalSearchRpcRequest;
import cn.com.glsx.stoassistant.model.request.withdrawal.StaffWithdrawalImportRpcRequest;
import cn.com.glsx.stoassistant.model.response.withdrawal.MerchantStaffWithdrawalListRpcResponse;
import cn.com.glsx.stoassistant.model.response.withdrawal.MerchantStaffWithdrawalPageRpcResponse;
import cn.com.glsx.stoassistant.model.response.withdrawal.StaffImportWithdrawalRpcResponse;
import cn.com.glsx.stoassistant.model.response.withdrawal.StaffWithdrawalUrlRpcResponse;
import cn.com.glsx.stoassistant.remote.MerchantStaffWithdrawalRemote;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @ClassName MerchantStaffWithdrawalService
* @Description
* @Author lichongyuan
* @Date 2022/10/14
*/
@Service
public class MerchantStaffWithdrawalService {
@Autowired
private MerchantStaffWithdrawalRemote merchantStaffWithdrawalRemote;
/**
* 获取提现管理列表
*
* @param request
* @return
*/
public WithdrawalPagination<MerchantStaffWithdrawalListRopResponse> getWithdrawalPage(MerchantStaffWithdrawalSearchRopRequest request) {
RpcPagination<MerchantStaffWithdrawalSearchRpcRequest> param = ConvertRequest.convertPage(request, new MerchantStaffWithdrawalSearchRpcRequest());
param.getCondition().setMerchantId(request.getMerchantNo());
RpcResponse<MerchantStaffWithdrawalPageRpcResponse> rpcResponse = merchantStaffWithdrawalRemote.getPage(param);
if (rpcResponse.isSuccess()) {
WithdrawalPagination<MerchantStaffWithdrawalListRopResponse> pagination = convertWithdrawalPage(rpcResponse.getResult(), MerchantStaffWithdrawalListRopResponse.class);
return pagination;
}
throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getMessage());
}
/**
* 提现列表分页转换
*
* @return 新分页参数
*/
private static <E, T> WithdrawalPagination<T> convertWithdrawalPage(MerchantStaffWithdrawalPageRpcResponse response, Class<T> clazz) {
RpcPagination<MerchantStaffWithdrawalListRpcResponse> list = response.getPagination();
WithdrawalPagination pagination = new WithdrawalPagination();
BeanUtils.copyProperties(response, pagination);
pagination.setReceivedAmount(response.getReceivedAmount());
pagination.setReceivingAmount(response.getReceivingAmount());
pagination.setReviewingAmount(response.getReviewingAmount());
pagination.setFailureAmount(response.getFailureAmount());
pagination.setTotalAmount(response.getTotalAmount());
pagination.setPageNum(list.getPageNum());
List<T> newList = ConvertResponse.convertList(list.getList(), clazz);
pagination.setData(newList);
pagination.setCount((int) list.getTotal());
pagination.setPageSize(list.getPageSize());
return pagination;
}
/**
* 批量提现审核
*/
public void batchWithdrawal(MerchantStaffWithdrawalUpdateRopRequest request) {
MerchantStaffWithdrawalInsertRpcRequest param = ConvertRequest.convertRequest(request, new MerchantStaffWithdrawalInsertRpcRequest());
param.setMerchantId(request.getMerchantNo());
param.setIdList(request.getIdList());
RpcResponse<Boolean> rpcResponse = merchantStaffWithdrawalRemote.batchWithdrawal(param);
if (rpcResponse.isFailed()) {
throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getMessage());
}
}
/**
* 导出提现列表
* @param request
* @return
*/
public String exportList(MerchantStaffWithdrawalSearchRopRequest request) {
MerchantStaffWithdrawalSearchRpcRequest param = ConvertRequest.convertRequest(request, new MerchantStaffWithdrawalSearchRpcRequest());
param.setMerchantId(request.getMerchantNo());
RpcResponse<String> rpcResponse = merchantStaffWithdrawalRemote.exportList(param);
if (rpcResponse.isSuccess()) {
return rpcResponse.getResult();
}
throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getMessage());
}
public Boolean failBatch(MerchantStaffFailBatchRopRequest request) {
MerchantStaffFailBatchRpcRequest rpcRequest = ConvertRequest.convertRequest(request, new MerchantStaffFailBatchRpcRequest());
RpcResponse<Boolean> rpcResponse = merchantStaffWithdrawalRemote.failBatch(rpcRequest);
if (rpcResponse.isSuccess()) {
return rpcResponse.getResult();
}
throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getMessage());
}
public StaffImportWithdrawalRopResponse importBankWithdrawal(StaffWithdrawalImportRopRequest request) {
StaffWithdrawalImportRpcRequest rpcRequest = ConvertRequest.convertRequest(request, new StaffWithdrawalImportRpcRequest());
RpcResponse<StaffImportWithdrawalRpcResponse> rpcResponse = merchantStaffWithdrawalRemote.importBankWithdrawal(rpcRequest);
if (rpcResponse.isSuccess()) {
return ConvertResponse.convertObject(rpcResponse.getResult(),StaffImportWithdrawalRopResponse.class);
}
throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getMessage());
}
public StaffWithdrawalUrlRopResponse exportBankWithdrawal(MerchantStaffWithdrawalSearchRopRequest request) {
MerchantStaffWithdrawalSearchRpcRequest rpcRequest = ConvertRequest.convertRequest(request, new MerchantStaffWithdrawalSearchRpcRequest());
RpcResponse<StaffWithdrawalUrlRpcResponse> rpcResponse = merchantStaffWithdrawalRemote.exportBankWithdrawal(rpcRequest);
if (rpcResponse.isSuccess()) {
return ConvertResponse.convertObject(rpcResponse.getResult(),StaffWithdrawalUrlRopResponse.class);
}
throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getMessage());
}
public String getWithdrawalRate(Integer merchantId) {
RpcResponse<String> rpcResponse = merchantStaffWithdrawalRemote.getWithdrawalRate(merchantId);
if (rpcResponse.isSuccess()) {
return rpcResponse.getResult();
}
throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getMessage());
}
}