From 21790ab31dfc32524ef4701ba2fa3e562a4d1c54 Mon Sep 17 00:00:00 2001 From: perry <292303709@qq.com> Date: Mon, 29 May 2023 09:46:14 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=88=86=E9=94=80=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recharge/RechargeOrderController.java | 1 + .../recharge/vo/RechargeOrderPageReqVO.java | 6 +- .../app/member/MemberController.java | 20 +++ .../app/member/vo/PromoterMemberOrderVO.java | 18 +++ .../mysql/recharge/RechargeOrderMapper.java | 5 +- .../recharge/RechargeOrderService.java | 5 + .../recharge/RechargeOrderServiceImpl.java | 75 ++++++++++- .../mapper/recharge/RechargeOrderMapper.xml | 17 +++ .../module/member/api/user/MemberUserApi.java | 3 + .../api/user/dto/AppUserInfoReqDTO.java | 19 +++ .../member/api/user/MemberUserApiImpl.java | 6 + .../user/vo/AppUserInfoReqVO.java | 26 +++- .../app/user/AppUserController.java | 4 +- .../dal/mysql/user/MemberUserMapper.java | 7 + .../service/promoter/PromoterService.java | 1 + .../service/promoter/PromoterServiceImpl.java | 3 + .../service/user/MemberUserService.java | 2 + .../service/user/MemberUserServiceImpl.java | 5 + .../module/system/api/tenant/TenantApi.java | 4 + .../system/api/tenant/dto/TenantDTO.java | 121 ++++++++++++++++++ .../system/api/tenant/TenantApiImpl.java | 10 ++ .../system/convert/tenant/TenantConvert.java | 3 + 22 files changed, 353 insertions(+), 8 deletions(-) create mode 100644 yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/vo/PromoterMemberOrderVO.java create mode 100644 yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/AppUserInfoReqDTO.java rename yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/{app => admin}/user/vo/AppUserInfoReqVO.java (60%) create mode 100644 yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/tenant/dto/TenantDTO.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 974b8e9ad..314963ab7 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 @@ -133,6 +133,7 @@ public class RechargeOrderController { @PreAuthenticated @Operation(summary = "退款") @RequestMapping(value = "/memberRefund", method = RequestMethod.POST) + @PreAuthorize("@ss.hasPermission('shop:recharge-order:refund')") public CommonResult memberRefund(@Valid @RequestBody RefundRequest request, HttpServletRequest servletRequest) throws Exception { log.info("memberRefund会员退款===>{}", request); Object obj=null; diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderPageReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderPageReqVO.java index ccb6d0728..198f403f2 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderPageReqVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderPageReqVO.java @@ -126,6 +126,10 @@ public class RechargeOrderPageReqVO extends PageParam { @Schema(description = "第三方支付流水号") private String paySerialNumber; - + /** + * 推广员id + */ + @Schema(description = "推广员id") + private Long promoterId; } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java index cc7bca07b..a3e2f99bb 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java @@ -1,10 +1,14 @@ package cn.iocoder.yudao.module.shop.controller.app.member; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeGearRespVO; +import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderPageReqVO; import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderRespVO; +import cn.iocoder.yudao.module.shop.controller.app.member.vo.PromoterMemberOrderVO; import cn.iocoder.yudao.module.shop.convert.recharge.RechargeOrderConvert; import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO; import cn.iocoder.yudao.module.shop.response.member.MemberHeadResponse; @@ -58,6 +62,22 @@ public class MemberController { public CommonResult> memberOrderInfo() { return CommonResult.success(rechargeOrderService.memberOrderInfo()); } + @Operation(summary = "获取当前登录账号的推广员推广会员记录") + @RequestMapping(value = "/promoterOrderInfo", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + public CommonResult> promoterOrderInfo(RechargeOrderPageReqVO pageRespVO) { + pageRespVO.setPromoterId(SecurityFrameworkUtils.getLoginUserId()); + return CommonResult.success(rechargeOrderService.promoterOrderInfo(pageRespVO)); + } + @Operation(summary = "获取当前登录发展会员数量统计") + @RequestMapping(value = "/promoterOrderCount", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + @Parameter(name = "type", description = "时间类型1、当日2、上周3、上月4、累计", required = true) + public CommonResult promoterOrderCount(@RequestParam Integer type) { + return CommonResult.success(rechargeOrderService.promoterOrderCount(type,SecurityFrameworkUtils.getLoginUserId())); + } @Operation(summary = "会员头部信息") @RequestMapping(value = "/memberHeadInfo", method = RequestMethod.GET) @PreAuthenticated diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/vo/PromoterMemberOrderVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/vo/PromoterMemberOrderVO.java new file mode 100644 index 000000000..ec3367600 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/vo/PromoterMemberOrderVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.shop.controller.app.member.vo; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(description = "会员发展数量统计") +public class PromoterMemberOrderVO { + @Schema(description = "总金额") + private Long memberCount; + @Schema(description = "总金额") + private BigDecimal totalAmount; + @Schema(description = "会员提成") + private Integer memberCommission; +} 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 764bd206b..e1f7ea04b 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 @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.shop.dal.mysql.recharge; +import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.*; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -10,6 +12,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Mapper; import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; /** * 订单 Mapper @@ -57,7 +60,7 @@ public interface RechargeOrderMapper extends BaseMapperX { .orderByDesc(RechargeOrderDO::getId)); } IPage findListPage(IPage page, @Param("data") RechargeOrderPageReqVO data); - + BigDecimal promoterOrderCount(@Param("startDate") LocalDateTime startDate, @Param("endDate")LocalDateTime endDate,@Param("promoterId") Long promoterId); List findListExcel(@Param("data") RechargeOrderExportReqVO data); default List selectList(RechargeOrderExportReqVO reqVO) { 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 c9c9a089f..dd6c80dd7 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 @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.shop.service.recharge; import java.util.*; import javax.validation.*; import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*; +import cn.iocoder.yudao.module.shop.controller.app.member.vo.PromoterMemberOrderVO; import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.shop.response.member.MemberHeadResponse; @@ -75,6 +76,10 @@ public interface RechargeOrderService { List memberOrderInfo(); + PageResult promoterOrderInfo(RechargeOrderPageReqVO pageRespVO); + + PromoterMemberOrderVO promoterOrderCount(Integer type,Long promoterId); + MemberHeadResponse memberHeadInfo(); List memberOrderInfoByPhone(String phone); 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 d3fc5ad04..e35cb0b5f 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,13 +1,19 @@ package cn.iocoder.yudao.module.shop.service.recharge; +import cn.hutool.core.date.LocalDateTimeUtil; 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; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; +import cn.iocoder.yudao.module.member.api.user.dto.AppUserInfoReqDTO; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.shop.controller.app.member.vo.PromoterMemberOrderVO; import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO; import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderInfoMapper; import cn.iocoder.yudao.module.shop.request.member.RefundRequest; import cn.iocoder.yudao.module.shop.response.member.MemberHeadResponse; +import cn.iocoder.yudao.module.system.api.tenant.TenantApi; +import cn.iocoder.yudao.module.system.api.tenant.dto.TenantDTO; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.beans.factory.annotation.Autowired; @@ -20,7 +26,11 @@ import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; import java.math.BigDecimal; +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.stream.Collectors; @@ -51,6 +61,11 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { private MemberUserApi userService; @Resource private PhoneRecordService phoneRecordService; + @Resource + private MemberUserApi memberUserApi; + + @Resource + private TenantApi tenantApi; @Override public Long createRechargeOrder(RechargeOrderCreateReqVO createReqVO) { @@ -125,7 +140,7 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); Assert.notNull(loginUser, "登录失效,请重新登录!"); List orderDOS = rechargeOrderMapper.selectList(Wrappers.lambdaQuery() - .eq(RechargeOrderDO::getUid, loginUser.getId()).eq(RechargeOrderDO::getPaid, 1)); + .eq(RechargeOrderDO::getUid, loginUser.getId()).ne(RechargeOrderDO::getPaid, 0)); if (!CollectionUtils.isEmpty(orderDOS)) { List rechargeOrderRespVOS = RechargeOrderConvert.INSTANCE.convertList(orderDOS); List collect1 = rechargeOrderRespVOS.stream().map(RechargeOrderBaseVO::getOrderId).collect(Collectors.toList()); @@ -153,6 +168,64 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { return null; } + @Override + public PageResult promoterOrderInfo(RechargeOrderPageReqVO pageReqVO) { + Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); + rechargeOrderMapper.findListPage(page, pageReqVO); + if (!CollectionUtils.isEmpty(page.getRecords())) { + List collect1 = page.getRecords().stream().map(RechargeOrderBaseVO::getOrderId).collect(Collectors.toList()); + List infoDOS = infoMapper.selectList(Wrappers.lambdaQuery().in(RechargeOrderInfoDO::getOrderNo, collect1)); + Map> collect = infoDOS.stream().collect(Collectors.groupingBy(RechargeOrderInfoDO::getOrderNo)); + for (RechargeOrderRespVO orderDO : page.getRecords()) { + StringBuilder grade = new StringBuilder(); + List infoDOS1 = collect.get(orderDO.getOrderId()); + for (RechargeOrderInfoDO infoDO : infoDOS1) { + if (infoDO.getPrice().compareTo(new BigDecimal("240")) == 0) { + grade.append("套餐1,"); + } else if (infoDO.getPrice().compareTo(new BigDecimal("400")) == 0) { + grade.append("套餐2,"); + } else if (infoDO.getPrice().compareTo(new BigDecimal("640")) == 0) { + grade.append("套餐3"); + } + } + orderDO.setGrade(grade.toString()); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + orderDO.setStringCreateTime(orderDO.getCreateTime().format(formatter)); + } + + return new PageResult<>(page.getRecords(), page.getTotal()); + } + return null; + } + + @Override + public PromoterMemberOrderVO promoterOrderCount(Integer type,Long promoterId) { + PromoterMemberOrderVO promoterMemberOrderVO = new PromoterMemberOrderVO(); + AppUserInfoReqDTO appUserInfoReqDTO = new AppUserInfoReqDTO(); + appUserInfoReqDTO.setPromoterId(promoterId); + if(type==1){ + appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(LocalDateTime.now())); + appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(LocalDateTime.now())); + }else if (type == 2){ + LocalDateTime todayOfLastWeek = LocalDateTime.now(); + LocalDateTime monday = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1); + LocalDateTime sunday = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1); + appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(monday)); + appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(sunday)); + } else if (type == 3) { + LocalDateTime lastMonth = LocalDateTime.now().minusMonths(1); // 当前月份减1 + LocalDateTime firstDay = lastMonth.with(TemporalAdjusters.firstDayOfMonth()); // 获取当前月的第一天 + LocalDateTime lastDay = lastMonth.with(TemporalAdjusters.lastDayOfMonth()); // 获取当前月的最后一天 + appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(firstDay)); + appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(lastDay)); + } + promoterMemberOrderVO.setTotalAmount(rechargeOrderMapper.promoterOrderCount(appUserInfoReqDTO.getStartTime(),appUserInfoReqDTO.getEndTime(),promoterId)); + promoterMemberOrderVO.setMemberCount(memberUserApi.promoterOrderCount(appUserInfoReqDTO)); + TenantDTO tenantDTO = tenantApi.getTenant(TenantContextHolder.getTenantId()); + promoterMemberOrderVO.setMemberCommission(tenantDTO.getMemberCommission()); + return promoterMemberOrderVO; + } + @Override public MemberHeadResponse memberHeadInfo() { MemberHeadResponse response = new MemberHeadResponse(); 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 840d91eeb..251b272c5 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 @@ -57,6 +57,19 @@ + +