mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 03:30:06 +08:00
trade: 增加分销 API
This commit is contained in:
parent
1ead368595
commit
6ef36d5ca6
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.trade.api.brokerage;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.api.brokerage.dto.BrokerageUserDTO;
|
||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum;
|
||||
|
||||
/**
|
||||
* 分销 API 接口
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
public interface BrokerageApi {
|
||||
|
||||
/**
|
||||
* 获得分销用户
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 分销用户信息
|
||||
*/
|
||||
BrokerageUserDTO getBrokerageUser(Long userId);
|
||||
|
||||
/**
|
||||
* 绑定推广员
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param bindUserId 推广员编号
|
||||
* @param bindMode 绑定模式 {@link BrokerageBindModeEnum}
|
||||
* @return 是否绑定
|
||||
*/
|
||||
boolean bindUser(Long userId, Long bindUserId, Integer bindMode);
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.trade.api.brokerage.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分销用户 DTO
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Data
|
||||
public class BrokerageUserDTO {
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
* <p>
|
||||
* 对应 MemberUserDO 的 id 字段
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 推广员编号
|
||||
* <p>
|
||||
* 关联 MemberUserDO 的 id 字段
|
||||
*/
|
||||
private Long bindUserId;
|
||||
/**
|
||||
* 推广员绑定时间
|
||||
*/
|
||||
private LocalDateTime bindUserTime;
|
||||
|
||||
/**
|
||||
* 推广资格
|
||||
*/
|
||||
private Boolean brokerageEnabled;
|
||||
/**
|
||||
* 成为分销员时间
|
||||
*/
|
||||
private LocalDateTime brokerageTime;
|
||||
|
||||
/**
|
||||
* 可用佣金
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 冻结佣金
|
||||
*/
|
||||
private Integer frozenPrice;
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.trade.api.brokerage;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.api.brokerage.dto.BrokerageUserDTO;
|
||||
import cn.iocoder.yudao.module.trade.convert.brokerage.user.BrokerageUserConvert;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.user.BrokerageUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 分销 API 接口实现类
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class BrokerageApiImpl implements BrokerageApi {
|
||||
|
||||
@Resource
|
||||
private BrokerageUserService brokerageUserService;
|
||||
|
||||
public BrokerageUserDTO getBrokerageUser(Long userId) {
|
||||
return BrokerageUserConvert.INSTANCE.convertDTO(brokerageUserService.getBrokerageUser(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bindUser(Long userId, Long bindUserId, Integer bindMode) {
|
||||
// todo 待实现
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ 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.api.brokerage.dto.BrokerageUserDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.BrokerageUserRespVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
|
||||
@ -58,4 +59,6 @@ public interface BrokerageUserConvert {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
BrokerageUserDTO convertDTO(BrokerageUserDO brokerageUser);
|
||||
}
|
||||
|
@ -33,6 +33,11 @@
|
||||
<artifactId>yudao-module-infra-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-trade-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
|
@ -8,6 +8,8 @@ import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.service.level.MemberLevelService;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import cn.iocoder.yudao.module.trade.api.brokerage.BrokerageApi;
|
||||
import cn.iocoder.yudao.module.trade.api.brokerage.dto.BrokerageUserDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Optional;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
@ -33,14 +36,18 @@ public class AppMemberUserController {
|
||||
@Resource
|
||||
private MemberLevelService levelService;
|
||||
|
||||
@Resource
|
||||
private BrokerageApi brokerageApi;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得基本信息")
|
||||
@PreAuthenticated
|
||||
public CommonResult<AppMemberUserInfoRespVO> getUserInfo() {
|
||||
MemberUserDO user = userService.getUser(getLoginUserId());
|
||||
MemberLevelDO level = levelService.getLevel(user.getLevelId());
|
||||
BrokerageUserDTO brokerageUser = brokerageApi.getBrokerageUser(user.getId());
|
||||
return success(MemberUserConvert.INSTANCE.convert(user, level)
|
||||
.setBrokerageEnabled(true) // TODO @疯狂:这里我先写死,后面改成 db 返回;
|
||||
.setBrokerageEnabled(Optional.ofNullable(brokerageUser).map(BrokerageUserDTO::getBrokerageEnabled).orElse(false))
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user