mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-31 09:30:05 +08:00
trade: 分销用户管理
This commit is contained in:
parent
5808f77ade
commit
166b1b31c0
@ -24,7 +24,7 @@ create table trade_config
|
||||
create table trade_brokerage_user
|
||||
(
|
||||
id bigint auto_increment comment '用户编号' primary key,
|
||||
brokerage_user_id bigint not null comment '推广员编号',
|
||||
brokerage_user_id bigint null comment '推广员编号',
|
||||
brokerage_bind_time datetime null comment '推广员绑定时间',
|
||||
brokerage_enabled bit default 1 not null comment '是否成为推广员',
|
||||
brokerage_time datetime null comment '成为分销员时间',
|
||||
@ -185,12 +185,15 @@ SELECT @parentId := LAST_INSERT_ID();
|
||||
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
|
||||
VALUES ('分销用户查询', 'trade:brokerage-user:query', 3, 1, @parentId, '', '', '', 0);
|
||||
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
|
||||
VALUES ('分销用户修改推广员', 'trade:brokerage-user:update-brokerage-user', 3, 2, @parentId, '', '', '', 0);
|
||||
VALUES ('分销用户推广人查询', 'trade:brokerage-user:user-query', 3, 2, @parentId, '', '', '', 0);
|
||||
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
|
||||
VALUES ('分销用户清除推广员', 'trade:brokerage-user:clear-brokerage-user', 3, 3, @parentId, '', '', '', 0);
|
||||
VALUES ('分销用户推广订单查询', 'trade:brokerage-user:order-query', 3, 3, @parentId, '', '', '', 0);
|
||||
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
|
||||
VALUES ('分销用户修改推广资格', 'trade:brokerage-user:update-brokerage-enable', 3, 4, @parentId, '', '', '', 0);
|
||||
|
||||
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
|
||||
VALUES ('分销用户修改推广员', 'trade:brokerage-user:update-brokerage-user', 3, 5, @parentId, '', '', '', 0);
|
||||
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
|
||||
VALUES ('分销用户清除推广员', 'trade:brokerage-user:clear-brokerage-user', 3, 6, @parentId, '', '', '', 0);
|
||||
|
||||
-- 增加菜单:佣金记录
|
||||
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name)
|
||||
|
@ -2,9 +2,15 @@ package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.convert.brokerage.user.TradeBrokerageUserConvert;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO;
|
||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.record.TradeBrokerageRecordService;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.UserBrokerageSummaryBO;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.user.TradeBrokerageUserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@ -15,8 +21,12 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
@Tag(name = "管理后台 - 分销用户")
|
||||
@RestController
|
||||
@ -26,6 +36,11 @@ public class TradeBrokerageUserController {
|
||||
|
||||
@Resource
|
||||
private TradeBrokerageUserService brokerageUserService;
|
||||
@Resource
|
||||
private TradeBrokerageRecordService brokerageRecordService;
|
||||
|
||||
@Resource
|
||||
private MemberUserApi memberUserApi;
|
||||
|
||||
@PutMapping("/update-brokerage-user")
|
||||
@Operation(summary = "修改推广员")
|
||||
@ -64,8 +79,26 @@ public class TradeBrokerageUserController {
|
||||
@Operation(summary = "获得分销用户分页")
|
||||
@PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')")
|
||||
public CommonResult<PageResult<TradeBrokerageUserRespVO>> getBrokerageUserPage(@Valid TradeBrokerageUserPageReqVO pageVO) {
|
||||
// 分页查询
|
||||
PageResult<TradeBrokerageUserDO> pageResult = brokerageUserService.getBrokerageUserPage(pageVO);
|
||||
return success(TradeBrokerageUserConvert.INSTANCE.convertPage(pageResult));
|
||||
|
||||
// 涉及到的用户
|
||||
Set<Long> userIds = convertSet(pageResult.getList(), TradeBrokerageUserDO::getId);
|
||||
// 查询用户信息
|
||||
Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(userIds);
|
||||
// 合计分佣订单
|
||||
Map<Long, UserBrokerageSummaryBO> userOrderSummaryMap = convertMap(userIds,
|
||||
userId -> userId,
|
||||
userId -> brokerageRecordService.summaryByUserIdAndBizTypeAndStatus(userId,
|
||||
BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus()));
|
||||
// 合计推广用户数量
|
||||
Map<Long, Long> brokerageUserCountMap = convertMap(userIds,
|
||||
userId -> userId,
|
||||
userId -> brokerageUserService.getCountByBrokerageUserId(userId));
|
||||
|
||||
// todo 合计提现
|
||||
|
||||
return success(TradeBrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,4 +19,30 @@ public class TradeBrokerageUserRespVO extends TradeBrokerageUserBaseVO {
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
// ========== 用户信息 ==========
|
||||
|
||||
@Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png")
|
||||
private String avatar;
|
||||
@Schema(description = "用户昵称", example = "李四")
|
||||
private String nickname;
|
||||
|
||||
|
||||
// ========== 推广信息 ==========
|
||||
|
||||
@Schema(description = "推广用户数量(一级)", example = "20019")
|
||||
private Integer brokerageUserCount;
|
||||
@Schema(description = "推广订单数量", example = "20019")
|
||||
private Integer brokerageOrderCount;
|
||||
@Schema(description = "推广订单金额", example = "20019")
|
||||
private Integer brokerageOrderPrice;
|
||||
|
||||
|
||||
// ========== 提现信息 ==========
|
||||
|
||||
@Schema(description = "已提现金额", example = "20019")
|
||||
private Integer withdrawPrice;
|
||||
@Schema(description = "已提现次数", example = "20019")
|
||||
private Integer withdrawCount;
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,17 @@
|
||||
package cn.iocoder.yudao.module.trade.convert.brokerage.user;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserRespVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.UserBrokerageSummaryBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 分销用户 Convert
|
||||
@ -24,4 +29,33 @@ public interface TradeBrokerageUserConvert {
|
||||
|
||||
PageResult<TradeBrokerageUserRespVO> convertPage(PageResult<TradeBrokerageUserDO> page);
|
||||
|
||||
default PageResult<TradeBrokerageUserRespVO> convertPage(PageResult<TradeBrokerageUserDO> pageResult,
|
||||
Map<Long, MemberUserRespDTO> userMap,
|
||||
Map<Long, Long> brokerageUserCountMap,
|
||||
Map<Long, UserBrokerageSummaryBO> userOrderSummaryMap) {
|
||||
PageResult<TradeBrokerageUserRespVO> result = convertPage(pageResult);
|
||||
for (TradeBrokerageUserRespVO vo : result.getList()) {
|
||||
// 用户信息
|
||||
Optional.ofNullable(userMap.get(vo.getId()))
|
||||
.ifPresent(user -> {
|
||||
vo.setNickname(user.getNickname());
|
||||
vo.setAvatar(user.getAvatar());
|
||||
});
|
||||
|
||||
// 推广用户数量(一级)
|
||||
vo.setBrokerageUserCount(MapUtil.getInt(brokerageUserCountMap, vo.getId(), 0));
|
||||
|
||||
Optional<UserBrokerageSummaryBO> orderSummaryOptional = Optional.ofNullable(userOrderSummaryMap.get(vo.getId()));
|
||||
// 推广订单数量
|
||||
vo.setBrokerageOrderCount(orderSummaryOptional.map(UserBrokerageSummaryBO::getCount).orElse(0));
|
||||
// 推广订单金额
|
||||
vo.setBrokerageOrderPrice(orderSummaryOptional.map(UserBrokerageSummaryBO::getPrice).orElse(0));
|
||||
|
||||
// todo 已提现次数
|
||||
vo.setWithdrawCount(0);
|
||||
// todo 已提现金额
|
||||
vo.setWithdrawPrice(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,11 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.TradeBrokerageRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.TradeBrokerageRecordDO;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.UserBrokerageSummaryBO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@ -46,4 +49,8 @@ public interface TradeBrokerageRecordMapper extends BaseMapperX<TradeBrokerageRe
|
||||
TradeBrokerageRecordDO::getBizId, bizId);
|
||||
}
|
||||
|
||||
@Select("select count(1), sum(price) from trade_brokerage_record where user_id = #{userId} and biz_type = #{bizType} and status = #{status}")
|
||||
UserBrokerageSummaryBO selectCountAndSumPriceByUserIdAndBizTypeAndStatus(@Param("userId") Long userId,
|
||||
@Param("bizType") Integer bizType,
|
||||
@Param("status") Integer status);
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package cn.iocoder.yudao.module.trade.service.brokerage.record;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.TradeBrokerageRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.TradeBrokerageRecordDO;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqBO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.TradeBrokerageRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.UserBrokerageSummaryBO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -44,7 +45,7 @@ public interface TradeBrokerageRecordService {
|
||||
* 取消佣金:将佣金记录,状态修改为已失效
|
||||
*
|
||||
* @param userId 会员编号
|
||||
* @param bizId 业务编号
|
||||
* @param bizId 业务编号
|
||||
*/
|
||||
void cancelBrokerage(Long userId, String bizId);
|
||||
|
||||
@ -55,4 +56,13 @@ public interface TradeBrokerageRecordService {
|
||||
*/
|
||||
int unfreezeRecord();
|
||||
|
||||
/**
|
||||
* 汇总用户佣金
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param bizType 业务类型
|
||||
* @param status 佣金状态
|
||||
* @return 用户佣金汇总
|
||||
*/
|
||||
UserBrokerageSummaryBO summaryByUserIdAndBizTypeAndStatus(Long userId, Integer bizType, Integer status);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.record.TradeBrokerageRe
|
||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqBO;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.UserBrokerageSummaryBO;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.user.TradeBrokerageUserService;
|
||||
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -203,6 +204,12 @@ public class TradeBrokerageRecordServiceImpl implements TradeBrokerageRecordServ
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserBrokerageSummaryBO summaryByUserIdAndBizTypeAndStatus(Long userId, Integer bizType, Integer status) {
|
||||
UserBrokerageSummaryBO summaryBO = tradeBrokerageRecordMapper.selectCountAndSumPriceByUserIdAndBizTypeAndStatus(userId, bizType, status);
|
||||
return summaryBO == null ? new UserBrokerageSummaryBO(0, 0) : summaryBO;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean unfreezeRecord(TradeBrokerageRecordDO record) {
|
||||
// 更新记录状态
|
||||
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.trade.service.brokerage.record.bo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 用户佣金合计 BO
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserBrokerageSummaryBO {
|
||||
/**
|
||||
* 佣金数量
|
||||
*/
|
||||
private Integer count;
|
||||
/**
|
||||
* 佣金总额
|
||||
*/
|
||||
private Integer price;
|
||||
}
|
@ -88,4 +88,11 @@ public interface TradeBrokerageUserService {
|
||||
*/
|
||||
void updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(Long id, int frozenBrokeragePrice);
|
||||
|
||||
/**
|
||||
* 获得推广用户数量(一级)
|
||||
*
|
||||
* @param brokerageUserId 推广员编号
|
||||
* @return 推广用户数量
|
||||
*/
|
||||
Long getCountByBrokerageUserId(Long brokerageUserId);
|
||||
}
|
||||
|
@ -109,4 +109,9 @@ public class TradeBrokerageUserServiceImpl implements TradeBrokerageUserService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCountByBrokerageUserId(Long brokerageUserId) {
|
||||
return brokerageUserMapper.selectCount(TradeBrokerageUserDO::getBrokerageUserId, brokerageUserId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -136,38 +136,4 @@ public class MemberUserDO extends TenantBaseDO {
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
// TODO @疯狂:看看要不要删除掉哈
|
||||
// ========== 分销相关 ==========
|
||||
|
||||
/**
|
||||
* 推广员编号
|
||||
*/
|
||||
@TableField(exist = false) // TODO 芋艿:避免报错
|
||||
private Long brokerageUserId;
|
||||
/**
|
||||
* 推广员绑定时间
|
||||
*/
|
||||
@TableField(exist = false) // TODO 芋艿:避免报错
|
||||
private LocalDateTime brokerageBindTime;
|
||||
/**
|
||||
* 是否成为推广员
|
||||
*/
|
||||
@TableField(exist = false) // TODO 芋艿:避免报错
|
||||
private Boolean brokerageEnabled;
|
||||
/**
|
||||
* 成为分销员时间
|
||||
*/
|
||||
@TableField(exist = false) // TODO 芋艿:避免报错
|
||||
private LocalDateTime brokerageTime;
|
||||
/**
|
||||
* 可用佣金
|
||||
*/
|
||||
@TableField(exist = false) // TODO 芋艿:避免报错
|
||||
private Integer brokeragePrice;
|
||||
/**
|
||||
* 冻结佣金
|
||||
*/
|
||||
@TableField(exist = false) // TODO 芋艿:避免报错
|
||||
private Integer frozenBrokeragePrice;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user