package com.engine.salary.wrapper;

import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;

import com.engine.salary.entity.hrm.dto.HrmInfoDTO;
import com.engine.salary.entity.hrm.param.HrmQueryParam;
import com.engine.salary.entity.siaccount.dto.InsuranceCompensationDTO;
import com.engine.salary.entity.siaccount.param.*;
import com.engine.salary.service.SIBalanceService;
import com.engine.salary.service.SICompensationService;
import com.engine.salary.service.SIRecessionService;
import com.engine.salary.service.SIRepairService;
import com.engine.salary.service.impl.SIBalanceServiceImpl;
import com.engine.salary.service.impl.SICompensationServiceImpl;
import com.engine.salary.service.impl.SIRecessionServiceImpl;
import com.engine.salary.service.impl.SIRepairServiceImpl;
import com.engine.salary.util.page.PageInfo;
import weaver.hrm.User;

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

/**
 * @Author weaver_cl
 * @Description: TODO
 * @Date 2022/4/18
 * @Version V1.0
 **/
public class SIAccountWrapper extends Service {
    private SIRecessionService getSIRecessionService(User user) {
        return (SIRecessionService) ServiceUtil.getService(SIRecessionServiceImpl.class, user);
    }

    private SICompensationService getSICompensationService(User user) {
        return (SICompensationService) ServiceUtil.getService(SICompensationServiceImpl.class, user);
    }

    private SIBalanceService getSIBalanceService(User user) {
        return (SIBalanceService) ServiceUtil.getService(SIBalanceServiceImpl.class, user);
    }

    private SIRepairService getSIRepairService(User user) {
        return (SIRepairService) ServiceUtil.getService(SIRepairServiceImpl.class, user);
    }

    /**
     * 新增退差数据
     * @param param 退差请求体
     */
    public void saveRecession(RecessionParam param) {
        long currentEmployeeId = user.getUID();
        getSIRecessionService(user).save(param, currentEmployeeId);
    }

    /**
     * 删除退差数据
     * @param ids 表数据id集合
     */
    public void delRecession(Collection<Long> ids) {
        long currentEmployeeId = user.getUID();
        getSIRecessionService(user).del(ids, currentEmployeeId);
    }

    /**
     * 可退差人员列表
     */
    public PageInfo<HrmInfoDTO> getEmployeeListByTaxAgent(HrmQueryParam param) {

        return getSIRecessionService(user).getEmployeeListByTaxAgent(param);
    }

    /**
     * 可调差人员列表
     */
    public List<HrmInfoDTO> getEmployeeListToCompensation(HrmQueryParam hrmQueryParam) {

        return getSICompensationService(user).getEmployeeListToCompensation(hrmQueryParam);
    }

    /**
     * 获取社保福利项
     */
    public List<Map<String, String>> compensationCategoryType(Long id) {

        return getSICompensationService(user).compensationCategoryType(id);
    }

    /**
     * 获取当前调差福利类型-公司方支出总计
     */
    public List<Map<String, String>> compensationComTotal(List<CompensationParam> paramList) {

        return getSICompensationService(user).compensationComTotal(paramList);
    }

    /**
     * 社保调差保存
     */
    public Map<String, Object> compensationSave(List<InsuranceCompensationDTO> param) {

        return getSICompensationService(user).compensationAccount(param);
    }

    /**
     * 社保调差默认配置保存
     */
    public String compensationConfigSave(List<InsuranceCompensationDTO> param) {

        return getSICompensationService(user).compensationConfigSave(param);
    }

    /**
     * 社保调差撤回
     */
    public String compensationBack(InsuranceCompensationDTO param) {

        return getSICompensationService(user).compensationRevert(param);
    }

    /**
     * 社保调差列表
     */
    public Map<String, Object> compensationList(InsuranceCompensationDTO param) {
        return getSICompensationService(user).compensationList(param.getBillMonth(), param.getPaymentOrganization());
    }

    /**
     * 删除补差数据
     * @param param 表数据id集合、账单月、个税扣缴义务人
     */
    public void delBalance(InspectAccountParam param) {
        long currentEmployeeId = user.getUID();
        getSIBalanceService(user).del(param, currentEmployeeId);
    }

    /**
     * 取指定月份的福利缴纳基数作为补缴基数
     * @param param
     * @return
     */
    public List<Map<String, String>> getSupplementPaymentForm(SupplementAccountBaseParam param) {
        return getSIRepairService(user).getSupplementPaymentForm(param);
    }

    /**
     * 获取待编辑的补缴费用相关福利项
     * @param param
     * @return
     */
    public List<Map<String, String>> getPaymentGroup(SupplementAccountBaseParam param) {
        return getSIRepairService(user).getPaymentGroup(param);
    }

    /**
     * 获取待编辑的补差费用相关福利项
     * @param param
     * @return
     */
    public List<Map<String, String>> getBalancePaymentGroup(BalanceAccountBaseParam param) {
        return getSIBalanceService(user).getPaymentGroup(param);
    }

    public void addNewBalance(BalanceAccountBaseParam param) {
        getSIBalanceService(user).addNewBalance(param);
    }
}
