CustomerReportController.java 4.85 KB
package cn.com.glsx.entmicro.controller;

import cn.com.glsx.entmicro.model.response.CustomerReportVO;
import cn.com.glsx.entmicro.model.response.GroupCustomerReportVO;
import cn.com.glsx.entmicro.request.customer.CustomerReportSearchRopRequest;
import cn.com.glsx.entmicro.service.CustomerReportService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;

import javax.annotation.Resource;

/**
 * @Description
 * @author chizw
 * @create 2022/1/11 11:04
 */
@Slf4j
@Api("客户报告接口")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
public class CustomerReportController {

    @Resource
    private CustomerReportService customerReportService;

    /**
     * 集团客户报告获取数据接口
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.group.report")
    @ApiOperation("集团客户报告获取数据接口")
    public RopResponse<RpcResponse<GroupCustomerReportVO>> getGroupCustomerReport(CustomerReportSearchRopRequest request) {
        try {
            return RopResponse.success(customerReportService.getGroupCustomerReport(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerReportController__invoke__getGroupCustomerReport__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 门店客户报告获取数据接口
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.merchant.report")
    @ApiOperation("门店客户报告获取数据接口")
    public RopResponse<RpcResponse<CustomerReportVO>> getMerchantCustomerReport(CustomerReportSearchRopRequest request) {
        try {
            return RopResponse.success(customerReportService.getMerchantCustomerReport(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerReportController__invoke__getMerchantCustomerReport__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 脚本 - 手动统计指定商户所有日期客户报告
     *
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.merchant.report.script")
    @ApiOperation("手动统计指定商户所有日期客户报告")
    public RopResponse<RpcResponse<Boolean>> handleStatisticsCustomerReportByAllDays(CustomerReportSearchRopRequest request) {
        try {
            RpcResponse<Boolean> flag = customerReportService.handleStatisticsCustomerReportByAllDays(request);
            return RopResponse.success(flag);
        } catch (RpcServiceException e) {
            log.info("=======CustomerReportController__invoke__handleStatisticsCustomerReportByAllDays__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 脚本 - 手动统计所有商户所有日期客户报告
     *
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.all.report.script")
    @ApiOperation("手动统计所有商户所有日期客户报告")
    public RopResponse<RpcResponse<Boolean>> handleStatisticsCustomerReportByAllMerchant(CustomerReportSearchRopRequest request) {
        try {
            RpcResponse<Boolean> flag = customerReportService.handleStatisticsCustomerReportByAllMerchant(request);
            return RopResponse.success(flag);
        } catch (RpcServiceException e) {
            log.info("=======CustomerReportController__invoke__handleStatisticsCustomerReportByAllMerchant__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 脚本 - 手动推送特定日期的周报/月报
     *
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.report.push")
    @ApiOperation("手动推送特定日期的周报/月报")
    public RopResponse<RpcResponse<Boolean>> handlePushWeeklyOrMonthlyReport(CustomerReportSearchRopRequest request) {
        try {
            RpcResponse<Boolean> flag = customerReportService.handlePushWeeklyOrMonthlyReport(request);
            return RopResponse.success(flag);
        } catch (RpcServiceException e) {
            log.info("=======CustomerReportController__invoke__handleStatisticsCustomerReportByAllMerchant__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }
}