/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：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.SlmFundSettleOtherMapper;
import market.Slm.FundManagement.service.SlmFundSettleOtherService;
import market.Slm.FundManagement.vo.SlmFundSettleOther;

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

@RemoteService(path="SlmFundSettleOtherService")
public class SlmFundSettleOtherServiceImpl extends BaseServiceImpl<SlmFundSettleOther,Object> implements SlmFundSettleOtherService {

	public ResultModel doAdd(SlmFundSettleOther other) {
		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);
			other.setFlag("1");
			other.setSeq(id);		
			other.setCreate_man_no(userId);
			other.setCreate_man_name(userName);
			other.setCreate_time(new Date());
			this.getMapper(SlmFundSettleOtherMapper.class).insert(other);
			rm.setState("200");
		}catch(Exception e){
			rm.setState("500");
			rm.setMsgInfo(e.getMessage());
			e.printStackTrace();
		}
		return rm;
	}
	
	/**
	 * 查询 line_no
	 * */
	public ResultModel doQueryWeb(CommonPage<SlmFundSettleOther> sum) {
		ResultModel rm=new ResultModel();
		SlmFundSettleOther other=sum.getObject();
		try{
			List<SlmFundSettleOther> otherList=this.getMapper(SlmFundSettleOtherMapper.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{
			SlmFundSettleOther other=new SlmFundSettleOther();
			other.setBill_no(bill_no);
			List<SlmFundSettleOther> otherList=this.getMapper(SlmFundSettleOtherMapper.class).find(other, 0, 0);
			for(SlmFundSettleOther others:otherList){
				this.getMapper(SlmFundSettleOtherMapper.class).delete(others.getSeq());
			}
			rm.setState("200");
		}catch(Exception e){
			rm.setState("500");
			rm.setMsgInfo(e.getMessage());
		}
		return rm;
	}
}
