package com.uas.platform.b2b.service.impl;

import com.uas.platform.b2b.dao.*;
import com.uas.platform.b2b.mobile.dao.DeputyEnterpriseDao;
import com.uas.platform.b2b.model.*;
import com.uas.platform.b2b.service.DeputyOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class DeputyOrderServiceImpl implements DeputyOrderService {

	@Autowired
	private DeputyOrderDao deputyOrderDao;

	@Autowired
	private DeputyEnterpriseDao deputyEnterpriseDao;

	@Override
	public List<DeputyOrder> findByDeputyuu(Long enuu) {
		String entryStatus = "已提交";
		String downloadStatus = "未下载";
		return deputyOrderDao.getByDeputyuuAndEntrystatusAndDownloadstatus(enuu, entryStatus, downloadStatus);
	}

	@Override
	public void print(Long id) {
		DeputyOrder order = deputyOrderDao.findOne(id);
		if (order != null) {
			order.setPrint((short) ((order.getPrint() == null ? 0 : order.getPrint()) + 1));
		}
		deputyOrderDao.save(order);
	}

	@Override
	public List<DeputyEnterprise> getList() {
		return deputyEnterpriseDao.findAll();
	}

}
