MerchantServiceCenterService.java
2.01 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
package cn.com.glsx.busassistant.service;
import cn.com.glsx.dj.smartcarlife.dto.businessassistant.MerchantServiceCenterDTO;
import cn.com.glsx.dj.smartcarlife.remote.MerchantServiceCenterRemote;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Slf4j
@Service
public class MerchantServiceCenterService {
@Autowired
private MerchantServiceCenterRemote merchantServiceCenterRemote;
public List<Integer> listYqMerchantIdsByPartnerMerchantIds(List<Integer> partnerMerchantIds){
log.debug("查询园区店列表,partnerMerchantIds:{}", partnerMerchantIds);
MerchantServiceCenterDTO merchantServiceCenterDTO = MerchantServiceCenterDTO.builder().partnerMerchantIds(partnerMerchantIds).build();
List<MerchantServiceCenterDTO> yqMerchants = listYqMerchants(merchantServiceCenterDTO);
List<Integer> yqMerchantIds = Optional.ofNullable(yqMerchants).orElse(new ArrayList<>()).stream()
.map(MerchantServiceCenterDTO::getYqMerchantId)
.distinct().collect(Collectors.toList());
log.debug("查询园区店列表返回,yqMerchantIds:{}", yqMerchantIds);
return yqMerchantIds;
}
public List<MerchantServiceCenterDTO> listYqMerchants(MerchantServiceCenterDTO merchantServiceCenterDTO){
RpcResponse<List<MerchantServiceCenterDTO>> res = merchantServiceCenterRemote.listByServiceMerchantId(merchantServiceCenterDTO);
if(res.isSuccess()){
return res.getResult();
}else{
log.error("失败,res:{}", res);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, "查询商户员工列表失败");
}
}
}