package com.hzs.activity.recommend.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.activity.recommend.mapper.AcRecomUpgradeRecordMapper;
import com.hzs.activity.recommend.param.AcDirectPushUpgradeListParam;
import com.hzs.activity.recommend.service.IAcRecomUpgradeRecordService;
import com.hzs.activity.recommend.vo.AcDirectPushUpgradeListVO;
import com.hzs.common.core.enums.EDelFlag;
import com.hzs.common.core.enums.EGrade;
import com.hzs.common.core.utils.bean.BeanUtils;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.activity.recommend.AcRecomUpgradeRecord;
import com.hzs.common.domain.activity.recommend.AcRecomUpgradeRecordExt;
import com.hzs.common.domain.sale.order.SaOrder;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 推荐升级业务表 服务实现类
 */
@Service
public class AcRecomUpgradeRecordServiceImpl extends ServiceImpl<AcRecomUpgradeRecordMapper, AcRecomUpgradeRecord> implements IAcRecomUpgradeRecordService {

    @Override
    public Boolean cancelOrder(Long orderId, Long pkModified) {
        LambdaUpdateWrapper<AcRecomUpgradeRecord> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(AcRecomUpgradeRecord::getDelFlag, EDelFlag.DELETE.getValue());
        updateWrapper.set(AcRecomUpgradeRecord::getPkModified, pkModified);
        updateWrapper.set(AcRecomUpgradeRecord::getModifiedTime, new Date());
        updateWrapper.eq(AcRecomUpgradeRecord::getPkOrderId, orderId);
        return update(updateWrapper);
    }

    @Override
    public AcRecomUpgradeRecord selectUpgradeRecordByOrderId(AcRecomUpgradeRecordExt upgradeRecord) {
        return baseMapper.selectUpgradeRecordByOrderId(upgradeRecord);
    }

    @Override
    public List<Long> selectRecommendNumber(AcRecomUpgradeRecordExt upgradeRecord) {
        return baseMapper.selectRecommendNumber(upgradeRecord);
    }

    @Override
    public Boolean updateUpgradeStatusById(List<Long> pkIds, Long pkModified, Integer upGradeStatus) {
        LambdaUpdateWrapper<AcRecomUpgradeRecord> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(AcRecomUpgradeRecord::getUpGradeStatus, upGradeStatus)
                .set(AcRecomUpgradeRecord::getPkModified, pkModified)
                .in(AcRecomUpgradeRecord::getPkId, pkIds);
        return this.update(updateWrapper);
    }

    @Override
    public List<SaOrder> listRecomOrder(Long pkMember, Integer pkGrade, Integer num, Date startTime, Date endTime) {
        return baseMapper.listRecomOrder(pkMember, pkGrade, num, startTime, endTime);
    }

    @Override
    public List<AcDirectPushUpgradeListVO> queryList(AcDirectPushUpgradeListParam param) {
        return baseMapper.queryList(param);
    }

}
