⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 financialaccountjb.java

📁 这是本人以前在学校时
💻 JAVA
字号:
/*
 * Created on 2006-6-22
 */
package com.funddeal.model.bean.financial_account;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;
import com.funddeal.base.PublicFunction;
import com.funddeal.base.interfaces.OperLogInterface;
import com.funddeal.model.bean.operare_log.OperareLogJB;
import com.funddeal.model.dao.financial_account.FinancialAccountDAO;
import com.funddeal.model.pojo.custom_entity.BringNumParamEntity;
import com.funddeal.model.pojo.custom_entity.OperLogParamEntity;
import com.funddeal.model.pojo.custom_entity.SearchParamEntity;
import com.funddeal.model.pojo.financial_account.FinancialAccount;

/**
 * @author <b>zhangxianxin<b><br>
 * @version
 * 资金帐号管理模块JavaBean<br>
 * 方法一:[boolean openFinancialAccount(FinancialAccount)]为合法客户开设一个资金帐户<br>
 * 方法二:[boolean updateFinancialAccount(FinancialAccount)]修改客户的资金帐户信息<br>
 */
public class FinancialAccountJB {
	public static String errorMsg="";
	
	/**
	 * 资金帐户开户(给合法用户添加一个资金帐号)
	 * @param fA:实体对象
	 * @return True|False(成功与否)
	 */
	public boolean openFinancialAccount(FinancialAccount fA ,OperLogParamEntity olpe)
	{
		errorMsg="";
		boolean flag=false;
		PublicFunction pf=new PublicFunction();
		
		String client=fA.getClientNo();
		SearchParamEntity spe=new SearchParamEntity();
		spe.setPojoName("Client");
		spe.setPropertyName("clientNo");
		spe.setValue(client);
		
		boolean bn= pf.exist(spe);//判断客户编号是否存在
		if(bn)
		{
			spe.setPojoName("FinancialAccount");
			spe.setPropertyName("clientNo");
			spe.setValue(client);
			boolean bool=pf.exist(spe);//判断客房是否已开通资金帐号
			if(!bool)
			{
				if("".equals(PublicFunction.errorMsg))
				{
//					产生一个自动编号
					BringNumParamEntity bPE=new BringNumParamEntity();
					bPE.setPojoName("FinancialAccount");
					bPE.setPropertyId("accountId");
					bPE.setTableName("FINANCIAL_ACCOUNT");
					String accountNo=pf.bringNumber(bPE);
//					将值设置到实体中,以便添加记录
					fA.setAccountNo(accountNo);
					fA.setStatus("正常");
					fA.setCreatedDate(Calendar.getInstance());
					FinancialAccountDAO faDAO=new FinancialAccountDAO();
					try {
						String id=faDAO.openFinancialAccount(fA);//调用数据访问对象中的资金帐号开户的方法
						if(id.length()==32){
							flag=true;
							/*
							 * 添加相应的日志
							 */
//////////////////////////////////////////////////////////////////////////						
							olpe.setOperResultId(accountNo);			//
							olpe.setOperTableName("FINANCIAL_ACCOUNT");	//
							olpe.setOperType("添加资金帐号");				//
							OperLogInterface pif=new OperareLogJB();	//
							pif.addOperareLog(olpe);					//
//////////////////////////////////////////////////////////////////////////							
						}
					}catch(HibernateException e){
						errorMsg=e.getMessage();
						System.out.println(errorMsg);
					}
				}else{
					errorMsg=PublicFunction.errorMsg;
				}
			}else
			{
				errorMsg="该客户已开通了资金帐号!!";
				System.out.println(errorMsg);
			}
		}
		else
		{
			if("".equals(PublicFunction.errorMsg))
				errorMsg="该客户编号不存在!请先开通客户帐号!";
			else
				errorMsg=PublicFunction.errorMsg;
			System.out.println(errorMsg);
		}
		return flag;
	}
	
	
	/**
	 * 删除资金帐号(必须将资金帐号的编号封装到资金帐号的实体之中)
	 * @param fA:资金帐号实体对象
	 * @return True|False(成功与否)
	 */
	public boolean delFinancialAccount(FinancialAccount fA,OperLogParamEntity olpe)
	{
		errorMsg="";
		boolean flag=false;
		String accountNo= fA.getAccountNo();//取出客户资金帐号号码
		SearchParamEntity spe=new SearchParamEntity();//实例化查找方法的参数实体
		spe.setPojoName("FinancialAccount");//封装数据
		spe.setPropertyName("accountNo");//封装数据
		spe.setValue(accountNo);//封装数据
		PublicFunction pf=new PublicFunction();//实例化公共方法类
		Query query= pf.search(spe);//取出客户资金帐号所对应的客户资金信息
		try {
			int cut=query.list().size();
			if(cut!=0)
			{
				fA=(FinancialAccount)query.list().get(0);
				FinancialAccountDAO fAdao=new FinancialAccountDAO();
				flag=fAdao.delteFinancialAccount(fA);//调用数据访问对象中的删除方法
				if(!flag)
					errorMsg=FinancialAccountDAO.errorMsg;
				else{
					/*
					 * 添加相应的日志
					 */
//////////////////////////////////////////////////////////////////////		
					olpe.setOperResultId(fA.getAccountNo());		//
					olpe.setOperTableName("FINANCIAL_ACCOUNT");		//
					olpe.setOperType("删除资金记录");					//
					OperLogInterface pif=new OperareLogJB();		//
					pif.addOperareLog(olpe);						//
//////////////////////////////////////////////////////////////////////		
				}
			}else{
				if(PublicFunction.errorMsg.equals(""))
					errorMsg="该资金帐号不存在";
				else
					errorMsg=PublicFunction.errorMsg;
			}
		} catch (HibernateException e) {
			errorMsg=e.getMessage();
			e.printStackTrace();
		}
		return flag;
	}
	
	
	/**
	 * 追加资金
	 * @param fA:实体对象
	 * @return True|False(成功与否)
	 */
	public boolean addFinancial(FinancialAccount fA ,OperLogParamEntity olpe)
	{
		errorMsg="";
		boolean flag=false;
		String accountNo = fA.getAccountNo();//获得提交过来的资金帐号
		PublicFunction pf=new PublicFunction();
		SearchParamEntity spe=new SearchParamEntity();
		spe.setPojoName("FinancialAccount");
		spe.setPropertyName("accountNo");
		spe.setValue(accountNo);
		Query query= pf.search(spe);//查找该资金帐号是否存在
		try {
			if(query.list().size()!= 0)
			{
				FinancialAccount f=new FinancialAccount();
				try {
					f=(FinancialAccount)query.list().get(0);//取得资金帐号的信息
				} catch (HibernateException e){
					errorMsg=e.getMessage();
					e.printStackTrace();
				}
				String status=f.getStatus();
				if(status.equals("正常")){
					float financingAmount=f.getFinancingAmount();
					financingAmount+=fA.getFinancingAmount();//追加资金金额
					f.setFinancingAmount(financingAmount);
					FinancialAccountDAO faDAO=new FinancialAccountDAO();
					if(faDAO.updatFinancialAccount(f)){
						flag=true;
						/*
						 * 添加相应的日志
						 */
//////////////////////////////////////////////////////////////////////			
						olpe.setOperResultId(f.getAccountNo());		//
						olpe.setOperTableName("FINANCIAL_ACCOUNT");	//
						olpe.setOperType("追加资金");				//
						OperLogInterface pif=new OperareLogJB();	//
						pif.addOperareLog(olpe);					//
//////////////////////////////////////////////////////////////////////						
					}else{
						errorMsg=FinancialAccountDAO.errorMsg;
					}
				}else{
					errorMsg="该客户的资金帐号为<font color='red'>"+ status +"</font>状态,不能为其追加资金!";
				}
			}
			else
			{
				if(PublicFunction.errorMsg.equals(""))
					errorMsg="该资金帐号不存在!";
				else
					errorMsg=PublicFunction.errorMsg;
			}
		} catch (HibernateException e) {
			errorMsg=e.getMessage();
			e.printStackTrace();
		}
		return flag;
	}

