package com.iamberry.wechat.service.order;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iamberry.wechat.core.entity.order.ProbationOrder;
import com.iamberry.wechat.face.order.AdminProbationOrderService;
import com.iamberry.wechat.service.mapper.AdminProbationOrderMapper;

@Service
public class AdminProbationOrderServiceImpl implements AdminProbationOrderService{

	@Autowired
	private AdminProbationOrderMapper adminProbationOrderMapper;
	
	@Override
	public ProbationOrder getProbationOrderByOrderId(
			ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		return adminProbationOrderMapper.getProbationOrderByOrderId(probationOrder);
	}

	@Override
	public boolean updateProbationOrderStatus(ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		int num = adminProbationOrderMapper.updateProbationOrderStatus(probationOrder);
		if (num > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public List<ProbationOrder> selectProbationList(
			ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		return adminProbationOrderMapper.selectProbationList(probationOrder);
	}

	@Override
	public Integer selectProbationCount(ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		 int count = adminProbationOrderMapper.selectProbationCount(probationOrder);
		 return	count = count % probationOrder.getPage().getPageSize() == 0? count/probationOrder.getPage().getPageSize():(count/probationOrder.getPage().getPageSize())+1;
	}

	@Override
	public boolean updateAdminRemark(ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		int num = adminProbationOrderMapper.updateAdminRemark(probationOrder);
		if (num > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean updateSendName(ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		int num =  adminProbationOrderMapper.updateSendName(probationOrder);
		if (num > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean updateProbationEndTime(ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		int num = adminProbationOrderMapper.updateProbationEndTime(probationOrder);
		if (num > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean updateUserRemark(ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		int num = adminProbationOrderMapper.updateUserRemark(probationOrder);
		if (num > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean updatePauseStartTime(ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		int num = adminProbationOrderMapper.updatePauseStartTime(probationOrder);
		if (num > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean updateSendDate(ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		int num = adminProbationOrderMapper.updateSendDate(probationOrder);
		if (num > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean updatePauseEndTime(ProbationOrder probationOrder) {
		// TODO Auto-generated method stub
		int num = adminProbationOrderMapper.updatePauseEndTime(probationOrder);
		if (num > 0) {
			return true;
		} else {
			return false;
		}
	}

}
