SopTaskCustomerService.java 3.62 KB
package cn.com.glsx.stoassistant.service.sop;

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 cn.com.glsx.marketing.model.request.sop.SopCustomerPageRpcRequest;
import cn.com.glsx.marketing.model.request.sop.SopStageUpdateRpcRequest;
import cn.com.glsx.marketing.model.request.sop.SopTaskCustomerRequest;
import cn.com.glsx.marketing.model.response.sop.SopCustomerArchivesRpcResponse;
import cn.com.glsx.marketing.model.response.sop.SopCustomerRpcResponse;
import cn.com.glsx.marketing.remote.sop.SopTaskCustomerRemote;
import cn.com.glsx.stoassistant.convert.ConvertRequest;
import cn.com.glsx.stoassistant.convert.ConvertResponse;
import cn.com.glsx.stoassistant.request.sop.CustomerIdRopRequest;
import cn.com.glsx.stoassistant.request.sop.SaveSopTaskRopRequest;
import cn.com.glsx.stoassistant.request.sop.SopCustomerPageRopRequest;
import cn.com.glsx.stoassistant.request.sop.SopStageUpdateRopRequest;
import cn.com.glsx.stoassistant.response.sop.SopCustomerArchivesResponse;
import cn.com.glsx.stoassistant.response.sop.SopCustomerRopResponse;
import cn.com.glsx.stoassistant.utils.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


@Service
public class SopTaskCustomerService {

    @Autowired
    private SopTaskCustomerRemote sopTaskCustomerRemote;

    public Boolean saveSopTaskCustomer(SaveSopTaskRopRequest request) {
        RpcResponse<Boolean> rpcResponse = sopTaskCustomerRemote.saveSopTaskCustomer(request.getRequestList());
        if (rpcResponse.isSuccess()) {
            return rpcResponse.getResult();
        }
        throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getException().getMessage());
    }

    public Pagination<SopCustomerRopResponse> sopTaskCustomerPage(SopCustomerPageRopRequest request) {
        SopCustomerPageRpcRequest rpcRequest = ConvertRequest.convertRequest(request, new SopCustomerPageRpcRequest());
        RpcResponse<RpcPagination<SopCustomerRpcResponse>> rpcResponse = sopTaskCustomerRemote.sopTaskCustomerPage(rpcRequest);
        if (rpcResponse.isSuccess()) {
            return ConvertResponse.convertPage(rpcResponse.getResult(),SopCustomerRopResponse.class);
        }
        throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getException().getMessage());
    }

    public List<SopCustomerArchivesResponse> getCustomerArchives(CustomerIdRopRequest request) {
        SopTaskCustomerRequest rpcRequest = ConvertRequest.convertRequest(request, new SopTaskCustomerRequest());
        RpcResponse<List<SopCustomerArchivesRpcResponse>> rpcResponse = sopTaskCustomerRemote.sopCustomerArchives(rpcRequest);
        if (rpcResponse.isSuccess()) {
            return ConvertResponse.convertList(rpcResponse.getResult(),SopCustomerArchivesResponse.class);
        }
        throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getException().getMessage());
    }

    public Boolean changeCustomerStage(SopStageUpdateRopRequest request) {
        SopStageUpdateRpcRequest rpcRequest = ConvertRequest.convertRequest(request, new SopStageUpdateRpcRequest());
        RpcResponse<Boolean> rpcResponse = sopTaskCustomerRemote.changeCustomerStage(rpcRequest);
        if (rpcResponse.isSuccess()) {
            return rpcResponse.getResult();
        }
        throw new RpcServiceException(rpcResponse.getException().getErrId(), rpcResponse.getException().getMessage());
    }
}