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 84208e0a0..dd8815b22 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 @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeGearRes 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.controller.app.member.vo.ShoppingMemberOrderVO; 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.request.member.MemberChangeTieRequest; @@ -72,6 +73,15 @@ public class MemberController { pageRespVO.setPromoterId(SecurityFrameworkUtils.getLoginUserId()); return CommonResult.success(rechargeOrderService.promoterOrderInfo(pageRespVO)); } + @Operation(summary = "获取当前登录商城数量统计") + @RequestMapping(value = "/shoppingOrderCount", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + @Parameter(name = "type", description = "时间类型1、当日2、上周3、上月4、累计", required = true) + public CommonResult shoppingOrderCount(@RequestParam Integer type) { + return CommonResult.success(rechargeOrderService.shoppingOrderCount(type,SecurityFrameworkUtils.getLoginUserId())); + } + @Operation(summary = "获取当前登录发展会员数量统计") @RequestMapping(value = "/promoterOrderCount", 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/ShoppingMemberOrderVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/vo/ShoppingMemberOrderVO.java new file mode 100644 index 000000000..ed3dbd55f --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/vo/ShoppingMemberOrderVO.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 ShoppingMemberOrderVO { + @Schema(description = "总金额") + private Long memberCount; + @Schema(description = "总金额") + private BigDecimal totalAmount; + @Schema(description = "会员提成") + private Integer goodsCommission; +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/order/StoreOrderMapper.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/order/StoreOrderMapper.java index 610a740a8..7bc0caf0e 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/order/StoreOrderMapper.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/order/StoreOrderMapper.java @@ -12,6 +12,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.List; /** @@ -71,4 +72,6 @@ public interface StoreOrderMapper extends BaseMapperX { * @param spreadId 推广人uid */ OrderBrokerageData getBrokerageData(@Param("uid") Long uid, @Param("spreadId") Integer spreadId); + + BigDecimal shoppingOrderCount(@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/order/impl/StoreOrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java index e8f27e161..0a0a27ef0 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java @@ -1393,8 +1393,7 @@ public class StoreOrderServiceImpl extends ServiceImpl"); 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 956b84802..e63bcc482 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 @@ -4,6 +4,7 @@ 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.controller.app.member.vo.ShoppingMemberOrderVO; import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest; @@ -86,4 +87,6 @@ public interface RechargeOrderService { List memberOrderInfoByPhone(String phone); Boolean memberChangeTie(MemberChangeTieRequest changeTieRequest); + + ShoppingMemberOrderVO shoppingOrderCount(Integer type, Long loginUserId); } 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 4ebd663a5..5d4fd8ad2 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 @@ -9,7 +9,9 @@ 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.controller.app.member.vo.ShoppingMemberOrderVO; import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO; +import cn.iocoder.yudao.module.shop.dal.mysql.order.StoreOrderMapper; import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderInfoMapper; import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest; import cn.iocoder.yudao.module.shop.request.member.RefundRequest; @@ -68,6 +70,9 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { private MemberUserApi memberUserApi; @Resource private TenantApi tenantApi; + @Resource + private StoreOrderMapper storeOrderMapper; + @Override public Long createRechargeOrder(RechargeOrderCreateReqVO createReqVO) { @@ -131,21 +136,21 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); rechargeOrderMapper.findPromoterDrawPage(page, pageReqVO); List list = page.getRecords(); - if(list!=null && list.size() > 0){ + 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)); + 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){ + if (promoterDrawNew != null) { promoterDrawVO.setDealAmount(promoterDrawNew.getDealAmount()); promoterDrawVO.setTotalAmount(promoterDrawNew.getTotalAmount()); promoterDrawVO.setOrderCount(promoterDrawNew.getOrderCount()); - if(promoterDrawVO.getMemberCommission()==null){ + if (promoterDrawVO.getMemberCommission() == null) { promoterDrawVO.setMemberCommission(0); } - promoterDrawVO.setDrawAmount(NumberUtil.mul(promoterDrawNew.getDealAmount(),NumberUtil.div(promoterDrawVO.getMemberCommission().toString(),"100",2))); - }else { + 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)); @@ -156,6 +161,7 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { } return new PageResult<>(list, page.getTotal()); } + @Override public List getRechargeOrderList(RechargeOrderExportReqVO exportReqVO) { return rechargeOrderMapper.selectList(exportReqVO); @@ -230,14 +236,14 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { } @Override - public PromoterMemberOrderVO promoterOrderCount(Integer type,Long promoterId) { + public PromoterMemberOrderVO promoterOrderCount(Integer type, Long promoterId) { PromoterMemberOrderVO promoterMemberOrderVO = new PromoterMemberOrderVO(); AppUserInfoReqDTO appUserInfoReqDTO = new AppUserInfoReqDTO(); appUserInfoReqDTO.setPromoterId(promoterId); - if(type==1){ + if (type == 1) { appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(LocalDateTime.now())); appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(LocalDateTime.now())); - }else if (type == 2){ + } else if (type == 2) { LocalDateTime todayOfLastWeek = LocalDateTime.now().minusDays(7); LocalDateTime monday = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1); LocalDateTime sunday = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1); @@ -250,7 +256,7 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(firstDay)); appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(lastDay)); } - BigDecimal totalAmount =rechargeOrderMapper.promoterOrderCount(appUserInfoReqDTO.getStartTime(),appUserInfoReqDTO.getEndTime(),promoterId); + BigDecimal totalAmount = rechargeOrderMapper.promoterOrderCount(appUserInfoReqDTO.getStartTime(), appUserInfoReqDTO.getEndTime(), promoterId); promoterMemberOrderVO.setTotalAmount(totalAmount); promoterMemberOrderVO.setMemberCount(memberUserApi.promoterOrderCount(appUserInfoReqDTO)); TenantDTO tenantDTO = tenantApi.getTenant(TenantContextHolder.getTenantId()); @@ -320,7 +326,36 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { Assert.notNull(loginUser, "登录失效,请重新登录!"); MemberUserRespDTO user = userService.getUser(loginUser.getId()); user.setPromoterId(changeTieRequest.getPromoterId()); - return memberUserApi.updateById(user)>0; + return memberUserApi.updateById(user) > 0; + } + + @Override + public ShoppingMemberOrderVO shoppingOrderCount(Integer type, Long promoterId) { + ShoppingMemberOrderVO shoppingMemberOrderVO = new ShoppingMemberOrderVO(); + 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().minusDays(7); + 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)); + } + BigDecimal totalAmount = storeOrderMapper.shoppingOrderCount(appUserInfoReqDTO.getStartTime(), appUserInfoReqDTO.getEndTime(), promoterId); + shoppingMemberOrderVO.setTotalAmount(totalAmount); + shoppingMemberOrderVO.setMemberCount(memberUserApi.promoterOrderCount(appUserInfoReqDTO)); + TenantDTO tenantDTO = tenantApi.getTenant(TenantContextHolder.getTenantId()); + shoppingMemberOrderVO.setGoodsCommission(tenantDTO.getGoodsCommission()); + return shoppingMemberOrderVO; } } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/order/StoreOrderMapper.xml b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/order/StoreOrderMapper.xml index f4f6484ce..ec9e928f3 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/order/StoreOrderMapper.xml +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/order/StoreOrderMapper.xml @@ -51,4 +51,17 @@ right join eb_user_brokerage_record as br on br.link_id = o.order_id and br.status = 3 and br.uid = #{spreadId} where o.uid = #{uid} and o.status > 1; + +