package com.fs.his.service.impl;

import com.fs.common.exception.CustomException;
import com.fs.common.utils.DateUtils;
import com.fs.his.domain.FsUserExtract;
import com.fs.his.mapper.FsUserExtractMapper;
import com.fs.his.param.FsUserExtractParam;
import com.fs.his.service.IFsUserExtractService;
import com.fs.his.vo.FsUserExtractVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户提现管理Service业务层处理
 *
 * @author fs
 * @date 2023-06-25
 */
@Service
public class FsUserExtractServiceImpl implements IFsUserExtractService
{
    @Autowired
    private FsUserExtractMapper fsUserExtractMapper;

    /**
     * 查询用户提现管理
     *
     * @param extractId 用户提现管理主键
     * @return 用户提现管理
     */
    @Override
    public FsUserExtract selectFsUserExtractByExtractId(String extractId)
    {
        return fsUserExtractMapper.selectFsUserExtractByExtractId(extractId);
    }

    /**
     * 查询用户提现管理列表
     *
     * @param fsUserExtract 用户提现管理
     * @return 用户提现管理
     */
    @Override
    public List<FsUserExtract> selectFsUserExtractList(FsUserExtract fsUserExtract)
    {
        return fsUserExtractMapper.selectFsUserExtractList(fsUserExtract);
    }

    /**
     * 新增用户提现管理
     *
     * @param fsUserExtract 用户提现管理
     * @return 结果
     */
    @Override
    public int insertFsUserExtract(FsUserExtract fsUserExtract)
    {
        fsUserExtract.setCreateTime(DateUtils.getNowDate());
        return fsUserExtractMapper.insertFsUserExtract(fsUserExtract);
    }

    /**
     * 修改用户提现管理
     *
     * @param fsUserExtract 用户提现管理
     * @return 结果
     */
    @Override
    public int updateFsUserExtract(FsUserExtract fsUserExtract)
    {
        if (fsUserExtract!=null)throw new CustomException("非法操作");
        if (fsUserExtract.getStatus()!=null&&fsUserExtract.getStatus()==1){
            //退款操作
        }

        fsUserExtract.setUpdateTime(DateUtils.getNowDate());
        fsUserExtract.setFailTime(DateUtils.getNowDate());
        return fsUserExtractMapper.updateFsUserExtract(fsUserExtract);
    }

    /**
     * 批量删除用户提现管理
     *
     * @param extractIds 需要删除的用户提现管理主键
     * @return 结果
     */
    @Override
    public int deleteFsUserExtractByExtractIds(String[] extractIds)
    {
        return fsUserExtractMapper.deleteFsUserExtractByExtractIds(extractIds);
    }

    /**
     * 删除用户提现管理信息
     *
     * @param extractId 用户提现管理主键
     * @return 结果
     */
    @Override
    public int deleteFsUserExtractByExtractId(String extractId)
    {
        return fsUserExtractMapper.deleteFsUserExtractByExtractId(extractId);
    }

    @Override
    public List<FsUserExtractVO> selectFsUserExtractListVO(FsUserExtractParam fsUserExtract) {
        return fsUserExtractMapper.selectFsUserExtractListVO(fsUserExtract);
    }
}
