DataCustomerRemoteImpl.java 2.88 KB
package cn.com.glsx.entmicro.remote;

import cn.com.glsx.entmicro.Enum.BusinessExceptionEnum;
import cn.com.glsx.entmicro.dto.DataGroupCustomerDTO;
import cn.com.glsx.entmicro.dto.DataMerchantCustomerDTO;
import cn.com.glsx.entmicro.dto.DataTotalCustomerDTO;
import cn.com.glsx.entmicro.dto.request.DataMerhcantCustomerRequest;
import cn.com.glsx.entmicro.service.DataCustomerService;
import cn.com.glsx.entmicro.service.drainage.DracScrmStatisticService;
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 com.alibaba.dubbo.config.annotation.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author wangxw
 * @version 1.0.0
 * @ClassName DataCustomerRemoteImpl.java
 * @description: ${description}
 * @createTime 2021年11月21日 16:35:00
 */
@Slf4j
@Component
@Service(version = "1.0.0", protocol = "dubbo", timeout = 10000)
public class DataCustomerRemoteImpl implements DataCustomerRemote {

    @Autowired
    private DataCustomerService dataCustomerService;

    @Autowired
    private DracScrmStatisticService dracScrmStatisticService;

    @Override
    public RpcResponse<DataTotalCustomerDTO> statisticsCustomerTotalCount(Integer merchantId) {
        RpcAssert.assertNotNull(merchantId, DefaultErrorEnum.PARAMETER_NULL, "params must not be null");
        DataTotalCustomerDTO dataTotalCustomerDTO = new DataTotalCustomerDTO();
        try {
            dataTotalCustomerDTO = dataCustomerService.statisticCustomerTotalCount(merchantId);
        } catch (Exception e) {
            log.error("statisticsCustomerTotalCount merchantId:{} is exception.", e.getMessage());
            throw new RpcServiceException(BusinessExceptionEnum.CUSTOMER_TOTAL_COUNT_ERROR);
        }
        return RpcResponse.success(dataTotalCustomerDTO);
    }

    @Override
    public RpcResponse<DataGroupCustomerDTO> statisticsCustomerGroupCount(Integer merchantId) {
        RpcAssert.assertNotNull(merchantId, DefaultErrorEnum.PARAMETER_NULL, "params must not be null");
        DataGroupCustomerDTO customerTypeCount = new DataGroupCustomerDTO();
        try {
            customerTypeCount = dracScrmStatisticService.findCustomerTypeCount(merchantId);
        } catch (Exception e) {
            log.error("statisticsCustomerTotalCount merchantId:{} is exception.", e.getMessage());
            throw new RpcServiceException(BusinessExceptionEnum.CUSTOMER_GROUP_COUNT_ERROR);
        }
        return RpcResponse.success(customerTypeCount);
    }

    @Override
    public RpcResponse<List<DataMerchantCustomerDTO>> statisticsMerchantCustomer(DataMerhcantCustomerRequest dataMerhcantCustomerRequest) {
        return null;
    }
}