|
|
@@ -9,13 +9,12 @@ import com.ydtech.modules.admin.constants.MoneyAttrConstants;
|
|
|
import com.ydtech.modules.admin.constants.WithdrawTypeConstants;
|
|
|
import com.ydtech.modules.admin.dao.SysUserAccountMapper;
|
|
|
import com.ydtech.modules.admin.model.SysUser;
|
|
|
-import com.ydtech.modules.admin.model.po.SysAmountAuditingEntity;
|
|
|
-import com.ydtech.modules.admin.model.po.SysUserAccount;
|
|
|
-import com.ydtech.modules.admin.model.po.SysUserAccountHistory;
|
|
|
-import com.ydtech.modules.admin.model.po.SysUserBankCard;
|
|
|
+import com.ydtech.modules.admin.model.dto.*;
|
|
|
+import com.ydtech.modules.admin.model.po.*;
|
|
|
import com.ydtech.modules.admin.model.vo.SubOrder;
|
|
|
import com.ydtech.modules.admin.model.vo.SysUserAccountVo;
|
|
|
import com.ydtech.modules.admin.service.*;
|
|
|
+import com.ydtech.modules.admin.utils.SliceUpDateUtil;
|
|
|
import com.ydtech.modules.base.controller.BaseController;
|
|
|
import com.ydtech.modules.esm.service.EsmUserReferrerService;
|
|
|
import com.ydtech.modules.message.constants.MessageTypeConstants;
|
|
|
@@ -36,10 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author Administrator
|
|
|
@@ -79,10 +75,13 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
@Autowired
|
|
|
private SysUserService sysUserService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysAmountAuditingHistoryService sysAmountAuditingHistoryService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void addOrUpdate(SysUserAccount sysUserAccount) {
|
|
|
- SysUserAccount newSysAccount = baseMapper.getById(sysUserAccount.getUserId());
|
|
|
+ //SysUserAccount newSysAccount = baseMapper.getById(sysUserAccount.getUserId());
|
|
|
// 初始化
|
|
|
if (sysUserAccount.getHandlingFee() == null) {
|
|
|
sysUserAccount.setHandlingFee(BigDecimal.ZERO);
|
|
|
@@ -93,11 +92,17 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
if (sysUserAccount.getPromotion() == null) {
|
|
|
sysUserAccount.setPromotion(BigDecimal.ZERO);
|
|
|
}
|
|
|
+ //添加总金额 = 手续费+跟单费+推广费
|
|
|
+ BigDecimal sumAmount=BigDecimal.ZERO;
|
|
|
+ BigDecimal userAmount=BigDecimal.ZERO;
|
|
|
+ userAmount= userAmount.add(sysUserAccount.getHandlingFee()==null?BigDecimal.ZERO:sysUserAccount.getHandlingFee())
|
|
|
+ .add(sysUserAccount.getDocumentary()==null?BigDecimal.ZERO:sysUserAccount.getDocumentary())
|
|
|
+ .add(sysUserAccount.getPromotion()==null?BigDecimal.ZERO:sysUserAccount.getPromotion());
|
|
|
|
|
|
// 如果用户id有值则累加 没有则 新增
|
|
|
String userId = sysUserAccount.getUserId();
|
|
|
SysUserAccount sysUserAccountEntity = super.getById(userId);
|
|
|
- SysUserAccount newAccount = new SysUserAccount();
|
|
|
+ //SysUserAccount newAccount = new SysUserAccount();
|
|
|
|
|
|
if (ObjectUtils.isNotEmpty(sysUserAccountEntity)) {
|
|
|
sysUserAccountEntity.setHandlingFee(sysUserAccount.getHandlingFee().add(sysUserAccountEntity.getHandlingFee()));
|
|
|
@@ -106,6 +111,11 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
|
|
|
sysUserAccountEntity.setDocumentaryStatus(sysUserAccount.getDocumentaryStatus());
|
|
|
}
|
|
|
+ sumAmount= sumAmount.add(sysUserAccountEntity.getHandlingFee()==null?BigDecimal.ZERO:sysUserAccountEntity.getHandlingFee())
|
|
|
+ .add(sysUserAccountEntity.getDocumentary()==null?BigDecimal.ZERO:sysUserAccountEntity.getDocumentary())
|
|
|
+ .add(sysUserAccountEntity.getPromotion()==null?BigDecimal.ZERO:sysUserAccountEntity.getPromotion());
|
|
|
+ // add by hxl 2024-06-18 插入总金额
|
|
|
+ sysUserAccountEntity.setSumAmount((sysUserAccountEntity.getSumAmount()==null?BigDecimal.ZERO:sysUserAccountEntity.getSumAmount()).add(sumAmount));
|
|
|
baseMapper.updateById(sysUserAccountEntity);
|
|
|
} else {
|
|
|
sysUserAccountEntity = new SysUserAccount();
|
|
|
@@ -127,6 +137,11 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
|
|
|
sysUserAccountEntity.setDocumentaryStatus(sysUserAccount.getDocumentaryStatus());
|
|
|
}
|
|
|
+ sumAmount= sumAmount.add(sysUserAccountEntity.getHandlingFee()==null?BigDecimal.ZERO:sysUserAccountEntity.getHandlingFee())
|
|
|
+ .add(sysUserAccountEntity.getDocumentary()==null?BigDecimal.ZERO:sysUserAccountEntity.getDocumentary())
|
|
|
+ .add(sysUserAccountEntity.getPromotion()==null?BigDecimal.ZERO:sysUserAccountEntity.getPromotion());
|
|
|
+ // add by hxl 2024-06-18 插入总金额
|
|
|
+ sysUserAccountEntity.setSumAmount((sysUserAccountEntity.getSumAmount()==null?BigDecimal.ZERO:sysUserAccountEntity.getSumAmount()).add(sumAmount));
|
|
|
baseMapper.insert(sysUserAccountEntity);
|
|
|
}
|
|
|
StringBuilder commissionMessage = new StringBuilder();
|
|
|
@@ -145,9 +160,10 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
|
|
|
sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getDocumentary());
|
|
|
} else {
|
|
|
- BigDecimal subtract = newSysAccount.getDocumentary().subtract(sysUserAccount.getDocumentary());
|
|
|
+ BigDecimal subtract = sysUserAccountEntity.getDocumentary().subtract(sysUserAccount.getDocumentary());
|
|
|
sysUserAccountHistory.setSurplusAmount(subtract);
|
|
|
}
|
|
|
+ sysUserAccountHistory.setBusinessSegmentsType(1);
|
|
|
sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
|
|
|
}
|
|
|
//手续费
|
|
|
@@ -159,9 +175,10 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
|
|
|
sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getHandlingFee());
|
|
|
} else {
|
|
|
- BigDecimal subtract = newSysAccount.getHandlingFee().subtract(sysUserAccount.getHandlingFee());
|
|
|
+ BigDecimal subtract = sysUserAccountEntity.getHandlingFee().subtract(sysUserAccount.getHandlingFee());
|
|
|
sysUserAccountHistory.setSurplusAmount(subtract);
|
|
|
}
|
|
|
+ sysUserAccountHistory.setBusinessSegmentsType(1);
|
|
|
sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
|
|
|
}
|
|
|
//推广费
|
|
|
@@ -174,12 +191,32 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
|
|
|
sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getPromotion());
|
|
|
} else {
|
|
|
- BigDecimal subtract = newSysAccount.getPromotion().subtract(sysUserAccount.getPromotion());
|
|
|
+ BigDecimal subtract = sysUserAccountEntity.getPromotion().subtract(sysUserAccount.getPromotion());
|
|
|
sysUserAccountHistory.setSurplusAmount(subtract);
|
|
|
}
|
|
|
+ sysUserAccountHistory.setBusinessSegmentsType(1);
|
|
|
sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
|
|
|
|
|
|
}
|
|
|
+ //历史记录表添加收费+跟单费用 add by hxl 2024-06-18
|
|
|
+ if(sysUserAccount.getDocumentary() != null && sysUserAccount.getDocumentary().compareTo(BigDecimal.ZERO) != 0 || sysUserAccount.getPromotion() != null && sysUserAccount.getPromotion().compareTo(BigDecimal.ZERO) != 0 ){
|
|
|
+ BigDecimal sum = (sysUserAccount.getDocumentary()==null?BigDecimal.ZERO:sysUserAccount.getDocumentary())
|
|
|
+ .add(sysUserAccount.getPromotion()==null?BigDecimal.ZERO:sysUserAccount.getPromotion());
|
|
|
+ BigDecimal oldSum = (sysUserAccountEntity.getDocumentary()==null?BigDecimal.ZERO:sysUserAccountEntity.getDocumentary())
|
|
|
+ .add(sysUserAccountEntity.getPromotion()==null?BigDecimal.ZERO:sysUserAccountEntity.getPromotion());
|
|
|
+
|
|
|
+ sysUserAccountHistory.setId(null);
|
|
|
+ sysUserAccountHistory.setAmount(sum);
|
|
|
+ sysUserAccountHistory.setProperty(MoneyAttrConstants.M_4.getCode());
|
|
|
+ if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
|
|
|
+ sysUserAccountHistory.setSurplusAmount(userAmount);
|
|
|
+ } else {
|
|
|
+ BigDecimal subtract = oldSum.subtract(sum);
|
|
|
+ sysUserAccountHistory.setSurplusAmount(subtract);
|
|
|
+ }
|
|
|
+ sysUserAccountHistory.setBusinessSegmentsType(1);
|
|
|
+ sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
|
|
|
+ }
|
|
|
}
|
|
|
//添加佣金消息
|
|
|
messageSecretaryService.addMessage(MessageTypeConstants.M_5,sysUserAccount.getUserId(),"你有一条佣金消息," + commissionMessage.toString());
|
|
|
@@ -214,6 +251,8 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory(); // 记录
|
|
|
sysUserAccountHistory.setDocumentary(1); // 1提现
|
|
|
sysUserAccountHistory.setUserId(userId);
|
|
|
+ sysUserAccountHistory.setProperty(3);
|
|
|
+ sysUserAccountHistory.setBusinessSegmentsType(1);
|
|
|
SysAmountAuditingEntity sysAmountAuditingEntity = new SysAmountAuditingEntity();//审核记录表
|
|
|
sysAmountAuditingEntity.setUserId(userId);
|
|
|
sysAmountAuditingEntity.setAmount(sysUserAccountVo.getAmount());
|
|
|
@@ -239,10 +278,9 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
if (StringUtils.isNotEmpty(userId)) {
|
|
|
SysUserAccount sysUserAccount = baseMapper.getById(userId);
|
|
|
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(sysUserAccountVo.getAmountStatus())) {
|
|
|
- sysUserAccountHistory.setProperty(Integer.valueOf(sysUserAccountVo.getAmountStatus())); //金额类型
|
|
|
-
|
|
|
+ //if (StringUtils.isNotEmpty(sysUserAccountVo.getAmountStatus())) {
|
|
|
+ //sysUserAccountHistory.setProperty(Integer.valueOf(sysUserAccountVo.getAmountStatus())); //金额类型
|
|
|
+ /**
|
|
|
if ("1".equals(sysUserAccountVo.getAmountStatus())) {
|
|
|
// 用户当前费用金
|
|
|
beforeAmount = sysUserAccount.getHandlingFee();
|
|
|
@@ -264,6 +302,16 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
sysUserAccount.setPromotionAmountPayment(sysUserAccount.getPromotionAmountPayment().add(amount));
|
|
|
sysUserAccount.setPromotionAmountWithdrawal(sysUserAccount.getPromotionAmountWithdrawal().add(amount));
|
|
|
}
|
|
|
+ **/
|
|
|
+ //提现前的金额
|
|
|
+ beforeAmount = sysUserAccount.getSumAmount()==null?BigDecimal.ZERO:sysUserAccount.getSumAmount();
|
|
|
+ //提现后的金额
|
|
|
+ afterAmount = beforeAmount.subtract(amount);
|
|
|
+ sysUserAccount.setSumAmount(afterAmount);
|
|
|
+ //支付中总金额 = 原先的支付金额 + 提现的金额
|
|
|
+ sysUserAccount.setSumAmountPayment((sysUserAccount.getSumAmountPayment()==null?BigDecimal.ZERO:sysUserAccount.getSumAmountPayment()).add(amount));
|
|
|
+ //提现的总金额 = 原先的提现总金额 + 提现的金额
|
|
|
+ sysUserAccount.setSumAmountWithdrawal((sysUserAccount.getSumAmountWithdrawal()==null?BigDecimal.ZERO:sysUserAccount.getSumAmountWithdrawal().add(amount)));
|
|
|
// 用户相差
|
|
|
if (beforeAmount.compareTo(zero) == 0 || afterAmount.compareTo(zero) < 0) {
|
|
|
return HttpResult.ok("余额不足");
|
|
|
@@ -273,18 +321,33 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
sysUserAccountHistory.setUserAmount(beforeAmount); // 用户剩余金额
|
|
|
sysAmountAuditingEntity.setCreateTime(new Date());
|
|
|
sysAmountAuditingEntity.setAuditingStatus("2"); // 2 为待审核 3 审核通过
|
|
|
- sysAmountAuditingEntity.setAmountStatus(sysUserAccountVo.getAmountStatus());
|
|
|
+ // sysAmountAuditingEntity.setAmountStatus(sysUserAccountVo.getAmountStatus());
|
|
|
// 新增金额记录
|
|
|
sysAmountAuditingService.save(sysAmountAuditingEntity);
|
|
|
sysUserAccountHistory.setAuditiingId(sysAmountAuditingEntity.getId());
|
|
|
sysUserAccountService.updateById(sysUserAccount);
|
|
|
sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
|
|
|
- }
|
|
|
+ // }
|
|
|
+ // 提现审核插入轨迹表 待审核数据 和审核处理中的数据
|
|
|
+
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ Date date = calendar.getTime();
|
|
|
+ calendar.add(Calendar.MINUTE, 1);
|
|
|
+ Date afterDate = calendar.getTime();
|
|
|
+ SysAmountAuditingHistory sysAmountAuditingHistory =new SysAmountAuditingHistory(null, sysAmountAuditingEntity.getId(), amount, userId,date,"1", "1",sysUserAccountHistory.getId());
|
|
|
+ SysAmountAuditingHistory sysAmountAuditingHistoryTwo =new SysAmountAuditingHistory(null, sysAmountAuditingEntity.getId(), amount, userId,afterDate, "2", "1",sysUserAccountHistory.getId());
|
|
|
+ sysAmountAuditingHistoryService.save(sysAmountAuditingHistory);
|
|
|
+ sysAmountAuditingHistoryService.save(sysAmountAuditingHistoryTwo);
|
|
|
|
|
|
}
|
|
|
return HttpResult.ok("提现成功,等待审核");
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/18 17:30
|
|
|
+ * @Description: 提现修改为总金额
|
|
|
+ */
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public HttpResult withdraw(SysUserAccountVo sysUserAccountVo) {
|
|
|
@@ -324,29 +387,41 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
|
|
|
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(sysUserAccount.getHandlingAmountPayment().add(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(sysUserAccount.getDocumentaryAmountpayment().add(amount));
|
|
|
+ sysUserAccount.setDocumentaryAmountWithdrawal(sysUserAccount.getDocumentaryAmountWithdrawal().add(amount));
|
|
|
+ } else {
|
|
|
+ beforeAmount = sysUserAccount.getPromotion();
|
|
|
+ afterAmount = beforeAmount.subtract(amount);
|
|
|
+ sysUserAccount.setPromotion(afterAmount);
|
|
|
+ sysUserAccount.setPromotionAmountPayment(sysUserAccount.getPromotionAmountPayment().add(amount));
|
|
|
+ sysUserAccount.setPromotionAmountWithdrawal(sysUserAccount.getPromotionAmountWithdrawal().add(amount));
|
|
|
+ }
|
|
|
+ **/
|
|
|
+ //提现前的金额
|
|
|
+ beforeAmount = sysUserAccount.getSumAmount();
|
|
|
+ //提现后的金额
|
|
|
+ afterAmount = beforeAmount.subtract(amount);
|
|
|
+ sysUserAccount.setSumAmount(afterAmount);
|
|
|
+ //支付中总金额 = 原先的支付金额 + 提现的金额
|
|
|
+ sysUserAccount.setSumAmountPayment(sysUserAccount.getSumAmountPayment().add(amount));
|
|
|
+ //提现的总金额 = 原先的提现总金额 + 提现的金额
|
|
|
+ sysUserAccount.setSumAmountWithdrawal(sysUserAccount.getSumAmountWithdrawal().add(amount));
|
|
|
|
|
|
- if ("1".equals(sysUserAccountVo.getAmountStatus())) {
|
|
|
-// 用户当前费用金
|
|
|
- beforeAmount = sysUserAccount.getHandlingFee();
|
|
|
- afterAmount = beforeAmount.subtract(amount);
|
|
|
- sysUserAccount.setHandlingFee(afterAmount);
|
|
|
- sysUserAccount.setHandlingAmountPayment(sysUserAccount.getHandlingAmountPayment().add(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(sysUserAccount.getDocumentaryAmountpayment().add(amount));
|
|
|
- sysUserAccount.setDocumentaryAmountWithdrawal(sysUserAccount.getDocumentaryAmountWithdrawal().add(amount));
|
|
|
- } else {
|
|
|
- beforeAmount = sysUserAccount.getPromotion();
|
|
|
- afterAmount = beforeAmount.subtract(amount);
|
|
|
- sysUserAccount.setPromotion(afterAmount);
|
|
|
- sysUserAccount.setPromotionAmountPayment(sysUserAccount.getPromotionAmountPayment().add(amount));
|
|
|
- sysUserAccount.setPromotionAmountWithdrawal(sysUserAccount.getPromotionAmountWithdrawal().add(amount));
|
|
|
- }
|
|
|
-// 用户相差
|
|
|
+ // 用户相差
|
|
|
if (beforeAmount.compareTo(zero) == 0 || afterAmount.compareTo(zero) < 0) {
|
|
|
return HttpResult.error("余额不足");
|
|
|
}
|
|
|
@@ -392,8 +467,8 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
BigDecimal willDocumentary = BigDecimal.ZERO; //预收 非跟单佣金
|
|
|
BigDecimal willPromotion = BigDecimal.ZERO; //预收 推广
|
|
|
//BigDecimal receivedWillHalding = BigDecimal.ZERO; //实收手续费佣金
|
|
|
- // BigDecimal receivedWillDocumentary = BigDecimal.ZERO; //实收非跟单佣金
|
|
|
- // BigDecimal receivedWillPromotion = BigDecimal.ZERO; //实收推广费
|
|
|
+ // BigDecimal receivedWillDocumentary = BigDecimal.ZERO; //实收非跟单佣金
|
|
|
+ // BigDecimal receivedWillPromotion = BigDecimal.ZERO; //实收推广费
|
|
|
// 预收手续费佣金
|
|
|
willPromotion = this.willPromotionAll(willPromotion, userId,"1");
|
|
|
// 实收手续费佣金
|
|
|
@@ -411,15 +486,15 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
- if (!CollectionUtils.isEmpty(willListnew)) {
|
|
|
- for (InsFeeOrderNew item : willListnew) {
|
|
|
- if (ObjectUtils.isNotEmpty(item)) {
|
|
|
- //1.实收手续费佣金 2. 实收非跟单佣金
|
|
|
- receivedWillHalding = willHalding.add(this.willAmountNew(item,1));
|
|
|
- receivedWillDocumentary = willDocumentary.add(this.willAmountNew(item,2));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ if (!CollectionUtils.isEmpty(willListnew)) {
|
|
|
+ for (InsFeeOrderNew item : willListnew) {
|
|
|
+ if (ObjectUtils.isNotEmpty(item)) {
|
|
|
+ //1.实收手续费佣金 2. 实收非跟单佣金
|
|
|
+ receivedWillHalding = willHalding.add(this.willAmountNew(item,1));
|
|
|
+ receivedWillDocumentary = willDocumentary.add(this.willAmountNew(item,2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
**/
|
|
|
//预收手续费佣金
|
|
|
sysUserAccountVo.setWillHalding(willHalding);
|
|
|
@@ -444,7 +519,7 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
//预收手续费佣金
|
|
|
sysUserAccountVo.setWillPromotion(willPromotion);
|
|
|
//实收手续费佣金
|
|
|
- // sysUserAccountVo.setReceivedWillPromotion(receivedWillPromotion);
|
|
|
+ // sysUserAccountVo.setReceivedWillPromotion(receivedWillPromotion);
|
|
|
return sysUserAccountVo;
|
|
|
}
|
|
|
|
|
|
@@ -720,6 +795,9 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
}
|
|
|
return subOrder;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @version
|
|
|
* @author: hxl
|
|
|
@@ -735,8 +813,281 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
-}
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/19 9:04
|
|
|
+ * @Description: 查询我的账户总金额
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BigDecimal getUserSumAmountByUserId(String userId) {
|
|
|
+ if(StringUtils.isBlank(userId)){
|
|
|
+ throw new SystemException("用户id-userId不能为空");
|
|
|
+ }
|
|
|
+ //通过用户id查询用户账户的总金额
|
|
|
+ LambdaQueryWrapper<SysUserAccount> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SysUserAccount::getUserId, userId);
|
|
|
+ SysUserAccount sysUserAccount = sysUserAccountService.getOne(queryWrapper);
|
|
|
+ if(sysUserAccount==null){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ return sysUserAccount.getSumAmount()==null?BigDecimal.ZERO:sysUserAccount.getSumAmount();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/19 11:04
|
|
|
+ * @Description: 查询预收数据明细
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public MyCollectInAdvanceAllDto findMyCollectInAdvanceByUserId(MyCollectInAdvanceQueryDto myCollectInAdvanceQueryDto) {
|
|
|
+ if(StringUtils.isBlank(myCollectInAdvanceQueryDto.getUserId())){
|
|
|
+ throw new SystemException("用户id-userId不能为空");
|
|
|
+ }
|
|
|
+ BigDecimal sumAmount=BigDecimal.ZERO;
|
|
|
+ //判断时间类型 1.一周内 2. 一月内 3. 三月内 4. 三月内
|
|
|
+ HashMap<String, String> dateMap = getDateMapByType(myCollectInAdvanceQueryDto.getDateQueryType());
|
|
|
+ myCollectInAdvanceQueryDto.setStartDate(dateMap.get("startDate"));
|
|
|
+ myCollectInAdvanceQueryDto.setEndDate(dateMap.get("endDate"));
|
|
|
+ if(myCollectInAdvanceQueryDto.getBusinessSegmentsType()==null || "".equals(myCollectInAdvanceQueryDto.getBusinessSegmentsType())){
|
|
|
+ myCollectInAdvanceQueryDto.setBusinessSegmentsType("1");
|
|
|
+ }
|
|
|
+ if(myCollectInAdvanceQueryDto.getTransactionType()==null || "".equals(myCollectInAdvanceQueryDto.getTransactionType())){
|
|
|
+ myCollectInAdvanceQueryDto.setTransactionType("1");
|
|
|
+ }
|
|
|
+ Page<MyCollectInAdvanceDto> page = new Page<>(myCollectInAdvanceQueryDto.getPageNum(), myCollectInAdvanceQueryDto.getPageSize());
|
|
|
+ page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
|
|
|
+ Page<MyCollectInAdvanceDto> orderVoPage = new Page<>();
|
|
|
+ // 1为车险板块
|
|
|
+ if ("1".equals(myCollectInAdvanceQueryDto.getBusinessSegmentsType())) {
|
|
|
+ //金额类型 1. 手续费金额 +跟单金额 2. 推广金额
|
|
|
+ if("2".equals(myCollectInAdvanceQueryDto.getTransactionType())){
|
|
|
+ orderVoPage = insFeeOrderNewService.findMyCollectInAdvanceWillAmountByUserId(page,myCollectInAdvanceQueryDto);
|
|
|
+ Long total=insFeeOrderNewService.findMyCollectInAdvanceWillAmountByUserIdCount(myCollectInAdvanceQueryDto);
|
|
|
+ orderVoPage.setTotal(total);
|
|
|
+ sumAmount = insFeeOrderNewService.findSumWillAmount(myCollectInAdvanceQueryDto);
|
|
|
+ }else{
|
|
|
+ orderVoPage = insFeeOrderNewService.findMyCollectInAdvanceSumByUserId(page,myCollectInAdvanceQueryDto);
|
|
|
+ Long total=insFeeOrderNewService.findMyCollectInAdvanceSumByUserIdCount(myCollectInAdvanceQueryDto);
|
|
|
+ orderVoPage.setTotal(total);
|
|
|
+ sumAmount = insFeeOrderNewService.findSumAmount(myCollectInAdvanceQueryDto);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //其他板块预留逻辑处理
|
|
|
+ }
|
|
|
+ BasePageResult<MyCollectInAdvanceDto> myCollectInAdvanceDtoBasePageResult = new BasePageResult<>(myCollectInAdvanceQueryDto.getPageNum(), myCollectInAdvanceQueryDto.getPageSize(), orderVoPage.getTotal(),
|
|
|
+ orderVoPage.getPages()
|
|
|
+ , orderVoPage.getRecords());
|
|
|
+ return new MyCollectInAdvanceAllDto(sumAmount,myCollectInAdvanceDtoBasePageResult);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/19 11:57
|
|
|
+ * @Description: 通过时间类型判断
|
|
|
+ */
|
|
|
+ private static HashMap<String,String> getDateMapByType(String type) {
|
|
|
+ HashMap<String,String> map =new HashMap<>();
|
|
|
+ String startDateStr="";
|
|
|
+ String endDateStr="";
|
|
|
+ if("0".equals(type)){
|
|
|
+ //全部
|
|
|
+ startDateStr=null;
|
|
|
+ endDateStr=null;
|
|
|
+ }else if("1".equals(type)){
|
|
|
+ // 一周内
|
|
|
+ startDateStr=SliceUpDateUtil.getWeekFirstAndLastDay(new Date(),1)+" 00:00:00";
|
|
|
+ endDateStr=SliceUpDateUtil.getWeekFirstAndLastDay(new Date(),2)+" 23:59:59";
|
|
|
+ }else if("2".equals(type)){
|
|
|
+ // 一月内
|
|
|
+ startDateStr=SliceUpDateUtil.getMonthFirstAndLastDay(new Date(),1)+" 00:00:00";
|
|
|
+ endDateStr=SliceUpDateUtil.getMonthFirstAndLastDay(new Date(),2)+" 23:59:59";
|
|
|
+ }else if("3".equals(type)){
|
|
|
+ // 三月内
|
|
|
+ startDateStr=SliceUpDateUtil.getThreeMonthFirstAndLastDay(new Date(),1,3)+" 00:00:00";
|
|
|
+ endDateStr=SliceUpDateUtil.getThreeMonthFirstAndLastDay(new Date(),2,3)+" 23:59:59";
|
|
|
+ }else if("4".equals(type)){
|
|
|
+ // 三月内
|
|
|
+ startDateStr=SliceUpDateUtil.getThreeMonthFirstAndLastDay(new Date(),1,6)+" 00:00:00";
|
|
|
+ endDateStr=SliceUpDateUtil.getThreeMonthFirstAndLastDay(new Date(),2,6)+" 23:59:59";
|
|
|
+ }
|
|
|
+ map.put("startDate",startDateStr);
|
|
|
+ map.put("endDate",endDateStr);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/19 11:04
|
|
|
+ * @Description: 查询收支数据明细
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public MyCollectInAdvanceAllDto findIncomeAndExpensesByUserId(MyIncomeAndExpensesQueryDto myIncomeAndExpensesQueryDto) {
|
|
|
+ if(StringUtils.isBlank(myIncomeAndExpensesQueryDto.getUserId())){
|
|
|
+ throw new SystemException("用户id-userId不能为空");
|
|
|
+ }
|
|
|
+ BigDecimal sumAmountSR=BigDecimal.ZERO;
|
|
|
+ BigDecimal sumAmountZC=BigDecimal.ZERO;
|
|
|
+ BasePageResult<MyCollectInAdvanceDto> myCollectInAdvanceDtoBasePageResult=new BasePageResult<MyCollectInAdvanceDto>();
|
|
|
+ //判断时间类型 1.一周内 2. 一月内 3. 三月内 4. 三月内
|
|
|
+ HashMap<String, String> dateMap = getDateMapByType(myIncomeAndExpensesQueryDto.getDateQueryType());
|
|
|
+ myIncomeAndExpensesQueryDto.setStartDate(dateMap.get("startDate"));
|
|
|
+ myIncomeAndExpensesQueryDto.setEndDate(dateMap.get("endDate"));
|
|
|
+ Page<MyCollectInAdvanceDto> page = new Page<>(myIncomeAndExpensesQueryDto.getPageNum(), myIncomeAndExpensesQueryDto.getPageSize());
|
|
|
+ page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
|
|
|
+ Page<MyCollectInAdvanceDto> orderVoPage = new Page<>();
|
|
|
+ if(myIncomeAndExpensesQueryDto.getBusinessSegmentsType()==null || "".equals(myIncomeAndExpensesQueryDto.getBusinessSegmentsType())){
|
|
|
+ myIncomeAndExpensesQueryDto.setBusinessSegmentsType("1");
|
|
|
+ }
|
|
|
+ if(myIncomeAndExpensesQueryDto.getTransactionType()==null || "".equals(myIncomeAndExpensesQueryDto.getTransactionType())){
|
|
|
+ myIncomeAndExpensesQueryDto.setTransactionType("1");
|
|
|
+ }
|
|
|
+ if(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()==null || "".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())){
|
|
|
+ myIncomeAndExpensesQueryDto.setIncomeAndExpensesType("1");
|
|
|
+ }
|
|
|
+ // 1为车险板块
|
|
|
+ if ("1".equals(myIncomeAndExpensesQueryDto.getBusinessSegmentsType())) {
|
|
|
+ //判断收入类型 1 收入 查询账号的历史记录表
|
|
|
+ if("1".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())){
|
|
|
|
|
|
+ //金额类型 1. 手续费金额 +跟单金额 2. 推广金额
|
|
|
+ if("2".equals(myIncomeAndExpensesQueryDto.getTransactionType())){
|
|
|
+ myIncomeAndExpensesQueryDto.setTransactionType("3");
|
|
|
+ }else if("1".equals(myIncomeAndExpensesQueryDto.getTransactionType())){
|
|
|
+ myIncomeAndExpensesQueryDto.setTransactionType("4");
|
|
|
+ }else{
|
|
|
+ throw new SystemException("收入类型不能选择提现类型");
|
|
|
+ }
|
|
|
+ myIncomeAndExpensesQueryDto.setIncomeAndExpensesType("2");
|
|
|
+ orderVoPage = sysUserAccountHistoryService.findMyIncomeAndExpensesAmountByUserId(page,myIncomeAndExpensesQueryDto);
|
|
|
+ Long total=sysUserAccountHistoryService.findMyIncomeAndExpensesAmountByUserIdCount(myIncomeAndExpensesQueryDto);
|
|
|
+ orderVoPage.setTotal(total);
|
|
|
|
|
|
+ sumAmountSR=sysUserAccountHistoryService.findSumAmount(myIncomeAndExpensesQueryDto);
|
|
|
+ sumAmountZC=sysUserAccountHistoryService.findSumAmountByUserId(myIncomeAndExpensesQueryDto.getUserId(),"2");
|
|
|
+ List<MyCollectInAdvanceDto> recordsNew =new ArrayList<>();
|
|
|
+ if(orderVoPage.getRecords()!=null && orderVoPage.getRecords().size()>0){
|
|
|
+ for(MyCollectInAdvanceDto dto :orderVoPage.getRecords()){
|
|
|
+ if ("4".equals(dto.getTransactionType())) {
|
|
|
+ dto.setTransactionType("1");
|
|
|
+ }else if("3".equals(dto.getTransactionType())){
|
|
|
+ dto.setTransactionType("2");
|
|
|
+ }
|
|
|
+ dto.setIncomeAndExpensesType("1");
|
|
|
+ recordsNew.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderVoPage.setRecords(recordsNew);
|
|
|
+ myCollectInAdvanceDtoBasePageResult=new BasePageResult<>(myIncomeAndExpensesQueryDto.getPageNum(), myIncomeAndExpensesQueryDto.getPageSize(), orderVoPage.getTotal(),
|
|
|
+ orderVoPage.getPages()
|
|
|
+ , orderVoPage.getRecords());
|
|
|
+ // 2.支出 查看提现记录表
|
|
|
+ }else if("2".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())){
|
|
|
+ //金额类型 3
|
|
|
+ if(!"3".equals(myIncomeAndExpensesQueryDto.getTransactionType())){
|
|
|
+ throw new SystemException("支出类型不能选择(手续+跟单)或者手续费类型");
|
|
|
+ }
|
|
|
+ myIncomeAndExpensesQueryDto.setIncomeAndExpensesType("1");
|
|
|
+ orderVoPage = sysUserAccountHistoryService.findMyIncomeAndExpensesAmountByUserId(page,myIncomeAndExpensesQueryDto);
|
|
|
+ Long total=sysUserAccountHistoryService.findMyIncomeAndExpensesAmountByUserIdCount(myIncomeAndExpensesQueryDto);
|
|
|
+ orderVoPage.setTotal(total);
|
|
|
+ List<MyCollectInAdvanceDto> recordsNew =new ArrayList<>();
|
|
|
+ if(orderVoPage.getRecords()!=null && orderVoPage.getRecords().size()>0){
|
|
|
+ for(MyCollectInAdvanceDto dto :orderVoPage.getRecords()){
|
|
|
+ dto.setIncomeAndExpensesType("2");
|
|
|
+ recordsNew.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderVoPage.setRecords(recordsNew);
|
|
|
+ myCollectInAdvanceDtoBasePageResult=new BasePageResult<>(myIncomeAndExpensesQueryDto.getPageNum(), myIncomeAndExpensesQueryDto.getPageSize(), orderVoPage.getTotal(),
|
|
|
+ orderVoPage.getPages()
|
|
|
+ , orderVoPage.getRecords());
|
|
|
+ sumAmountSR=sysUserAccountHistoryService.findSumAmountByUserId(myIncomeAndExpensesQueryDto.getUserId(),"1");
|
|
|
+ }
|
|
|
|
|
|
+ } else {
|
|
|
+ //其他板块预留逻辑处理
|
|
|
+ }
|
|
|
+ return new MyCollectInAdvanceAllDto(sumAmountSR,sumAmountZC,myCollectInAdvanceDtoBasePageResult);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/20 13:48
|
|
|
+ * @Description: 提现详情
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public WithdrawalDetalsDto findDetailById(String id) {
|
|
|
+ //id为历史表的id
|
|
|
+ //通过历史记录表查询数据
|
|
|
+ SysUserAccountHistory his = sysUserAccountHistoryService.getById(id);
|
|
|
+ LambdaQueryWrapper<SysAmountAuditingHistory> lqw = new LambdaQueryWrapper<>();
|
|
|
+ lqw.eq(SysAmountAuditingHistory::getHistoryId, id);
|
|
|
+ lqw.orderByAsc(SysAmountAuditingHistory::getCreateTime);
|
|
|
+ List<SysAmountAuditingHistory> listAll = sysAmountAuditingHistoryService.list(lqw);
|
|
|
+ SysAmountAuditingEntity audi = sysAmountAuditingService.getById(his.getAuditiingId());
|
|
|
+ WithdrawalDetalsDto withdrawalDetalsDto=new WithdrawalDetalsDto();
|
|
|
+ if(audi!=null){
|
|
|
+ withdrawalDetalsDto.setBankNumber(audi.getBankNumber());
|
|
|
+ withdrawalDetalsDto.setTransactionNumber(audi.getId());
|
|
|
+ withdrawalDetalsDto.setWithdrawalAmount(audi.getAmount());
|
|
|
+ withdrawalDetalsDto.setBankAccount(audi.getBankAccount());
|
|
|
+ }
|
|
|
+ List<WithdrawalDetalsRecordDto> recordList =new ArrayList<WithdrawalDetalsRecordDto>();
|
|
|
+ if(listAll!=null && listAll.size()>0){
|
|
|
+ SysAmountAuditingHistory first = listAll.get(0);
|
|
|
+ SysAmountAuditingHistory last = listAll.get(listAll.size() - 1);
|
|
|
+ //申请时间
|
|
|
+ Date createTime = first.getCreateTime();
|
|
|
+ withdrawalDetalsDto.setApplicationDate(createTime);
|
|
|
+ String auditingStatus = last.getAuditingStatus();
|
|
|
+ withdrawalDetalsDto.setWithdrawalStatus(auditingStatus);
|
|
|
+ String auditingStatusName="";
|
|
|
+ if("1".equals(auditingStatus)){
|
|
|
+ auditingStatusName="提现申请";
|
|
|
+ }else if("2".equals(auditingStatus)){
|
|
|
+ auditingStatusName="处理中";
|
|
|
+ }else if("3".equals(auditingStatus)){
|
|
|
+ auditingStatusName="提现失败";
|
|
|
+ }else if("4".equals(auditingStatus)){
|
|
|
+ auditingStatusName="提现成功";
|
|
|
+ withdrawalDetalsDto.setPaymentDate(last.getCreateTime());
|
|
|
+ }
|
|
|
+ withdrawalDetalsDto.setWithdrawalStatusName(auditingStatusName);
|
|
|
+ WithdrawalDetalsRecordDto dto1 = new WithdrawalDetalsRecordDto("1", false, "提现申请", null);
|
|
|
+ WithdrawalDetalsRecordDto dto2 = new WithdrawalDetalsRecordDto("2", false, "处理中", null);
|
|
|
+ WithdrawalDetalsRecordDto dto3 = null;
|
|
|
+ WithdrawalDetalsRecordDto dto4 = new WithdrawalDetalsRecordDto("4", false, "提现成功", null);
|
|
|
+ for(SysAmountAuditingHistory sysAmountAuditingHistory:listAll){
|
|
|
+ if("1".equals(sysAmountAuditingHistory.getAuditingStatus())){
|
|
|
+ dto1.setProcessingStatusFlag(true);
|
|
|
+ dto1.setProcessingDate(sysAmountAuditingHistory.getCreateTime());
|
|
|
+ }else if("2".equals(sysAmountAuditingHistory.getAuditingStatus())){
|
|
|
+ dto2.setProcessingStatusFlag(true);
|
|
|
+ dto2.setProcessingDate(sysAmountAuditingHistory.getCreateTime());
|
|
|
+ }else if("3".equals(sysAmountAuditingHistory.getAuditingStatus())){
|
|
|
+ dto3 =new WithdrawalDetalsRecordDto("3", true, "提现失败", sysAmountAuditingHistory.getCreateTime());
|
|
|
+ }else if("4".equals(sysAmountAuditingHistory.getAuditingStatus())){
|
|
|
+ dto4.setProcessingStatusFlag(true);
|
|
|
+ dto4.setProcessingDate(sysAmountAuditingHistory.getCreateTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ recordList.add(dto1);
|
|
|
+ recordList.add(dto2);
|
|
|
+ if(dto3!=null){
|
|
|
+ recordList.add(dto3);
|
|
|
+ withdrawalDetalsDto.setRejectReason(audi.getRejectReason()==null?"":audi.getRejectReason());
|
|
|
+ }else{
|
|
|
+ recordList.add(dto4);
|
|
|
+ }
|
|
|
+ withdrawalDetalsDto.setRecord(recordList);
|
|
|
+ }
|
|
|
+ return withdrawalDetalsDto;
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public OrderDetalsDto findOrderDetailById(String subOrderId) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|