/**
 * Copyright 2019 DH
 * All right reserved.
 * 项目名称: 大恒泰山系统
 * 创建日期:2022/8/22
 */
package org.springblade.modules.business.check.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.enums.OrderStatusEnum;
import org.springblade.modules.business.check.order.dto.CheckOrderInfoDTO;
import org.springblade.modules.business.check.order.entity.CheckOrderInfoEntity;
import org.springblade.modules.business.check.order.mapper.RtuCheckOrderMapper;
import org.springblade.modules.business.check.order.service.IRtuCheckOrderService;
import org.springblade.modules.business.check.order.vo.CheckOrderCountVO;
import org.springblade.modules.business.check.order.vo.CheckOrderInfoVO;
import org.springblade.modules.business.check.process.entity.OrderProcessInfoEntity;
import org.springframework.stereotype.Service;

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

/***
 * Date:2022/8/22
 * Title:文件所属模块（必须填写）
 * Description：对本文件的详细描述，原则上不能少于30字
 * @author dylan
 * @version 1.0
 * Remark：认为有必要的其他信息
 */
@Service
public class RtuCheckOrderServiceImpl extends BaseServiceImpl<RtuCheckOrderMapper, CheckOrderInfoEntity> implements IRtuCheckOrderService {
	@Override
	public IPage<CheckOrderInfoVO> selectPage(IPage<CheckOrderInfoVO> page, CheckOrderInfoDTO checkOrderInfoDTO) {
		return page.setRecords(baseMapper.selectPage(page, checkOrderInfoDTO));
	}

	@Override
	public Long unconfirmOrderCount(CheckOrderInfoDTO checkOrderInfoDTO) {
		return baseMapper.unconfirmOrderCount(checkOrderInfoDTO);
	}

	@Override
	public List<CheckOrderInfoVO> unconfirmOrderList(CheckOrderInfoDTO checkOrderInfoDTO) {

		return baseMapper.unconfirmOrderList(checkOrderInfoDTO);
	}

	@Override
	public boolean updateOrderStatus(CheckOrderInfoEntity orderInfoEntity) {

		LambdaUpdateWrapper<CheckOrderInfoEntity> updateWrapper = Wrappers.<CheckOrderInfoEntity>update().lambda();
		updateWrapper.eq(CheckOrderInfoEntity::getId, orderInfoEntity.getId());
		updateWrapper.set(CheckOrderInfoEntity::getOrderStatusKey, orderInfoEntity.getOrderStatusKey());
		updateWrapper.set(CheckOrderInfoEntity::getOrderDesc, orderInfoEntity.getOrderDesc());
		updateWrapper.set(CheckOrderInfoEntity::getUpdateTime, new Date());
		this.update(updateWrapper);

		return false;
	}

	@Override
	public List<CheckOrderCountVO> orderReportCount(CheckOrderInfoDTO checkOrderInfoDTO) {
		return baseMapper.orderReportCount(checkOrderInfoDTO);
	}

	@Override
	public Long orderCount(CheckOrderInfoDTO checkOrderInfoDTO) {
		return baseMapper.orderCount(checkOrderInfoDTO);
	}

	@Override
	public Long unCloseOrderCount(CheckOrderInfoDTO checkOrderInfoDTO) {
		return baseMapper.unCloseOrderCount(checkOrderInfoDTO);
	}
}
