admin
2019-07-30 573c491b4a1ba60e12a5678a01c1546c0077c1ee
fanli/src/main/java/com/yeshi/fanli/service/impl/user/BindingAccountServiceImpl.java
@@ -22,6 +22,7 @@
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.UserAccountBindingHistory;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.exception.AlipayAccountException;
@@ -30,6 +31,8 @@
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.UserAccountBindingHistoryService;
import com.yeshi.fanli.service.inter.user.UserMoneyService;
import com.yeshi.fanli.service.inter.user.UserNotificationService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
@@ -50,7 +53,13 @@
   private UserNotificationService userNotificationService;
   @Resource
   private UserAccountBindingHistoryService userAccountBindingHistoryService;
   @Resource
   private UserMoneyDetailMapper userMoneyDetailMapper;
   @Resource
   private UserMoneyService userMoneyService;
   public List<BindingAccount> getBindingAccountByUid(long uid) {
      return bindingAccountMapper.selectByUid(uid);
@@ -140,8 +149,7 @@
      // 需要转账验证
      BigDecimal money = new BigDecimal("0.1");
      transferAlipayWithVerify(account, name);
      // 扣款
      userInfoMapper.subHongBaoByUid(uid, money);
      // 转账成功
      // 插入转账成功表
      AlipayAccountValidNormalHistory history = new AlipayAccountValidNormalHistory();
@@ -150,10 +158,10 @@
      history.setName(name);
      history.setUid(uid);
      alipayAccountValidNormalHistoryMapper.insertSelective(history);
      UserMoneyDetail userMoneyDetail = null;
      // 新版资金
      try {
         UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createExtractAccountValid(history, money);
         userMoneyDetailMapper.insert(userMoneyDetail);
         userMoneyDetail = UserMoneyDetailFactory.createExtractAccountValid(history, money);
      } catch (UserMoneyDetailException e) {
         try {
            LogHelper.errorDetailInfo(e);
@@ -161,6 +169,9 @@
            e1.printStackTrace();
         }
      }
      // 扣款
      userMoneyService.subUserMoney(uid, money, userMoneyDetail);
      userNotificationService.alipayAccountValidRight(uid, money, account);
@@ -199,6 +210,17 @@
   @Override
   public BindingAccount changeAlipayBindingWithVerify(Long uid, String name, String account)
         throws AlipayTransferException, AlipayApiException, AlipayAccountException {
      BindingAccount bindingAccount = bindingAccountMapper.selectByUidAndType(uid, BindingAccount.TYPE_ALIPAY);
      if (bindingAccount != null) {
         // 验证是否7天内更换了手机号
         UserAccountBindingHistory history = userAccountBindingHistoryService.getLatestHistory(uid,
               UserAccountBindingHistory.TYPE_PHONE);
         // 手机号更换绑定的7天内不能提现
         if (history != null && !history.getFirst()
               && (System.currentTimeMillis() - history.getCreateTime().getTime()) < 1000 * 60 * 60 * 24 * 7L) {
            throw new AlipayAccountException(111, "修改手机号7天内不允许修改支付宝账号");
         }
      }
      try {
         validAlipayAccount(uid, account, name);
@@ -210,7 +232,6 @@
         throw new AlipayAccountException(e1.getCode(), e1.getMsg());
      }
      BindingAccount bindingAccount = bindingAccountMapper.selectByUidAndType(uid, BindingAccount.TYPE_ALIPAY);
      if (bindingAccount == null)// 创建账号
      {
         bindingAccount = new BindingAccount();