“mitao”
2025-12-23 9ff0db3f0cca9eab06d04a9773d725a1acc831d8
Merge remote-tracking branch 'origin/master'

# Conflicts:
# ruoyi-system/src/main/java/com/ruoyi/system/model/TIntegralSettlement.java
4个文件已添加
16个文件已修改
519 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/UserIndexController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TAppUserMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBigGiftPackageOrderMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TAppUser.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TCommissionTransactionFlow.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TIntegralSettlement.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/UserProfitPageListQuery.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/UserPromotionPageListQuery.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TAppUserService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TBigGiftPackageOrderService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TAppUserServiceImpl.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBigGiftPackageOrderServiceImpl.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCommissionTransactionFlowServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/ProfitPageListVo.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/PromotionPageListVo.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/UserProfitPageListVo.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/UserPromotionPageListVo.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TAppUserMapper.xml 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TBigGiftPackageOrderMapper.xml 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java
@@ -12,6 +12,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.BasePage;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.exception.ServiceException;
@@ -28,7 +29,7 @@
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.*;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.IntegralChangeRecordVo;
import com.ruoyi.system.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
@@ -44,6 +45,7 @@
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
@@ -94,6 +96,9 @@
    @Autowired
    private TBigGiftPackageOrderService bigGiftPackageOrderService;
    @Autowired
    private TIntegralSettlementService integralSettlementService;
    @ApiOperation(value = "用户管理分页列表")
