package com.ghy.customer.service.impl;

import com.ghy.common.utils.AdapayUtils;
import com.ghy.customer.domain.CustomerBank;
import com.ghy.customer.mapper.CustomerBankMapper;
import com.ghy.customer.service.CustomerBankService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author HH 2022/5/20
 */
@Service
public class CustomerBankServiceImpl implements CustomerBankService {

    @Resource
    CustomerBankMapper customerBankMapper;

    @Override
    public List<CustomerBank> getCustomerBankList(CustomerBank customerBank) {
        return customerBankMapper.getCustomerBankList(customerBank);
    }

    @Override
    public CustomerBank selectByCustomerId(Long customerId) {
        List<CustomerBank> list = customerBankMapper.selectByCustomerId(customerId);
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }

    @Override
    public List<CustomerBank> selectByCustomerIdAndDeptId(Long customerId, Long deptId) {
        return customerBankMapper.selectByCustomerIdAndDeptId(customerId, deptId);
    }

    @Override
    public CustomerBank selectByCustomerBankId(Long customerBankId) {
        return customerBankMapper.selectByCustomerBankId(customerBankId);
    }

    @Override
    public int deleteByIds(Long[] customerBankIds) {
        return customerBankMapper.deleteByIds(customerBankIds);
    }

    @Override
    public int deleteByCustomerBankId(Long customerBankId) {
        return customerBankMapper.deleteByCustomerBankId(customerBankId);
    }

    @Override
    public int insertCustomerBank(CustomerBank customerBank) {
        customerBank.setAdapayMemberId(AdapayUtils.getCustomerMemberId(customerBank.getCustomerId(), customerBank.getDeptId()));
        return customerBankMapper.insertCustomerBank(customerBank);
    }

    @Override
    public int updateCustomerBank(CustomerBank customerBank) {
        return customerBankMapper.updateCustomerBank(customerBank);
    }

    @Override
    public CustomerBank getByMemberId(String memberId) {
        return customerBankMapper.getByMemberId(memberId);
    }

    @Override
    public int updateByMemberId(CustomerBank customerBank) {
        return customerBankMapper.updateByMemberId(customerBank);
    }

}