package com.fjhx.sale.service.claim.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.account.entity.account.bo.AccountRunningWaterBo;
import com.fjhx.account.entity.account.dto.AccountRunningWaterDto;
import com.fjhx.account.entity.account.dto.AccountRunningWaterSelectDto;
import com.fjhx.account.entity.account.po.AccountManagement;
import com.fjhx.account.entity.account.po.AccountRemainder;
import com.fjhx.account.entity.account.po.AccountRunningWater;
import com.fjhx.account.entity.account.vo.AccountRunningWaterVo;
import com.fjhx.account.entity.tax.po.TaxRefundDetails;
import com.fjhx.account.mapper.account.AccountRunningWaterMapper;
import com.fjhx.account.service.account.AccountManagementService;
import com.fjhx.account.service.account.AccountRemainderService;
import com.fjhx.account.service.account.AccountRunningWaterService;
import com.fjhx.account.service.tax.TaxRefundDetailsService;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.common.entity.corporation.po.Corporation;
import com.fjhx.common.service.corporation.CorporationService;
import com.fjhx.common.utils.Assert;
import com.fjhx.common.utils.ExchangeRateUtil;
import com.fjhx.item.util.excel.util.ExcelUtil;
import com.fjhx.sale.service.claim.ClaimContractService;
import com.fjhx.sale.service.claim.SaleAccountRunningWaterService;
import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
import com.fjhx.tenant.service.dict.DictTenantDataService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;


/**
 * <p>
 * 账户资金流水表 服务实现类
 * </p>
 *
 * @author
 * @since 2023-04-06
 */
@Service
public class SaleAccountRunningWaterServiceImpl implements SaleAccountRunningWaterService {

    @Autowired
    private ClaimContractService claimContractService;

    @Autowired
    private AccountRunningWaterService accountRunningWaterService;


    @Override
    public Page<AccountRunningWaterVo> getPage(AccountRunningWaterSelectDto dto) {
        if (StringUtils.isNotEmpty(dto.getKeyword())) {
            List<Long> accountIdList = claimContractService.getAccountWaterIdsByContractCode(dto.getKeyword());
            dto.setAccountWaterIdList(accountIdList);
        }
        Page<AccountRunningWaterVo> page = accountRunningWaterService.getPage(dto);
        return page;
    }
}
