BusinessAssistantMerchantController.java 9 KB
package cn.com.glsx.busassistant.controller;

import cn.com.glsx.busassistant.request.activity.ActivityIdRequest;
import cn.com.glsx.busassistant.request.merchant.CoProductRopRequest;
import cn.com.glsx.busassistant.request.merchant.*;
import cn.com.glsx.busassistant.request.messageBox.MessageBoxCheckRopRequest;
import cn.com.glsx.busassistant.request.messageBox.MessageBoxPageRopRequest;
import cn.com.glsx.busassistant.response.merchant.MerchantBaseRopResponse;
import cn.com.glsx.busassistant.response.merchant.MerchantBySceneRopResponse;
import cn.com.glsx.busassistant.response.merchant.MerchantPageRopResponse;
import cn.com.glsx.busassistant.response.merchant.MerchantRopResponse;
import cn.com.glsx.busassistant.response.messageBox.MessageBoxPageRopResponse;
import cn.com.glsx.busassistant.service.BusiAssistantMerchantService;
import cn.com.glsx.busassistant.util.Pagination;
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 cn.com.glsx.scrm.shopmall.dto.stoassistant.NewestActivityReportDTO;
import cn.com.glsx.scrm.shopmall.remote.ActivityReportRemote;
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.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Author xiongzs
 * @Description 生意助手-门店接口
 * @date 2022/10/14 13:51
 * @Version 1.0
 */

@Slf4j
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("生意助手-门店")
public class BusinessAssistantMerchantController {

    @Autowired
    private BusiAssistantMerchantService merchantService;
    @Autowired
    private ActivityReportRemote activityReportRemote;

    @ApiOperation("申请门店列表")
    @ServiceMethod(method = "scrm.api.busassistant.merchant.page", needInSession = NeedInSessionType.YES)
    public RopResponse<Pagination<MerchantPageRopResponse>> getApplyMerchantPage(MerchantPageRopRequest ropRequest) {
        try {
            return RopResponse.success(merchantService.getApplyMerchantPage(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======BusinessAssistantActivityControllerr__invoke__MerchantPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ApiOperation("申请门店")
    @ServiceMethod(method = "scrm.api.busassistant.merchant.apply", needInSession = NeedInSessionType.YES)
    public RopResponse<Boolean> addApplyMerchant(MerchantApplyRopRequest ropRequest) {
        try {
            merchantService.addApplyMerchant(ropRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======BusinessAssistantActivityControllerr__invoke__MerchantApply__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ApiOperation("确认申请门店")
    @ServiceMethod(method = "scrm.api.busassistant.merchant.confirm", needInSession = NeedInSessionType.YES)
    public RopResponse<Boolean> confirmMerchant(MerchantConfirmRopRequest ropRequest) {
        try {
            merchantService.confirmMerchant(ropRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======BusinessAssistantActivityControllerr__invoke__Merchantconfirm__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ApiOperation("根据场景查询已开通的商户")
    @ServiceMethod(method = "scrm.api.busassistant.merchant.byscene", needInSession = NeedInSessionType.NO)
    public RopResponse<List<MerchantBySceneRopResponse>> findMerchantByScene(MerchantBySceneRopRequest request) {
        try {
            return RopResponse.success(merchantService.findMerchantByScene(request));
        } catch (RpcServiceException e) {
            log.info("=======BusinessAssistantActivityControllerr__invoke__MerchantByScene__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }


    @ApiOperation("消息盒子列表")
    @ServiceMethod(method = "scrm.api.busassistant.messageBox.page", needInSession = NeedInSessionType.YES)
    public RopResponse<Pagination<MessageBoxPageRopResponse>> getMessageBoxPage(MessageBoxPageRopRequest pageReuest) {
        try {
            return RopResponse.success(merchantService.getMessageBoxPage(pageReuest));
        } catch (RpcServiceException e) {
            log.info("=======BusinessAssistantActivityControllerr__invoke__MessageBoxPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ApiOperation("查询是否有未读消息")
    @ServiceMethod(method = "scrm.api.busassistant.messageBox.isread", needInSession = NeedInSessionType.YES)
    public RopResponse<Boolean> checkMessageReadStatus(MessageBoxCheckRopRequest ropRequest) {
        try {
            return RopResponse.success(merchantService.checkMessageReadStatus(ropRequest.getServiceMerchantId()));
        } catch (RpcServiceException e) {
            log.info("=======BusinessAssistantActivityControllerr__invoke__MessageBoxIsRead__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ApiOperation("获取最新战报消息")
    @ServiceMethod(method = "scrm.api.busassistant.message.battleMessage", needInSession = NeedInSessionType.YES)
    public RopResponse<MessageBoxPageRopResponse> getNewestMessage(MessageBoxCheckRopRequest ropRequest) {
        try {
            return RopResponse.success(merchantService.getNewestMessage(ropRequest.getServiceMerchantId()));
        } catch (RpcServiceException e) {
            log.info("=======BusinessAssistantActivityControllerr__invoke__battleMessage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ApiOperation("获取活动最新战报")
    @ServiceMethod(method = "scrm.api.busassistant.crowd.activity.newest.report",needInSession = NeedInSessionType.YES)
    private RopResponse<NewestActivityReportDTO> getNewestActivityReport(ActivityIdRequest request){
        log.error("获取活动最新战报,活动id={}",request.getActivityId());
        try {
            RpcResponse<NewestActivityReportDTO> rpcResponse = activityReportRemote.getBattleReportUrlByActivityId(request.getActivityId());
            if(rpcResponse.isFailed()){
                return RopResponse.error(rpcResponse.getMessage());
            }
            if(!rpcResponse.hasResult()){
                return RopResponse.success(null);
            }
            return RopResponse.success(rpcResponse.getResult());
        }catch (Exception e){
            log.error("获取活动最新战报,活动id={},异常:{}",request.getActivityId(),e);
            return RopResponse.error("系统异常");
        }
    }

    @ApiOperation("申请合作产品")
    @ServiceMethod(method = "scrm.api.busassistant.merchant.addCoProduct", needInSession = NeedInSessionType.NO)
    public RopResponse<Boolean> addCoProduct(CoProductRopRequest ropRequest) {
        try {
            return RopResponse.success(merchantService.addCoProduct(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======BusinessAssistantActivityControllerr__invoke__addCoProduct__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ApiOperation("根据场景值、服务商查询4s店")
    @ServiceMethod(method = "scrm.api.busassistant.merchant.getMerchantListBySceneRemote", needInSession = NeedInSessionType.NO)
    public RopResponse<List<MerchantBaseRopResponse>> getMerchantListBySceneRemote(MerchantBySceneRemoteRopRequest ropRequest) {
        try {
            return RopResponse.success(merchantService.getMerchantListBySceneRemote(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======BusinessAssistantActivityControllerr__invoke__getMerchantListBySceneRemote__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ApiOperation("查询商户详情")
    @ServiceMethod(method = "scrm.api.busassistant.merchant.getMerchantIdByMerchantNo", needInSession = NeedInSessionType.NO)
    public RopResponse<List<MerchantRopResponse>> getMerchantIdByMerchantNo(MerchantRopRequest ropRequest) {
        try {
            return RopResponse.success(merchantService.getMerchantIdByMerchantNo(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======BusinessAssistantActivityControllerr__invoke__getMerchantIdByMerchantNo__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

}