	/**
	 * 提取资金
	 * @param fA:实体对象
	 * @return True|False(成功与否)
	 */
	public boolean getFinancial(FinancialAccount fA,OperLogParamEntity olpe)
	{
		errorMsg="";
		boolean flag=false;
		String accountNo = fA.getAccountNo();//获得提交过来的资金帐号
		String passWord = fA.getPassword();//获理客户资金帐号密码
		
		PublicFunction pf=new PublicFunction();
		
		SearchParamEntity spe=new SearchParamEntity();
		spe.setPojoName("FinancialAccount");
		spe.setPropertyName("accountNo");
		spe.setValue(accountNo);
		
		Query query= pf.search(spe);//查找该资金帐号是否存在
		try {
			if(query.list().size()!= 0)
			{
				FinancialAccount f=new FinancialAccount();
				try {
					f=(FinancialAccount)query.list().get(0);//取得资金帐号的信息
				} catch (HibernateException e) {
					e.printStackTrace();
					errorMsg=e.getMessage();
				}
				if(passWord.equals(f.getPassword()))
				{
					String status=f.getStatus();
					if(status.equals("正常")){
						float financingAmount=f.getFinancingAmount();
						if(financingAmount>fA.getFinancingAmount())
						{
							financingAmount-=fA.getFinancingAmount();//取出资金
							f.setFinancingAmount(financingAmount);
							FinancialAccountDAO faDAO=new FinancialAccountDAO();
							if(faDAO.updatFinancialAccount(f)){
								flag=true;
								/*
								 * 添加相应的日志
								 */
//////////////////////////////////////////////////////////////////////////////					
								olpe.setOperResultId(f.getAccountNo());		//
								olpe.setOperTableName("FINANCIAL_ACCOUNT");	//
								olpe.setOperType("提取资金");					//
								OperLogInterface pif=new OperareLogJB();	//
								pif.addOperareLog(olpe);					//
//////////////////////////////////////////////////////////////////////////////
							}else{
								errorMsg=FinancialAccountDAO.errorMsg;
							}
						}
						else{
							errorMsg="资金帐号余额不足!";
						}
					}else{
						errorMsg="该客户的资金帐号为<font color='red'>"+ status +"</font>状态,不能提取资金!";
					}
				}else{
					errorMsg="密码错误!";
				}
			}
			else{
				if(PublicFunction.errorMsg.equals(""))
					errorMsg="该资金帐号不存在!!!";
				else
					errorMsg=PublicFunction.errorMsg;
			}
		} catch (HibernateException e) {
			e.printStackTrace();
			errorMsg=e.getMessage();
		}
		return flag;
	}
	
