package com.fs.newAdv.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fs.common.exception.base.BusinessException;
import com.fs.newAdv.domain.Lead;
import com.fs.newAdv.domain.PromotionAccount;
import com.fs.newAdv.enums.AdvertiserTypeEnum;
import com.fs.newAdv.mapper.LeadMapper;
import com.fs.newAdv.mapper.PromotionAccountMapper;
import com.fs.newAdv.service.IPromotionAccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;

/**
 * 推广账号服务实现类
 *
 * @author zhangqin
 * @date 2025-11-03
 */
@Slf4j
@Service
public class PromotionAccountServiceImpl extends ServiceImpl<PromotionAccountMapper, PromotionAccount>  implements IPromotionAccountService {

    @Autowired
    private PromotionAccountMapper promotionAccountMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchDelete(Long[] ids) {
        return promotionAccountMapper.deleteBatchIds(Arrays.asList(ids)) > 0;
    }

    @Override
    public PromotionAccount getAppByAppId(String appId, AdvertiserTypeEnum advertiserTypeEnum) {
        return this.getOne(new LambdaQueryWrapper<PromotionAccount>()
                .eq(PromotionAccount::getAppId, appId)
                .eq(PromotionAccount::getAdvertiserId, advertiserTypeEnum.getCode()));
    }
}

