From 3df7c3cec0630eb3a208d9e9d2049b56a48e16a4 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期五, 22 三月 2019 15:23:21 +0800
Subject: [PATCH] 专题编辑bug
---
fanli/src/main/java/com/yeshi/fanli/service/impl/user/BindingAccountServiceImpl.java | 88 +++++++++++++++++++------------------------
1 files changed, 39 insertions(+), 49 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/BindingAccountServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/BindingAccountServiceImpl.java
index 199482d..913473f 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/BindingAccountServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/BindingAccountServiceImpl.java
@@ -1,6 +1,5 @@
package com.yeshi.fanli.service.impl.user;
-import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
@@ -9,11 +8,6 @@
import javax.annotation.Resource;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.springframework.orm.hibernate4.HibernateCallback;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -22,81 +16,69 @@
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayFundTransToaccountTransferRequest;
import com.alipay.api.response.AlipayFundTransToaccountTransferResponse;
-import com.yeshi.fanli.dao.mybatis.AccountDetailsMapper;
import com.yeshi.fanli.dao.mybatis.AlipayAccountValidNormalHistoryMapper;
import com.yeshi.fanli.dao.mybatis.BindingAccountMapper;
import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
-import com.yeshi.fanli.dao.user.BindingAccountDao;
-import com.yeshi.fanli.entity.bus.user.AccountDetails;
+import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper;
import com.yeshi.fanli.entity.bus.user.AlipayAccountValidNormalHistory;
import com.yeshi.fanli.entity.bus.user.BindingAccount;
import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.exception.AlipayAccountException;
import com.yeshi.fanli.exception.AlipayTransferException;
import com.yeshi.fanli.exception.BindingAccountException;
+import com.yeshi.fanli.exception.money.UserMoneyDetailException;
+import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.user.BindingAccountService;
import com.yeshi.fanli.service.inter.user.UserNotificationService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.factory.AccountDetailsFactory;
+import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
import net.sf.json.JSONObject;
@Service
public class BindingAccountServiceImpl implements BindingAccountService {
-
- @Resource
- private BindingAccountDao bindingAccountDao;
@Resource
private BindingAccountMapper bindingAccountMapper;
@Resource
private AlipayAccountValidNormalHistoryMapper alipayAccountValidNormalHistoryMapper;
@Resource
private UserInfoMapper userInfoMapper;
- @Resource
- private AccountDetailsMapper accountDetailsMapper;
+
@Resource
private UserNotificationService userNotificationService;
+ @Resource
+ private UserMoneyDetailMapper userMoneyDetailMapper;
+
public List<BindingAccount> getBindingAccountByUid(long uid) {
- return bindingAccountDao.list("from BindingAccount ba where ba.userInfo.id=?", new Serializable[] { uid });
+ return bindingAccountMapper.selectByUid(uid);
}
public void addBindingAccount(BindingAccount addAccount) throws BindingAccountException {
- List<BindingAccount> list = bindingAccountDao.list(
- "from BindingAccount ba where ba.userInfo.id=? and ba.type=?",
- new Serializable[] { addAccount.getUserInfo().getId(), addAccount.getType() });
- if (list == null || list.size() == 0) {
- bindingAccountDao.save(addAccount);
+ BindingAccount account = bindingAccountMapper.selectByUidAndType(addAccount.getUserInfo().getId(),
+ addAccount.getType());
+
+ if (account == null) {
+ bindingAccountMapper.insertSelective(addAccount);
} else {
throw new BindingAccountException(Constant.BA_EXIST);
}
}
- public Integer deleteBindingAccount(final BindingAccount account) {
- return (Integer) bindingAccountDao.excute(new HibernateCallback() {
-
- public Integer doInHibernate(Session session) throws HibernateException {
- Transaction transaction = session.beginTransaction();
- Query delete = session.createQuery("delete BindingAccount ba where ba.userInfo.id=? and ba.type=?");
- delete.setLong(0, account.getUserInfo().getId());
- delete.setInteger(1, account.getType());
- int update = delete.executeUpdate();
- transaction.commit();
- return update;
- }
-
- });
+ @Transactional
+ public Integer deleteBindingAccount(BindingAccount account) {
+ BindingAccount oldAccount = bindingAccountMapper.selectByUidAndType(account.getUserInfo().getId(),
+ account.getType());
+ if (oldAccount != null)
+ bindingAccountMapper.deleteByPrimaryKey(oldAccount.getId());
+ return 1;
}
public BindingAccount getBindingAccountByUidAndType(long uid, int type) {
-
- List<BindingAccount> list = bindingAccountDao
- .list("from BindingAccount ba where ba.userInfo.id=? and ba.type=?", new Serializable[] { uid, type });
- if (list != null && list.size() != 0) {
- return list.get(0);
- }
- return null;
+ BindingAccount account = bindingAccountMapper.selectByUidAndType(uid, type);
+ return account;
}
@Override
@@ -109,11 +91,11 @@
bindingAccount.setName(name);
bindingAccount.setType(BindingAccount.TYPE_ALIPAY);
bindingAccount.setUserInfo(new UserInfo(uid));
- bindingAccountDao.create(bindingAccount);
+ bindingAccountMapper.insertSelective(bindingAccount);
} else {
bindingAccount.setName(name);
bindingAccount.setAccount(account);
- bindingAccountDao.update(bindingAccount);
+ bindingAccountMapper.updateByPrimaryKeySelective(bindingAccount);
}
return bindingAccount;
}
@@ -168,10 +150,18 @@
history.setName(name);
history.setUid(uid);
alipayAccountValidNormalHistoryMapper.insertSelective(history);
- // 璧勯噾璁板綍 绔欏唴淇�
- AccountDetails accountDetails = AccountDetailsFactory.create("-" + money.toString(),
- AccountDetailsFactory.VALID_ALIPAY_ACCOUNT, null, null, new UserInfo(uid));
- accountDetailsMapper.insertSelective(accountDetails);
+ // 鏂扮増璧勯噾
+ try {
+ UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createExtractAccountValid(history, money);
+ userMoneyDetailMapper.insert(userMoneyDetail);
+ } catch (UserMoneyDetailException e) {
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+
userNotificationService.alipayAccountValidRight(uid, money, account);
}
@@ -254,7 +244,7 @@
caLatest.setTimeInMillis(latest.getCreateTime().getTime());
Calendar nowLatest = Calendar.getInstance();
if (caLatest.get(Calendar.MONTH) == nowLatest.get(Calendar.MONTH))// 涓婃鏇存敼鍜岀幇鍦ㄦ槸鍚屼竴涓湀
- throw new BindingAccountException(2, "鏈湀鏀粯瀹濈粦瀹氭鏁拌秴闄�");
+ throw new BindingAccountException(2, "姣忔湀浠呭彲淇敼1娆℃彁鐜拌处鍙凤紝璇蜂笅鏈堝啀璇曞惂銆�");
}
return true;
}
--
Gitblit v1.8.0