package com.iamberry.wechat.service.eo;

import com.iamberry.wechat.core.entity.eo.SettlementGift;
import com.iamberry.wechat.face.eo.SettlementGiftService;
import com.iamberry.wechat.service.mapper.SettlementGiftMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  结算赠品接口
 * @author Administrator
 * @Date 2019-05-23
 */
@Service
public class SettlementGiftServiceImpl  implements SettlementGiftService {
    @Autowired
    private SettlementGiftMapper settlementGiftMapper;
    /**
     * 获取集合
     * @param  settlementGift
     * @return List
     */
    @Override
    public List<SettlementGift> getSettlementGiftList(SettlementGift settlementGift){
        return  settlementGiftMapper.getSettlementGiftList(settlementGift);
    }

    @Override
    public List<SettlementGift> getSettlementGiftListAll(int[] str) {

        List<SettlementGift> settlementGiftList = settlementGiftMapper.getSettlementGiftListAll(str);
//        for (Promotions pro:promotionsList) {
//            SettlementGift settlementGift = new SettlementGift();
//            settlementGift.setPromotionsId( pro.getPromotionsId());
//            List<SettlementGift> settlementGiftPartList = settlementGiftMapper.getSettlementGiftListAll(settlementGift);
//            for (SettlementGift sg:settlementGiftPartList){
//                boolean flag = true;
//                for (SettlementGift allsg:settlementGiftList) {
//                    if(allsg.getSettGiftId() == sg.getSettGiftId()){
//                        flag = false;
//                    }
//                }
//                if(flag){
//                    settlementGiftList.add(sg);
//                }
//            }
//        }
//        Collections.sort(settlementGiftList, new Comparator<SettlementGift>() {
//            @Override
//            public int compare(SettlementGift o1, SettlementGift o2) {
//                // 按照学生的年龄进行升序排列
//                if (o1.getSettGiftSort() > o2.getSettGiftSort()) {
//                    return 1;
//                }
//                if (o1.getSettGiftSort() == o2.getSettGiftSort()) {
//                    return 0;
//                }
//                return -1;
//            }
//        });

        return  settlementGiftList;
    }


    /**
     * 查询单条数据
     * @param  id
     * @return  settlementGift
     */
    @Override
    public SettlementGift getSettlementGiftById(Integer  id){
        return  settlementGiftMapper.getSettlementGiftById(id);
    }
}