package com.ruoyi.frequency.userwithdrawalwaywi.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.code.PublicCommon;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.frequency.userwithdrawalway.entity.UserWithdrawalWay;
import com.ruoyi.frequency.userwithdrawalwaywi.entity.UserWithdrawalWayWi;
import com.ruoyi.frequency.userwithdrawalwaywi.mapper.UserWithdrawalWayWiMapper;
import com.ruoyi.frequency.userwithdrawalwaywi.service.UserWithdrawalWayWiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户提现方式(历史提现记录关联提现方式)Service业务层处理
 *
 * @author liwenlong
 * @date 2023-07-20
 */
@Service
public class UserWithdrawalWayWiServiceImpl extends ServiceImpl<UserWithdrawalWayWiMapper, UserWithdrawalWayWi>  implements UserWithdrawalWayWiService
{
    @Autowired
    private UserWithdrawalWayWiMapper userWithdrawalWayWiMapper;

    /**
     * 查询用户提现方式(历史提现记录关联提现方式)
     *
     * @param id 用户提现方式(历史提现记录关联提现方式)主键
     * @return 用户提现方式(历史提现记录关联提现方式)
     */
    @Override
    public UserWithdrawalWayWi selectUserWithdrawalWayWiById(Long id)
    {
        return userWithdrawalWayWiMapper.selectUserWithdrawalWayWiById(id);
    }

    /**
     * 查询用户提现方式(历史提现记录关联提现方式)列表
     *
     * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式)
     * @return 用户提现方式(历史提现记录关联提现方式)
     */
    @Override
    public List<UserWithdrawalWayWi> selectUserWithdrawalWayWiList(UserWithdrawalWayWi userWithdrawalWayWi)
    {
        return userWithdrawalWayWiMapper.selectUserWithdrawalWayWiList(userWithdrawalWayWi);
    }

    /**
     * 新增用户提现方式(历史提现记录关联提现方式)
     *
     * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式)
     * @return 结果
     */
    @Override
    public int insertUserWithdrawalWayWi(UserWithdrawalWayWi userWithdrawalWayWi)
    {
        userWithdrawalWayWi.setCreateTime(DateUtils.getNowDate());
        return userWithdrawalWayWiMapper.insertUserWithdrawalWayWi(userWithdrawalWayWi);
    }

    /**
     * 修改用户提现方式(历史提现记录关联提现方式)
     *
     * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式)
     * @return 结果
     */
    @Override
    public int updateUserWithdrawalWayWi(UserWithdrawalWayWi userWithdrawalWayWi)
    {
        userWithdrawalWayWi.setUpdateTime(DateUtils.getNowDate());
        return userWithdrawalWayWiMapper.updateUserWithdrawalWayWi(userWithdrawalWayWi);
    }

    /**
     * 批量删除用户提现方式(历史提现记录关联提现方式)
     *
     * @param ids 需要删除的用户提现方式(历史提现记录关联提现方式)主键
     * @return 结果
     */
    @Override
    public int deleteUserWithdrawalWayWiByIds(Long[] ids)
    {
        return userWithdrawalWayWiMapper.deleteUserWithdrawalWayWiByIds(ids);
    }

    /**
     * 删除用户提现方式(历史提现记录关联提现方式)信息
     *
     * @param id 用户提现方式(历史提现记录关联提现方式)主键
     * @return 结果
     */
    @Override
    public int deleteUserWithdrawalWayWiById(Long id)
    {
        return userWithdrawalWayWiMapper.deleteUserWithdrawalWayWiById(id);
    }


    @Override
    public UserWithdrawalWayWi addUserWithdrawalWayWi(UserWithdrawalWay userWithdrawalWay) {

        UserWithdrawalWayWi withdrawalWayWi = new UserWithdrawalWayWi()
                .setCashAccount(userWithdrawalWay.getCashAccount())
                .setContactWay(userWithdrawalWay.getContactWay())
                .setLinkman(userWithdrawalWay.getLinkman())
                .setDelFlag(PublicCommon.启用)
                .setAccountOpeningSubBranch(userWithdrawalWay.getAccountOpeningSubBranch())
                .setAreaCode(userWithdrawalWay.getAreaCode())
                .setPfWayId(userWithdrawalWay.getPfWayId())
                .setUserId(userWithdrawalWay.getUserId())
                .setUserType(userWithdrawalWay.getUserType())
                .setUserWithdrawalWayId(userWithdrawalWay.getId());

        this.save(withdrawalWayWi);

        return withdrawalWayWi;
    }
}
