From 7619a9f22077642a1bcd77f9d18f012f123d7b54 Mon Sep 17 00:00:00 2001 From: tangqian Date: Wed, 31 May 2023 12:00:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A8=E5=B9=BF=E5=91=98=E6=8F=90?= =?UTF-8?q?=E6=88=90=E4=BF=A1=E6=81=AF=E6=9F=A5=E8=AF=A2=E5=92=8C=E5=AF=BC?= =?UTF-8?q?=E5=87=BA.=20=E5=95=86=E5=9F=8E=E6=8F=90=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recharge/RechargeOrderController.java | 13 +++ .../recharge/vo/PromoterDrawExcelVO.java | 43 +++++++ .../recharge/vo/PromoterDrawReqExcelVO.java | 34 ++++++ .../mysql/recharge/RechargeOrderMapper.java | 1 + .../recharge/RechargeOrderService.java | 2 + .../recharge/RechargeOrderServiceImpl.java | 53 ++++++--- .../mapper/recharge/RechargeOrderMapper.xml | 106 +++++++++++++++--- 7 files changed, 221 insertions(+), 31 deletions(-) create mode 100644 yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawExcelVO.java create mode 100644 yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawReqExcelVO.java diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java index 2bbeaba3f..e726f5ee2 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java @@ -122,6 +122,19 @@ public class RechargeOrderController { return success(pageResult); } + @GetMapping("/promoterDraw-excel") + @Operation(summary = "导出推广员抽佣统计") + @PreAuthorize("@ss.hasPermission('shop:recharge-order:export')") + @OperateLog(type = EXPORT) + @TenantIgnore + public void getRechargeOrderExcel(@Valid PromoterDrawReqExcelVO excelVO, HttpServletResponse response) throws IOException { + if(!TenantContextHolder.ID_SYSTEM.equals(SecurityFrameworkUtils.getLoginUser().getTenantId())){ + excelVO.setTenantId(SecurityFrameworkUtils.getLoginUser().getTenantId()); + } + List list = rechargeOrderService.findPromoterDrawExcel(excelVO); + ExcelUtils.write(response, "推广员抽佣统计.xls", "数据", PromoterDrawExcelVO.class, list); + } + @GetMapping("/export-excel") @Operation(summary = "导出订单 Excel") diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawExcelVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawExcelVO.java new file mode 100644 index 000000000..b14072a85 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawExcelVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + + +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +public class PromoterDrawExcelVO { + @ExcelProperty( "用户id") + private Long userId; + @ExcelProperty( "组织id") + private Long deptId; + @ExcelProperty( "商户id") + private Long tenantId; + @ExcelProperty( "组织名称") + private String deptName; + @ExcelProperty( "组织结构名称") + private String parentOrganizationName; + @ExcelProperty( "推广员名称") + private String nickname; + @ExcelProperty( "手机号") + private String mobile; + @ExcelProperty( "成为推广员时间") + private LocalDateTime createTime; + @ExcelProperty( "会员提成") + private Integer memberCommission; + @ExcelProperty( "商品提成") + private Integer goodsCommission; + + @ExcelProperty( "成交定单数") + private BigDecimal orderCount; + @ExcelProperty( "可提现金额") + private BigDecimal drawAmount; + @ExcelProperty( "成交金额") + private BigDecimal dealAmount; + @ExcelProperty( "累计金额") + private BigDecimal totalAmount; + +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawReqExcelVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawReqExcelVO.java new file mode 100644 index 000000000..209d7b21b --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawReqExcelVO.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Data +public class PromoterDrawReqExcelVO implements Serializable { + + + private static final long serialVersionUID = -3999440180896951708L; + private Long tenantId; + + @Schema(description = "商户名称") + private String deptName; + @Schema(description = "组织结构名称") + private String parentOrganizationName; + @Schema(description = "推广员名称") + private String nickname; + @Schema(description = "手机号") + private String mobile; + @Schema(description = "成为推广员时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + + +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/recharge/RechargeOrderMapper.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/recharge/RechargeOrderMapper.java index f6138ee4b..efd503b3e 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/recharge/RechargeOrderMapper.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/recharge/RechargeOrderMapper.java @@ -62,6 +62,7 @@ public interface RechargeOrderMapper extends BaseMapperX { IPage findListPage(IPage page, @Param("data") RechargeOrderPageReqVO data); IPage findPromoterDrawPage(IPage page, @Param("data") PromoterDrawReqVO data); + List findPromoterDrawExcel(@Param("data") PromoterDrawReqExcelVO data); List findPromoterDrawCount(@Param("promoterIds") List promoterIds); BigDecimal promoterOrderCount(@Param("startDate") LocalDateTime startDate, @Param("endDate")LocalDateTime endDate,@Param("promoterId") Long promoterId); diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java index e63bcc482..8adfbc846 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java @@ -89,4 +89,6 @@ public interface RechargeOrderService { Boolean memberChangeTie(MemberChangeTieRequest changeTieRequest); ShoppingMemberOrderVO shoppingOrderCount(Integer type, Long loginUserId); + + List findPromoterDrawExcel(PromoterDrawReqExcelVO excelVO); } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java index 5d4fd8ad2..2e1b71cae 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java @@ -132,31 +132,49 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { return new PageResult<>(page.getRecords(), page.getTotal()); } @Override + public List findPromoterDrawExcel(PromoterDrawReqExcelVO excelVO) { + return rechargeOrderMapper.findPromoterDrawExcel(excelVO); + } + @Override public PageResult findPromoterDrawPage(PromoterDrawReqVO pageReqVO) { Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); rechargeOrderMapper.findPromoterDrawPage(page, pageReqVO); List list = page.getRecords(); if (list != null && list.size() > 0) { - List collect1 = list.stream().map(PromoterDrawVO::getUserId).collect(Collectors.toList()); - List promoterDrawVOList = rechargeOrderMapper.findPromoterDrawCount(collect1); - Map nameList = promoterDrawVOList.stream().collect(toMap(PromoterDrawVO::getUserId, value -> value, (value1, value2) -> value1)); +// List collect1 = list.stream().map(PromoterDrawVO::getUserId).collect(Collectors.toList()); +// List promoterDrawVOList = rechargeOrderMapper.findPromoterDrawCount(collect1); +// Map nameList = promoterDrawVOList.stream().collect(toMap(PromoterDrawVO::getUserId, value -> value, (value1, value2) -> value1)); list.forEach(promoterDrawVO -> { - PromoterDrawVO promoterDrawNew = nameList.get(promoterDrawVO.getUserId()); - if (promoterDrawNew != null) { - promoterDrawVO.setDealAmount(promoterDrawNew.getDealAmount()); - promoterDrawVO.setTotalAmount(promoterDrawNew.getTotalAmount()); - promoterDrawVO.setOrderCount(promoterDrawNew.getOrderCount()); - if (promoterDrawVO.getMemberCommission() == null) { - promoterDrawVO.setMemberCommission(0); - } - promoterDrawVO.setDrawAmount(NumberUtil.mul(promoterDrawNew.getDealAmount(), NumberUtil.div(promoterDrawVO.getMemberCommission().toString(), "100"), 2)); - } else { - promoterDrawVO.setDealAmount(new BigDecimal(0)); - promoterDrawVO.setTotalAmount(new BigDecimal(0)); - promoterDrawVO.setOrderCount(new BigDecimal(0)); + if (promoterDrawVO.getMemberCommission() == null) { promoterDrawVO.setMemberCommission(0); - promoterDrawVO.setDrawAmount(new BigDecimal(0)); } + if (promoterDrawVO.getTotalAmount() == null) { + promoterDrawVO.setTotalAmount(new BigDecimal(0)); + } + if (promoterDrawVO.getDealAmount() == null) { + promoterDrawVO.setDealAmount(new BigDecimal(0)); + } + if (promoterDrawVO.getOrderCount() == null) { + promoterDrawVO.setOrderCount(new BigDecimal(0)); + } + promoterDrawVO.setDrawAmount(NumberUtil.mul(promoterDrawVO.getDealAmount(), NumberUtil.div(promoterDrawVO.getMemberCommission().toString(), "100"), 2)); + +// PromoterDrawVO promoterDrawNew = nameList.get(promoterDrawVO.getUserId()); +// if (promoterDrawNew != null) { +// promoterDrawVO.setDealAmount(promoterDrawNew.getDealAmount()); +// promoterDrawVO.setTotalAmount(promoterDrawNew.getTotalAmount()); +// promoterDrawVO.setOrderCount(promoterDrawNew.getOrderCount()); +// if (promoterDrawVO.getMemberCommission() == null) { +// promoterDrawVO.setMemberCommission(0); +// } +// promoterDrawVO.setDrawAmount(NumberUtil.mul(promoterDrawNew.getDealAmount(), NumberUtil.div(promoterDrawVO.getMemberCommission().toString(), "100"), 2)); +// } else { +// promoterDrawVO.setDealAmount(new BigDecimal(0)); +// promoterDrawVO.setTotalAmount(new BigDecimal(0)); +// promoterDrawVO.setOrderCount(new BigDecimal(0)); +// promoterDrawVO.setMemberCommission(0); +// promoterDrawVO.setDrawAmount(new BigDecimal(0)); +// } }); } return new PageResult<>(list, page.getTotal()); @@ -358,4 +376,5 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { return shoppingMemberOrderVO; } + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/recharge/RechargeOrderMapper.xml b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/recharge/RechargeOrderMapper.xml index 5ff09ab76..eebeee2c6 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/recharge/RechargeOrderMapper.xml +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/recharge/RechargeOrderMapper.xml @@ -12,21 +12,28 @@ +