	/**
	 * [冻结|解冻]资金帐号
	 * @param fA:实体对象
	 * @return True|False(操作成功与否)
	 */
	public boolean FrozenOrThawAccounts(FinancialAccount fA,OperLogParamEntity olpe)
	{
		errorMsg="";
		boolean flag=false;
		String accountId = fA.getAccountId();//获得提交过来的资金帐号主键
		PublicFunction pf=new PublicFunction();
		SearchParamEntity spe=new SearchParamEntity();
		spe.setPojoName("FinancialAccount");
		spe.setPropertyName("accountId");
		spe.setValue(accountId);
		Query query= pf.search(spe);//查找该资金帐号是否存在
		try {
			if(query.list().size()!= 0){
				FinancialAccount f=new FinancialAccount();
				f=(FinancialAccount)query.list().get(0);//取得资金帐号的信息
				if(f.getStatus().equals("正常")){
					f.setStatus("冻结");
				}else if(f.getStatus().equals("冻结")){
					f.setStatus("正常");
				}
				FinancialAccountDAO faDAO=new FinancialAccountDAO();
				if(faDAO.updatFinancialAccount(f)){
					flag=true;
					/*
					 * 添加相应的日志
					 */
//////////////////////////////////////////////////////////////////	
					olpe.setOperResultId(f.getAccountNo());		//
					olpe.setOperTableName("FINANCIAL_ACCOUNT");	//
					String operType="";							//
					if(f.getStatus()=="正常"){					//
						operType="冻结资金帐号";					//
					}else if(f.getStatus()=="冻结"){				//
						operType="解冻资金帐号";					//
					}											//
					olpe.setOperType(operType);					//
					OperLogInterface pif=new OperareLogJB();	//
					pif.addOperareLog(olpe);					//
//////////////////////////////////////////////////////////////////
				}else{
					errorMsg=FinancialAccountDAO.errorMsg;
				}
			}
			else{
				errorMsg="该资金帐号不存在!!!";
			}
		}catch (HibernateException e) {
			e.printStackTrace();
			errorMsg=e.getMessage();
		}
		return flag;
	}

	/**
	 * 查找客户资金帐号JavaBean
	 * @param searchClass:查找的类型
	 * @param searchValue:要查找的值
	 * @return 记录集对象(如果查找有记录,则记录集ArrayList不为空)
	 */
	public Collection SearchFinaAccount(String searchClass,String searchValue)
	{
		errorMsg="";
		Collection col=null;
		if(searchValue.equals(""))
		{
			errorMsg="要查找的值不能为空";
			return col;
		}
		String propertyName="";
		if(searchClass.equals("financialAccount")){
			propertyName="accountNo";
		}else if(searchClass.equals("clientNo")){
			propertyName="clientNo";
		}

		String hql="from FinancialAccount as fa where fa." + propertyName + "='" + searchValue +"'";
		FinancialAccountDAO faDAO=new FinancialAccountDAO();
		col=faDAO.searchFinancialAccount(hql);
		ArrayList al=(ArrayList)col;
		if(al.size()<=0)errorMsg=FinancialAccountDAO.errorMsg;
		return col;
	}
	
	public Collection SearchClientForFinaAccountNo(String clientNo)
	{
		errorMsg="";
		Collection col=null;
		SearchParamEntity spe=new SearchParamEntity();
		spe.setPojoName("Client");
		spe.setPropertyName("clientNo");
		spe.setValue(clientNo);
		FinancialAccountDAO faDAO=new FinancialAccountDAO();
		col=faDAO.searchClient(spe);
		return col;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -