充值记录统计
This commit is contained in:
@ -160,5 +160,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode CAROUSEL_NOT_EXISTS = new ErrorCode(1_004_025_00, "小程序轮播图不存在");
|
ErrorCode CAROUSEL_NOT_EXISTS = new ErrorCode(1_004_025_00, "小程序轮播图不存在");
|
||||||
|
|
||||||
ErrorCode TIME_NOT_SATISFY = new ErrorCode(1_004_026_00, "27号后不能充值");
|
ErrorCode TIME_NOT_SATISFY = new ErrorCode(1_004_026_00, "27号后不能充值");
|
||||||
|
|
||||||
|
ErrorCode GROUP_COUNT_NOT_EXISTS = new ErrorCode(1_004_027_00, "用户分组充值统计不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.group;
|
package cn.iocoder.yudao.module.member.controller.admin.group;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.group.vo.*;
|
import cn.iocoder.yudao.module.member.controller.admin.group.vo.*;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserListVO;
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserListVO;
|
||||||
import cn.iocoder.yudao.module.member.convert.group.MemberGroupConvert;
|
import cn.iocoder.yudao.module.member.convert.group.MemberGroupConvert;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.card.CardMapper;
|
||||||
|
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.service.group.MemberGroupService;
|
import cn.iocoder.yudao.module.member.service.group.MemberGroupService;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
|
import cn.iocoder.yudao.module.member.util.MemberTimeUtils;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -25,7 +31,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@ -40,6 +48,8 @@ public class MemberGroupController {
|
|||||||
private MemberGroupService groupService;
|
private MemberGroupService groupService;
|
||||||
@Resource
|
@Resource
|
||||||
private MemberUserService userService;
|
private MemberUserService userService;
|
||||||
|
@Resource
|
||||||
|
private CardMapper cardMapper;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建用户分组")
|
@Operation(summary = "创建用户分组")
|
||||||
@ -95,6 +105,12 @@ public class MemberGroupController {
|
|||||||
vo.setMobile(user.getMobile());
|
vo.setMobile(user.getMobile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<MemberUserDO> memberByGroupId = groupService.getByGroupId(vo.getId());
|
||||||
|
if(CollectionUtil.isNotEmpty(memberByGroupId)){
|
||||||
|
List<Long> collect = memberByGroupId.stream().map(MemberUserDO::getId).collect(Collectors.toList());
|
||||||
|
BigDecimal month = cardMapper.getTotalMoneyByGroup(collect, MemberTimeUtils.getYear(DateUtil.date()), MemberTimeUtils.getMonth(DateUtil.date()));
|
||||||
|
vo.setMonth(month);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return success(memberGroupRespVOPageResult);
|
return success(memberGroupRespVOPageResult);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 用户分组 Response VO")
|
@Schema(description = "管理后台 - 用户分组 Response VO")
|
||||||
@ -21,4 +22,7 @@ public class MemberGroupRespVO extends MemberGroupBaseVO {
|
|||||||
|
|
||||||
@Schema(description = "管理员手机", example = "1")
|
@Schema(description = "管理员手机", example = "1")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
|
@Schema(description = "本月充值金额", example = "1")
|
||||||
|
private BigDecimal month;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.groupcount;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.groupcount.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.groupcount.GroupCountDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.groupcount.GroupCountService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 用户分组充值统计")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/member/group-count")
|
||||||
|
@Validated
|
||||||
|
public class GroupCountController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GroupCountService groupCountService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建用户分组充值统计")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:group-count:create')")
|
||||||
|
public CommonResult<Long> createGroupCount(@Valid @RequestBody GroupCountSaveReqVO createReqVO) {
|
||||||
|
return success(groupCountService.createGroupCount(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新用户分组充值统计")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:group-count:update')")
|
||||||
|
public CommonResult<Boolean> updateGroupCount(@Valid @RequestBody GroupCountSaveReqVO updateReqVO) {
|
||||||
|
groupCountService.updateGroupCount(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除用户分组充值统计")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:group-count:delete')")
|
||||||
|
public CommonResult<Boolean> deleteGroupCount(@RequestParam("id") Long id) {
|
||||||
|
groupCountService.deleteGroupCount(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得用户分组充值统计")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:group-count:query')")
|
||||||
|
public CommonResult<GroupCountRespVO> getGroupCount(@RequestParam("id") Long id) {
|
||||||
|
GroupCountDO groupCount = groupCountService.getGroupCount(id);
|
||||||
|
return success(BeanUtils.toBean(groupCount, GroupCountRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得用户分组充值统计分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:group-count:query')")
|
||||||
|
public CommonResult<PageResult<GroupCountRespVO>> getGroupCountPage(@Valid GroupCountPageReqVO pageReqVO) {
|
||||||
|
PageResult<GroupCountDO> pageResult = groupCountService.getGroupCountPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, GroupCountRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出用户分组充值统计 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:group-count:export')")
|
||||||
|
@OperateLog(type = EXPORT)
|
||||||
|
public void exportGroupCountExcel(@Valid GroupCountPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<GroupCountDO> list = groupCountService.getGroupCountPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "用户分组充值统计.xls", "数据", GroupCountRespVO.class,
|
||||||
|
BeanUtils.toBean(list, GroupCountRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.groupcount.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 用户分组充值统计分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class GroupCountPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "分组ID", example = "23738")
|
||||||
|
private Long groupId;
|
||||||
|
|
||||||
|
@Schema(description = "名称", example = "李四")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@Schema(description = "充值金额")
|
||||||
|
private BigDecimal money;
|
||||||
|
|
||||||
|
@Schema(description = "管理员手机号")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@Schema(description = "时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private String[] time;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.groupcount.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 用户分组充值统计 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class GroupCountRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9709")
|
||||||
|
@ExcelProperty("编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "分组ID", example = "23738")
|
||||||
|
@ExcelProperty("分组ID")
|
||||||
|
private Long groupId;
|
||||||
|
|
||||||
|
@Schema(description = "名称", example = "李四")
|
||||||
|
@ExcelProperty("名称")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@Schema(description = "充值金额")
|
||||||
|
@ExcelProperty("充值金额")
|
||||||
|
private BigDecimal money;
|
||||||
|
|
||||||
|
@Schema(description = "管理员手机号")
|
||||||
|
@ExcelProperty("管理员手机号")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@Schema(description = "时间")
|
||||||
|
@ExcelProperty("时间")
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.groupcount.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 用户分组充值统计新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class GroupCountSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9709")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "分组ID", example = "23738")
|
||||||
|
private Long groupId;
|
||||||
|
|
||||||
|
@Schema(description = "名称", example = "李四")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@Schema(description = "充值金额")
|
||||||
|
private BigDecimal money;
|
||||||
|
|
||||||
|
@Schema(description = "管理员手机号")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@Schema(description = "时间")
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.dataobject.groupcount;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户分组充值统计 DO
|
||||||
|
*
|
||||||
|
* @author 秦俊旗
|
||||||
|
*/
|
||||||
|
@TableName("member_group_count")
|
||||||
|
@KeySequence("member_group_count_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class GroupCountDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 分组ID
|
||||||
|
*/
|
||||||
|
private Long groupId;
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String groupName;
|
||||||
|
/**
|
||||||
|
* 充值金额
|
||||||
|
*/
|
||||||
|
private BigDecimal money;
|
||||||
|
/**
|
||||||
|
* 管理员手机号
|
||||||
|
*/
|
||||||
|
private String mobile;
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
}
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.member.controller.app.card.vo.FaceVo;
|
|||||||
import cn.iocoder.yudao.module.member.dal.dataobject.billing.BillingDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.billing.BillingDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||||
import cn.iocoder.yudao.module.member.enums.BillingStatusEnum;
|
import cn.iocoder.yudao.module.member.enums.BillingStatusEnum;
|
||||||
|
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
@ -83,10 +84,12 @@ public interface CardMapper extends BaseMapperX<CardDO> {
|
|||||||
.eq(CardDO::getType, type)
|
.eq(CardDO::getType, type)
|
||||||
.eq(CardDO::getBillingExist, var)
|
.eq(CardDO::getBillingExist, var)
|
||||||
.in(CardDO::getUserId, userIds));
|
.in(CardDO::getUserId, userIds));
|
||||||
|
DateTime date = DateUtil.date();
|
||||||
|
int year = date.year();
|
||||||
|
cardDOS=cardDOS.stream().filter(f-> f.getCreateTime().getYear()==year).collect(Collectors.toList());
|
||||||
if(var2!=null){
|
if(var2!=null){
|
||||||
return cardDOS.stream().filter(f-> f.getCreateTime().getMonth().getValue()==var2).collect(Collectors.toList());
|
return cardDOS.stream().filter(f-> f.getCreateTime().getMonth().getValue()==var2).collect(Collectors.toList());
|
||||||
}else{
|
}else{
|
||||||
DateTime date = DateUtil.date();
|
|
||||||
int i = date.monthBaseOne();
|
int i = date.monthBaseOne();
|
||||||
return cardDOS.stream().filter(f-> f.getCreateTime().getMonth().getValue()!=i).collect(Collectors.toList());
|
return cardDOS.stream().filter(f-> f.getCreateTime().getMonth().getValue()!=i).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -97,10 +100,12 @@ public interface CardMapper extends BaseMapperX<CardDO> {
|
|||||||
.eq(CardDO::getType, type)
|
.eq(CardDO::getType, type)
|
||||||
.eq(CardDO::getBillingExist, BillingStatusEnum.BILLING_INVOICING_REJECTION.getCode())
|
.eq(CardDO::getBillingExist, BillingStatusEnum.BILLING_INVOICING_REJECTION.getCode())
|
||||||
.in(CardDO::getUserId, userIds));
|
.in(CardDO::getUserId, userIds));
|
||||||
|
DateTime date = DateUtil.date();
|
||||||
|
int year = date.year();
|
||||||
|
cardDOS=cardDOS.stream().filter(f-> f.getCreateTime().getYear()==year).collect(Collectors.toList());
|
||||||
if(var!=null){
|
if(var!=null){
|
||||||
cardDOS=cardDOS.stream().filter(f-> f.getCreateTime().getMonth().getValue()==var).collect(Collectors.toList());
|
cardDOS=cardDOS.stream().filter(f-> f.getCreateTime().getMonth().getValue()==var).collect(Collectors.toList());
|
||||||
}else{
|
}else{
|
||||||
DateTime date = DateUtil.date();
|
|
||||||
int i = date.monthBaseOne();
|
int i = date.monthBaseOne();
|
||||||
cardDOS=cardDOS.stream().filter(f-> f.getCreateTime().getMonth().getValue()!=i).collect(Collectors.toList());
|
cardDOS=cardDOS.stream().filter(f-> f.getCreateTime().getMonth().getValue()!=i).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -110,5 +115,17 @@ public interface CardMapper extends BaseMapperX<CardDO> {
|
|||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default BigDecimal getTotalMoneyByGroup(List<Long> userIds,Integer year,Integer month) {
|
||||||
|
List<CardDO> cardDOS = selectList(new LambdaQueryWrapper<CardDO>()
|
||||||
|
.eq(CardDO::getFlag, CardDO.ADD)
|
||||||
|
.eq(CardDO::getType, CostTypeEnum.ADMIN_PAY.getCode())
|
||||||
|
.in(CardDO::getUserId, userIds)
|
||||||
|
.apply("DATE_FORMAT(create_time, '%Y-%m')= {0}",year+"-"+month));
|
||||||
|
return cardDOS.stream()
|
||||||
|
.map(CardDO::getChangeMoney)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
}
|
||||||
|
|
||||||
int udpateEXit(@Param("orderIds") Collection<Long> orderIds,@Param("exit") Integer exit,@Param("num")String num);
|
int udpateEXit(@Param("orderIds") Collection<Long> orderIds,@Param("exit") Integer exit,@Param("num")String num);
|
||||||
}
|
}
|
@ -41,6 +41,8 @@ public interface MemberGroupMapper extends BaseMapperX<MemberGroupDO> {
|
|||||||
|
|
||||||
List<MemberUserDO> getMemberByGroupId(MemberGroupPageVO vo);
|
List<MemberUserDO> getMemberByGroupId(MemberGroupPageVO vo);
|
||||||
|
|
||||||
|
List<MemberUserDO> getByGroupId(Long groupId);
|
||||||
|
|
||||||
void deleteMember(@Param("groupId")Long groupId, @Param("list")List<Long> memberIds);
|
void deleteMember(@Param("groupId")Long groupId, @Param("list")List<Long> memberIds);
|
||||||
|
|
||||||
Long memberCount(MemberGroupPageVO vo);
|
Long memberCount(MemberGroupPageVO vo);
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.mysql.groupcount;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.groupcount.GroupCountDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.groupcount.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户分组充值统计 Mapper
|
||||||
|
*
|
||||||
|
* @author 秦俊旗
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface GroupCountMapper extends BaseMapperX<GroupCountDO> {
|
||||||
|
|
||||||
|
default PageResult<GroupCountDO> selectPage(GroupCountPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<GroupCountDO>()
|
||||||
|
.eqIfPresent(GroupCountDO::getGroupId, reqVO.getGroupId())
|
||||||
|
.likeIfPresent(GroupCountDO::getGroupName, reqVO.getGroupName())
|
||||||
|
.eqIfPresent(GroupCountDO::getMoney, reqVO.getMoney())
|
||||||
|
.eqIfPresent(GroupCountDO::getMobile, reqVO.getMobile())
|
||||||
|
.betweenIfPresent(GroupCountDO::getTime, reqVO.getTime())
|
||||||
|
.betweenIfPresent(GroupCountDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(GroupCountDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.job;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.groupcount.GroupCountDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.storebusiness.StoreBusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.business.BusinessMapper;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.card.CardMapper;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.group.MemberGroupMapper;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.groupcount.GroupCountMapper;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.storebusiness.StoreBusinessMapper;
|
||||||
|
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
|
import cn.iocoder.yudao.module.member.util.MemberTimeUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:qjq
|
||||||
|
* @Date:2024/4/3 14:50
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class GroupCountJob implements JobHandler {
|
||||||
|
@Resource
|
||||||
|
private MemberGroupMapper groupMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GroupCountMapper groupCountMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CardMapper cardMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberUserService userService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行任务
|
||||||
|
*
|
||||||
|
* @param param 参数
|
||||||
|
* @return 结果
|
||||||
|
* @throws Exception 异常
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@TenantIgnore
|
||||||
|
public String execute(String param) {
|
||||||
|
//查询所有部门分组
|
||||||
|
List<MemberGroupDO> memberGroupDOS = groupMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
|
||||||
|
List<GroupCountDO> adds = new ArrayList<>();
|
||||||
|
//查询上个月的充值金额
|
||||||
|
for (MemberGroupDO memberGroupDO : memberGroupDOS) {
|
||||||
|
List<MemberUserDO> memberByGroupId = groupMapper.getByGroupId(memberGroupDO.getId());
|
||||||
|
if (CollectionUtil.isEmpty(memberByGroupId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<Long> collect = memberByGroupId.stream().map(MemberUserDO::getId).collect(Collectors.toList());
|
||||||
|
DateTime currentDate = DateUtil.date();
|
||||||
|
DateTime lastMonthDate = DateUtil.offsetMonth(currentDate, -1);
|
||||||
|
Integer year = MemberTimeUtils.getYear(lastMonthDate);
|
||||||
|
Integer month = MemberTimeUtils.getMonth(lastMonthDate);
|
||||||
|
BigDecimal money = cardMapper.getTotalMoneyByGroup(collect, year, month);
|
||||||
|
|
||||||
|
GroupCountDO groupCountDO = new GroupCountDO();
|
||||||
|
groupCountDO.setGroupId(memberGroupDO.getId());
|
||||||
|
groupCountDO.setGroupName(memberGroupDO.getName());
|
||||||
|
groupCountDO.setMoney(money);
|
||||||
|
groupCountDO.setTime(year+"-"+month);
|
||||||
|
if(memberGroupDO.getUserId()!=null){
|
||||||
|
MemberUserDO user = userService.getUser(memberGroupDO.getUserId());
|
||||||
|
if (ObjectUtil.isNotEmpty(user)){
|
||||||
|
groupCountDO.setMobile(user.getMobile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
adds.add(groupCountDO);
|
||||||
|
}
|
||||||
|
groupCountMapper.insertBatch(adds);
|
||||||
|
|
||||||
|
log.info("[execute][生成上月统计充值数据 {}条]", adds.size());
|
||||||
|
return String.format("生成上月统计充值数据 %s 条 ", adds.size());
|
||||||
|
}
|
||||||
|
}
|
@ -98,6 +98,8 @@ public interface MemberGroupService {
|
|||||||
*/
|
*/
|
||||||
PageResult<MemberUserVO> getMemberByGroupId(MemberGroupPageVO vo);
|
PageResult<MemberUserVO> getMemberByGroupId(MemberGroupPageVO vo);
|
||||||
|
|
||||||
|
List<MemberUserDO> getByGroupId(Long groupId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除会员
|
* 删除会员
|
||||||
*
|
*
|
||||||
|
@ -135,6 +135,11 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MemberUserDO> getByGroupId(Long groupId) {
|
||||||
|
return memberGroupMapper.getByGroupId(groupId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMember(MemberGroupVO deleteVO) {
|
public void deleteMember(MemberGroupVO deleteVO) {
|
||||||
memberGroupMapper.deleteMember(deleteVO.getGroupId(),deleteVO.getUserId());
|
memberGroupMapper.deleteMember(deleteVO.getGroupId(),deleteVO.getUserId());
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.groupcount;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.groupcount.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.groupcount.GroupCountDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户分组充值统计 Service 接口
|
||||||
|
*
|
||||||
|
* @author 秦俊旗
|
||||||
|
*/
|
||||||
|
public interface GroupCountService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建用户分组充值统计
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createGroupCount(@Valid GroupCountSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户分组充值统计
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateGroupCount(@Valid GroupCountSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户分组充值统计
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteGroupCount(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得用户分组充值统计
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 用户分组充值统计
|
||||||
|
*/
|
||||||
|
GroupCountDO getGroupCount(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得用户分组充值统计分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 用户分组充值统计分页
|
||||||
|
*/
|
||||||
|
PageResult<GroupCountDO> getGroupCountPage(GroupCountPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.groupcount;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.groupcount.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.groupcount.GroupCountDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.groupcount.GroupCountMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户分组充值统计 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 秦俊旗
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class GroupCountServiceImpl implements GroupCountService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GroupCountMapper groupCountMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createGroupCount(GroupCountSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
GroupCountDO groupCount = BeanUtils.toBean(createReqVO, GroupCountDO.class);
|
||||||
|
groupCountMapper.insert(groupCount);
|
||||||
|
// 返回
|
||||||
|
return groupCount.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateGroupCount(GroupCountSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateGroupCountExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
GroupCountDO updateObj = BeanUtils.toBean(updateReqVO, GroupCountDO.class);
|
||||||
|
groupCountMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteGroupCount(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateGroupCountExists(id);
|
||||||
|
// 删除
|
||||||
|
groupCountMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateGroupCountExists(Long id) {
|
||||||
|
if (groupCountMapper.selectById(id) == null) {
|
||||||
|
throw exception(GROUP_COUNT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GroupCountDO getGroupCount(Long id) {
|
||||||
|
return groupCountMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<GroupCountDO> getGroupCountPage(GroupCountPageReqVO pageReqVO) {
|
||||||
|
return groupCountMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.member.util;
|
package cn.iocoder.yudao.module.member.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import org.aspectj.apache.bcel.generic.RET;
|
import org.aspectj.apache.bcel.generic.RET;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@ -89,4 +91,12 @@ public class MemberTimeUtils {
|
|||||||
return date.atTime(LocalTime.MAX);
|
return date.atTime(LocalTime.MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Integer getYear(DateTime date) {
|
||||||
|
return DateUtil.year(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getMonth(DateTime date) {
|
||||||
|
return DateUtil.month(date) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,14 @@
|
|||||||
limit #{limitOne},#{pageSize}
|
limit #{limitOne},#{pageSize}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getByGroupId" resultType="cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO">
|
||||||
|
select mu.*
|
||||||
|
from member_group_member mgm
|
||||||
|
left join yudao.member_user mu on mgm.member_id = mu.id
|
||||||
|
where mgm.group_id = #{groupId}
|
||||||
|
and mu.status = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
<delete id="deleteMember">
|
<delete id="deleteMember">
|
||||||
delete from member_group_member
|
delete from member_group_member
|
||||||
where group_id = #{groupId} and member_id in
|
where group_id = #{groupId} and member_id in
|
||||||
|
Reference in New Issue
Block a user