MerchantWithdrawalPointsConfigService.java
5.87 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
package cn.com.glsx.stoassistant.service.withdrawal;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import cn.com.glsx.scrm.system.dto.LoginUserDTO;
import cn.com.glsx.stoassistant.convert.ConvertRequest;
import cn.com.glsx.stoassistant.convert.MerchantWithdrawalPointsConfigConverter;
import cn.com.glsx.stoassistant.model.request.withdrawal.MerchantWithdrawalPointsConfigCheckRpcRequest;
import cn.com.glsx.stoassistant.model.request.withdrawal.MerchantWithdrawalPointsConfigDeleteRpcRequest;
import cn.com.glsx.stoassistant.model.request.withdrawal.MerchantWithdrawalPointsConfigSaveRpcRequest;
import cn.com.glsx.stoassistant.model.request.withdrawal.MerchantWithdrawalPointsConfigSearchRpcRequest;
import cn.com.glsx.stoassistant.model.response.withdrawal.MerchantWithdrawalPointsConfigResponse;
import cn.com.glsx.stoassistant.remote.MerchantWithdrawalPointsConfigRemote;
import cn.com.glsx.stoassistant.request.withdrawal.MerchantWithdrawalPointsConfigCheckRopRequest;
import cn.com.glsx.stoassistant.request.withdrawal.MerchantWithdrawalPointsConfigDeleteRopRequest;
import cn.com.glsx.stoassistant.request.withdrawal.MerchantWithdrawalPointsConfigSaveRopRequest;
import cn.com.glsx.stoassistant.request.withdrawal.MerchantWithdrawalPointsConfigSearchRopRequest;
import cn.com.glsx.stoassistant.utils.Pagination;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.rop.util.RopThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Author yelq
* @Version 1.0
* @Description: 提现白名单
* @Date 2023/8/10 17:48
*/
@Slf4j
@Service
public class MerchantWithdrawalPointsConfigService {
@Autowired
private MerchantWithdrawalPointsConfigRemote merchantWithdrawalPointsConfigRemote;
public RpcPagination<MerchantWithdrawalPointsConfigResponse> withdrawalOfPointsPage(MerchantWithdrawalPointsConfigSearchRopRequest request) {
RpcPagination<MerchantWithdrawalPointsConfigSearchRpcRequest> requestDTO = ConvertRequest.convertPage(request, new MerchantWithdrawalPointsConfigSearchRpcRequest());
RpcResponse<RpcPagination<MerchantWithdrawalPointsConfigResponse>> rpcResponse = merchantWithdrawalPointsConfigRemote.withdrawalOfPointsPage(requestDTO);
if (rpcResponse.isSuccess()){
return rpcResponse.getResult();
}
log.error("白名单列表查询失败:{}", JSON.toJSONString(rpcResponse));
throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getException().getMessage());
}
public MerchantWithdrawalPointsConfigResponse withdrawalOfPointsMerchantCheck(MerchantWithdrawalPointsConfigCheckRopRequest request) {
MerchantWithdrawalPointsConfigCheckRpcRequest requestDTO = ConvertRequest.convertRequest(request, new MerchantWithdrawalPointsConfigCheckRpcRequest());
if (requestDTO.getSelectMerchantId()==null){
//未传参默认拿登录参数中的门店号
requestDTO.setSelectMerchantId(request.getMerchantId());
}
RpcResponse<MerchantWithdrawalPointsConfigResponse> response = merchantWithdrawalPointsConfigRemote.withdrawalOfPointsMerchantCheck(requestDTO);
if (response.isSuccess()){
return response.getResult();
}
log.error("积分提现门店白名单配置校验失败:{}", JSON.toJSONString(response));
throw new RpcServiceException(response.getException().getErrId(), response.getException().getMessage());
}
public Boolean withdrawalOfPointsMerchantListSave(MerchantWithdrawalPointsConfigSaveRopRequest request) {
MerchantWithdrawalPointsConfigSaveRpcRequest requestDTO = MerchantWithdrawalPointsConfigConverter.INSTANCE.toMerchantWithdrawalPointsConfigSaveRpcRequest(request);
try {
if (request.getCreatedBy()==null){
//运营端登录配置,获取登录信息
LoginUserDTO loginUser = RopThreadLocal.getLoginUser(LoginUserDTO.class);
requestDTO.setCreatedBy(loginUser.getId());
}
} catch (Exception e) {
log.info("获取登录信息失败:",e);
}
RpcResponse<Boolean> response = merchantWithdrawalPointsConfigRemote.withdrawalOfPointsMerchantListSave(requestDTO);
if (response.isSuccess()){
return response.getResult();
}
log.error("积分提现门店白名单配置失败:{}", JSON.toJSONString(response));
throw new RpcServiceException(response.getException().getErrId(), response.getException().getMessage());
}
public Boolean withdrawalOfPointsMerchantListDelete(MerchantWithdrawalPointsConfigDeleteRopRequest request) {
MerchantWithdrawalPointsConfigDeleteRpcRequest requestDTO = MerchantWithdrawalPointsConfigConverter.INSTANCE.toMerchantWithdrawalPointsConfigDeleteRpcRequest(request);
try {
if (request.getCreatedBy()==null){
//运营端登录配置,获取登录信息
LoginUserDTO loginUser = RopThreadLocal.getLoginUser(LoginUserDTO.class);
requestDTO.setCreatedBy(loginUser.getId());
}
} catch (Exception e) {
log.info("获取登录信息失败:",e);
}
RpcResponse<Boolean> response = merchantWithdrawalPointsConfigRemote.withdrawalOfPointsMerchantListDelete(requestDTO);
if (response.isSuccess()){
return response.getResult();
}
log.error("积分提现门店白名单删除失败:{}", JSON.toJSONString(response));
throw new RpcServiceException(response.getException().getErrId(), response.getException().getMessage());
}
}