package market.Qms.com.service.impl;
import java.util.List;

import market.Qms.com.mapper.PscRDeliveryMapper;
import market.Qms.com.service.PscRDeliveryService;
import market.Qms.com.vo.PscRDelivery;
import market.Qms.common.ReturnMsg;

import com.hnshituo.basic.service.impl.BaseServiceImpl;
import com.hnshituo.basic.spring.remoting.annotation.RemoteService;

@RemoteService(serviceInterface=PscRDeliveryService.class)
public class PscRDeliveryServiceImpl extends BaseServiceImpl<PscRDelivery, String> implements PscRDeliveryService {

	@Override
	public void InsertSteel(List<PscRDelivery> delivery) {
		// TODO Auto-generated method stub
		PscRDeliveryMapper mapper=this.getMapper(PscRDeliveryMapper.class);
		for (PscRDelivery pscRDelivery : delivery) {
			PscRDelivery _delivery=new PscRDelivery();
			_delivery.setPsc(pscRDelivery.getPsc());
			_delivery.setDeliveryStateCode(pscRDelivery.getDeliveryStateCode());
			List<PscRDelivery> _listDelivery=mapper.find(_delivery, 0, 0);
			if(_listDelivery.size()>0){
				continue;
			}
			mapper.insert(pscRDelivery);
		}
	}

	@Override
	public ReturnMsg DelOrRenew(String psc,String deliveryCode, Boolean flag) {
		// TODO Auto-generated method stub
		ReturnMsg msg=new ReturnMsg<>();
		try{
			// TODO Auto-generated method stub
/*			PscRDelivery pscR=new PscRDelivery();
			pscR.setDeliveryStateCode(deliveryCode);
			pscR.setPsc(psc);
			pscR.setValidflag(flag?"0":"1");*/
			if(!flag){
				msg.setMessage(" 2017-12-25 开始不支持恢复操作");
				msg.setSuccess(false);
				return msg;
			}
			this.getMapper(PscRDeliveryMapper.class).delete(psc,deliveryCode);
			msg.setMessage(flag?"废除成功":"恢复成功");
			msg.setSuccess(true);
		}catch(Exception ex){
			msg.setMessage(ex.getMessage());
			msg.setSuccess(false);
		}
		return msg;
	}

}
