CustomerReportService.java 3.97 KB
package cn.com.glsx.entmicro.service;

import cn.com.glsx.entmicro.convert.ConvertRequest;
import cn.com.glsx.entmicro.model.request.CustomerReportSearchRpcRequest;
import cn.com.glsx.entmicro.model.response.CustomerReportVO;
import cn.com.glsx.entmicro.model.response.GroupCustomerReportVO;
import cn.com.glsx.entmicro.remote.CustomerReportRemote;
import cn.com.glsx.entmicro.request.customer.CustomerReportSearchRopRequest;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
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 javax.annotation.Resource;

@Service
@Slf4j
public class CustomerReportService {

    @Autowired
    private CustomerReportRemote customerReportRemote;

    /**
     * 获取集团客户报告数据
     *
     * @param request
     * @return
     */
    public RpcResponse<GroupCustomerReportVO> getGroupCustomerReport(CustomerReportSearchRopRequest request) {
        CustomerReportSearchRpcRequest rpcRequest = ConvertRequest.convertRequest(request, new CustomerReportSearchRpcRequest());
        RpcResponse<GroupCustomerReportVO> response = customerReportRemote.merchantGroupCustomerReportQuery(rpcRequest);
        log.info("rop集团客户报告数据:{}", response);
        if (null != response && response.isSuccess()) {
            return response;
        }
        throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
    }

    /**
     * 获取门店客户报告数据
     *
     * @param request
     * @return
     */
    public RpcResponse<CustomerReportVO> getMerchantCustomerReport(CustomerReportSearchRopRequest request) {
        CustomerReportSearchRpcRequest rpcRequest = ConvertRequest.convertRequest(request, new CustomerReportSearchRpcRequest());
        RpcResponse<CustomerReportVO> response = customerReportRemote.merchantCustomerReportQuery(rpcRequest);
        log.info("rop门店客户报告数据:{}", response);
        if (null != response && response.isSuccess()) {
            return response;
        }
        throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
    }

    /**
     * 脚本 - 手动统计指定商户所有日期客户报告
     *
     * @param request
     */
    public RpcResponse<Boolean> handleStatisticsCustomerReportByAllDays(CustomerReportSearchRopRequest request) {
        CustomerReportSearchRpcRequest rpcRequest = ConvertRequest.convertRequest(request, new CustomerReportSearchRpcRequest());
        RpcResponse<Boolean> flag = customerReportRemote.handleStatisticsCustomerReportByAllDays(rpcRequest);
        log.info("手动统计" + request.getMerchantId() + "商户所有日期客户报告脚本已执行");
        return flag;
    }

    /**
     * 脚本 - 手动统计所有商户所有日期客户报告
     *
     * @param request
     */
    public RpcResponse<Boolean> handleStatisticsCustomerReportByAllMerchant(CustomerReportSearchRopRequest request) {
        CustomerReportSearchRpcRequest rpcRequest = ConvertRequest.convertRequest(request, new CustomerReportSearchRpcRequest());
        RpcResponse<Boolean> flag = customerReportRemote.handleStatisticsCustomerReportByAllMerchant(rpcRequest);
        log.info("手动统计所有商户所有日期客户报告脚本已执行");
        return flag;
    }

    /**
     * 脚本 - 手动推送特定日期的周报/月报
     *
     * @param request
     */
    public RpcResponse<Boolean> handlePushWeeklyOrMonthlyReport(CustomerReportSearchRopRequest request) {
        CustomerReportSearchRpcRequest rpcRequest = ConvertRequest.convertRequest(request, new CustomerReportSearchRpcRequest());
        RpcResponse<Boolean> flag = customerReportRemote.handlePushWeeklyOrMonthlyReport(rpcRequest);
        log.info("手动推送" + request.getStartDate() + "至" + request.getEndDate() + "的周报/月报脚本已执行");
        return flag;
    }
}