mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-15 01:54:58 +08:00
code review:分销逻辑
This commit is contained in:
parent
51899c4c13
commit
421bb7d154
@ -14,7 +14,7 @@
|
|||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
<description>
|
<description>
|
||||||
错误码 ErrorCode 的自动配置功能,提供如下功能:
|
错误码 ErrorCode 的自动配置功能,提供如下功能:
|
||||||
1. 远程读取:项目启动时,从 system-server 服务,读取数据库中的 ErrorCode 错误码,实现错误码的提水可配置;
|
1. 远程读取:项目启动时,从 system-server 服务,读取数据库中的 ErrorCode 错误码,实现错误码的提示可配置;
|
||||||
2. 自动更新:管理员在管理后台修数据库中的 ErrorCode 错误码时,项目自动从 system-server 服务加载最新的 ErrorCode 错误码;
|
2. 自动更新:管理员在管理后台修数据库中的 ErrorCode 错误码时,项目自动从 system-server 服务加载最新的 ErrorCode 错误码;
|
||||||
3. 自动写入:项目启动时,将项目本地的错误码写到 system-server 服务中,方便管理员在管理后台编辑;
|
3. 自动写入:项目启动时,将项目本地的错误码写到 system-server 服务中,方便管理员在管理后台编辑;
|
||||||
</description>
|
</description>
|
||||||
|
@ -87,7 +87,7 @@ public interface ErrorCodeConstants {
|
|||||||
// ========== 分销提现 模块 1011008000 ==========
|
// ========== 分销提现 模块 1011008000 ==========
|
||||||
ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1011008000, "佣金提现记录不存在");
|
ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1011008000, "佣金提现记录不存在");
|
||||||
ErrorCode BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING = new ErrorCode(1011008001, "佣金提现记录状态不是审核中");
|
ErrorCode BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING = new ErrorCode(1011008001, "佣金提现记录状态不是审核中");
|
||||||
ErrorCode BROKERAGE_WITHDRAW_MIN_PRICE = new ErrorCode(1011008002, "提现金额不能低于{}元");
|
ErrorCode BROKERAGE_WITHDRAW_MIN_PRICE = new ErrorCode(1011008002, "提现金额不能低于 {} 元");
|
||||||
ErrorCode BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH = new ErrorCode(1011008003, "您当前最多可提现{}元");
|
ErrorCode BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH = new ErrorCode(1011008003, "您当前最多可提现 {} 元");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,9 @@ public enum BrokerageWithdrawStatusEnum implements IntArrayValuable {
|
|||||||
WITHDRAW_FAIL(21, "提现失败"),
|
WITHDRAW_FAIL(21, "提现失败"),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// TODO @疯狂:字典现在枚举在每个模块的 DictTypeConstants 里哈;可以创建一个出来;主要是想,治理每个模块到底有多少个枚举;
|
||||||
public static final String DICT_TYPE = "BROKERAGE_WITHDRAW_STATUS";
|
public static final String DICT_TYPE = "BROKERAGE_WITHDRAW_STATUS";
|
||||||
|
|
||||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawStatusEnum::getStatus).toArray();
|
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawStatusEnum::getStatus).toArray();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +45,7 @@ public class AppBrokerageRecordController {
|
|||||||
return success(BrokerageRecordConvert.INSTANCE.convertPage02(pageResult));
|
return success(BrokerageRecordConvert.INSTANCE.convertPage02(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @疯狂:这里还有一个漏网之鱼~
|
||||||
@GetMapping("/get-product-brokerage-price")
|
@GetMapping("/get-product-brokerage-price")
|
||||||
@Operation(summary = "获得商品的分销金额")
|
@Operation(summary = "获得商品的分销金额")
|
||||||
public CommonResult<AppBrokerageProductPriceRespVO> getProductBrokeragePrice(@RequestParam("spuId") Long spuId) {
|
public CommonResult<AppBrokerageProductPriceRespVO> getProductBrokeragePrice(@RequestParam("spuId") Long spuId) {
|
||||||
|
@ -55,6 +55,7 @@ public class AppBrokerageUserController {
|
|||||||
@PreAuthenticated
|
@PreAuthenticated
|
||||||
public CommonResult<AppBrokerageUserRespVO> getBrokerageUser() {
|
public CommonResult<AppBrokerageUserRespVO> getBrokerageUser() {
|
||||||
Optional<BrokerageUserDO> user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId()));
|
Optional<BrokerageUserDO> user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId()));
|
||||||
|
// 返回数据
|
||||||
AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO()
|
AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO()
|
||||||
.setBrokerageEnabled(user.map(BrokerageUserDO::getBrokerageEnabled).orElse(false))
|
.setBrokerageEnabled(user.map(BrokerageUserDO::getBrokerageEnabled).orElse(false))
|
||||||
.setBrokeragePrice(user.map(BrokerageUserDO::getBrokeragePrice).orElse(0))
|
.setBrokeragePrice(user.map(BrokerageUserDO::getBrokeragePrice).orElse(0))
|
||||||
@ -66,6 +67,7 @@ public class AppBrokerageUserController {
|
|||||||
@Operation(summary = "绑定推广员")
|
@Operation(summary = "绑定推广员")
|
||||||
@PreAuthenticated
|
@PreAuthenticated
|
||||||
public CommonResult<Boolean> bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) {
|
public CommonResult<Boolean> bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) {
|
||||||
|
// TODO @疯狂:是不是 isNewUser 不用传递哈,交给 service 自己计算出来?
|
||||||
return success(brokerageUserService.bindBrokerageUser(getLoginUserId(), reqVO.getBindUserId(), false));
|
return success(brokerageUserService.bindBrokerageUser(getLoginUserId(), reqVO.getBindUserId(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,17 +76,17 @@ public class AppBrokerageUserController {
|
|||||||
@PreAuthenticated
|
@PreAuthenticated
|
||||||
public CommonResult<AppBrokerageUserMySummaryRespVO> getBrokerageUserSummary() {
|
public CommonResult<AppBrokerageUserMySummaryRespVO> getBrokerageUserSummary() {
|
||||||
Long userId = getLoginUserId();
|
Long userId = getLoginUserId();
|
||||||
|
// 统计 yesterdayPrice、withdrawPrice、firstBrokerageUserCount、secondBrokerageUserCount 字段
|
||||||
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
||||||
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
|
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
|
||||||
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
|
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
|
||||||
|
|
||||||
AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO()
|
AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO()
|
||||||
.setYesterdayPrice(brokerageRecordService.getSummaryPriceByUserId(userId, BrokerageRecordBizTypeEnum.ORDER.getType(), beginTime, endTime))
|
.setYesterdayPrice(brokerageRecordService.getSummaryPriceByUserId(userId, BrokerageRecordBizTypeEnum.ORDER.getType(), beginTime, endTime))
|
||||||
.setWithdrawPrice(brokerageWithdrawService.getSummaryPriceByUserIdAndStatus(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.getStatus()))
|
.setWithdrawPrice(brokerageWithdrawService.getSummaryPriceByUserIdAndStatus(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.getStatus()))
|
||||||
.setBrokeragePrice(0)
|
.setBrokeragePrice(0).setFrozenPrice(0)
|
||||||
.setFrozenPrice(0)
|
|
||||||
.setFirstBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 1))
|
.setFirstBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 1))
|
||||||
.setSecondBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 2));
|
.setSecondBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 2));
|
||||||
|
// 设置 brokeragePrice、frozenPrice 字段
|
||||||
Optional.ofNullable(brokerageUserService.getBrokerageUser(userId))
|
Optional.ofNullable(brokerageUserService.getBrokerageUser(userId))
|
||||||
.ifPresent(user -> respVO.setBrokeragePrice(user.getBrokeragePrice()).setFrozenPrice(user.getFrozenPrice()));
|
.ifPresent(user -> respVO.setBrokeragePrice(user.getBrokeragePrice()).setFrozenPrice(user.getFrozenPrice()));
|
||||||
return success(respVO);
|
return success(respVO);
|
||||||
@ -117,7 +119,6 @@ public class AppBrokerageUserController {
|
|||||||
@PreAuthenticated
|
@PreAuthenticated
|
||||||
public CommonResult<PageResult<AppBrokerageUserChildSummaryRespVO>> getBrokerageUserChildSummaryPage(
|
public CommonResult<PageResult<AppBrokerageUserChildSummaryRespVO>> getBrokerageUserChildSummaryPage(
|
||||||
AppBrokerageUserChildSummaryPageReqVO pageReqVO) {
|
AppBrokerageUserChildSummaryPageReqVO pageReqVO) {
|
||||||
// 分页查询
|
|
||||||
PageResult<AppBrokerageUserChildSummaryRespVO> pageResult = brokerageUserService.getBrokerageUserChildSummaryPage(pageReqVO, getLoginUserId());
|
PageResult<AppBrokerageUserChildSummaryRespVO> pageResult = brokerageUserService.getBrokerageUserChildSummaryPage(pageReqVO, getLoginUserId());
|
||||||
return success(pageResult);
|
return success(pageResult);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLogi
|
|||||||
@Validated
|
@Validated
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AppBrokerageWithdrawController {
|
public class AppBrokerageWithdrawController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BrokerageWithdrawService brokerageWithdrawService;
|
private BrokerageWithdrawService brokerageWithdrawService;
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ public class AppBrokerageWithdrawController {
|
|||||||
PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(
|
PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(
|
||||||
BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId()));
|
BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId()));
|
||||||
// 拼接信息
|
// 拼接信息
|
||||||
|
// TODO @疯狂:后端可以直接用 DictFrameworkUtils.getDictDataLabel() 去渲染哈;这样就不用 getDictDataLabelMap 方法了;
|
||||||
Map<String, String> statusNameMap = dictDataApi.getDictDataLabelMap(BrokerageWithdrawStatusEnum.DICT_TYPE);
|
Map<String, String> statusNameMap = dictDataApi.getDictDataLabelMap(BrokerageWithdrawStatusEnum.DICT_TYPE);
|
||||||
return success(BrokerageWithdrawConvert.INSTANCE.convertPage02(pageResult, statusNameMap));
|
return success(BrokerageWithdrawConvert.INSTANCE.convertPage02(pageResult, statusNameMap));
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|||||||
import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO;
|
import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
|
||||||
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -24,13 +25,15 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
@Validated
|
@Validated
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AppTradeConfigController {
|
public class AppTradeConfigController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TradeConfigService tradeConfigService;
|
private TradeConfigService tradeConfigService;
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得交易配置")
|
||||||
public CommonResult<AppTradeConfigRespVO> getTradeConfig() {
|
public CommonResult<AppTradeConfigRespVO> getTradeConfig() {
|
||||||
TradeConfigDO tradeConfig = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO());
|
TradeConfigDO tradeConfig = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO());
|
||||||
|
// TODO @疯狂:是不是直接 convert 就好啦;
|
||||||
AppTradeConfigRespVO respVO = new AppTradeConfigRespVO()
|
AppTradeConfigRespVO respVO = new AppTradeConfigRespVO()
|
||||||
.setBrokeragePosterUrls(tradeConfig.getBrokeragePostUrls())
|
.setBrokeragePosterUrls(tradeConfig.getBrokeragePostUrls())
|
||||||
.setBrokerageFrozenDays(tradeConfig.getBrokerageFrozenDays())
|
.setBrokerageFrozenDays(tradeConfig.getBrokerageFrozenDays())
|
||||||
|
@ -18,6 +18,7 @@ public class AppTradeConfigRespVO {
|
|||||||
@Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
@Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||||
private Integer brokerageWithdrawMinPrice;
|
private Integer brokerageWithdrawMinPrice;
|
||||||
|
|
||||||
|
// TODO @疯狂:如果是 list,要不加个 s,复数;
|
||||||
@Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
|
@Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
|
||||||
private List<Integer> brokerageWithdrawType;
|
private List<Integer> brokerageWithdrawType;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
@Validated
|
@Validated
|
||||||
public class AppDeliverConfigController {
|
public class AppDeliverConfigController {
|
||||||
|
|
||||||
|
// TODO @芋艿:这里后面干掉,合并到 AppTradeConfigController 中
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得配送配置")
|
@Operation(summary = "获得配送配置")
|
||||||
public CommonResult<AppDeliveryConfigRespVO> getDeliveryConfig() {
|
public CommonResult<AppDeliveryConfigRespVO> getDeliveryConfig() {
|
||||||
|
@ -58,12 +58,12 @@ public interface BrokerageUserConvert {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
default PageResult<AppBrokerageUserRankByUserCountRespVO> convertPage03(PageResult<AppBrokerageUserRankByUserCountRespVO> pageResult, Map<Long, MemberUserRespDTO> userMap) {
|
default PageResult<AppBrokerageUserRankByUserCountRespVO> convertPage03(PageResult<AppBrokerageUserRankByUserCountRespVO> pageResult,
|
||||||
for (AppBrokerageUserRankByUserCountRespVO vo : pageResult.getList()) {
|
Map<Long, MemberUserRespDTO> userMap) {
|
||||||
copyTo(userMap.get(vo.getId()), vo);
|
pageResult.getList().forEach(vo -> copyTo(userMap.get(vo.getId()), vo));
|
||||||
}
|
|
||||||
return pageResult;
|
return pageResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByUserCountRespVO to);
|
void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByUserCountRespVO to);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import java.util.List;
|
|||||||
public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
|
public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
|
||||||
|
|
||||||
default PageResult<BrokerageRecordDO> selectPage(BrokerageRecordPageReqVO reqVO) {
|
default PageResult<BrokerageRecordDO> selectPage(BrokerageRecordPageReqVO reqVO) {
|
||||||
// 分页查询
|
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<BrokerageRecordDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<BrokerageRecordDO>()
|
||||||
.eqIfPresent(BrokerageRecordDO::getUserId, reqVO.getUserId())
|
.eqIfPresent(BrokerageRecordDO::getUserId, reqVO.getUserId())
|
||||||
.eqIfPresent(BrokerageRecordDO::getBizType, reqVO.getBizType())
|
.eqIfPresent(BrokerageRecordDO::getBizType, reqVO.getBizType())
|
||||||
@ -59,7 +58,8 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
|
|||||||
@Param("bizType") Integer bizType,
|
@Param("bizType") Integer bizType,
|
||||||
@Param("status") Integer status);
|
@Param("status") Integer status);
|
||||||
|
|
||||||
@Select("SELECT SUM(price) FROM trade_brokerage_record WHERE user_id = #{userId} AND biz_type = #{bizType} " +
|
@Select("SELECT SUM(price) FROM trade_brokerage_record " +
|
||||||
|
"WHERE user_id = #{userId} AND biz_type = #{bizType} " +
|
||||||
"AND create_time BETWEEN #{beginTime} AND #{endTime}")
|
"AND create_time BETWEEN #{beginTime} AND #{endTime}")
|
||||||
Integer selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(@Param("userId") Long userId,
|
Integer selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(@Param("userId") Long userId,
|
||||||
@Param("bizType") Integer bizType,
|
@Param("bizType") Integer bizType,
|
||||||
@ -76,4 +76,5 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
|
|||||||
@Param("status") Integer status,
|
@Param("status") Integer status,
|
||||||
@Param("beginTime") LocalDateTime beginTime,
|
@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -145,4 +145,5 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> {
|
|||||||
default List<BrokerageUserDO> selectListByBindUserId(Long bindUserId) {
|
default List<BrokerageUserDO> selectListByBindUserId(Long bindUserId) {
|
||||||
return selectList(BrokerageUserDO::getBindUserId, bindUserId);
|
return selectList(BrokerageUserDO::getBindUserId, bindUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,8 @@ public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO
|
|||||||
.eq(BrokerageWithdrawDO::getStatus, status));
|
.eq(BrokerageWithdrawDO::getStatus, status));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Select("SELECT SUM(price) FROM trade_brokerage_withdraw WHERE user_id = #{userId} AND status = #{status}")
|
@Select("SELECT SUM(price) FROM trade_brokerage_withdraw " +
|
||||||
|
"WHERE user_id = #{userId} AND status = #{status}")
|
||||||
Integer selectSummaryPriceByUserIdAndStatus(@Param("userId") Long userId, @Param("status") Integer status);
|
Integer selectSummaryPriceByUserIdAndStatus(@Param("userId") Long userId, @Param("status") Integer status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public interface BrokerageRecordService {
|
|||||||
PageResult<BrokerageRecordDO> getBrokerageRecordPage(BrokerageRecordPageReqVO pageReqVO);
|
PageResult<BrokerageRecordDO> getBrokerageRecordPage(BrokerageRecordPageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加佣金
|
* 增加佣金【多级分佣】
|
||||||
*
|
*
|
||||||
* @param userId 会员编号
|
* @param userId 会员编号
|
||||||
* @param bizType 业务类型
|
* @param bizType 业务类型
|
||||||
@ -46,7 +46,7 @@ public interface BrokerageRecordService {
|
|||||||
void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, @Valid List<BrokerageAddReqBO> list);
|
void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, @Valid List<BrokerageAddReqBO> list);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加佣金
|
* 增加佣金【只针对自己】
|
||||||
*
|
*
|
||||||
* @param userId 会员编号
|
* @param userId 会员编号
|
||||||
* @param bizType 业务类型
|
* @param bizType 业务类型
|
||||||
@ -95,6 +95,7 @@ public interface BrokerageRecordService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得用户佣金排行分页列表(基于佣金总数)
|
* 获得用户佣金排行分页列表(基于佣金总数)
|
||||||
|
*
|
||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 排行榜分页
|
* @return 排行榜分页
|
||||||
*/
|
*/
|
||||||
@ -108,4 +109,5 @@ public interface BrokerageRecordService {
|
|||||||
* @return 用户的排名
|
* @return 用户的排名
|
||||||
*/
|
*/
|
||||||
Integer getUserRankByPrice(Long userId, LocalDateTime[] times);
|
Integer getUserRankByPrice(Long userId, LocalDateTime[] times);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -240,10 +240,11 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
|||||||
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
|
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @疯狂:这个求出来,应该是不准的?例如说超过 100+ 名后?
|
||||||
@Override
|
@Override
|
||||||
public Integer getUserRankByPrice(Long userId, LocalDateTime[] times) {
|
public Integer getUserRankByPrice(Long userId, LocalDateTime[] times) {
|
||||||
AppBrokerageUserRankPageReqVO pageParam = new AppBrokerageUserRankPageReqVO().setTimes(times);
|
AppBrokerageUserRankPageReqVO pageParam = new AppBrokerageUserRankPageReqVO().setTimes(times);
|
||||||
// 取前100名
|
// 取前 100 名
|
||||||
pageParam.setPageSize(100);
|
pageParam.setPageSize(100);
|
||||||
PageResult<AppBrokerageUserRankByPriceRespVO> pageResult = getBrokerageUserChildSummaryPageByPrice(pageParam);
|
PageResult<AppBrokerageUserRankByPriceRespVO> pageResult = getBrokerageUserChildSummaryPageByPrice(pageParam);
|
||||||
// 获得索引
|
// 获得索引
|
||||||
@ -255,21 +256,23 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) {
|
public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) {
|
||||||
// 校验佣金余额
|
// 1. 校验佣金余额
|
||||||
BrokerageUserDO user = brokerageUserService.getBrokerageUser(userId);
|
BrokerageUserDO user = brokerageUserService.getBrokerageUser(userId);
|
||||||
int balance = Optional.of(user)
|
int balance = Optional.of(user)
|
||||||
.map(BrokerageUserDO::getBrokeragePrice).orElse(0);
|
.map(BrokerageUserDO::getBrokeragePrice).orElse(0);
|
||||||
if (balance + brokeragePrice < 0) {
|
if (balance + brokeragePrice < 0) {
|
||||||
|
// TODO @疯狂:要不 MoneyUtils 那,统一搞个 format 金额的方法?然后把分到元的字符串,统一收口掉;
|
||||||
throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance));
|
throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扣减佣金余额
|
// 2. 更新佣金余额
|
||||||
boolean success = brokerageUserService.updateUserPrice(userId, brokeragePrice);
|
boolean success = brokerageUserService.updateUserPrice(userId, brokeragePrice);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
// 失败时,则抛出异常。只会出现扣减佣金时,余额不足的情况
|
||||||
throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance));
|
throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增记录
|
// 3. 新增记录
|
||||||
BrokerageRecordDO record = BrokerageRecordConvert.INSTANCE.convert(user, bizType, bizId, 0, brokeragePrice,
|
BrokerageRecordDO record = BrokerageRecordConvert.INSTANCE.convert(user, bizType, bizId, 0, brokeragePrice,
|
||||||
null, title, null, null);
|
null, title, null, null);
|
||||||
brokerageRecordMapper.insert(record);
|
brokerageRecordMapper.insert(record);
|
||||||
|
@ -67,7 +67,6 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
|||||||
public void updateBrokerageUserId(Long id, Long bindUserId) {
|
public void updateBrokerageUserId(Long id, Long bindUserId) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
BrokerageUserDO brokerageUser = validateBrokerageUserExists(id);
|
BrokerageUserDO brokerageUser = validateBrokerageUserExists(id);
|
||||||
|
|
||||||
// 绑定关系未发生变化
|
// 绑定关系未发生变化
|
||||||
if (Objects.equals(brokerageUser.getBindUserId(), bindUserId)) {
|
if (Objects.equals(brokerageUser.getBindUserId(), bindUserId)) {
|
||||||
return;
|
return;
|
||||||
@ -185,6 +184,13 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补全绑定用户的字段
|
||||||
|
*
|
||||||
|
* @param bindUserId 绑定的用户编号
|
||||||
|
* @param brokerageUser update 对象
|
||||||
|
* @return 补全后的 update 对象
|
||||||
|
*/
|
||||||
private BrokerageUserDO fillBindUserData(Long bindUserId, BrokerageUserDO brokerageUser) {
|
private BrokerageUserDO fillBindUserData(Long bindUserId, BrokerageUserDO brokerageUser) {
|
||||||
return brokerageUser.setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now());
|
return brokerageUser.setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now());
|
||||||
}
|
}
|
||||||
@ -255,6 +261,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 下级不能绑定自己的上级
|
// 下级不能绑定自己的上级
|
||||||
|
// TODO @疯狂:这里是不是查询不到的时候,应该有个 break 结束循环哈
|
||||||
for (int i = 0; i <= Short.MAX_VALUE; i++) {
|
for (int i = 0; i <= Short.MAX_VALUE; i++) {
|
||||||
if (Objects.equals(bindUser.getBindUserId(), user.getId())) {
|
if (Objects.equals(bindUser.getBindUserId(), user.getId())) {
|
||||||
throw exception(BROKERAGE_BIND_LOOP);
|
throw exception(BROKERAGE_BIND_LOOP);
|
||||||
@ -263,18 +270,24 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据绑定用户编号,获得绑定用户编号列表
|
||||||
|
*
|
||||||
|
* @param bindUserId 绑定用户编号
|
||||||
|
* @param level 绑定用户的层级。
|
||||||
|
* 如果 level 为空,则查询 1+2 两个层级
|
||||||
|
* @return 绑定用户编号列表
|
||||||
|
*/
|
||||||
private List<Long> buildBindUserIdsByLevel(Long bindUserId, Integer level) {
|
private List<Long> buildBindUserIdsByLevel(Long bindUserId, Integer level) {
|
||||||
|
Assert.isTrue(level == null || level <= 2, "目前只支持 level 小于等于 2");
|
||||||
List<Long> bindUserIds = CollUtil.newArrayList();
|
List<Long> bindUserIds = CollUtil.newArrayList();
|
||||||
if (level == null || level == 1) {
|
if (level == null || level == 1) {
|
||||||
bindUserIds.add(bindUserId);
|
bindUserIds.add(bindUserId);
|
||||||
}
|
}
|
||||||
if (level == null || level == 2) {
|
if (level == null || level == 2) {
|
||||||
List<Long> firstUserIds = convertList(brokerageUserMapper.selectListByBindUserId(bindUserId), BrokerageUserDO::getId);
|
bindUserIds.addAll(convertList(brokerageUserMapper.selectListByBindUserId(bindUserId), BrokerageUserDO::getId));
|
||||||
bindUserIds.addAll(firstUserIds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bindUserIds;
|
return bindUserIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ public interface BrokerageWithdrawService {
|
|||||||
* @param status 审核状态
|
* @param status 审核状态
|
||||||
* @param auditReason 驳回原因
|
* @param auditReason 驳回原因
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason);
|
void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,14 +4,13 @@
|
|||||||
|
|
||||||
<select id="selectSummaryPageByUserId"
|
<select id="selectSummaryPageByUserId"
|
||||||
resultType="cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO">
|
resultType="cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO">
|
||||||
SELECT bu.id, bu.bind_user_time AS brokerageTime,
|
SELECT bu.id, bu.bind_user_time AS brokerageTime, u.nickname, u.avatar,
|
||||||
u.nickname, u.avatar,
|
|
||||||
(SELECT SUM(price) FROM trade_brokerage_record r
|
(SELECT SUM(price) FROM trade_brokerage_record r
|
||||||
WHERE r.user_id = u.id AND biz_type = 1 AND r.status = 1 AND r.deleted = FALSE) AS brokeragePrice,
|
WHERE r.user_id = u.id AND biz_type = 1 AND r.status = 1 AND r.deleted = FALSE) AS brokeragePrice,
|
||||||
(SELECT COUNT(1) FROM trade_brokerage_record r
|
(SELECT COUNT(1) FROM trade_brokerage_record r
|
||||||
WHERE r.user_id = u.id AND biz_type = 1 AND r.status = 1 AND r.deleted = FALSE) AS brokerageOrderCount,
|
WHERE r.user_id = u.id AND biz_type = 1 AND r.status = 1 AND r.deleted = FALSE) AS brokerageOrderCount,
|
||||||
(SELECT COUNT(1) FROM trade_brokerage_user c
|
(SELECT COUNT(1) FROM trade_brokerage_user c
|
||||||
WHERE c.bind_user_id = u.id AND c.deleted = FALSE) AS brokerageUserCount
|
WHERE c.bind_user_id = u.id AND c.deleted = FALSE) AS brokerageUserCount
|
||||||
FROM member_user AS u
|
FROM member_user AS u
|
||||||
JOIN trade_brokerage_user AS bu ON bu.id = u.id
|
JOIN trade_brokerage_user AS bu ON bu.id = u.id
|
||||||
<where>
|
<where>
|
||||||
@ -22,8 +21,7 @@
|
|||||||
AND bu.bind_user_id = #{userId}
|
AND bu.bind_user_id = #{userId}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.level == 2">
|
<if test="param.level == 2">
|
||||||
AND bu.bind_user_id = (SELECT id FROM trade_brokerage_user c WHERE c.bind_user_id =
|
AND bu.bind_user_id IN (SELECT id FROM trade_brokerage_user c WHERE c.bind_user_id = #{userId})
|
||||||
#{userId})
|
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
<choose>
|
<choose>
|
||||||
@ -41,4 +39,5 @@
|
|||||||
</otherwise>
|
</otherwise>
|
||||||
</choose>
|
</choose>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -38,6 +38,7 @@ public class DictDataApiImpl implements DictDataApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DictDataRespDTO> getDictDataList(String type) {
|
public List<DictDataRespDTO> getDictDataList(String type) {
|
||||||
|
// TODO @疯狂:不用 DictDataExportReqVO 哈;可以考虑直接加个允许传递 type 传递的
|
||||||
List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(type));
|
List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(type));
|
||||||
return DictDataConvert.INSTANCE.convertList04(list);
|
return DictDataConvert.INSTANCE.convertList04(list);
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,12 @@ public class AppDictDataController {
|
|||||||
@Resource
|
@Resource
|
||||||
private DictDataService dictDataService;
|
private DictDataService dictDataService;
|
||||||
|
|
||||||
|
// TODO @疯狂:暂时不用 path 参数哈;主要考虑一些中间件支持的一般,例如说链路追踪之类的;还是作为一个参数噶;
|
||||||
@GetMapping("/type/{dictType}")
|
@GetMapping("/type/{dictType}")
|
||||||
@Operation(summary = "根据字典类型查询字典数据信息")
|
@Operation(summary = "根据字典类型查询字典数据信息")
|
||||||
public CommonResult<List<AppDictDataRespVO>> getDicts(@PathVariable String dictType) {
|
public CommonResult<List<AppDictDataRespVO>> getDictDataList(@PathVariable String dictType) {
|
||||||
List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(dictType));
|
List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(dictType));
|
||||||
return success(DictDataConvert.INSTANCE.convertList03(list));
|
return success(DictDataConvert.INSTANCE.convertList03(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ import lombok.NoArgsConstructor;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class AppDictDataRespVO extends DictDataBaseVO {
|
public class AppDictDataRespVO extends DictDataBaseVO {
|
||||||
|
|
||||||
|
// TODO @疯狂:app 的接口,不集成 admin 接口的 vo 哈;看看是不是只返回必要的字段,类似 remark、sort 不好返回的哈;
|
||||||
|
|
||||||
@Schema(description = "字典数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "字典数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user