| | |
| | | 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.UserMoneyDebt;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDebt.UserMoneyDebtTypeEnum;
|
| | | 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.UserMoneyDebtException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.BindingAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountBindingHistoryService;
|
| | | import com.yeshi.fanli.service.inter.user.UserNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.UserMoneyService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | |
| | | private AlipayAccountValidNormalHistoryMapper alipayAccountValidNormalHistoryMapper;
|
| | | @Resource
|
| | | private UserInfoMapper userInfoMapper;
|
| | |
|
| | | @Resource
|
| | | private UserNotificationService userNotificationService;
|
| | |
|
| | | @Resource
|
| | | private UserAccountBindingHistoryService userAccountBindingHistoryService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyDetailMapper userMoneyDetailMapper;
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | | @Resource
|
| | | private UserMoneyDebtService userMoneyDebtService;
|
| | |
|
| | | public List<BindingAccount> getBindingAccountByUid(long uid) {
|
| | | return bindingAccountMapper.selectByUid(uid);
|
| | |
| | |
|
| | | UserInfo userInfo = userInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userInfo.getMyHongBao().compareTo(new BigDecimal("0")) <= 0)
|
| | | throw new AlipayAccountException(AlipayAccountException.CODE_NO_MONEY, "你的账户目前没有余额,无需绑定提现帐号。");
|
| | | throw new AlipayAccountException(AlipayAccountException.CODE_NO_MONEY, "你的账户无余额,无需绑定提现帐号。");
|
| | |
|
| | | // 需要转账验证
|
| | | BigDecimal money = new BigDecimal("0.1");
|
| | | transferAlipayWithVerify(account, name);
|
| | | // 扣款
|
| | | userInfoMapper.subHongBaoByUid(uid, money);
|
| | |
|
| | | // 转账成功
|
| | | // 插入转账成功表
|
| | | AlipayAccountValidNormalHistory history = new AlipayAccountValidNormalHistory();
|
| | |
| | | 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);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | userNotificationService.alipayAccountValidRight(uid, money, account);
|
| | | // 余额充足
|
| | | if (userInfo.getMyHongBao().compareTo(money) >= 0) {
|
| | | // 扣款
|
| | | userMoneyService.subUserMoney(uid, money, userMoneyDetail);
|
| | | userMoneyMsgNotificationService.alipayAccountValid(history);
|
| | | } else {// 余额不足,暂时不扣款,加入借贷关系
|
| | | UserMoneyDebt debt = new UserMoneyDebt();
|
| | | debt.setCreateTime(new Date());
|
| | | debt.setLeftMoney(money);
|
| | | debt.setOriginMoney(money);
|
| | | debt.setSourceId(history.getId());
|
| | | debt.setType(UserMoneyDebtTypeEnum.extractVerify);
|
| | | debt.setUid(uid);
|
| | | try {
|
| | | userMoneyDebtService.addUserMoneyDebt(debt);
|
| | | } catch (UserMoneyDebtException e) {
|
| | | LogHelper.errorDetailInfo(e, "验证ID:" + history.getId(), "");
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
| | | UserAccountBindingHistory.TYPE_PHONE);
|
| | | // 手机号更换绑定的7天内不能提现
|
| | | if (history != null && !history.getFirst()
|
| | | && (System.currentTimeMillis() - history.getCreateTime().getTime()) > 1000 * 60 * 60 * 24 * 7L) {
|
| | | && (System.currentTimeMillis() - history.getCreateTime().getTime()) < 1000 * 60 * 60 * 24 * 7L) {
|
| | | throw new AlipayAccountException(111, "修改手机号7天内不允许修改支付宝账号");
|
| | | }
|
| | | }
|