|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ydtech.core.page.HttpResult;
|
|
import com.ydtech.core.page.HttpResult;
|
|
|
|
|
+import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.admin.constants.MoneyAttrConstants;
|
|
import com.ydtech.modules.admin.constants.MoneyAttrConstants;
|
|
|
import com.ydtech.modules.admin.constants.WithdrawTypeConstants;
|
|
import com.ydtech.modules.admin.constants.WithdrawTypeConstants;
|
|
|
import com.ydtech.modules.admin.dao.SysUserAccountMapper;
|
|
import com.ydtech.modules.admin.dao.SysUserAccountMapper;
|
|
@@ -209,7 +210,7 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
return HttpResult.ok("有未提现审核单据, 请审核完成之后再提现");
|
|
return HttpResult.ok("有未提现审核单据, 请审核完成之后再提现");
|
|
|
}
|
|
}
|
|
|
// 通过银行卡id 查询卡包
|
|
// 通过银行卡id 查询卡包
|
|
|
- Long fromBankCardId = sysUserAccountVo.getFromBankCardId();
|
|
|
|
|
|
|
+ String fromBankCardId = sysUserAccountVo.getFromBankCardId();
|
|
|
if (fromBankCardId != null) {
|
|
if (fromBankCardId != null) {
|
|
|
SysUserBankCard byId = sysUserBankCardService.getById(fromBankCardId);
|
|
SysUserBankCard byId = sysUserBankCardService.getById(fromBankCardId);
|
|
|
// String bankUserId = byId.getUserId();
|
|
// String bankUserId = byId.getUserId();
|
|
@@ -272,6 +273,88 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
return HttpResult.ok("提现成功,等待审核");
|
|
return HttpResult.ok("提现成功,等待审核");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public HttpResult withdraw(SysUserAccountVo sysUserAccountVo) {
|
|
|
|
|
+ String userId = sysUserAccountVo.getUserId();
|
|
|
|
|
+ BigDecimal zero = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal beforeAmount;
|
|
|
|
|
+ BigDecimal afterAmount;
|
|
|
|
|
+// 用户当前金额
|
|
|
|
|
+ BigDecimal amount = sysUserAccountVo.getAmount();
|
|
|
|
|
+ SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory(); // 记录
|
|
|
|
|
+ sysUserAccountHistory.setDocumentary(1); // 1提现
|
|
|
|
|
+ sysUserAccountHistory.setUserId(userId);
|
|
|
|
|
+ SysAmountAuditingEntity sysAmountAuditingEntity = new SysAmountAuditingEntity();//审核记录表
|
|
|
|
|
+ sysAmountAuditingEntity.setUserId(userId);
|
|
|
|
|
+ sysAmountAuditingEntity.setAmount(sysUserAccountVo.getAmount());
|
|
|
|
|
+ SysAmountAuditingEntity judge = sysAmountAuditingService.getByUserId(userId, sysUserAccountVo.getAmountStatus());
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(judge)) {
|
|
|
|
|
+ throw new SystemException("有未提现审核单据, 请审核完成之后再提现");
|
|
|
|
|
+ }
|
|
|
|
|
+// 通过银行卡id 查询卡包
|
|
|
|
|
+ String fromBankCardId = sysUserAccountVo.getFromBankCardId();
|
|
|
|
|
+ SysUserBankCard byId = sysUserBankCardService.getByBankNumber(fromBankCardId);
|
|
|
|
|
+ if (byId == null) {
|
|
|
|
|
+ throw new SystemException("该卡未绑定此账号,或输入卡号错误,请检查");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (fromBankCardId != null && byId.getUserId().equals(userId)) {
|
|
|
|
|
+ byId.setIsDefault(1);
|
|
|
|
|
+
|
|
|
|
|
+ sysAmountAuditingEntity.setBankNumber(byId.getBankNumber());
|
|
|
|
|
+ sysUserAccountHistory.setFromBankCard(byId.getBankNumber());
|
|
|
|
|
+ sysUserBankCardService.updateById(byId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(userId)) {
|
|
|
|
|
+ SysUserAccount sysUserAccount = baseMapper.getById(userId);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(sysUserAccountVo.getAmountStatus())) {
|
|
|
|
|
+ sysUserAccountHistory.setProperty(Integer.valueOf(sysUserAccountVo.getAmountStatus())); //金额类型
|
|
|
|
|
+
|
|
|
|
|
+ if ("1".equals(sysUserAccountVo.getAmountStatus())) {
|
|
|
|
|
+// 用户当前费用金
|
|
|
|
|
+ beforeAmount = sysUserAccount.getHandlingFee();
|
|
|
|
|
+ afterAmount = beforeAmount.subtract(amount);
|
|
|
|
|
+ sysUserAccount.setHandlingFee(afterAmount);
|
|
|
|
|
+ sysUserAccount.setHandlingAmountPayment(amount);
|
|
|
|
|
+ sysUserAccount.setHandlingAmountWithdrawal(sysUserAccount.getHandlingAmountWithdrawal().add(amount));
|
|
|
|
|
+ } else if ("2".equals(sysUserAccountVo.getAmountStatus())) {
|
|
|
|
|
+// 用户当前 非跟单佣金
|
|
|
|
|
+ beforeAmount = sysUserAccount.getDocumentary();
|
|
|
|
|
+ afterAmount = beforeAmount.subtract(amount);
|
|
|
|
|
+ sysUserAccount.setDocumentary(afterAmount);
|
|
|
|
|
+ sysUserAccount.setDocumentaryAmountpayment(amount);
|
|
|
|
|
+ sysUserAccount.setDocumentaryAmountWithdrawal(sysUserAccount.getDocumentaryAmountWithdrawal().add(amount));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ beforeAmount = sysUserAccount.getPromotion();
|
|
|
|
|
+ afterAmount = beforeAmount.subtract(amount);
|
|
|
|
|
+ sysUserAccount.setPromotion(afterAmount);
|
|
|
|
|
+ sysUserAccount.setPromotionAmountPayment(amount);
|
|
|
|
|
+ sysUserAccount.setPromotionAmountWithdrawal(sysUserAccount.getPromotionAmountWithdrawal().add(amount));
|
|
|
|
|
+ }
|
|
|
|
|
+// 用户相差
|
|
|
|
|
+ if (beforeAmount.compareTo(zero) == 0 || afterAmount.compareTo(zero) < 0) {
|
|
|
|
|
+ return HttpResult.ok("余额不足");
|
|
|
|
|
+ }
|
|
|
|
|
+ sysUserAccountHistory.setAmount(amount); // 金额
|
|
|
|
|
+ sysUserAccountHistory.setSurplusAmount(afterAmount); // 剩余金额
|
|
|
|
|
+ sysUserAccountHistory.setUserAmount(beforeAmount); // 用户剩余金额
|
|
|
|
|
+ sysAmountAuditingEntity.setCreateTime(new Date());
|
|
|
|
|
+ sysAmountAuditingEntity.setAuditingStatus("2"); // 2 为待审核 3 审核通过
|
|
|
|
|
+ sysAmountAuditingEntity.setAmountStatus(sysUserAccountVo.getAmountStatus());
|
|
|
|
|
+// 新增金额记录
|
|
|
|
|
+ sysAmountAuditingService.save(sysAmountAuditingEntity);
|
|
|
|
|
+ sysUserAccountHistory.setAuditiingId(sysAmountAuditingEntity.getId());
|
|
|
|
|
+ sysUserAccountService.updateById(sysUserAccount);
|
|
|
|
|
+ sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok("提现成功,等待审核");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public SysUserAccount getSysUserAmount(String userid) {
|
|
public SysUserAccount getSysUserAmount(String userid) {
|
|
|
SysUserAccount sysUserAccount = baseMapper.getById(userid);
|
|
SysUserAccount sysUserAccount = baseMapper.getById(userid);
|