From fc29029540d2ef413c23ec40debacfd0517e4131 Mon Sep 17 00:00:00 2001 From: perry <292303709@qq.com> Date: Tue, 30 May 2023 18:40:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E4=BD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recharge/RechargeOrderController.java | 12 ++++ .../admin/recharge/vo/PromoterDrawReqVO.java | 35 ++++++++++++ .../admin/recharge/vo/PromoterDrawVO.java | 42 ++++++++++++++ .../recharge/vo/RechargeOrderRespVO.java | 6 +- .../mysql/recharge/RechargeOrderMapper.java | 4 ++ .../recharge/RechargeOrderService.java | 2 +- .../recharge/RechargeOrderServiceImpl.java | 33 ++++++++++- .../mapper/recharge/RechargeOrderMapper.xml | 57 +++++++++++++++++++ 8 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawReqVO.java create mode 100644 yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawVO.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 9de506f87..2bbeaba3f 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 @@ -110,6 +110,18 @@ public class RechargeOrderController { return success(pageResult); } + @PostMapping("/findPromoterDrawPage") + @Operation(summary = "获得推广员抽佣统计") + @PreAuthorize("@ss.hasPermission('shop:recharge-order:query')") + @TenantIgnore + public CommonResult> getRechargeOrderPage(@RequestBody PromoterDrawReqVO pageVO) { + if(!TenantContextHolder.ID_SYSTEM.equals(SecurityFrameworkUtils.getLoginUser().getTenantId())){ + pageVO.setTenantId(SecurityFrameworkUtils.getLoginUser().getTenantId()); + } + PageResult pageResult = rechargeOrderService.findPromoterDrawPage(pageVO); + return success(pageResult); + } + @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/PromoterDrawReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawReqVO.java new file mode 100644 index 000000000..1eced7a28 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawReqVO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Data +public class PromoterDrawReqVO extends PageParam { + + + + 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/controller/admin/recharge/vo/PromoterDrawVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawVO.java new file mode 100644 index 000000000..e2bd4351d --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterDrawVO.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +public class PromoterDrawVO { + @Schema(description = "用户id") + private Long userId; + @Schema(description = "组织id") + private Long deptId; + @Schema(description = "商户id") + 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 = "成为推广员时间") + private LocalDateTime createTime; + @Schema(description = "会员提成") + private Integer memberCommission; + @Schema(description = "商品提成") + private Integer goodsCommission; + + @Schema(description = "成交定单数") + private BigDecimal orderCount; + @Schema(description = "可提现金额") + private BigDecimal drawAmount; + @Schema(description = "成交金额") + private BigDecimal dealAmount; + @Schema(description = "累计金额") + 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/RechargeOrderRespVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderRespVO.java index fb0abb9bd..c86fa7b00 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderRespVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderRespVO.java @@ -2,6 +2,9 @@ package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; import java.time.LocalDateTime; @Schema(description = "管理后台 - 订单 Response VO") @@ -26,5 +29,6 @@ public class RechargeOrderRespVO extends RechargeOrderBaseVO { private String parentOrganizationName; @Schema(description = "推广员名称") private String nickname; - + @Schema(description = "提成金额", required = true, example = "3114") + private BigDecimal commissionPrice; } 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 e1f7ea04b..f6138ee4b 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 @@ -60,6 +60,10 @@ public interface RechargeOrderMapper extends BaseMapperX { .orderByDesc(RechargeOrderDO::getId)); } IPage findListPage(IPage page, @Param("data") RechargeOrderPageReqVO data); + + IPage findPromoterDrawPage(IPage page, @Param("data") PromoterDrawReqVO data); + + List findPromoterDrawCount(@Param("promoterIds") List promoterIds); BigDecimal promoterOrderCount(@Param("startDate") LocalDateTime startDate, @Param("endDate")LocalDateTime endDate,@Param("promoterId") Long promoterId); List findListExcel(@Param("data") RechargeOrderExportReqVO data); 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 940318697..956b84802 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 @@ -64,7 +64,7 @@ public interface RechargeOrderService { * @return 订单分页 */ PageResult getRechargeOrderPage(RechargeOrderPageReqVO pageReqVO); - + PageResult findPromoterDrawPage(PromoterDrawReqVO pageReqVO); /** * 获得订单列表, 用于 Excel 导出 * 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 cece4dc71..cad99e646 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 @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.shop.service.recharge; import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.NumberUtil; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; @@ -44,6 +45,7 @@ import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderMapper; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.shop.enums.ErrorCodeConstants.*; +import static java.util.stream.Collectors.toMap; /** * 订单 Service 实现类 @@ -124,7 +126,36 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { rechargeOrderMapper.findListPage(page, pageReqVO); return new PageResult<>(page.getRecords(), page.getTotal()); } - + @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.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)); + promoterDrawVO.setMemberCommission(0); + promoterDrawVO.setDrawAmount(new BigDecimal(0)); + } + }); + } + return new PageResult<>(list, page.getTotal()); + } @Override public List getRechargeOrderList(RechargeOrderExportReqVO exportReqVO) { return rechargeOrderMapper.selectList(exportReqVO); 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 81c55329f..63af8496c 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 @@ -10,6 +10,61 @@ --> + + + +