package com.inkasso.factoring.salesManagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.inkasso.factoring.common.enums.SalesContractPersonTypeEnum;
import com.inkasso.factoring.salesManagement.dao.CSalesContractPersonInfoMapper;
import com.inkasso.factoring.salesManagement.entity.CSalesContractBasicInfo;
import com.inkasso.factoring.salesManagement.entity.CSalesContractPersonInfo;
import com.inkasso.factoring.salesManagement.service.ICSalesContractBasicInfoService;
import com.inkasso.factoring.salesManagement.service.ICSalesContractPersonInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 销售合同-人员信息 服务实现类
 * </p>
 *
 * @author yafan
 * @since 2023-11-28
 */
@Service
public class CSalesContractPersonInfoServiceImpl extends ServiceImpl<CSalesContractPersonInfoMapper, CSalesContractPersonInfo>
        implements ICSalesContractPersonInfoService {

    @Autowired
    private ICSalesContractBasicInfoService salesContractBasicInfoService;

    @Override
    public List<CSalesContractPersonInfo> getAcceptanceSettlementPerson(Long salesManagementId) {

        CSalesContractBasicInfo basicInfo = salesContractBasicInfoService.getOne(new QueryWrapper<CSalesContractBasicInfo>()
                .eq("c_sales_contract_management_id", salesManagementId));
        if (basicInfo != null) {
            List<CSalesContractPersonInfo> personInfoList = list(new QueryWrapper<CSalesContractPersonInfo>().eq("type", SalesContractPersonTypeEnum.SALESCONTRACTPERSONTYPE_ACCEPTANCE.getCode())
                    .or().eq("type", SalesContractPersonTypeEnum.SALESCONTRACTPERSONTYPE_SETTLEMENT.getCode()));
            basicInfo.setPersonInfoList(personInfoList);
        }
        return null;
    }

    @Override
    public List<CSalesContractPersonInfo> findSettlementAgentInfoByType(String type) {
        return this.baseMapper.findSettlementAgentInfoByType(type);
    }
}
