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

📄 accountlogdao.java

📁 国内很牛的软件公司花费两年半开发的用EJB3开发的代码,采用STRUTS和EJB3,目前系统进行第二版.所以拿出来共享
💻 JAVA
字号:
package com.ufmobile.business.account.dao;

import java.math.BigDecimal;
import java.util.List;
import java.util.Date;
import javax.persistence.EntityManager;

import com.ufmobile.business.account.bo.Account.BussinessType;
import com.ufmobile.business.account.entity.AccmoneyEntity;
import com.ufmobile.business.account.entity.AccountlogEntity;
import com.ufmobile.common.dao.UFMobileDAO;

public class AccountLogDAO extends UFMobileDAO {

	public AccountLogDAO() {
		super();
		
	}

	/**
	 * @param manager
	 */
	public AccountLogDAO(EntityManager manager) {
		super(manager);
		
	}
	
	/**
	 * <p>
	 *  取得充值的最近日期

	 * <p>
	 * 作者:msf <br>
	 * 日期:Dec 18, 2006
	 * @param sAccountID
	 * @return
	 */
	public Date getLastFillDate(String sAccountID){
		String sSQL="from AccountlogEntity where accountid=:accid and businesstype=0 order by operatetime desc";
		
		List<AccountlogEntity> l=getManager().createQuery(sSQL).setParameter("accid",sAccountID).getResultList();
		
		if(l!=null&&l.size()>0&&l.get(0)!=null){
			return l.get(0).getOperatetime();
		}
		return null;
	}
	public AccountlogEntity recordLog(AccmoneyEntity moneyEntity,BigDecimal money, BussinessType Type,String usrname,String reason){
		return recordLog( moneyEntity, money,  Type, usrname, reason,new Long(-1));
	}
	/**
	 * <p>
	 * 记录充值,扣费,返还日志
	 * <p>
	 * 作者:msf <br>
	 * 日期:Dec 18, 2006
	 * @param moneyEntity
	 * @param money
	 * @param Type
	 * @param reason
	 * @param cardId TODO
	 * @param usrid
	 * @return
	 */
	public AccountlogEntity recordLog(AccmoneyEntity moneyEntity,BigDecimal money, BussinessType Type,String usrname,String reason,Long cardId){
		AccountlogEntity et = new AccountlogEntity();
		
		et.setAccountid(moneyEntity.getAccountid());
		et.setBusinesstype(Type);
		if(Type==BussinessType.fill){
			et.setAccin(money);
			et.setAccobject(cardId);
			
		}else if(Type==BussinessType.debuct){
			et.setAccout(money);
			
		}else if(Type==BussinessType.back){
			et.setBack(money);
			
		}
		
		et.setAccout(money);
		et.setAccintotal(moneyEntity.getAccin());
		et.setAccouttotal(moneyEntity.getAccout());
		et.setBacktotal(moneyEntity.getBack());
		
		et.setMeno(reason);
		et.setAccoperator(usrname);
		et.setOperatetime(new Date(System.currentTimeMillis()));
		getManager().persist(et);
		return et;
	}
	/**
	 * <p>
	 *
	 * <p>
	 * 作者:msf <br>
	 * 日期:Dec 18, 2006
	 * @param accountid
	 * @param start
	 * @param end
	 * @return
	 */
	public List queryByPeriod(String accountid, Date start, Date end){
		String sSQL="from AccountlogEntity where accountid=:accid and (operatetime between :start and :end)";
		return getManager().createQuery(sSQL).setParameter("start",start).setParameter("end",end).setParameter("accid",accountid).getResultList();
		
	}
	/**
	 * <p>
	 *
	 * <p>
	 * 作者:msf <br>
	 * 日期:Dec 18, 2006
	 * @param accountid
	 * @return
	 */
	public List queryByAccountID(String accountid){
		String sSQL="from AccountlogEntity where accountid=:accid ";
		return getManager().createQuery(sSQL).setParameter("accid",accountid).getResultList();
		
	}
}

⌨️ 快捷键说明

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