@@ -567,5 +572,134 @@
        return R.ok(tBigGiftPackageOrderPage);
    }
    @ApiOperation(value = "用户- 推广记录")
    @PostMapping("/promotionPageList")
    public R<Page<UserPromotionPageListVo>> promotionPageList(@RequestBody @Valid UserPromotionPageListQuery query) {
        Page<UserPromotionPageListVo> page = new Page<>(query.getPageNum(), query.getPageSize());
        List<UserPromotionPageListVo> list = appUserService.userPromotionPageList(page,query);
        page.setRecords(list);
        return R.ok(page);
    }
    @ApiOperation(value = "用户-推广记录导出")
    @PostMapping(value = "/exportUserPromotion")
    @Log(title = "推广记录-导出", businessType = BusinessType.EXPORT)
    public void exportUserPromotion(@RequestBody @Valid UserPromotionPageListQuery query){
        List<UserPromotionPageListVo> list = appUserService.userPromotionPageListExport(query);
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), UserPromotionPageListVo.class, list);
        HttpServletResponse response = WebUtils.response();
        assert response != null;
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("推广记录导出信息.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    @ApiOperation(value = "用户收益明细")
    @PostMapping("/profitUserPageList")
    public R<Page<UserProfitPageListVo>> profitUserPageList(@RequestBody @Valid UserProfitPageListQuery query) {
        Page<UserProfitPageListVo> page = new Page<>(query.getPageNum(), query.getPageSize());
        List<UserProfitPageListVo> list = bigGiftPackageOrderService.profitUserPageList(page,query);
        page.setRecords(list);
        return R.ok(page);
    }
    @ApiOperation(value = "用户收益明细导出")
    @PostMapping(value = "/exportUserProfit")
    @Log(title = "收益明细-导出", businessType = BusinessType.EXPORT)
    public void exportUserProfit(@RequestBody @Valid UserProfitPageListQuery query){
        List<UserProfitPageListVo> list = bigGiftPackageOrderService.profitUserPageListExport(query);
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), UserProfitPageListVo.class, list);
        HttpServletResponse response = WebUtils.response();
        assert response != null;
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("收益明细导出信息.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    @ApiOperation(value = "用户- 结算记录")
    @PostMapping("/settlementPageList")
    public R<Page<TIntegralSettlement>> settlementPageList(@RequestBody @Valid GoldChangeRecordQuery query) {
        Page<TIntegralSettlement> page = new Page<>(query.getPageNum(), query.getPageSize());
        LambdaQueryWrapper<TIntegralSettlement> queryWrapper = new LambdaQueryWrapper<TIntegralSettlement>().eq(TIntegralSettlement::getAppUserId, query.getUserId()).orderByDesc(TIntegralSettlement::getCreateTime);
        Page<TIntegralSettlement> integralSettlementPage = integralSettlementService.page(page, queryWrapper);
        return R.ok(integralSettlementPage);
    }
    @ApiOperation(value = "用户结算记录导出")
    @PostMapping(value = "/exportSettlementPageList")
    @Log(title = "结算记录-导出", businessType = BusinessType.EXPORT)
    public void exportSettlementPageList(@RequestBody @Valid GoldChangeRecordQuery query){
        List<TIntegralSettlement> list = integralSettlementService.list(new LambdaQueryWrapper<TIntegralSettlement>().eq(TIntegralSettlement::getAppUserId, query.getUserId()).orderByDesc(TIntegralSettlement::getCreateTime));
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TIntegralSettlement.class, list);
        HttpServletResponse response = WebUtils.response();
        assert response != null;
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("结算记录导出信息.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/UserIndexController.java
@@ -72,7 +72,7 @@
            Date now = new Date();
            List<TCommissionTransactionFlow> list = commissionTransactionFlowService.lambdaQuery().eq(TCommissionTransactionFlow::getAppUserId, userId)
                    .between(TCommissionTransactionFlow::getCreateTime, DateUtil.beginOfMonth(now), DateUtil.endOfMonth(now)).list();
            Integer total = list.stream().mapToInt(TCommissionTransactionFlow::getCommissionAmount).sum();
            BigDecimal total = list.stream().map(TCommissionTransactionFlow::getCommissionAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
            appUser.setEstimatedMonthlyIntegral(total);
        }
        return R.ok(appUser);
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TAppUserMapper.java
@@ -6,7 +6,9 @@
import com.ruoyi.system.model.TAppUser;
import com.ruoyi.system.query.AppUserListQuery;
import com.ruoyi.system.query.PromotionPageListQuery;
import com.ruoyi.system.query.UserPromotionPageListQuery;
import com.ruoyi.system.vo.PromotionPageListVo;
import com.ruoyi.system.vo.UserPromotionPageListVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -33,4 +35,9 @@
    List<TAppUser> transferPageUserList(@Param("query") AppUserListQuery query, @Param("pageInfo") PageInfo<TAppUser> pageInfo);
    List<UserPromotionPageListVo> userPromotionPageList(@Param("page") Page<UserPromotionPageListVo> page, @Param("query") UserPromotionPageListQuery query);
    List<UserPromotionPageListVo> userPromotionPageListExport(@Param("query") UserPromotionPageListQuery query);
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBigGiftPackageOrderMapper.java
@@ -6,7 +6,9 @@
import com.ruoyi.system.query.BigGiftPackageOrderQuery;
import com.ruoyi.system.query.GoldChangeRecordQuery;
import com.ruoyi.system.query.ProfitPageListQuery;
import com.ruoyi.system.query.UserProfitPageListQuery;
import com.ruoyi.system.vo.ProfitPageListVo;
import com.ruoyi.system.vo.UserProfitPageListVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -32,4 +34,8 @@
    List<TBigGiftPackageOrder> pageOrderList(@Param("tBigGiftPackageOrderPage") Page<TBigGiftPackageOrder> tBigGiftPackageOrderPage, @Param("query") GoldChangeRecordQuery query);
    List<UserProfitPageListVo> profitUserPageList(@Param("page") Page<UserProfitPageListVo> page, @Param("query") UserProfitPageListQuery query, @Param("sTime") String sTime, @Param("eTime") String eTime);
    List<UserProfitPageListVo> profitUserPageListExport(@Param("query") UserProfitPageListQuery query, @Param("sTime") String sTime, @Param("eTime") String eTime);
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TAppUser.java
@@ -129,6 +129,6 @@
    @ApiModelProperty(value = "当月预估积分")
    @TableField(exist = false)
    private Integer estimatedMonthlyIntegral;
    private BigDecimal estimatedMonthlyIntegral;
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TCommissionTransactionFlow.java
@@ -58,7 +58,7 @@
    @ApiModelProperty(value = "佣金收入金额")
    @TableField("commission_amount")
    private Integer commissionAmount;
    private BigDecimal commissionAmount;
    @ApiModelProperty(value = "添加时间")
    @TableField("create_time")
ruoyi-system/src/main/java/com/ruoyi/system/model/TIntegralSettlement.java
@@ -1,6 +1,8 @@
package com.ruoyi.system.model;
import java.math.BigDecimal;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDate;
@@ -8,6 +10,8 @@
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -39,19 +43,25 @@
    @ApiModelProperty(value = "结算周期")
    @TableField("settlement_interval")
    @Excel(name = "结算周期")
    private String settlementInterval;
    @ApiModelProperty(value = "结算开始时间")
    @TableField("settlement_start_time")
    @Excel(name = "结算开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate settlementStartTime;
    @ApiModelProperty(value = "结算结束时间")
    @TableField("settlement_end_time")
    @Excel(name = "结算结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate settlementEndTime;
    @ApiModelProperty(value = "合计结算积分")
    @TableField("total_settlement_integral")
    private BigDecimal totalSettlementIntegral;
    @Excel(name = "结算积分")
    private Integer totalSettlementIntegral;
    @ApiModelProperty(value = "添加时间")
    @TableField("create_time")
@@ -71,9 +81,8 @@
    @ApiModelProperty("备注")
    @TableField("remark")
    @Excel(name = "备注")
    private String remark;
ruoyi-system/src/main/java/com/ruoyi/system/query/UserProfitPageListQuery.java
New file
@@ -0,0 +1,28 @@
package com.ruoyi.system.query;
import com.ruoyi.common.core.domain.BasePage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@ApiModel("用户收益明细分页查询参数")
public class UserProfitPageListQuery extends BasePage {
    @ApiModelProperty("用户姓名")
    private String userName;
    @ApiModelProperty("用户手机号")
    private String phone;
    @ApiModelProperty("订单编号")
    private String code;
    @ApiModelProperty("下单时间 2022-02-02 - 2022-03-03")
    private String createTime;
    @ApiModelProperty("用户id")
    @NotNull(message = "用户id不能为空")
    private Integer userId;
}
ruoyi-system/src/main/java/com/ruoyi/system/query/UserPromotionPageListQuery.java
New file
@@ -0,0 +1,26 @@
package com.ruoyi.system.query;
import com.ruoyi.common.core.domain.BasePage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@ApiModel(value = "用户推广记录列表查询参数")
public class UserPromotionPageListQuery extends BasePage {
    @ApiModelProperty(value = "用户名")
    private String userName;
    @ApiModelProperty(value = "联系电话")
    private String phone;
    @ApiModelProperty(value = "用户id")
    @NotNull(message = "用户id不能为空")
    private Integer userId;
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TAppUserService.java
@@ -8,8 +8,10 @@
import com.ruoyi.system.query.AppUserListQuery;
import com.ruoyi.system.query.ProfitPageListQuery;
import com.ruoyi.system.query.PromotionPageListQuery;
import com.ruoyi.system.query.UserPromotionPageListQuery;
import com.ruoyi.system.vo.ProfitPageListVo;
import com.ruoyi.system.vo.PromotionPageListVo;
import com.ruoyi.system.vo.UserPromotionPageListVo;
import javax.validation.Valid;
import java.util.List;
@@ -47,4 +49,8 @@
    PageInfo<TAppUser> transferPageUserList(AppUserListQuery query);
    List<UserPromotionPageListVo> userPromotionPageList(Page<UserPromotionPageListVo> page, @Valid UserPromotionPageListQuery query);
    List<UserPromotionPageListVo> userPromotionPageListExport(@Valid UserPromotionPageListQuery query);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TBigGiftPackageOrderService.java
@@ -7,8 +7,10 @@
import com.ruoyi.system.query.BigGiftPackageOrderQuery;
import com.ruoyi.system.query.GoldChangeRecordQuery;
import com.ruoyi.system.query.ProfitPageListQuery;
import com.ruoyi.system.query.UserProfitPageListQuery;
import com.ruoyi.system.vo.ProfitPageListVo;
import com.ruoyi.system.vo.PlaceOrderVO;
import com.ruoyi.system.vo.UserProfitPageListVo;
import javax.validation.Valid;
import java.util.List;
@@ -55,4 +57,8 @@
    List<TBigGiftPackageOrder> pageOrderList(Page<TBigGiftPackageOrder> tBigGiftPackageOrderPage, GoldChangeRecordQuery query);
    List<UserProfitPageListVo> profitUserPageList(Page<UserProfitPageListVo> page, @Valid UserProfitPageListQuery query);
    List<UserProfitPageListVo> profitUserPageListExport(@Valid UserProfitPageListQuery query);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TAppUserServiceImpl.java
@@ -10,8 +10,10 @@
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.AppUserListQuery;
import com.ruoyi.system.query.PromotionPageListQuery;
import com.ruoyi.system.query.UserPromotionPageListQuery;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.PromotionPageListVo;
import com.ruoyi.system.vo.UserPromotionPageListVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -108,7 +110,68 @@
                BigDecimal totalOne = giftPackageOrders.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).map(TBigGiftPackageOrder::getPaymentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
                promotionPageListVo.setTotalConsume(totalOne);
                Integer totalIncome = flows.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).mapToInt(TCommissionTransactionFlow::getCommissionAmount).sum();
                BigDecimal totalIncome = flows.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).map(TCommissionTransactionFlow::getCommissionAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
                promotionPageListVo.setTotalIncome(totalIncome);
                Integer totalSettledIncome = settlements.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).mapToInt(TIntegralSettlement::getTotalSettlementIntegral).sum();
                promotionPageListVo.setTotalSettledIncome(totalSettledIncome);
            }
        }
        return list;
    }
    @Override
    public List<UserPromotionPageListVo> userPromotionPageList(Page<UserPromotionPageListVo> page, UserPromotionPageListQuery query) {
        List<UserPromotionPageListVo> list = this.baseMapper.userPromotionPageList(page,query);
        if (!list.isEmpty()) {
            List<Integer> userIds = list.stream().map(UserPromotionPageListVo::getUserId).collect(Collectors.toList());
//            List<TPhysicalGoodsOrder> physicalGoodsOrders = tPhysicalGoodsOrderService.list(new LambdaQueryWrapper<TPhysicalGoodsOrder>().in(TPhysicalGoodsOrder::getAppUserId, userIds).notIn(TPhysicalGoodsOrder::getStatus,Arrays.asList(1,4)));
            List<TBigGiftPackageOrder> giftPackageOrders = tBigGiftPackageOrderService.list(new LambdaQueryWrapper<TBigGiftPackageOrder>().in(TBigGiftPackageOrder::getAppUserId, userIds).notIn(TBigGiftPackageOrder::getStatus,Arrays.asList(1,5)));
            List<TCommissionTransactionFlow> flows = tCommissionTransactionFlowService.list(new LambdaQueryWrapper<TCommissionTransactionFlow>().in(TCommissionTransactionFlow::getAppUserId, userIds));
            List<TIntegralSettlement> settlements = tIntegralSettlementService.list(new LambdaQueryWrapper<TIntegralSettlement>().in(TIntegralSettlement::getAppUserId, userIds));
            for (UserPromotionPageListVo promotionPageListVo : list) {
//                BigDecimal total = physicalGoodsOrders.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).map(TPhysicalGoodsOrder::getPaymentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
                BigDecimal totalOne = giftPackageOrders.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).map(TBigGiftPackageOrder::getPaymentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
                promotionPageListVo.setTotalConsume(totalOne);
                BigDecimal totalIncome = flows.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).map(TCommissionTransactionFlow::getCommissionAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
                promotionPageListVo.setTotalIncome(totalIncome);
                Integer totalSettledIncome = settlements.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).mapToInt(TIntegralSettlement::getTotalSettlementIntegral).sum();
                promotionPageListVo.setTotalSettledIncome(totalSettledIncome);
            }
        }
        return list;
    }
    @Override
    public List<UserPromotionPageListVo> userPromotionPageListExport(UserPromotionPageListQuery query) {
        List<UserPromotionPageListVo> list = this.baseMapper.userPromotionPageListExport(query);
        if (!list.isEmpty()) {
            List<Integer> userIds = list.stream().map(UserPromotionPageListVo::getUserId).collect(Collectors.toList());
//            List<TPhysicalGoodsOrder> physicalGoodsOrders = tPhysicalGoodsOrderService.list(new LambdaQueryWrapper<TPhysicalGoodsOrder>().in(TPhysicalGoodsOrder::getAppUserId, userIds).notIn(TPhysicalGoodsOrder::getStatus,Arrays.asList(1,4)));
            List<TBigGiftPackageOrder> giftPackageOrders = tBigGiftPackageOrderService.list(new LambdaQueryWrapper<TBigGiftPackageOrder>().in(TBigGiftPackageOrder::getAppUserId, userIds).notIn(TBigGiftPackageOrder::getStatus,Arrays.asList(1,5)));
            List<TCommissionTransactionFlow> flows = tCommissionTransactionFlowService.list(new LambdaQueryWrapper<TCommissionTransactionFlow>().in(TCommissionTransactionFlow::getAppUserId, userIds));
            List<TIntegralSettlement> settlements = tIntegralSettlementService.list(new LambdaQueryWrapper<TIntegralSettlement>().in(TIntegralSettlement::getAppUserId, userIds));
            for (UserPromotionPageListVo promotionPageListVo : list) {
//                BigDecimal total = physicalGoodsOrders.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).map(TPhysicalGoodsOrder::getPaymentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
                BigDecimal totalOne = giftPackageOrders.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).map(TBigGiftPackageOrder::getPaymentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
                promotionPageListVo.setTotalConsume(totalOne);
                BigDecimal totalIncome = flows.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).map(TCommissionTransactionFlow::getCommissionAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
                promotionPageListVo.setTotalIncome(totalIncome);
                Integer totalSettledIncome = settlements.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).mapToInt(TIntegralSettlement::getTotalSettlementIntegral).sum();
@@ -139,7 +202,7 @@
                BigDecimal totalOne = giftPackageOrders.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).map(TBigGiftPackageOrder::getPaymentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
                promotionPageListVo.setTotalConsume(totalOne);
                Integer totalIncome = flows.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).mapToInt(TCommissionTransactionFlow::getCommissionAmount).sum();
                BigDecimal totalIncome = flows.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).map(TCommissionTransactionFlow::getCommissionAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
                promotionPageListVo.setTotalIncome(totalIncome);
                Integer totalSettledIncome = settlements.stream().filter(e -> e.getAppUserId().equals(promotionPageListVo.getUserId())).mapToInt(TIntegralSettlement::getTotalSettlementIntegral).sum();
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBigGiftPackageOrderServiceImpl.java
@@ -21,6 +21,7 @@
import com.ruoyi.system.query.BigGiftPackageOrderQuery;
import com.ruoyi.system.query.GoldChangeRecordQuery;
import com.ruoyi.system.query.ProfitPageListQuery;
import com.ruoyi.system.query.UserProfitPageListQuery;
import com.ruoyi.system.service.TBigGiftPackageOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.service.TCommissionTransactionFlowService;
@@ -28,6 +29,7 @@
import com.ruoyi.system.utils.ICBCPayUtil;
import com.ruoyi.system.utils.OrderCodeGenerator;
import com.ruoyi.system.vo.PlaceOrderVO;
import com.ruoyi.system.vo.UserProfitPageListVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -221,6 +223,56 @@
    }
    @Override
    public List<UserProfitPageListVo> profitUserPageList(Page<UserProfitPageListVo> page, UserProfitPageListQuery query) {
        String sTime = null;
        String eTime = null;
        if(query.getCreateTime()!=null && !query.getCreateTime().isEmpty()){
            String[] split = query.getCreateTime().split(" - ");
            sTime = split[0] + " 00:00:00";
            eTime = split[1] + " 23:59:59";
        }
        List<UserProfitPageListVo> profitPageListVos = this.baseMapper.profitUserPageList(page,query, sTime, eTime);
        if(!profitPageListVos.isEmpty()){
            List<Integer> orderIds = profitPageListVos.stream().map(UserProfitPageListVo::getId).collect(Collectors.toList());
            List<TCommissionTransactionFlow> tCommissionTransactionFlows = commissionTransactionFlowMapper.selectList(new LambdaQueryWrapper<TCommissionTransactionFlow>().in(TCommissionTransactionFlow::getOrderId, orderIds));
            for (UserProfitPageListVo profitPageListVo : profitPageListVos) {
                List<TCommissionTransactionFlow> flows = tCommissionTransactionFlows.stream().filter(e -> e.getOrderId().equals(profitPageListVo.getId()) && e.getAppUserId().equals(query.getUserId())).collect(Collectors.toList());
                profitPageListVo.setSelfProfit(flows.stream().map(TCommissionTransactionFlow::getCommissionAmount).reduce(BigDecimal.ZERO,BigDecimal::add));
            }
        }
        return profitPageListVos;
    }
    @Override
    public List<UserProfitPageListVo> profitUserPageListExport(UserProfitPageListQuery query) {
        String sTime = null;
        String eTime = null;
        if(query.getCreateTime()!=null && !query.getCreateTime().isEmpty()){
            String[] split = query.getCreateTime().split(" - ");
            sTime = split[0] + " 00:00:00";
            eTime = split[1] + " 23:59:59";
        }
        List<UserProfitPageListVo> profitPageListVos = this.baseMapper.profitUserPageListExport(query, sTime, eTime);
        if(!profitPageListVos.isEmpty()){
            List<Integer> orderIds = profitPageListVos.stream().map(UserProfitPageListVo::getId).collect(Collectors.toList());
            List<TCommissionTransactionFlow> tCommissionTransactionFlows = commissionTransactionFlowMapper.selectList(new LambdaQueryWrapper<TCommissionTransactionFlow>().in(TCommissionTransactionFlow::getOrderId, orderIds));
            for (UserProfitPageListVo profitPageListVo : profitPageListVos) {
                List<TCommissionTransactionFlow> flows = tCommissionTransactionFlows.stream().filter(e -> e.getOrderId().equals(profitPageListVo.getId()) && e.getAppUserId().equals(query.getUserId())).collect(Collectors.toList());
                profitPageListVo.setSelfProfit(flows.stream().map(TCommissionTransactionFlow::getCommissionAmount).reduce(BigDecimal.ZERO,BigDecimal::add));
            }
        }
        return profitPageListVos;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public PlaceOrderVO placeOrder(BigGiftPlaceOrderDTO dto, Integer appUserId, String openid) {
        // 1. 校验商品是否存在
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCommissionTransactionFlowServiceImpl.java
@@ -197,7 +197,7 @@
        flow.setOrderId(orderId);
        flow.setOrderType(orderType);
        flow.setOrderPrice(orderPrice);
        flow.setCommissionAmount(commissionAmount.intValue());
        flow.setCommissionAmount(commissionAmount);
        flow.setCreateTime(LocalDateTime.now());
        save(flow);
ruoyi-system/src/main/java/com/ruoyi/system/vo/ProfitPageListVo.java
@@ -37,9 +37,9 @@
    @ApiModelProperty("推广员收益")
    @Excel(name = "推广员收益", orderNum = "6", width = 20)
    private Integer saleProfit=0;
    private BigDecimal saleProfit=BigDecimal.ZERO;
    @ApiModelProperty("合伙人收益")
    @Excel(name = "合伙人收益", orderNum = "7", width = 20)
    private Integer partnerProfit=0;
    private BigDecimal partnerProfit=BigDecimal.ZERO;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/PromotionPageListVo.java
@@ -62,7 +62,7 @@
    @ApiModelProperty(value = "合计收益")
    @Excel(name = "合计收益", width = 20)
    private Integer totalIncome;
    private BigDecimal totalIncome;
    @ApiModelProperty(value = "已结算收益")
    @Excel(name = "已结算收益", width = 20)
ruoyi-system/src/main/java/com/ruoyi/system/vo/UserProfitPageListVo.java
New file
@@ -0,0 +1,42 @@
package com.ruoyi.system.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@ApiModel("收益明细Vo")
public class UserProfitPageListVo {
    @ApiModelProperty("订单id")
    private Integer id;
    @ApiModelProperty("订单编号")
    @Excel(name = "订单编号", orderNum = "1", width = 20)
    private String code;
    @ApiModelProperty("下单时间")
    @Excel(name = "下单时间", orderNum = "2", width = 20,format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @ApiModelProperty("下单用户")
    @Excel(name = "下单用户", orderNum = "3", width = 20)
    private String userName;
    @ApiModelProperty("用户手机号")
    @Excel(name = "用户手机号", orderNum = "4", width = 20)
    private String phone;
    @ApiModelProperty("订单价格")
    @Excel(name = "订单价格", orderNum = "5", width = 20)
    private BigDecimal orderPrice;
    @ApiModelProperty("本人收益金额")
    @Excel(name = "本人收益金额", orderNum = "6", width = 20)
    private BigDecimal selfProfit=BigDecimal.ZERO;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/UserPromotionPageListVo.java
New file
@@ -0,0 +1,53 @@
package com.ruoyi.system.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
@ApiModel(value = "用户推广记录列表Vo")
public class UserPromotionPageListVo {
    @ApiModelProperty(value = "头像")
    @Excel(name = "头像", width = 20, imageType = 1, type = 2)
    private String avatar;
    @ApiModelProperty(value = "用户名")
    @Excel(name = "用户名", width = 20)
    private String userName;
    @ApiModelProperty(value = "用户ID")
    private Integer userId;
    @ApiModelProperty(value = "联系电话")
    @Excel(name = "联系电话", width = 20)
    private String phone;
    @ApiModelProperty(value = "性别 1=男,2=女")
    @Excel(name = "性别",width = 20,replace ={ "男_1","女_2"})
    private Integer gender;
    @ApiModelProperty(value = "当前角色 1=游客,2=营销员,3=合伙人")
    @Excel(name = "当前角色", width = 20, replace = {"游客_1", "营销员_2", "合伙人_3"})
    private Integer roleName;
    @ApiModelProperty(value = "状态 1=正常,2=冻结")
    @Excel(name = "状态", width = 20, replace = {"使用中_1", "冻结_2"})
    private Integer status;
    @ApiModelProperty(value = "合计消费")
    @Excel(name = "合计消费", width = 20)
    private BigDecimal totalConsume;
    @ApiModelProperty(value = "合计收益")
    @Excel(name = "合计收益", width = 20)
    private BigDecimal totalIncome;
    @ApiModelProperty(value = "已结算收益")
    @Excel(name = "已结算收益", width = 20)
    private Integer totalSettledIncome;
}
ruoyi-system/src/main/resources/mapper/system/TAppUserMapper.xml
@@ -116,4 +116,29 @@
        order by t1.create_time desc
    </select>
    <select id="userPromotionPageList" resultType="com.ruoyi.system.vo.UserPromotionPageListVo">
        select t1.id userId,t1.name userName,t1.phone phone,t1.gender,t1.profile_photo avatar,t1.user_type roleName,t1.status status
        from t_app_user t1
        where t1.referrer_user_id = #{query.userId} and t1.status !=3 and  t1.referrer_status =2
        <if test="query.userName != null and query.userName != ''">
            and t1.name like concat('%',#{query.userName},'%')
        </if>
        <if test="query.phone != null and query.phone != ''">
            and t1.phone like concat('%',#{query.phone},'%')
        </if>
        order by t1.create_time desc
    </select>
    <select id="userPromotionPageListExport" resultType="com.ruoyi.system.vo.UserPromotionPageListVo">
        select t1.id userId,t1.name userName,t1.phone phone,t1.gender,t1.profile_photo avatar,t1.user_type roleName,t1.status status
        from t_app_user t1
        where t1.referrer_user_id = #{query.userId} and t1.status !=3 and  t1.referrer_status =2
        <if test="query.userName != null and query.userName != ''">
            and t1.name like concat('%',#{query.userName},'%')
        </if>
        <if test="query.phone != null and query.phone != ''">
            and t1.phone like concat('%',#{query.phone},'%')
        </if>
        order by t1.create_time desc
    </select>
</mapper>
ruoyi-system/src/main/resources/mapper/system/TBigGiftPackageOrderMapper.xml
@@ -128,5 +128,41 @@
        WHERE t1.del_flag = 0 and t2.id = #{query.userId}
        order by t1.create_time desc
    </select>
    <select id="profitUserPageList" resultType="com.ruoyi.system.vo.UserProfitPageListVo">
        select t1.id,t1.code,t1.create_time,t2.name userName,t2.phone,t1.order_price
        from t_big_gift_package_order t1 left join t_app_user t2 on t1.app_user_id = t2.id
        where t1.del_flag = 0 and t2.referrer_user_id  = #{query.userId} and t2.referrer_status =2
        <if test="query.phone != null and query.phone != ''">
            AND t2.phone = #{query.phone}
        </if>
        <if test="query.code != null and query.code != ''">
            AND t1.code = #{query.code}
        </if>
        <if test="query.userName != null and query.userName != ''">
            AND t2.name like concat('%',#{query.userName},'%')
        </if>
        <if test="sTime !=null ">
            AND t1.create_time BETWEEN #{sTime} AND #{eTime}
        </if>
        order by t1.create_time desc
    </select>
    <select id="profitUserPageListExport" resultType="com.ruoyi.system.vo.UserProfitPageListVo">
        select t1.id,t1.code,t1.create_time,t2.name userName,t2.phone,t1.order_price
        from t_big_gift_package_order t1 left join t_app_user t2 on t1.app_user_id = t2.id
        where t1.del_flag = 0 and t2.referrer_user_id  = #{query.userId} and t2.referrer_status =2
        <if test="query.phone != null and query.phone != ''">
            AND t2.phone = #{query.phone}
        </if>
        <if test="query.code != null and query.code != ''">
            AND t1.code = #{query.code}
        </if>
        <if test="query.userName != null and query.userName != ''">
            AND t2.name like concat('%',#{query.userName},'%')
        </if>
        <if test="sTime !=null ">
            AND t1.create_time BETWEEN #{sTime} AND #{eTime}
        </if>
        order by t1.create_time desc
    </select>
</mapper>