package com.yuchen.saas.park.service.service.property;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuchen.saas.park.api.entity.property.PropertyPaymentRefundAccountInfo;
import com.yuchen.saas.park.api.enums.property.AccountBizTypeEnum;
import com.yuchen.saas.park.api.enums.property.RecordTypeEnum;
import com.yuchen.saas.park.service.mapper.property.PropertyPaymentRefundAccountInfoMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Nullable;

@Service
public class PropertyPaymentRefundAccountInfoService extends ServiceImpl<PropertyPaymentRefundAccountInfoMapper, PropertyPaymentRefundAccountInfo> {

    public void removeAccountInfo(long retraceId, AccountBizTypeEnum accountBizTypeEnum, RecordTypeEnum recordTypeEnum) {
        LambdaQueryWrapper<PropertyPaymentRefundAccountInfo> qw = new LambdaQueryWrapper<>();
        qw.eq(PropertyPaymentRefundAccountInfo::getRetraceId,retraceId);
        qw.eq(PropertyPaymentRefundAccountInfo::getAccountBizType,accountBizTypeEnum.getValue());
        qw.eq(PropertyPaymentRefundAccountInfo::getRecordType,recordTypeEnum.getValue());
        this.remove(qw);
    }

    @Nullable
    public PropertyPaymentRefundAccountInfo getPaymentRefundAccountInfo(long retraceId, AccountBizTypeEnum accountBizTypeEnum,RecordTypeEnum recordTypeEnum) {
        LambdaQueryWrapper<PropertyPaymentRefundAccountInfo> qw = new LambdaQueryWrapper<>();
        qw.eq(PropertyPaymentRefundAccountInfo::getRetraceId,retraceId);
        qw.eq(PropertyPaymentRefundAccountInfo::getAccountBizType,accountBizTypeEnum.getValue());
        qw.eq(PropertyPaymentRefundAccountInfo::getRecordType,recordTypeEnum.getValue());
        return this.getOne(qw);
    }


}
