|
|
@@ -8,12 +8,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.jzg.commons.core.base.BaseController;
|
|
|
+import com.jzg.commons.entity.account.po.SysUserAccountChangeLog;
|
|
|
import com.jzg.commons.entity.dto.*;
|
|
|
import com.jzg.commons.entity.po.*;
|
|
|
import com.jzg.commons.entity.vo.*;
|
|
|
import com.jzg.commons.util.BigDecimalUtil;
|
|
|
import com.jzg.organization.client.QuoteClient;
|
|
|
import com.jzg.organization.mapper.SysAmountAuditingMapper;
|
|
|
+import com.jzg.organization.mapper.SysUserAccountIncomeLogMapper;
|
|
|
import com.jzg.organization.mapper.SysUserAccountMapper;
|
|
|
import com.jzg.organization.service.*;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -56,6 +58,9 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
@Autowired
|
|
|
private SysAmountAuditingService sysAmountAuditingService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysUserAccountIncomeLogMapper sysUserAccountIncomeLogMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private SysDeptService sysDeptService;
|
|
|
@Autowired
|
|
|
@@ -123,6 +128,7 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
if (systemCode == null) {
|
|
|
systemCode = baseController.getAppSystemCode();
|
|
|
}
|
|
|
+ log.info("获取用户钱包信息:mobile=[{}],systemCode=[{}]", mobile, systemCode);
|
|
|
String userId = baseController.getUserId();
|
|
|
log.info("查询用户的钱包信息:mobile=[{}], systemCode=[{}],userId=[{}]", mobile, systemCode, userId);
|
|
|
SysUser sysUser = sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getMobile, mobile));
|
|
|
@@ -195,57 +201,70 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
sysUserWalletVo.setTotalInviteCount(String.valueOf(sysUserJzgInfoList.size()));
|
|
|
// 获取累计收入
|
|
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ // LocalDate todayDay = now.minusDays(1);
|
|
|
+ LocalDate todayDay = now;
|
|
|
// 获取今天的开始时间和结束时间
|
|
|
- LocalDateTime todayStart = LocalDate.now().atStartOfDay();
|
|
|
- LocalDateTime todayEnd = LocalDate.now().atTime(23, 59, 59, 999);
|
|
|
- List<SysAmountAuditing> sysAmountAuditingListToday = sysAmountAuditingService
|
|
|
- .list(new LambdaQueryWrapper<SysAmountAuditing>()
|
|
|
- .eq(SysAmountAuditing::getUserId, sysUser.getId())
|
|
|
- .ge(SysAmountAuditing::getCreateTime, todayStart)
|
|
|
- .le(SysAmountAuditing::getCreateTime, todayEnd)
|
|
|
- .in(SysAmountAuditing::getAuditingStatus, 0, 1));
|
|
|
- sysUserWalletVo.setTodayExpense(sysAmountAuditingListToday.stream()
|
|
|
- .map(SysAmountAuditing::getAmount)
|
|
|
- .map(amount -> amount != null ? amount : BigDecimal.ZERO)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- // 今日订单收入
|
|
|
- // 初始化今日收入为0
|
|
|
- BigDecimal todayIncome = BigDecimal.ZERO;
|
|
|
- InsFeeOrdersParam feeOrdersParamTodayIncome = new InsFeeOrdersParam();
|
|
|
- feeOrdersParamTodayIncome.setCreateTimeStart(todayStart);
|
|
|
- feeOrdersParamTodayIncome.setCreateTimeEnd(todayEnd);
|
|
|
- feeOrdersParamTodayIncome.setUserId(sysUserJzgInfo.getUserId());
|
|
|
-
|
|
|
- List<InsFeeOrders> insFeeOrdersListTodayIncome = quoteClient.getInsFeeOrderByUserId(feeOrdersParamTodayIncome);
|
|
|
- BigDecimal orderIncome = insFeeOrdersListTodayIncome.stream()
|
|
|
- .map(InsFeeOrders::getTotalReceivablePremium)
|
|
|
- .map(amount -> amount != null ? amount : BigDecimal.ZERO)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- todayIncome = todayIncome.add(orderIncome);
|
|
|
- // 今日分销收入
|
|
|
- InsFeeOrdersParam feeOrdersParam1 = new InsFeeOrdersParam();
|
|
|
- feeOrdersParam1.setCreateTimeStart(todayStart);
|
|
|
- feeOrdersParam1.setCreateTimeEnd(todayEnd);
|
|
|
- feeOrdersParam1.setDistributorId(sysUserJzgInfo.getId());
|
|
|
- List<InsFeeOrders> distributionList = quoteClient.getInsFeeOrdersList(feeOrdersParam1);
|
|
|
-
|
|
|
- BigDecimal distributionIncome = distributionList.stream()
|
|
|
- .map(order -> {
|
|
|
- BigDecimal fee = BigDecimal.ZERO;
|
|
|
- if (sysUserJzgInfo.getId().equals(order.getFirstDistributorId())) {
|
|
|
- fee = fee.add(order.getFirstDistributionFee() != null ? order.getFirstDistributionFee() : BigDecimal.ZERO);
|
|
|
- }
|
|
|
- if (sysUserJzgInfo.getId().equals(order.getSecondDistributorId())) {
|
|
|
- fee = fee.add(order.getSecondDistributionFee() != null ? order.getSecondDistributionFee() : BigDecimal.ZERO);
|
|
|
- }
|
|
|
- if (sysUserJzgInfo.getId().equals(order.getThirdDistributorId())) {
|
|
|
- fee = fee.add(order.getThirdDistributionFee() != null ? order.getThirdDistributionFee() : BigDecimal.ZERO);
|
|
|
- }
|
|
|
- return fee;
|
|
|
- })
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- todayIncome = todayIncome.add(distributionIncome);
|
|
|
+ LocalDateTime todayStart = todayDay.atStartOfDay();
|
|
|
+ LocalDateTime todayEnd = todayDay.atTime(23, 59, 59, 999);
|
|
|
+ LambdaQueryWrapper<SysUserAccountChangeLog> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(SysUserAccountChangeLog::getUserId, sysUser.getId());
|
|
|
+ wrapper.ge(SysUserAccountChangeLog::getCreateTime, todayStart);
|
|
|
+ wrapper.le(SysUserAccountChangeLog::getCreateTime, todayEnd);
|
|
|
+
|
|
|
+ List<SysUserAccountChangeLog> changeLogs = sysUserAccountIncomeLogMapper.selectList(wrapper);
|
|
|
+ BigDecimal todayIncome = changeLogs.stream().map(SysUserAccountChangeLog::getAmount).filter(BigDecimalUtil::biggerZero).reduce(BigDecimal.ZERO, BigDecimalUtil::add);
|
|
|
+ BigDecimal todayExpense = changeLogs.stream().map(SysUserAccountChangeLog::getAmount).map(BigDecimalUtil::negate).filter(BigDecimalUtil::biggerZero).reduce(BigDecimal.ZERO, BigDecimalUtil::add);
|
|
|
sysUserWalletVo.setTodayIncome(todayIncome);
|
|
|
+ sysUserWalletVo.setTodayExpense(todayExpense);
|
|
|
+// List<SysAmountAuditing> sysAmountAuditingListToday = sysAmountAuditingService
|
|
|
+// .list(new LambdaQueryWrapper<SysAmountAuditing>()
|
|
|
+// .eq(SysAmountAuditing::getUserId, sysUser.getId())
|
|
|
+// .ge(SysAmountAuditing::getCreateTime, todayStart)
|
|
|
+// .le(SysAmountAuditing::getCreateTime, todayEnd)
|
|
|
+// .in(SysAmountAuditing::getAuditingStatus, 0, 1));
|
|
|
+// sysUserWalletVo.setTodayExpense(sysAmountAuditingListToday.stream()
|
|
|
+// .map(SysAmountAuditing::getAmount)
|
|
|
+// .map(amount -> amount != null ? amount : BigDecimal.ZERO)
|
|
|
+// .reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+// // 今日订单收入
|
|
|
+// // 初始化今日收入为0
|
|
|
+// BigDecimal todayIncome = BigDecimal.ZERO;
|
|
|
+// InsFeeOrdersParam feeOrdersParamTodayIncome = new InsFeeOrdersParam();
|
|
|
+// feeOrdersParamTodayIncome.setCreateTimeStart(todayStart);
|
|
|
+// feeOrdersParamTodayIncome.setCreateTimeEnd(todayEnd);
|
|
|
+// feeOrdersParamTodayIncome.setUserId(sysUserJzgInfo.getUserId());
|
|
|
+//
|
|
|
+// List<InsFeeOrders> insFeeOrdersListTodayIncome = quoteClient.getInsFeeOrderByUserId(feeOrdersParamTodayIncome);
|
|
|
+// BigDecimal orderIncome = insFeeOrdersListTodayIncome.stream()
|
|
|
+// .map(InsFeeOrders::getTotalReceivablePremium)
|
|
|
+// .map(amount -> amount != null ? amount : BigDecimal.ZERO)
|
|
|
+// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+// todayIncome = todayIncome.add(orderIncome);
|
|
|
+// // 今日分销收入
|
|
|
+// InsFeeOrdersParam feeOrdersParam1 = new InsFeeOrdersParam();
|
|
|
+// feeOrdersParam1.setCreateTimeStart(todayStart);
|
|
|
+// feeOrdersParam1.setCreateTimeEnd(todayEnd);
|
|
|
+// feeOrdersParam1.setDistributorId(sysUserJzgInfo.getId());
|
|
|
+// List<InsFeeOrders> distributionList = quoteClient.getInsFeeOrdersList(feeOrdersParam1);
|
|
|
+//
|
|
|
+// BigDecimal distributionIncome = distributionList.stream()
|
|
|
+// .map(order -> {
|
|
|
+// BigDecimal fee = BigDecimal.ZERO;
|
|
|
+// if (sysUserJzgInfo.getId().equals(order.getFirstDistributorId())) {
|
|
|
+// fee = fee.add(order.getFirstDistributionFee() != null ? order.getFirstDistributionFee() : BigDecimal.ZERO);
|
|
|
+// }
|
|
|
+// if (sysUserJzgInfo.getId().equals(order.getSecondDistributorId())) {
|
|
|
+// fee = fee.add(order.getSecondDistributionFee() != null ? order.getSecondDistributionFee() : BigDecimal.ZERO);
|
|
|
+// }
|
|
|
+// if (sysUserJzgInfo.getId().equals(order.getThirdDistributorId())) {
|
|
|
+// fee = fee.add(order.getThirdDistributionFee() != null ? order.getThirdDistributionFee() : BigDecimal.ZERO);
|
|
|
+// }
|
|
|
+// return fee;
|
|
|
+// })
|
|
|
+// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+// todayIncome = todayIncome.add(distributionIncome);
|
|
|
+// sysUserWalletVo.setTodayIncome(todayIncome);
|
|
|
return sysUserWalletVo;
|
|
|
}
|
|
|
|
|
|
@@ -279,8 +298,53 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
|
|
|
param.setCreateTimeStart(createTimeStart);
|
|
|
param.setCreateTimeEnd(createTimeEnd);
|
|
|
}
|
|
|
-
|
|
|
+ if (createTimeStart != null && !createTimeStart.isEmpty()) {
|
|
|
+ log.info("createTimeStart=[{}]", createTimeStart);
|
|
|
+ if(StrUtil.length(createTimeStart) < "2026-07-15 23:59:59".length()){
|
|
|
+ createTimeStart += " 00:00:00";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (createTimeEnd != null && !createTimeEnd.isEmpty()) {
|
|
|
+ log.info("createTimeEnd=[{}]",createTimeEnd);
|
|
|
+ if(StrUtil.length(createTimeEnd) < "2026-07-15 23:59:59".length()){
|
|
|
+ createTimeEnd += " 23:59:59";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ param.setCreateTimeStart(createTimeStart);
|
|
|
+ param.setCreateTimeEnd(createTimeEnd);
|
|
|
List<IncomeAndExpenseList> allRecords = sysAmountAuditingService.getIncomeAndExpense(param);
|
|
|
+ allRecords = allRecords.stream().peek(action->{
|
|
|
+ if("0".equals(action.getStatus())){
|
|
|
+ action.setRemark("提现审核中");
|
|
|
+ }
|
|
|
+ List<ChangeLogDetail> stepList = new ArrayList<>();
|
|
|
+ if("0".equals(action.getAuditingStatus())){
|
|
|
+ stepList.add(new ChangeLogDetail("提交提现申请",action.getCreateTime(),true, null));
|
|
|
+ stepList.add(new ChangeLogDetail("财务人员审核",null, null,null));
|
|
|
+ stepList.add(new ChangeLogDetail("财务人员打款", null, null, null));
|
|
|
+ }else if(StrUtil.isEmpty(action.getAuditingStatus())){
|
|
|
+ if("1".equals(action.getStatus())){
|
|
|
+ if("1".equals(action.getIncomeAndExpense())){
|
|
|
+ stepList.add(new ChangeLogDetail("提交提现申请",action.getCreateTime(),true, null));
|
|
|
+ stepList.add(new ChangeLogDetail("财务人员审核",action.getPaymentTime(), true,null));
|
|
|
+ stepList.add(new ChangeLogDetail("财务人员打款", action.getPaymentTime(), true, null));
|
|
|
+ }
|
|
|
+ if("0".equals(action.getIncomeAndExpense())){
|
|
|
+ // 保费收入
|
|
|
+ stepList.add(new ChangeLogDetail("费用审核通过",action.getCreateTime(),true, null));
|
|
|
+ stepList.add(new ChangeLogDetail());
|
|
|
+ stepList.add(new ChangeLogDetail());
|
|
|
+ }
|
|
|
+ }else if("2".equals(action.getStatus())){
|
|
|
+ stepList.add(new ChangeLogDetail("提交提现申请",action.getCreateTime(),true, null));
|
|
|
+ stepList.add(new ChangeLogDetail("财务人员审核",action.getPaymentTime(), true,null));
|
|
|
+ stepList.add(new ChangeLogDetail("财务审核不通过", action.getRejectTime(), false, null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ action.setStepList(stepList);
|
|
|
+
|
|
|
+ }).toList();
|
|
|
+ allRecords= new ArrayList<>(allRecords);
|
|
|
// 排序
|
|
|
allRecords.sort((a, b) -> {
|
|
|
if (a.getCreateTime() == null) return 1;
|