package core.stlmes.server.sale.service.fund;

import java.sql.SQLException;
import core.stlmes.server.sale.po.fund.*;
import core.stlmes.server.sale.service.baseservice.BaseBll;
import java.util.*;

import CoreFS.SA06.CoreReturnObject;
import core.stlmes.server.sale.dao.fund.FundCustAccountDao;
import core.stlmes.server.sale.dao.fund.FundInOutDao;
import core.stlmes.server.sale.dbhelp.DbTrans;
import core.stlmes.server.sale.dao.*;

public class FundInAndOutMgt extends BaseBll
{
	public CoreReturnObject addFundRecord(java.util.HashMap map)
	{
		CoreReturnObject cro = new CoreReturnObject();
		if (map == null || map.size() == 0) return cro;
		core.stlmes.server.sale.po.fund.SelFundCustFundInoutBean bean = SelFundCustFundInoutBean
				.convertHashMapToBean(map);
		SelFundCustAccountBean cust = new SelFundCustAccountBean();
		cust.setBalancesubject(bean.getBalancesubject());
		cust.setBuyercode(bean.getBuyercode());
		double money = bean.getInoutmoney();
		FundCustAccountDao actdao = new FundCustAccountDao();
		FundInOutDao inoutdao = new FundInOutDao();
		DbTrans trans = new DbTrans();
		actdao.setTrans(trans);
		inoutdao.setTrans(trans);
		try
		{
			trans.beginTransaction();
			actdao.addMoneyToCustAccount(cust, money);
			inoutdao.insert(bean);
			trans.commit();

		}
		catch (java.sql.SQLException ex)
		{
			super.setCroErrMsg(cro, ex.getMessage());
			trans.rollback();
			return cro;
		}
		catch (java.lang.Exception ex)
		{
			super.setCroErrMsg(cro, ex.getMessage());
			trans.rollback();
			return cro;
		}
		return cro;

	}

}
