package com.iamberry.wechat.service.channel;

import com.iamberry.wechat.core.entity.channel.ChannelPrice;
import com.iamberry.wechat.face.channel.ChannelPriceService;
import com.iamberry.wechat.service.mapper.ChannelPriceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  渠道对应产品返利价格表接口
 * @author xm
 * @Date 2018-07-23
 */
@Service
public class ChannelPriceServiceImpl  implements ChannelPriceService {
    @Autowired
    private ChannelPriceMapper channelPriceMapper;
    /**
     * 获取集合
     * @param  channelPrice
     * @return List
     */
    @Override
    public List<ChannelPrice> getChannelPriceList(ChannelPrice  channelPrice){
        return  channelPriceMapper.getChannelPriceList(channelPrice);
    }

    /**
     * 获取集合-渠道列表展示
     * @param  channelPrice
     * @return List
     */
    @Override
    public List<ChannelPrice> getChannelProductList(ChannelPrice  channelPrice){
        return  channelPriceMapper.getChannelProductList(channelPrice);
    }

    @Override
    public ChannelPrice getChannelPriceByChannel(Integer channelId, Integer channelType, Integer colorId) {
        if(channelId>0 &&  channelType>0 && colorId > 0){
            ChannelPrice channelPrice = new ChannelPrice();
            channelPrice.setChannelId(channelId);
            channelPrice.setChannelType(channelType);
            channelPrice.setColorId(colorId);
            List<ChannelPrice> channelPriceList = channelPriceMapper.getChannelPriceList(channelPrice);
            if(channelPriceList.size() > 0){
                return channelPriceList.get(0);
            }
        }
        return null;
    }

    /**
     * 查询单条数据
     * @param  id
     * @return  channelPrice
     */
    @Override
    public  ChannelPrice  getChannelPriceById(Integer  id){
        return  channelPriceMapper.getChannelPriceById(id);
    }
    /**
     * 增加数据
     * @param  channelPrice
     * @return Integer
     */
    @Override
    public  Integer  save(ChannelPrice  channelPrice){
        return  channelPriceMapper.save(channelPrice);
    }
    /**
     * 修改数据
     * @param  channelPrice
     * @return Integer
     */
    @Override
    public  Integer  update(ChannelPrice  channelPrice){
        return  channelPriceMapper.update(channelPrice);
    }
    /**
     * 删除数据
     * @param  id
     * @return Integer
     */
    @Override
    public  Integer  delete(Integer  id){
        return  channelPriceMapper.delete(id);
    }
    /**
     * 增加数据 <集合>
     * @param  channelPriceList
     * @return Integer
     */
    @Override
    public  Integer  saveList(List<ChannelPrice>  channelPriceList){
        return  channelPriceMapper.saveList(channelPriceList);
    }
    /**
     * 删除数据 <集合>
     * @param  ids
     * @return Integer
     */
    @Override
    public  Integer  deleteList(Integer[]  ids){
        return  channelPriceMapper.deleteList(ids);
    }
}
