EntmicroStaffRemoteImpl.java 12.7 KB
package cn.com.glsx.entmicro.remote;

import cn.com.glsx.entmicro.entity.EntmicroStaff;
import cn.com.glsx.entmicro.model.request.*;
import cn.com.glsx.entmicro.model.request.wechatcloudcontrol.login.WechatDepositRequest;
import cn.com.glsx.entmicro.model.response.EntmicroFollowerStaffResponse;
import cn.com.glsx.entmicro.model.response.EntmicroStaffResponse;
import cn.com.glsx.entmicro.service.EntmicroStaffService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author Lichongyuan
 * @Description:
 * @date 2021/9/16 14:39
 */
@Component
@Service(version = "1.0.0", protocol = "dubbo", timeout = 10000)
@Slf4j
public class EntmicroStaffRemoteImpl implements EntmicroStaffRemote {

    @Autowired
    private EntmicroStaffService entmicroStaffService;

    /**
     * 新增员工信息
     *
     * @param entmicroStaffRequest
     * @return
     */
    @Override
    public RpcResponse<Boolean> saveEntmicroStaff(EntmicroStaffRequest entmicroStaffRequest) {
        try {
            EntmicroStaff entmicroStaff = new EntmicroStaff();
            BeanUtils.copyProperties(entmicroStaffRequest, entmicroStaff);
            entmicroStaffService.saveEntmicroStaff(entmicroStaff, true);
            return RpcResponse.success(true);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 修改员工信息
     *
     * @param entmicroStaffRequest
     * @return
     */
    @Override
    public RpcResponse<Boolean> upateEntmicroStaff(EntmicroStaffRequest entmicroStaffRequest) {
        try {
            EntmicroStaff entmicroStaff = new EntmicroStaff();
            BeanUtils.copyProperties(entmicroStaffRequest, entmicroStaff);
            entmicroStaff.setMerchantid(entmicroStaffRequest.getMerchantId());
            entmicroStaffService.updateEntmicroStaff(entmicroStaff, true);
            return RpcResponse.success(true);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 删除员工信息
     *
     * @param entmicroStaffRequest
     * @return
     */
    @Override
    public RpcResponse<Boolean> deleteEntmicroStaff(EntmicroStaffRequest entmicroStaffRequest) {
        try {
            EntmicroStaff entmicroStaff = new EntmicroStaff();
            BeanUtils.copyProperties(entmicroStaffRequest, entmicroStaff);
            entmicroStaffService.deleteEntmicroStaff(entmicroStaff);
            return RpcResponse.success(true);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 查询外部联系人权限员工
     *
     * @param entmicroStaffRequest
     * @return
     */
    @Override
    public RpcResponse<List<EntmicroStaffResponse>> listOutSideContactStaff(EntmicroStaffRequest entmicroStaffRequest) {
        try {
            List<EntmicroStaffResponse> resultList = entmicroStaffService.listIsAddOutsiderStaff(entmicroStaffRequest);
            return RpcResponse.success(resultList);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 同步外部联系人权限企微员工
     *
     * @param entmicroStaffRequest
     * @return
     */
    @Override
    public RpcResponse<Boolean> syncEntmicroIsOutsiderStaff(EntmicroStaffRequest entmicroStaffRequest) {
        try {
            entmicroStaffService.syncIsAddOutSiderStaffList(entmicroStaffRequest.getMerchantId());
            return RpcResponse.success(true);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 企微端登录
     *
     * @param phoneAuthorizeRequest 入参
     * @return
     */
    @Override
    public RpcResponse<Boolean> entmicroLogin(PhoneAuthorizeRequest phoneAuthorizeRequest) {
        try {
            entmicroStaffService.entmicroLogin(phoneAuthorizeRequest);
            return RpcResponse.success(true);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 查询跟进人
     *
     * @param staffRequestDTO 员工入参
     * @return
     */
    @Override
    public RpcResponse<List<EntmicroStaffResponse>> findFollowStaff(StaffRequestDTO staffRequestDTO) {
        try {
            List<EntmicroStaffResponse> list = entmicroStaffService.findFollowStaff(staffRequestDTO);
            return RpcResponse.success(list);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 查询员工详情
     *
     * @param staffRequestDTO
     * @return
     */
    @Override
    public RpcResponse<EntmicroStaffResponse> findStaffDetail(StaffRequestDTO staffRequestDTO) {
        try {
            EntmicroStaffResponse entmicroStaffResponse = entmicroStaffService.findStaffDetail(staffRequestDTO);
            return RpcResponse.success(entmicroStaffResponse);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<EntmicroStaffResponse>> findlistEntmicroStaff(EntmicroStaffRequest entmicroStaffRequest) {
        try {
            List<EntmicroStaffResponse> entmicroStaffResponse = entmicroStaffService.findlistEntmicroStaff(entmicroStaffRequest);
            return RpcResponse.success(entmicroStaffResponse);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<EntmicroStaffResponse>> findLordGroup(LordCustomerGroupRequest lordCustomerGroupRequest) {
        try {
            List<EntmicroStaffResponse> entmicroStaffResponse = entmicroStaffService.findLordGroup(lordCustomerGroupRequest);
            return RpcResponse.success(entmicroStaffResponse);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<EntmicroStaffResponse>> findStaffByMerchantId(EntmicroStaffRequest entmicroStaffRequest) {
        try {
            log.info("EntmicroStaffRemoteImpl====invoke====findStaffByMerchantId: {}", JSONArray.toJSONString(entmicroStaffRequest));
            List<EntmicroStaffResponse> entmicroStaffResponse = entmicroStaffService.findStaffByMerchantId(entmicroStaffRequest);
            return RpcResponse.success(entmicroStaffResponse);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 根据员工id查询员工详情
     *
     * @param staffIds 员工id集合
     * @return
     */
    @Override
    public RpcResponse<Map<Integer, EntmicroStaffResponse>> findStaffDetailByIds(List<Integer> staffIds, String staffName) {
        try {
            Map<Integer, EntmicroStaffResponse> staffDetailByIds = entmicroStaffService.findStaffDetailByIds(staffIds, staffName);
            return RpcResponse.success(staffDetailByIds);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<Map<String, EntmicroStaffResponse>> findStaffDetailByUserIds(List<String> userIds, Integer merchantId) {
        try {
            Map<String, EntmicroStaffResponse> staffDetailByIds = entmicroStaffService.findStaffDetailByUserIds(userIds, merchantId);
            return RpcResponse.success(staffDetailByIds);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<EntmicroStaffResponse>> getStaffByBusinessType(String businessTypeList, Integer merchantId) {
        try {
            List<EntmicroStaffResponse> staffByBusinessType = entmicroStaffService.getEntmicroByBusinessType(businessTypeList, merchantId);
            return RpcResponse.success(staffByBusinessType);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 修改员工敏感信息
     *
     * @param updateStaffSensitiveInfoRequest
     * @return
     */
    @Override
    public RpcResponse<Boolean> updateStaffSensitiveInfo(UpdateStaffSensitiveInfoRequest updateStaffSensitiveInfoRequest) {
        try {
            entmicroStaffService.updateStaffSensitiveInfo(updateStaffSensitiveInfoRequest);
            return RpcResponse.success(true);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }


    /**
     * 查询门店下面已经开启的员工
     *
     * @param merchantStartStaffRequest
     * @return
     */
    @Override
    public RpcResponse<List<EntmicroStaffResponse>> findMerchantStartStaff(MerchantStartStaffRequest merchantStartStaffRequest) {
        try {
            List<EntmicroStaffResponse> merchantStartStaff = entmicroStaffService.findMerchantStartStaff(merchantStartStaffRequest);
            return RpcResponse.success(merchantStartStaff);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        } catch (Exception e) {
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<RpcPagination<EntmicroStaffResponse>> wechatDepositList(RpcPagination<WechatDepositRequest> pagination) {
        try {
            RpcPagination<EntmicroStaffResponse> listRpcPagination = entmicroStaffService.wechatDepositList(pagination);
            return RpcResponse.success(listRpcPagination);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 手动同步单个员工
     *
     * @param merchantId
     * @param userId
     * @return
     */
    @Override
    public RpcResponse<Boolean> syncSingleStaff(Integer merchantId, String userId) {
        try {
            EntmicroStaff entmicroSimpleStaff = entmicroStaffService.getEntmicroSimpleStaff(entmicroStaffService.findSupMerchantNo(merchantId), userId);
            EntmicroStaffResponse byMerchantIdAndUserId = entmicroStaffService.findByMerchantIdAndUserId(entmicroSimpleStaff);
            if (byMerchantIdAndUserId == null) {
                entmicroStaffService.saveEntmicroStaff(entmicroSimpleStaff, true);
            }else {
                entmicroSimpleStaff.setCreatedTime(null);
                entmicroStaffService.updateEntmicroStaff(entmicroSimpleStaff, true);
            }
            return RpcResponse.success(true);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<RpcPagination<EntmicroStaffResponse>> wechatDepositNotAccessList(RpcPagination<WechatDepositRequest> pagination) {
        try {
            RpcPagination<EntmicroStaffResponse> listRpcPagination = entmicroStaffService.wechatDepositNotAccessList(pagination);
            return RpcResponse.success(listRpcPagination);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        }
    }

    /**
     * 查询门店下面已经开启的员工
     *
     * @param autMerchantNo
     * @param merchantNo
     * @return
     */
    @Override
    public RpcResponse<List<EntmicroStaffResponse>> findResidentEntmicroStaff(Integer autMerchantNo, Integer merchantNo) {
        try {
            List<EntmicroStaffResponse> merchantStartStaff = entmicroStaffService.findResidentEntmicroStaff(autMerchantNo,merchantNo);
            return RpcResponse.success(merchantStartStaff);
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        } catch (Exception e) {
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<EntmicroStaffResponse>> findStaffList(List<StaffRequestDTO> requestDTO) {
        try {
            return RpcResponse.success(entmicroStaffService.findStaffDetailList(requestDTO));
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        } catch (Exception e) {
            return RpcResponse.error(e);
        }
    }

    @Override
    public RpcResponse<List<EntmicroStaffResponse>> findStaffListByTopMerchantId(EntmicroStaffRequest requestDTO) {
        try {
            return RpcResponse.success(entmicroStaffService.findStaffListByTopMerchantId(requestDTO));
        } catch (RpcServiceException e) {
            return RpcResponse.error(e);
        } catch (Exception e) {
            return RpcResponse.error(e);
        }
    }
}