/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2018-01-13
 * 描述            ：客户三级账户历史信息表
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
 ***********************************************************/
package market.Slm.FundManagement.impl;
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.SlmFundThirdAccountHisMapper;
import market.Slm.FundManagement.service.SlmFundThirdAccountHisService;
import market.Slm.FundManagement.vo.SlmFundThirdAccount;
import market.Slm.FundManagement.vo.SlmFundThirdAccountHis;

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

@RemoteService(path="SlmFundThirdAccountHisService")
public class SlmFundThirdAccountHisServiceImpl extends BaseServiceImpl<SlmFundThirdAccountHis,Object> implements SlmFundThirdAccountHisService {
	
	/**
	 * 查询三级账户的结转信息
	 * */
	public ResultModel doQueryWeb(CommonPage<SlmFundThirdAccountHis> sum){
		ResultModel rm=new ResultModel();
		SlmFundThirdAccountHis his=sum.getObject();
		try{
			List<SlmFundThirdAccountHis> list=this.getMapper(SlmFundThirdAccountHisMapper.class).findWithCondition(null, " third_account_no='"+his.getThird_account_no()+"'", " carryover_time desc ", 0, 0);
			rm.setState("200");
			rm.setData(list);
		}catch(Exception e){
			rm.setState("500");
			rm.setMsgInfo(e.getMessage());
		}
		return rm;
	}
	
	//新增
	public ResultModel doAdd(SlmFundThirdAccount account,String carryover_seq){
		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 seq=new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+PbMethod.RandomCreate(13);
			SlmFundThirdAccountHis his=new SlmFundThirdAccountHis();
			his.setThird_account_no(account.getThird_account_no());
			his.setSeq(seq);
			his.setThird_account_name(account.getThird_account_name());
			his.setFirst_account_no(account.getFirst_account_no());
			his.setFirst_account_name(account.getFirst_account_name());
			his.setSecond_account_no(account.getSecond_account_no());
			his.setSecond_account_name(account.getSecond_account_name());
			his.setBalance_object_no(account.getBalance_object_no());
			his.setBalance_object_name(account.getBalance_object_name());
			his.setCustomer_no(account.getCustomer_no());
			his.setCustomer_name(account.getCustomer_name());
			his.setInit_fund(account.getInit_fund());
			his.setUse_fund(account.getUse_fund());
			his.setIn_fund(account.getIn_fund());
			his.setOut_fund(account.getOut_fund());
			his.setSettlement_fund(account.getSettlement_fund());
			his.setUsed_fund(account.getUsed_fund());
			his.setInit_time(account.getInit_time());
			his.setCarryover_seq(carryover_seq);
			his.setCarryover_flag("1"); 		//结转状态？
			his.setCarryover_man_no(userId);
			his.setCarryover_man_name(userName);
			his.setCarryover_time(new Date());
			this.getMapper(SlmFundThirdAccountHisMapper.class).insert(his);
			rm.setState("200");
		}catch(Exception e){
			rm.setState("500");
			rm.setMsgInfo(e.getMessage());
		}
		return rm;
	}
}