BusiAssistantActivityRemoteImpl.java 10.7 KB
package cn.com.glsx.busassistant.remote;

import cn.com.glsx.busassistant.model.request.activity.*;
import cn.com.glsx.busassistant.model.request.product.BusiAssistantBaseRequest;
import cn.com.glsx.busassistant.model.request.product.QcCodeRequest;
import cn.com.glsx.busassistant.model.response.activity.*;
import cn.com.glsx.busassistant.model.response.product.OpenedProductRpcResponse;
import cn.com.glsx.busassistant.model.response.product.SceneProductRpcResponse;
import cn.com.glsx.busassistant.service.activity.BusiAssistantActivityService;
import cn.com.glsx.busassistant.service.product.BusiAssistantProductService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Author xiongzs

 * @date 2022/10/12 14:49
 * @Version 1.0
 */
@Slf4j
@DubboService(validation = "true",version = "1.0.0",protocol = "dubbo",timeout = 10000)
public class BusiAssistantActivityRemoteImpl implements BusiAssistantActivityRemote {

    @Autowired
    private BusiAssistantActivityService activityService;

    @Autowired
    private BusiAssistantProductService productService;

    @Override
    public RpcResponse<Boolean> addBusiAssistantActivity(ActivityApplyRpcRequest rpcRequest) {
        try {
            activityService.addBusiAssistantActivity(rpcRequest);
            return RpcResponse.success(true);
        } catch (RpcServiceException e) {
            log.error("申请开通活动异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<Boolean> confirmOpenActivity(ActivityConfirmRpcRequest rpcRequest) {
        try {
            return RpcResponse.success(activityService.confirmOpenActivity(rpcRequest));
        } catch (RpcServiceException e) {
            log.error("确认开通活动异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("确认开通活动异常:{}",e);
            return RpcResponse.error(e);
        }
    }


    @Override
    public RpcResponse<RpcPagination<ActivityRpcResponse>> findActivityPage(ActivityRpcPageRequest pageRequest) {
        try {
            Page<ActivityRpcResponse> page = activityService.findActivityPage(pageRequest);
            return RpcResponse.success(RpcPagination.copyPage(page));
        } catch (RpcServiceException e) {
            log.error("分页查询活动申请列表异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("分页查询活动申请列表异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<SceneProductRpcResponse>> findOpenedProductRecord(BusiAssistantBaseRequest request) {
        try {
            return RpcResponse.success(activityService.findOpenedProductRecord(request));
        } catch (RpcServiceException e) {
            log.error("查询已开通场景、产品记录异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("查询已开通场景、产品记录异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<ActivityOpenedByMerchantRpcResponse>> findOpenedActivityByMerchantIds(ActivityMerchantRpcRequest request) {
        try {
            List<ActivityOpenedByMerchantRpcResponse> responseList = activityService.findOpenedActivityByMerchantIds(request);
            return RpcResponse.success(responseList);
        } catch (RpcServiceException e) {
            log.error("通过商户号集合查询已开通场景异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("通过商户号集合查询已开通场景异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<SceneProductModelRpcResponse>> findProductsBySceneCode(String sceneCode) {
        try {
            return RpcResponse.success(productService.findProductsBySceneCode(sceneCode));
        } catch (RpcServiceException e) {
            log.error("根据场景编码查询产品异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("根据场景编码查询产品异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<SceneProductModelRpcResponse>> findSceneAndProductOpened(SceneAndProductOpenedRpcRequest request) {
        try {
            return RpcResponse.success(activityService.findSceneAndProductOpened(request));
        } catch (RpcServiceException e) {
            log.error("服务商+门店查询所有场景和产品的开通状态异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("服务商+门店查询所有场景和产品的开通状态异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<String> createQrCode(QcCodeRequest rpcRequest) {
        try {
            return RpcResponse.success(productService.createQrCode(rpcRequest));
        } catch (RpcServiceException e) {
            log.error("获取员工活动链接异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("获取员工活动链接异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<Boolean> openActivityForExternal(OpenActivityForExternalRpcRequest rpcRequest) {
        try {
            return RpcResponse.success(activityService.openActivityForExternal(rpcRequest));
        } catch (RpcServiceException e) {
            log.error("转化加、众筹活动直接开通活动异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("转化加、众筹活动直接开通活动异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<SceneOpenStatus>> findSceneOpenStatus(ActivityOpenStatusForStoAssRpcRequest rpcRequest) {
        try {
            return RpcResponse.success(activityService.findSceneOpenStatus(rpcRequest));
        } catch (RpcServiceException e) {
            log.error("查看所有场景的开通状态--门店助手异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("查看所有场景的开通状态--门店助手异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<ProductStatus>> findProductOpenStatus(ActivityOpenStatusForStoAssRpcRequest rpcRequest) {
        try {
            return RpcResponse.success(activityService.findProductOpenStatus(rpcRequest));
        } catch (RpcServiceException e) {
            log.error("根据场景查看产品的开通状态--门店助手异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("根据场景查看产品的开通状态--门店助手异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<Boolean> finishActivityByCrowdFundActId(Integer crowdFundActId) {
        try {
            return RpcResponse.success(activityService.finishActivityByCrowdFundActId(crowdFundActId));
        } catch (RpcServiceException e) {
            log.error("结束众筹活动异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("结束众筹活动异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<String> findSceneCodeByProductCode(String productCode) {
        try {
            return RpcResponse.success(productService.getSceneCodeByProductCode(productCode));
        } catch (RpcServiceException e) {
            log.error("根据产品编码查询场景异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("根据产品编码查询场景异常:{}",e);
            return RpcResponse.error(e);
        }
    }
    @Override
    public RpcResponse<Boolean> lightScene(Integer actId) {
        try {
            return RpcResponse.success(activityService.lightScene(actId));
        } catch (RpcServiceException e) {
            log.error("手动点亮场景异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("手动点亮场景异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<String> getActivityUrl() {
        try {
            return RpcResponse.success(activityService.getActivityUrl());
        } catch (RpcServiceException e) {
            log.error("获取活动链接配置:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("获取活动链接配置:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<Boolean> lightSceneByMerchantNo(LightSceneRpcRequest request) {
        try {
            return RpcResponse.success(activityService.lightSceneByMerchantNo(request));
        } catch (RpcServiceException e) {
            log.error("根据商户号点亮对应场景:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("根据商户号点亮对应场景:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<Boolean> openProductList(MerchantProductsRpcRequest rpcRequest) {
        try {
            return RpcResponse.success(activityService.openProductList(rpcRequest));
        } catch (RpcServiceException e) {
            log.error("开通产品集合异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("开通产品集合异常:{}",e);
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<SceneProductStatusResponse>> findSceneProductStatus(ActivityMerchantRpcRequest request) {
        try {
            return RpcResponse.success(activityService.findSceneProductStatus(request));
        } catch (RpcServiceException e) {
            log.error("开通产品集合异常:{}",e);
            return RpcResponse.error(e);
        }catch (Exception e){
            log.error("开通产品集合异常:{}",e);
            return RpcResponse.error(e);
        }
    }
}