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

📄 accountlogdao2.java

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

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

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.Accountlog2Entity;
import com.ufmobile.business.account.entity.AccountlogEntity;
import com.ufmobile.common.dao.UFMobileDAO;

public class AccountLogDAO2 extends UFMobileDAO {

	public AccountLogDAO2() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param manager
	 */
	public AccountLogDAO2(EntityManager manager) {
		super(manager);
		// TODO Auto-generated constructor stub
	}

	public Date getLastFillDate(String sAccountID) {

        String sSQL="from Accountlog2Entity where accountid=:accid and businesstype=0 order by operatetime desc";
        
		List<Accountlog2Entity> 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 Accountlog2Entity 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 usrid
	 * @param reason
	 * @param cardId 
	 * @return
	 */
	public Accountlog2Entity recordLog(AccmoneyEntity moneyEntity, BigDecimal money, BussinessType Type, String usrname, String reason, Long cardId) {
		Accountlog2Entity et = new Accountlog2Entity();

		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.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 accountEntity
	 * @param Type
	 * @param usrid
	 * @param reason
	 * @return
	 */
	public Accountlog2Entity recordLog(String accountid,BussinessType Type, String usrname, String reason) {
		Accountlog2Entity et = new Accountlog2Entity();

		et.setAccountid(accountid);
		et.setBusinesstype(Type);
		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 Accountlog2Entity where operatetime between :start and :end";
		return getManager().createQuery(sSQL).setParameter("start",start).setParameter("end",end).getResultList();
		
	}
	/**
	 * <p>
	 *
	 * <p>
	 * 作者:msf <br>
	 * 日期:Dec 18, 2006
	 * @param accountid
	 * @return
	 */
	public List queryByAccountID(String accountid){
		String sSQL="from Accountlog2Entity where accountid=:accid ";
		return getManager().createQuery(sSQL).setParameter("accid",accountid).getResultList();
		
	}
	
	/**
	 * <p>
	 *
	 * <p>
	 * 作者:yulm <br>
	 * 日期:Oct 29, 2007
	 * @param accountid
	 * @return
	 */
	public Accountlog2Entity queryByAccountID(String accountid,BussinessType bussinesstype){
		StringBuffer sb = new StringBuffer(""); 
		sb.append("from Accountlog2Entity where accountid=:accid and businesstype=2 order by id desc");
		List<Accountlog2Entity> list = getManager().createQuery(sb.toString()).setParameter("accid",accountid).getResultList();
		Accountlog2Entity ae = null ;
		if(list.size()>0){
			ae = list.get(0);
		}
		return ae;
	}
	
	/**
	 * <p>
	 *
	 * <p>
	 * 作者:yulm <br>
	 * 日期:Oct 29, 2007
	 * @param 
	 * @return
	 */
	public List getAllAcountId(){
		StringBuffer sb = new StringBuffer(""); 
		sb.append("select t.accountid from Accountlog2Entity t group by t.accountid");
		List list = getManager().createQuery(sb.toString()).getResultList();
		return list;
	}
	
	
}

⌨️ 快捷键说明

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