package com.yeshi.fanli.service.impl.user;
|
|
import java.io.Serializable;
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
|
import org.hibernate.HibernateException;
|
import org.hibernate.Query;
|
import org.hibernate.Session;
|
import org.springframework.orm.hibernate4.HibernateCallback;
|
import org.springframework.stereotype.Service;
|
|
import com.yeshi.fanli.dao.user.MoneyRecordDao;
|
import com.yeshi.fanli.entity.bus.user.MoneyRecord;
|
import com.yeshi.fanli.service.inter.order.OrderService;
|
import com.yeshi.fanli.service.inter.user.MoneyRecordService;
|
import com.yeshi.fanli.util.Constant;
|
|
@Service
|
public class MoneyRecordServiceImpl implements MoneyRecordService {
|
|
@Resource
|
private MoneyRecordDao moneyRecordDao;
|
|
@Resource
|
private OrderService orderService;
|
|
public List<MoneyRecord> getMoneyRecord(long uid,int page) {
|
|
int start = page * Constant.PAGE_SIZE;
|
|
List<MoneyRecord> mrList = moneyRecordDao.list("from MoneyRecord mr where mr.userInfo.id=? order by mr.createtime desc", start,Constant.PAGE_SIZE, new Serializable[] { uid });
|
return mrList;
|
}
|
|
public void addMoneyRecord(MoneyRecord moneyRecord) {
|
moneyRecordDao.create(moneyRecord);
|
}
|
|
public int getCount(long uid) {
|
Long lcount = moneyRecordDao.getCount("select count(m.id) from MoneyRecord m where m.userInfo.id=?", new Serializable[]{uid});
|
return lcount.intValue();
|
}
|
|
public void deleteMoneyRecordByEid(final long eid) {
|
moneyRecordDao.excute(new HibernateCallback() {
|
|
public Object doInHibernate(Session session)
|
throws HibernateException {
|
Query q = session.createQuery("delete from MoneyRecord mr where mr.extract.id = ? ");
|
q.setParameter(0, eid);
|
q.executeUpdate();
|
return null;
|
}
|
});
|
}
|
|
@Override
|
public List<MoneyRecord> findAll() {
|
return moneyRecordDao.list("from MoneyRecord");
|
}
|
}
|