package com.fs.company.service.impl;

import java.util.List;

import com.fs.common.core.domain.R;
import com.fs.common.utils.DateUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.company.mapper.CompanyDivItemMapper;
import com.fs.company.domain.CompanyDivItem;
import com.fs.company.service.ICompanyDivItemService;

/**
 * 分账明细Service业务层处理
 *
 * @author fs
 * @date 2025-10-21
 */
@Service
public class CompanyDivItemServiceImpl extends ServiceImpl<CompanyDivItemMapper, CompanyDivItem> implements ICompanyDivItemService {

    /**
     * 查询分账明细
     *
     * @param id 分账明细主键
     * @return 分账明细
     */
    @Override
    public CompanyDivItem selectCompanyDivItemById(Long id)
    {
        return baseMapper.selectCompanyDivItemById(id);
    }

    /**
     * 查询分账明细列表
     *
     * @param companyDivItem 分账明细
     * @return 分账明细
     */
    @Override
    public List<CompanyDivItem> selectCompanyDivItemList(CompanyDivItem companyDivItem)
    {
        return baseMapper.selectCompanyDivItemList(companyDivItem);
    }

    /**
     * 新增分账明细
     *
     * @param companyDivItem 分账明细
     * @return 结果
     */
    @Override
    public int insertCompanyDivItem(CompanyDivItem companyDivItem)
    {
        companyDivItem.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insertCompanyDivItem(companyDivItem);
    }

    /**
     * 修改分账明细
     *
     * @param companyDivItem 分账明细
     * @return 结果
     */
    @Override
    public int updateCompanyDivItem(CompanyDivItem companyDivItem)
    {
        companyDivItem.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateCompanyDivItem(companyDivItem);
    }

    /**
     * 批量删除分账明细
     *
     * @param ids 需要删除的分账明细主键
     * @return 结果
     */
    @Override
    public int deleteCompanyDivItemByIds(Long[] ids)
    {
        return baseMapper.deleteCompanyDivItemByIds(ids);
    }

    /**
     * 删除分账明细信息
     *
     * @param id 分账明细主键
     * @return 结果
     */
    @Override
    public int deleteCompanyDivItemById(Long id)
    {
        return baseMapper.deleteCompanyDivItemById(id);
    }

    @Override
    public CompanyDivItem selectCompanyDivItemByOrderCode(String orderCode) {
        return baseMapper.selectCompanyDivItemByOrderCode(orderCode);
    }

    @Override
    public CompanyDivItem selectCompanyDivItemByPayCode(String payCode) {
        return baseMapper.selectCompanyDivItemByPayCode(payCode);
    }

    @Override
    public R confirmByPayCodes(List<String> payCodes) {
        if (payCodes != null && !payCodes.isEmpty()) {
            payCodes.forEach(HuiFuUtils::confirmByPayCode);
        }
        return R.ok();
    }

    @Override
    public R confirmByPayCodesScrm(List<String> payCodes) {
        if (payCodes != null && !payCodes.isEmpty()) {
            payCodes.forEach(HuiFuUtils::confirmByPayCodeScrm);
        }
        return R.ok();
    }
}
