package com.hzs.member.account.service;


import com.baomidou.mybatisplus.extension.service.IService;
import com.hzs.common.domain.member.account.CuMemberWithdraw;
import com.hzs.common.domain.member.account.CuMemberWithdrawExt;
import com.hzs.common.domain.system.config.BdWithdrawal;
import com.hzs.member.account.dto.MemberAccountAudit;
import com.hzs.member.account.vo.CuMemberPetitionVO;
import com.hzs.member.account.vo.CuMemberWithdrawVO;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 会员提现表 服务类
 * </p>
 *
 * @author hzs
 * @since 2022-09-06
 */
public interface ICuMemberWithdrawService extends IService<CuMemberWithdraw> {
    /**
     * 根据用户ID查询用户的提现次数
     *
     * @param pkMember 用户ID
     * @return Long
     */
    List<CuMemberWithdraw> getWithdrawTimes(Long pkMember);

    /**
     * 根据申请单号查询提现信息
     *
     * @param code 单号
     * @return CuMemberWithdraw
     */
    CuMemberWithdraw selectWithdrawByCode(String code);

    /**
     * 根据批次号查询审核记录
     *
     * @param batchNO 批次号
     * @return List<CuMemberWithdraw>
     */
    List<CuMemberWithdraw> selectWithdrawByBatch(String batchNO);


    /**
     * 保存提现
     *
     * @param cuMemberWithdraw 提现信息
     * @return Integer
     */
    Integer saveMemberWithdrawInfo(CuMemberWithdraw cuMemberWithdraw);

    /**
     * 更新审核信息
     *
     * @param memberAccountAudit 审核信息
     * @return Integer
     */
    Integer updateWithdrawByCode(MemberAccountAudit memberAccountAudit);


    /**
     * 查询列表信息
     *
     * @param cuMemberWithdrawVO 提现信息
     * @return List<CuMemberWithdrawExt>
     */
    Object[] selectMemberWithdrawList(CuMemberWithdrawVO cuMemberWithdrawVO);


    /**
     * 查询提现信息详情
     *
     * @param pkId ID
     * @return CuMemberWithdrawVO
     */
    CuMemberWithdrawVO queryCuMemberWithdrawDetail(Long pkId);

    /**
     * 打款
     *
     * @param memberWithdrawVO 充值信息
     * @return Integer
     */
    Integer withdrawPaymentByPkId(CuMemberWithdrawVO memberWithdrawVO);

    /**
     * 打款充正
     *
     * @param memberWithdrawVO 打款充正信息
     * @return Integer
     */
    Integer withdrawPaymentPositiveByPkId(CuMemberWithdrawVO memberWithdrawVO);


    /**
     * 获取余额
     *
     * @param pkMember  用户ID
     * @param pkCountry 国家ID
     * @return BigDecimal
     */
    BigDecimal getBalance(Long pkMember, Integer pkCountry, Integer accountsType);

    /**
     * 计算本次提现应该交的个税
     *
     * @param pkMember   用户ID
     * @param cashAmount 提现金额
     * @param pkCountry  国家ID
     * @param minAmount  最低提现金额
     * @return BigDecimal
     */
    BigDecimal computeIncomeTaxValue(Long pkMember, BigDecimal cashAmount, Integer pkCountry, BigDecimal minAmount);

    /**
     * 获取手续费金额
     *
     * @param pkCountry  国家ID
     * @param cashAmount 提现金额
     * @return BigDecimal
     */
    BigDecimal computeServiceCharge(Integer pkCountry, BigDecimal cashAmount);

    /**
     * 获取取整后的金额
     *
     * @param bdWithdrawal 提现配置信息
     * @param cashAmount   提现金额
     * @return BigDecimal
     */
    BigDecimal computeRounding(BdWithdrawal bdWithdrawal, BigDecimal cashAmount);

    /**
     * 自动提现
     */
    void autoWithdraw(BdWithdrawal withdrawal);


    /**
     * @param pkIds        主键集合
     * @param approveState 审核状态
     * @return List<CuMemberWithdraw>
     */
    List<CuMemberWithdraw> getWithdrawApproveStateByIds(List<Long> pkIds, Integer approveState);

    /**
     * 提现签呈显示
     *
     * @param pkIds
     * @return
     */
    CuMemberPetitionVO showMemberWithdrawPetition(List<Long> pkIds, Integer approveState);

    /**
     * 根据审核状态校验发起签呈
     *
     * @param pkIds        ID
     * @param approveState 审核状态
     * @return List<CuMemberWithdrawVO>
     */
    List<CuMemberWithdrawVO> checkWithdrawPetitionByState(List<Long> pkIds, Integer approveState);

    /**
     * 确认签呈
     *
     * @param cuMemberPetitionVO 签呈信息
     * @return Integer
     */
    Integer confirmWithdrawPetition(CuMemberPetitionVO cuMemberPetitionVO);


    /**
     * 会员端查询提现列表
     *
     * @param pkMember  会员编号
     * @param pkCountry 国家ID
     * @return List<CuMemberWithdrawExt>
     */
    Object[] selectMemberWithdrawListByPkMember(Long pkMember, Integer pkCountry);

    /**
     * 根据ID 修改提现状态
     *
     * @param pkId       主键ID
     * @param pkModified 修改人
     * @return Integer
     */
    Integer updateWithdrawStatusByPkId(Long pkId, Long pkModified);

}
