/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2018-01-13
 * 描述            ：客户结算运费信息表
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
 ***********************************************************/
package market.Slm.FundManagement.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import market.Com.pb.PbMethod;
import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;
import market.Slm.FundManagement.mapper.SlmFundSettleCarriageMapper;
import market.Slm.FundManagement.service.SlmFundSettleCarriageService;
import market.Slm.FundManagement.vo.SlmFundSettleCarriage;

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

@RemoteService(path="SlmFundSettleCarriageService")
public class SlmFundSettleCarriageServiceImpl extends BaseServiceImpl<SlmFundSettleCarriage,Object> implements SlmFundSettleCarriageService {

	public ResultModel doAdd(SlmFundSettleCarriage carriage) {
		ResultModel rm=new ResultModel();
		String userId=(String) this.getSession().getAttribute(HomeService.SESSION_USER_ID);
		String userName=(String) this.getSession().getAttribute(HomeService.SESSION_USER_NAME);
		try{
			String id=new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+PbMethod.RandomCreate(6);
			carriage.setFlag("1"); 	//编辑
			carriage.setCreate_man_no(userId);
			carriage.setCreate_man_name(userName);
			carriage.setCreate_time(new Date());
			carriage.setSeq(id);
			this.getMapper(SlmFundSettleCarriageMapper.class).insert(carriage);
			rm.setState("200");
		}catch(Exception e){
			rm.setState("500");
			rm.setMsgInfo(e.getMessage());
			e.printStackTrace();
		}
		return rm;
	}
	
	/**
	 * 查询 line_no
	 * */
	public ResultModel doQueryWeb(CommonPage<SlmFundSettleCarriage> sum) {
		ResultModel rm=new ResultModel();
		SlmFundSettleCarriage other=sum.getObject();
		try{
			List<SlmFundSettleCarriage> otherList=this.getMapper(SlmFundSettleCarriageMapper.class).findWithCondition(other,null," create_time desc" ,0, 0);
			rm.setData(otherList);
			rm.setState("200");
		}catch(Exception e){
			rm.setState("500");
			rm.setMsgInfo(e.getMessage());
		}
		return rm;
	}

	public ResultModel doDelete(String bill_no) {
		ResultModel rm=new ResultModel();
		try{
			SlmFundSettleCarriage carriage=new SlmFundSettleCarriage();
			carriage.setBill_no(bill_no);
			List<SlmFundSettleCarriage> carriageList=this.getMapper(SlmFundSettleCarriageMapper.class).find(carriage, 0, 0);
			for(SlmFundSettleCarriage carriages:carriageList){
				this.getMapper(SlmFundSettleCarriageMapper.class).delete(carriages.getSeq());
			}
			rm.setState("200");
		}catch(Exception e){
			rm.setState("500");
			rm.setMsgInfo(e.getMessage());
		}
		return rm;
	}
}
