package com.dayou.service.impl;

import com.dayou.brokerage.BrokerageCalculateSupport;
import com.dayou.brokerage.BrokerageCalculator;
import com.dayou.brokerage.MarketerBrokerageCalculator;
import com.dayou.brokerage.factory.BrokerageCalculateFactory;
import com.dayou.brokerage.constants.BrokerageRule;
import com.dayou.dto.ItemDTO;
import com.dayou.entity.ItemBrokerageDetail;
import com.dayou.mapper.ItemBrokerageDetailMapper;
import com.dayou.service.IItemBrokerageDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dayou.vo.BrokerageDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;

/**
 * <p>
 * 项目提成明细 服务实现类
 * </p>
 *
 * @author wucl
 * @since 2023-03-03
 */
@Service
public class ItemBrokerageDetailServiceImpl extends ServiceImpl<ItemBrokerageDetailMapper, ItemBrokerageDetail> implements IItemBrokerageDetailService {


    @Autowired
    private BrokerageCalculateSupport brokerageCalculateSupport;

    @Autowired
    private ItemBrokerageDetailMapper itemBrokerageDetailMapper;

    @Override
    @SuppressWarnings("unchecked")
    public Page<BrokerageDetailVO> selectPage(Page page, BrokerageDetailVO brokerageDetailVO){
        Page xPage = itemBrokerageDetailMapper.getPage(page,brokerageDetailVO);
        return xPage;
    }


    @Override
    public ItemBrokerageDetail detail(Long id){
        return this.getById(id);
    }

    @Override
    public Boolean add(ItemBrokerageDetail itemBrokerageDetail){
        return  this.save(itemBrokerageDetail);
    }

    @Override
    public Boolean update(ItemBrokerageDetail itemBrokerageDetail){
        return  this.updateById(itemBrokerageDetail);
    }

    @Override
    public Boolean delete(Long id){
        //逻辑删除
        return this.removeById(id);
    }

    @Override
    public Boolean crateBrokerageDetail(ItemDTO itemDTO) {
        BrokerageCalculator calculator = brokerageCalculateSupport.getCalculator(BrokerageRule.LAND_MARKETER_RULE);
        return null;
    }

    @Override
    public List<BrokerageDetailVO> xList(BrokerageDetailVO itemBrokerageDetailVO) {
        return itemBrokerageDetailMapper.xList(itemBrokerageDetailVO);
    }


}
