📄 accountbean.java
字号:
throw new AccountException("账户未启用,不能充值");
// if (account.getAgent() == null ||
// !account.getAgent().trim().equals(cardentity.getAgent().trim()))
// throw new AccountException("卡号与代理商不匹配");
// 充值,修改充值卡状态并记日志
BigDecimal money = cardentity.getMoneny();
cardentity.setCurmoneny(money);
cardentity.setUsedmoneny(money);
cardentity.setAccountId(account.getId());
cardentity.setAccountName(account.getName());
/**lgb:重构 2007/8/14**/
int localid = Integer.parseInt(paramDao.getParamValue(PublicParam.LOCAL_ID));
//SysparaEntity Value = init.getSysparaEntityByCode("localID");
cardentity.setSystemid(localid);
// 充值
AccmoneyEntity moneyEntity = moneyDao.fillMoney(accountid, Type, money);
// 记日志
if (Type == AccountType.Flow) {
logDao.recordLog(moneyEntity, money, BussinessType.fill, usrname, "充值", cardentity.getId());
} else if (Type == AccountType.Service) {
log2Dao.recordLog(moneyEntity, money, BussinessType.fill, usrname, "充值", cardentity.getId());
}
// 注销卡
card.fillMoney(cardentity, usrname);
}
/**
* 作者:chenjy <br>
* 日期:Oct 26, 2007
* 描述:账户增加余额
*
*/
void addmoney(String accountid, AccountType Type, BigDecimal money, String usrname, String reson) throws AccountException{
RunTimeLogger.info(getClass(), "增加余额");
// 增加余额
AccmoneyEntity moneyEntity = moneyDao.fillMoney(accountid, Type, money);
// 记日志
if (Type == AccountType.Flow) {
logDao.recordLog(moneyEntity, money, BussinessType.add, usrname, reson);
} else if (Type == AccountType.Service) {
log2Dao.recordLog(moneyEntity, money, BussinessType.add, usrname, reson);
}
return;
}
public List ListMeno(String accountid, AccountType Type, Date start, Date end) throws AccountException {
RunTimeLogger.info(getClass(), "查询明细");
// getManager().createNativeQuery("")
List ret = null;
if (Type == AccountType.Flow) {
ret = logDao.queryByPeriod(accountid, start, end);
} else if (Type == AccountType.Service) {
ret = log2Dao.queryByPeriod(accountid, start, end);
}
return ret;
}
public void modify(AccountEntity account) throws AccountException {
RunTimeLogger.info(getClass(), "修改账户");
accountDao.modify(account);
}
public List querybyAgent(String agentid, AccountType type) throws AccountException {
return null;
}
public void start(String accountid, String usrname, String reson) throws AccountException {
RunTimeLogger.info(getClass(), "账户启用");
accountDao.start(accountid);
log2Dao.recordLog(accountid, BussinessType.start, usrname, "账户启用");
}
public void stop(String accountid, String usrname, String reson) throws AccountException {
RunTimeLogger.info(getClass(), "账户停用");
accountDao.stop(accountid);
log2Dao.recordLog(accountid, BussinessType.stop, usrname, "账户启用");
}
/**
* 作者:msf <br>
* 日期:Dec 18, 2006
*
* @see com.ufmobile.business.account.bo.Account#querybyAccountID(java.lang.String)
*/
public AccountEntity querybyAccountID(String sID) {
RunTimeLogger.info(getClass(), "查询");
return accountDao.querybyAccountID(sID);
}
/**
* 作者:msf <br>
* 日期:Dec 18, 2006
*
* @see com.ufmobile.business.account.bo.Account#querybyAccountID(java.lang.String,
* com.ufmobile.business.account.bo.Account.AccountType)
*/
public AccountEntity querybyAccountID(String sID, AccountType type) {
RunTimeLogger.info(getClass(), "代理商查询");
AccountEntity ret = accountDao.querybyAccountID(sID);
if (type == null) {
ret.setMoneys(moneyDao.getAccmoneyEngtity(sID));
} else {
ret.setMoney(moneyDao.getAccmoneyEngtity(sID, type));
}
return ret;
}
/**
* 作者:msf <br>
* 日期:Feb 5, 2007
*
* @see com.ufmobile.business.account.bo.Account#deduct(java.lang.String,
* com.ufmobile.business.account.bo.Account.AccountType,
* java.lang.Integer, java.lang.Long, java.lang.String,
* java.lang.String, java.lang.String)
*/
public void deduct(String accountid, AccountType Type, Integer divNum, Long sendCount, String category, String usrname, String reson) throws AccountException {
RunTimeLogger.info(getClass(), "扣费2");
// 取费用标准
List<BusiPriceEntity> lsPrice = new PriceDAO(getManager(getClass())).getPriceByType(category);
if (lsPrice.size() == 0) {
RunTimeLogger.error(this, "没有找到价格类型");
return;
}
// 计算费用
double money = 0.0;
int iIndex = 0;
for (int i = 0; i < divNum.intValue(); i++) {
if (i < lsPrice.size() - 1)
iIndex = i;
else
iIndex = lsPrice.size() - 1;
money += lsPrice.get(iIndex).getPrice().doubleValue() * sendCount.longValue();
}
RunTimeLogger.error(getClass(), "流量计费@@@" + "帐户id" + accountid + "拆分条数" + divNum + "发送次数" + sendCount + "价格标准" + category + "批次号:" + reson + "用户名:" + usrname + "扣费金额:" + money);
// 扣费
if (money > 0.0)
deduct(accountid, Type, new BigDecimal(money), usrname, reson);
else {
RunTimeLogger.error(getClass(), "没有扣费@@@" + "帐户id" + accountid + "批次号:" + reson + "用户名:" + usrname);
}
}
/**
* 作者:msf <br>
* 日期:Feb 28, 2007
*
* @see com.ufmobile.business.account.bo.Account#queryAccountTotal(java.lang.String,
* java.lang.String, java.sql.Date, java.sql.Date, int)
*/
public int queryAccountTotal(String accountCode, String accountName, Date from, Date to, int isStarted) throws AccountException {
RunTimeLogger.info(getClass(), "查询账户总数");
return accountDao.queryAccountTotal(accountCode, accountName, from, to, isStarted);
}
/**
* 作者:msf <br>
* 日期:Feb 28, 2007
*
* @see com.ufmobile.business.account.bo.Account#queryAccountByPage(int,
* int, java.lang.String, java.lang.String, java.sql.Date,
* java.sql.Date, int)
*/
public List<AccountEntity> queryAccountByPage(int beginIndex, int maxNumber, String accountCode, String accountName, Date from, Date to, int isStarted) throws AccountException {
RunTimeLogger.info(getClass(), "查询账户");
return accountDao.queryAccountByPage(beginIndex, maxNumber, accountCode, accountName, from, to, isStarted);
}
/**
* 作者:msf <br>
* 日期:Feb 28, 2007
*
* @see com.ufmobile.business.account.bo.Account#changeAccountState(java.lang.Boolean,
* java.lang.String[])
*/
public void changeAccountState(Boolean isStarted, String... accountIds) {
RunTimeLogger.info(getClass(), "更改账户状态");
accountDao.changeAccountState(isStarted, accountIds);
}
/**
* 作者:msf <br>
* 日期:Feb 28, 2007
*
* @see com.ufmobile.business.account.bo.Account#batchDelete(java.lang.String[])
*/
public void batchDelete(String... accountIds) {
RunTimeLogger.info(getClass(), "批量删除账户");
accountDao.batchDelete(accountIds);
}
/**
* 作者:msf <br>
* 日期:Feb 28, 2007
*
* @see com.ufmobile.business.account.bo.Account#changeAgent(java.lang.String,
* java.lang.String)
*/
public void changeAgent(String agentCode, String accountID) {
accountDao.changeAccountAgent(agentCode, accountID);
}
public void updateAccountName(String accountId, String accountName) {
if (accountId == null)
return;
AccountEntity account = this.getManager().find(AccountEntity.class, accountId);
if (account != null) {
account.setName(accountName);
this.getManager().merge(account);
}
}
/**
* 作者:chenjy <br>
* 日期:Oct 26, 2007
* 描述:账户增加余额/减少余额
*
*/
public void adjustAccount(Long boothid, int adjustType,int accountType, int sysid,String comment,BigDecimal money,UserInfo user) throws Exception{
RunTimeLogger.info(getClass(), "增加余额或者减少余额。");
//判断是否是运营人员,因为运营人员才能调整
if(user == null){
throw new BusinessException(this.getClass(),"不合法用户-空。");
}else if(user.getType() != UserInfo.Operator){
throw new BusinessException(this.getClass(),"不合法用户-不具备权限。");
}
if(comment == null || comment.trim().length()<0){
throw new BusinessException(this.getClass(),"调整原因不能为空。");
}
if(money == null ){
throw new BusinessException(this.getClass(),"调整金额不能为空。");
}else if(money.doubleValue()<=0.0){
throw new BusinessException(this.getClass(),"调整金额不能为0或负数。");
}
if(adjustType<AccountAdjustEntity.ADJUST_TYPE_ADD ||adjustType>AccountAdjustEntity.ADJUST_TYPE_SUB){
throw new BusinessException(this.getClass(),"调整类型不合法。");
}
if(accountType<AccountAdjustEntity.ACCOUNT_SERVICE || accountType>AccountAdjustEntity.ACCOUNT_FLOW){
throw new BusinessException(this.getClass(),"账户类型不合法。");
}
if(boothid == null){
throw new BusinessException(this.getClass(),"必须选择商铺。");
}
Booth booth = (Booth)getBean(sysid,"BoothBean");
BoothEntity boothEntity = booth.findBooth(boothid);
if(boothEntity == null){
throw new BusinessException(this.getClass(),"选择的商铺不存在。");
}
if(adjustType == AccountAdjustEntity.ADJUST_TYPE_ADD){//增加余额
if(accountType==AccountAdjustEntity.ACCOUNT_SERVICE){//服务账户
AccountType accType = AccountType.Service;
this.addmoney(boothEntity.getAccountid(), accType, money, user.getUsrName(), "增加余额");
}else if(accountType==AccountAdjustEntity.ACCOUNT_FLOW){//流量账户
AccountType accType = AccountType.Flow;
this.addmoney(boothEntity.getAccountid(), accType, money, user.getUsrName(), "增加余额");
}
}else if(adjustType == AccountAdjustEntity.ADJUST_TYPE_SUB){//减少余额
if(accountType==AccountAdjustEntity.ACCOUNT_SERVICE){//服务账户
AccountType accType = AccountType.Service;
this.deduct(boothEntity.getAccountid(), accType, money, user.getUsrName(), "减少余额",BussinessType.subtract);
}else if(accountType==AccountAdjustEntity.ACCOUNT_FLOW){//流量账户
AccountType accType = AccountType.Flow;
this.deduct(boothEntity.getAccountid(), accType, money, user.getUsrName(), "减少余额",BussinessType.subtract);
}
}
//写入账户调整单
OperatorEntity opeEntity = new OperatorEntity();
opeEntity.setOperatorid(user.getUsrid());
AccountAdjustEntity accade = new AccountAdjustEntity();
accade.setAccountType(accountType);
accade.setAdjustType(adjustType);
accade.setStreetIdIn(sysid);
accade.setBoothIdIn(boothEntity);
accade.setComment(comment);
accade.setOperateType(user.getType());
accade.setOperateDate(new Date(System.currentTimeMillis()));
accade.setOperatorID(opeEntity);
accade.setMoney(money);
accaDao.create(accade);
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -