mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-31 17:40:05 +08:00
trade: 分销业务从 member 模块 转移到 trade模块
This commit is contained in:
parent
a68691f2d9
commit
9336a0a102
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.enums.brokerage;
|
package cn.iocoder.yudao.module.trade.enums.brokerage;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.enums.brokerage;
|
package cn.iocoder.yudao.module.trade.enums.brokerage;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.enums.brokerage;
|
package cn.iocoder.yudao.module.trade.enums.brokerage;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.enums.brokerage;
|
package cn.iocoder.yudao.module.trade.enums.brokerage;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.enums.brokerage;
|
package cn.iocoder.yudao.module.trade.enums.brokerage;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.enums.brokerage;
|
package cn.iocoder.yudao.module.trade.enums.brokerage;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
@ -54,6 +54,10 @@
|
|||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
|
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-spring-boot-starter-biz-ip</artifactId>
|
<artifactId>yudao-spring-boot-starter-biz-ip</artifactId>
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.brokerage.record;
|
package cn.iocoder.yudao.module.trade.controller.admin.brokerage.record;
|
||||||
|
|
||||||
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.brokerage.record.vo.MemberBrokerageRecordPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordRespVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordRespVO;
|
||||||
import cn.iocoder.yudao.module.member.convert.brokerage.record.MemberBrokerageRecordConvert;
|
import cn.iocoder.yudao.module.trade.convert.brokerage.record.MemberBrokerageRecordConvert;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
||||||
import cn.iocoder.yudao.module.member.service.brokerage.record.MemberBrokerageRecordService;
|
import cn.iocoder.yudao.module.trade.service.brokerage.record.MemberBrokerageRecordService;
|
||||||
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;
|
||||||
@ -24,7 +24,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 佣金记录")
|
@Tag(name = "管理后台 - 佣金记录")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/member/member-brokerage-record")
|
@RequestMapping("/trade/member-brokerage-record")
|
||||||
@Validated
|
@Validated
|
||||||
public class MemberBrokerageRecordController {
|
public class MemberBrokerageRecordController {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo;
|
package cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo;
|
package cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo;
|
package cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.trade.controller.admin.config.vo;
|
package cn.iocoder.yudao.module.trade.controller.admin.config.vo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageBindModeEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageEnabledConditionEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageWithdrawTypeEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Range;
|
import org.hibernate.validator.constraints.Range;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.member.convert.brokerage.record;
|
package cn.iocoder.yudao.module.trade.convert.brokerage.record;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordRespVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordRespVO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordBizTypeEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordStatusEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ public interface MemberBrokerageRecordConvert {
|
|||||||
|
|
||||||
PageResult<MemberBrokerageRecordRespVO> convertPage(PageResult<MemberBrokerageRecordDO> page);
|
PageResult<MemberBrokerageRecordRespVO> convertPage(PageResult<MemberBrokerageRecordDO> page);
|
||||||
|
|
||||||
default MemberBrokerageRecordDO convert(MemberUserDO user, String bizId, int brokerageFrozenDays, int brokerage, LocalDateTime unfreezeTime) {
|
default MemberBrokerageRecordDO convert(TradeBrokerageUserDO user, String bizId, int brokerageFrozenDays, int brokerage, LocalDateTime unfreezeTime) {
|
||||||
// 不冻结时,佣金直接就是结算状态
|
// 不冻结时,佣金直接就是结算状态
|
||||||
Integer status = brokerageFrozenDays > 0
|
Integer status = brokerageFrozenDays > 0
|
||||||
? BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus()
|
? BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus()
|
@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.common.util.string.StrUtils;
|
|||||||
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
|
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
|
||||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||||
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
||||||
import cn.iocoder.yudao.module.member.api.brokerage.dto.BrokerageAddReqDTO;
|
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqDTO;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.enums.DictTypeConstants;
|
import cn.iocoder.yudao.module.pay.enums.DictTypeConstants;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record;
|
package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordBizTypeEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordStatusEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.config;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler;
|
import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageBindModeEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageEnabledConditionEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageWithdrawTypeEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.member.dal.mysql.brokerage.record;
|
package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.record;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
@ -1,10 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user;
|
package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserPageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,4 +25,79 @@ public interface TradeBrokerageUserMapper extends BaseMapperX<TradeBrokerageUser
|
|||||||
.orderByDesc(TradeBrokerageUserDO::getId));
|
.orderByDesc(TradeBrokerageUserDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户可用佣金(增加)
|
||||||
|
*
|
||||||
|
* @param id 用户编号
|
||||||
|
* @param incrCount 增加佣金(正数)
|
||||||
|
*/
|
||||||
|
default void updateBrokeragePriceIncr(Long id, int incrCount) {
|
||||||
|
Assert.isTrue(incrCount > 0);
|
||||||
|
LambdaUpdateWrapper<TradeBrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<TradeBrokerageUserDO>()
|
||||||
|
.setSql(" brokerage_price = brokerage_price + " + incrCount)
|
||||||
|
.eq(TradeBrokerageUserDO::getId, id);
|
||||||
|
update(null, lambdaUpdateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户可用佣金(减少)
|
||||||
|
* 注意:理论上佣金可能已经提现,这时会扣出负数,确保平台不会造成损失
|
||||||
|
*
|
||||||
|
* @param id 用户编号
|
||||||
|
* @param incrCount 增加佣金(负数)
|
||||||
|
*/
|
||||||
|
default void updateBrokeragePriceDecr(Long id, int incrCount) {
|
||||||
|
Assert.isTrue(incrCount < 0);
|
||||||
|
LambdaUpdateWrapper<TradeBrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<TradeBrokerageUserDO>()
|
||||||
|
.setSql(" brokerage_price = brokerage_price + " + incrCount) // 负数,所以使用 + 号
|
||||||
|
.eq(TradeBrokerageUserDO::getId, id);
|
||||||
|
update(null, lambdaUpdateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户冻结佣金(增加)
|
||||||
|
*
|
||||||
|
* @param id 用户编号
|
||||||
|
* @param incrCount 增加冻结佣金(正数)
|
||||||
|
*/
|
||||||
|
default void updateFrozenBrokeragePriceIncr(Long id, int incrCount) {
|
||||||
|
Assert.isTrue(incrCount > 0);
|
||||||
|
LambdaUpdateWrapper<TradeBrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<TradeBrokerageUserDO>()
|
||||||
|
.setSql(" frozen_brokerage_price = frozen_brokerage_price + " + incrCount)
|
||||||
|
.eq(TradeBrokerageUserDO::getId, id);
|
||||||
|
update(null, lambdaUpdateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户冻结佣金(减少)
|
||||||
|
* 注意:理论上冻结佣金可能已经解冻,这时会扣出负数,确保平台不会造成损失
|
||||||
|
*
|
||||||
|
* @param id 用户编号
|
||||||
|
* @param incrCount 减少冻结佣金(负数)
|
||||||
|
*/
|
||||||
|
default void updateFrozenBrokeragePriceDecr(Long id, int incrCount) {
|
||||||
|
Assert.isTrue(incrCount < 0);
|
||||||
|
LambdaUpdateWrapper<TradeBrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<TradeBrokerageUserDO>()
|
||||||
|
.setSql(" frozen_brokerage_price = frozen_brokerage_price + " + incrCount) // 负数,所以使用 + 号
|
||||||
|
.eq(TradeBrokerageUserDO::getId, id);
|
||||||
|
update(null, lambdaUpdateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户冻结佣金(减少), 更新用户佣金(增加)
|
||||||
|
*
|
||||||
|
* @param id 用户编号
|
||||||
|
* @param incrCount 减少冻结佣金(负数)
|
||||||
|
* @return 更新条数
|
||||||
|
*/
|
||||||
|
default int updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(Long id, int incrCount) {
|
||||||
|
Assert.isTrue(incrCount < 0);
|
||||||
|
LambdaUpdateWrapper<TradeBrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<TradeBrokerageUserDO>()
|
||||||
|
.setSql(" frozen_brokerage_price = frozen_brokerage_price + " + incrCount + // 负数,所以使用 + 号
|
||||||
|
", brokerage_price = brokerage_price + " + -incrCount) // 负数,所以使用 - 号
|
||||||
|
.eq(TradeBrokerageUserDO::getId, id)
|
||||||
|
.ge(TradeBrokerageUserDO::getFrozenBrokeragePrice, -incrCount); // cas 逻辑
|
||||||
|
return update(null, lambdaUpdateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.member.job.brokerage;
|
package cn.iocoder.yudao.module.trade.job.brokerage;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||||
import cn.iocoder.yudao.module.member.service.brokerage.record.MemberBrokerageRecordService;
|
import cn.iocoder.yudao.module.trade.service.brokerage.record.MemberBrokerageRecordService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.member.service.brokerage.record;
|
package cn.iocoder.yudao.module.trade.service.brokerage.record;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.member.api.brokerage.dto.BrokerageAddReqDTO;
|
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqDTO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.service.brokerage.record;
|
package cn.iocoder.yudao.module.trade.service.brokerage.record;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.BooleanUtil;
|
import cn.hutool.core.util.BooleanUtil;
|
||||||
@ -6,17 +6,17 @@ import cn.hutool.core.util.NumberUtil;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.member.api.brokerage.dto.BrokerageAddReqDTO;
|
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqDTO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.convert.brokerage.record.MemberBrokerageRecordConvert;
|
import cn.iocoder.yudao.module.trade.convert.brokerage.record.MemberBrokerageRecordConvert;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointConfigDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.brokerage.record.MemberBrokerageRecordMapper;
|
import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.record.MemberBrokerageRecordMapper;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordBizTypeEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordStatusEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
|
||||||
import cn.iocoder.yudao.module.member.service.point.MemberPointConfigService;
|
import cn.iocoder.yudao.module.trade.service.brokerage.user.TradeBrokerageUserService;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -42,9 +42,9 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe
|
|||||||
@Resource
|
@Resource
|
||||||
private MemberBrokerageRecordMapper memberBrokerageRecordMapper;
|
private MemberBrokerageRecordMapper memberBrokerageRecordMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private MemberPointConfigService memberConfigService;
|
private TradeConfigService tradeConfigService;
|
||||||
@Resource
|
@Resource
|
||||||
private MemberUserService memberUserService;
|
private TradeBrokerageUserService tradeBrokerageUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MemberBrokerageRecordDO getMemberBrokerageRecord(Integer id) {
|
public MemberBrokerageRecordDO getMemberBrokerageRecord(Integer id) {
|
||||||
@ -59,7 +59,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void addBrokerage(Long buyerId, List<BrokerageAddReqDTO> list) {
|
public void addBrokerage(Long buyerId, List<BrokerageAddReqDTO> list) {
|
||||||
MemberPointConfigDO memberConfig = memberConfigService.getPointConfig();
|
TradeConfigDO memberConfig = tradeConfigService.getTradeConfig();
|
||||||
// 0 未启用分销功能
|
// 0 未启用分销功能
|
||||||
if (memberConfig == null || !BooleanUtil.isTrue(memberConfig.getBrokerageEnabled())) {
|
if (memberConfig == null || !BooleanUtil.isTrue(memberConfig.getBrokerageEnabled())) {
|
||||||
log.warn("[addBrokerage][增加佣金失败:brokerageEnabled 未配置,buyerId({})", buyerId);
|
log.warn("[addBrokerage][增加佣金失败:brokerageEnabled 未配置,buyerId({})", buyerId);
|
||||||
@ -67,7 +67,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1.1 获得一级推广人
|
// 1.1 获得一级推广人
|
||||||
MemberUserDO firstUser = memberUserService.getBrokerageUser(buyerId);
|
TradeBrokerageUserDO firstUser = tradeBrokerageUserService.getInviteBrokerageUser(buyerId);
|
||||||
if (firstUser == null || !BooleanUtil.isTrue(firstUser.getBrokerageEnabled())) {
|
if (firstUser == null || !BooleanUtil.isTrue(firstUser.getBrokerageEnabled())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe
|
|||||||
|
|
||||||
|
|
||||||
// 2.1 获得二级推广员
|
// 2.1 获得二级推广员
|
||||||
MemberUserDO secondUser = memberUserService.getUser(firstUser.getBrokerageUserId());
|
TradeBrokerageUserDO secondUser = tradeBrokerageUserService.getBrokerageUser(firstUser.getBrokerageUserId());
|
||||||
if (secondUser == null || !BooleanUtil.isTrue(secondUser.getBrokerageEnabled())) {
|
if (secondUser == null || !BooleanUtil.isTrue(secondUser.getBrokerageEnabled())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -103,9 +103,9 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus().equals(record.getStatus())) {
|
if (BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus().equals(record.getStatus())) {
|
||||||
memberUserService.updateUserFrozenBrokeragePrice(userId, -record.getPrice());
|
tradeBrokerageUserService.updateUserFrozenBrokeragePrice(userId, -record.getPrice());
|
||||||
} else if (BrokerageRecordStatusEnum.SETTLEMENT.getStatus().equals(record.getStatus())) {
|
} else if (BrokerageRecordStatusEnum.SETTLEMENT.getStatus().equals(record.getStatus())) {
|
||||||
memberUserService.updateUserBrokeragePrice(userId, -record.getPrice());
|
tradeBrokerageUserService.updateUserBrokeragePrice(userId, -record.getPrice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe
|
|||||||
* @param brokeragePercent 佣金比例
|
* @param brokeragePercent 佣金比例
|
||||||
* @param skuBrokeragePriceFun 商品 SKU 设置的佣金
|
* @param skuBrokeragePriceFun 商品 SKU 设置的佣金
|
||||||
*/
|
*/
|
||||||
private void addBrokerage(MemberUserDO user, List<BrokerageAddReqDTO> list, Integer brokerageFrozenDays,
|
private void addBrokerage(TradeBrokerageUserDO user, List<BrokerageAddReqDTO> list, Integer brokerageFrozenDays,
|
||||||
Integer brokeragePercent, Function<BrokerageAddReqDTO, Integer> skuBrokeragePriceFun) {
|
Integer brokeragePercent, Function<BrokerageAddReqDTO, Integer> skuBrokeragePriceFun) {
|
||||||
// 处理冻结时间
|
// 处理冻结时间
|
||||||
brokerageFrozenDays = ObjectUtil.defaultIfNull(brokerageFrozenDays, 0);
|
brokerageFrozenDays = ObjectUtil.defaultIfNull(brokerageFrozenDays, 0);
|
||||||
@ -170,10 +170,10 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe
|
|||||||
|
|
||||||
if (brokerageFrozenDays > 0) {
|
if (brokerageFrozenDays > 0) {
|
||||||
// 更新用户冻结佣金
|
// 更新用户冻结佣金
|
||||||
memberUserService.updateUserFrozenBrokeragePrice(user.getId(), totalBrokerage);
|
tradeBrokerageUserService.updateUserFrozenBrokeragePrice(user.getId(), totalBrokerage);
|
||||||
} else {
|
} else {
|
||||||
// 更新用户可用佣金
|
// 更新用户可用佣金
|
||||||
memberUserService.updateUserBrokeragePrice(user.getId(), totalBrokerage);
|
tradeBrokerageUserService.updateUserBrokeragePrice(user.getId(), totalBrokerage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新用户冻结佣金
|
// 更新用户冻结佣金
|
||||||
memberUserService.updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(record.getUserId(), -record.getPrice());
|
tradeBrokerageUserService.updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(record.getUserId(), -record.getPrice());
|
||||||
|
|
||||||
log.info("[unfreezeRecord][record({}) 更新为已结算成功]", record.getId());
|
log.info("[unfreezeRecord][record({}) 更新为已结算成功]", record.getId());
|
||||||
return true;
|
return true;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.member.api.brokerage.dto;
|
package cn.iocoder.yudao.module.trade.service.brokerage.record.bo;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -53,4 +53,36 @@ public interface TradeBrokerageUserService {
|
|||||||
* @param brokerageEnabled 推广资格
|
* @param brokerageEnabled 推广资格
|
||||||
*/
|
*/
|
||||||
void updateBrokerageEnabled(Long id, Boolean brokerageEnabled);
|
void updateBrokerageEnabled(Long id, Boolean brokerageEnabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得用户的推广人
|
||||||
|
*
|
||||||
|
* @param id 用户编号
|
||||||
|
* @return 用户的推广人
|
||||||
|
*/
|
||||||
|
TradeBrokerageUserDO getInviteBrokerageUser(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户佣金
|
||||||
|
*
|
||||||
|
* @param id 用户编号
|
||||||
|
* @param brokeragePrice 用户可用佣金
|
||||||
|
*/
|
||||||
|
void updateUserBrokeragePrice(Long id, int brokeragePrice);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户冻结佣金
|
||||||
|
*
|
||||||
|
* @param id 用户编号
|
||||||
|
* @param frozenBrokeragePrice 用户冻结佣金
|
||||||
|
*/
|
||||||
|
void updateUserFrozenBrokeragePrice(Long id, int frozenBrokeragePrice);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户冻结佣金(减少), 更新用户佣金(增加)
|
||||||
|
*
|
||||||
|
* @param id 用户编号
|
||||||
|
* @param frozenBrokeragePrice 减少冻结佣金(负数)
|
||||||
|
*/
|
||||||
|
void updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(Long id, int frozenBrokeragePrice);
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
package cn.iocoder.yudao.module.trade.service.brokerage.user;
|
package cn.iocoder.yudao.module.trade.service.brokerage.user;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserPageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user.TradeBrokerageUserMapper;
|
import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user.TradeBrokerageUserMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.MEMBER_FROZEN_BROKERAGE_PRICE_NOT_ENOUGH;
|
||||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_USER_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_USER_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,4 +64,43 @@ public class TradeBrokerageUserServiceImpl implements TradeBrokerageUserService
|
|||||||
validateBrokerageUserExists(id);
|
validateBrokerageUserExists(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TradeBrokerageUserDO getInviteBrokerageUser(Long id) {
|
||||||
|
return Optional.ofNullable(id)
|
||||||
|
.map(this::getBrokerageUser)
|
||||||
|
.map(TradeBrokerageUserDO::getBrokerageUserId)
|
||||||
|
.map(this::getBrokerageUser)
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateUserBrokeragePrice(Long id, int brokeragePrice) {
|
||||||
|
if (brokeragePrice > 0) {
|
||||||
|
brokerageUserMapper.updateBrokeragePriceIncr(id, brokeragePrice);
|
||||||
|
} else if (brokeragePrice < 0) {
|
||||||
|
brokerageUserMapper.updateBrokeragePriceDecr(id, brokeragePrice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateUserFrozenBrokeragePrice(Long id, int frozenBrokeragePrice) {
|
||||||
|
if (frozenBrokeragePrice > 0) {
|
||||||
|
brokerageUserMapper.updateFrozenBrokeragePriceIncr(id, frozenBrokeragePrice);
|
||||||
|
} else if (frozenBrokeragePrice < 0) {
|
||||||
|
brokerageUserMapper.updateFrozenBrokeragePriceDecr(id, frozenBrokeragePrice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(Long id, int frozenBrokeragePrice) {
|
||||||
|
Assert.isTrue(frozenBrokeragePrice < 0);
|
||||||
|
int updateRows = brokerageUserMapper.updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(id, frozenBrokeragePrice);
|
||||||
|
if (updateRows == 0) {
|
||||||
|
throw exception(MEMBER_FROZEN_BROKERAGE_PRICE_NOT_ENOUGH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.module.member.api.address.AddressApi;
|
import cn.iocoder.yudao.module.member.api.address.AddressApi;
|
||||||
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
||||||
import cn.iocoder.yudao.module.member.api.brokerage.BrokerageApi;
|
import cn.iocoder.yudao.module.trade.service.brokerage.record.MemberBrokerageRecordService;
|
||||||
import cn.iocoder.yudao.module.member.api.brokerage.dto.BrokerageAddReqDTO;
|
import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqDTO;
|
||||||
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
||||||
import cn.iocoder.yudao.module.member.api.point.MemberPointApi;
|
import cn.iocoder.yudao.module.member.api.point.MemberPointApi;
|
||||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
@ -120,7 +120,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||||||
@Resource
|
@Resource
|
||||||
private MemberPointApi memberPointApi;
|
private MemberPointApi memberPointApi;
|
||||||
@Resource
|
@Resource
|
||||||
private BrokerageApi brokerageApi;
|
private MemberBrokerageRecordService memberBrokerageRecordService;
|
||||||
@Resource
|
@Resource
|
||||||
private ProductCommentApi productCommentApi;
|
private ProductCommentApi productCommentApi;
|
||||||
|
|
||||||
@ -754,12 +754,12 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||||||
List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(orderId);
|
List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(orderId);
|
||||||
List<BrokerageAddReqDTO> list = convertList(orderItems,
|
List<BrokerageAddReqDTO> list = convertList(orderItems,
|
||||||
item -> TradeOrderConvert.INSTANCE.convert(item, productSkuApi.getSku(item.getSkuId())));
|
item -> TradeOrderConvert.INSTANCE.convert(item, productSkuApi.getSku(item.getSkuId())));
|
||||||
brokerageApi.addBrokerage(userId, list);
|
memberBrokerageRecordService.addBrokerage(userId, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
protected void cancelBrokerageAsync(Long userId, Long orderItemId) {
|
protected void cancelBrokerageAsync(Long userId, Long orderItemId) {
|
||||||
brokerageApi.cancelBrokerage(userId, String.valueOf(orderItemId));
|
memberBrokerageRecordService.cancelBrokerage(userId, String.valueOf(orderItemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.member.service.brokerage.record;
|
package cn.iocoder.yudao.module.trade.service.brokerage.record;
|
||||||
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.brokerage.record.MemberBrokerageRecordMapper;
|
import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.record.MemberBrokerageRecordMapper;
|
||||||
import cn.iocoder.yudao.module.member.service.point.MemberPointConfigService;
|
import cn.iocoder.yudao.module.trade.service.brokerage.user.TradeBrokerageUserService;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
@ -39,9 +39,9 @@ public class MemberBrokerageRecordServiceImplTest extends BaseDbUnitTest {
|
|||||||
private MemberBrokerageRecordMapper memberBrokerageRecordMapper;
|
private MemberBrokerageRecordMapper memberBrokerageRecordMapper;
|
||||||
|
|
||||||
@MockBean
|
@MockBean
|
||||||
private MemberPointConfigService memberPointConfigService;
|
private TradeConfigService tradeConfigService;
|
||||||
@MockBean
|
@MockBean
|
||||||
private MemberUserService memberUserService;
|
private TradeBrokerageUserService tradeBrokerageUserService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
@ -1,30 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.member.api.brokerage;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.member.api.brokerage.dto.BrokerageAddReqDTO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 佣金 API 接口
|
|
||||||
*
|
|
||||||
* @author owen
|
|
||||||
*/
|
|
||||||
public interface BrokerageApi {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加佣金
|
|
||||||
*
|
|
||||||
* @param userId 会员ID
|
|
||||||
* @param list 请求参数列表
|
|
||||||
*/
|
|
||||||
void addBrokerage(Long userId, List<BrokerageAddReqDTO> list);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取消佣金
|
|
||||||
*
|
|
||||||
* @param userId 会员ID
|
|
||||||
* @param bizId 业务编号
|
|
||||||
*/
|
|
||||||
void cancelBrokerage(Long userId, String bizId);
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.member.api.brokerage;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.member.api.brokerage.dto.BrokerageAddReqDTO;
|
|
||||||
import cn.iocoder.yudao.module.member.service.brokerage.record.MemberBrokerageRecordService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 佣金 API 实现类
|
|
||||||
*
|
|
||||||
* @author owen
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@Validated
|
|
||||||
public class BrokerageApiImpl implements BrokerageApi {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private MemberBrokerageRecordService memberBrokerageRecordService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addBrokerage(Long userId, List<BrokerageAddReqDTO> list) {
|
|
||||||
memberBrokerageRecordService.addBrokerage(userId, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelBrokerage(Long userId, String bizId) {
|
|
||||||
memberBrokerageRecordService.cancelBrokerage(userId, bizId);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.point.vo.config;
|
package cn.iocoder.yudao.module.member.controller.admin.point.vo.config;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageBindModeEnum;
|
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageEnabledConditionEnum;
|
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageWithdrawTypeEnum;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Range;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.PositiveOrZero;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员积分配置 Base VO,提供给添加、修改、详细的子 VO 使用
|
* 会员积分配置 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||||
@ -36,53 +28,4 @@ public class MemberPointConfigBaseVO {
|
|||||||
@NotNull(message = "1 元赠送积分不能为空")
|
@NotNull(message = "1 元赠送积分不能为空")
|
||||||
private Integer tradeGivePoint;
|
private Integer tradeGivePoint;
|
||||||
|
|
||||||
// ========== 分销相关 ==========
|
|
||||||
|
|
||||||
@Schema(description = "是否启用分佣", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
|
||||||
@NotNull(message = "是否启用分佣不能为空")
|
|
||||||
private Boolean brokerageEnabled;
|
|
||||||
|
|
||||||
@Schema(description = "分佣模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
|
||||||
@NotNull(message = "分佣模式不能为空")
|
|
||||||
@InEnum(value = BrokerageEnabledConditionEnum.class, message = "分佣模式必须是 {value}")
|
|
||||||
private Integer brokerageEnabledCondition;
|
|
||||||
|
|
||||||
@Schema(description = "分销关系绑定模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
|
||||||
@NotNull(message = "分销关系绑定模式不能为空")
|
|
||||||
@InEnum(value = BrokerageBindModeEnum.class, message = "分销关系绑定模式必须是 {value}")
|
|
||||||
private Integer brokerageBindMode;
|
|
||||||
|
|
||||||
@Schema(description = "分销海报图地址数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/yudao.jpg]")
|
|
||||||
private List<String> brokeragePostUrls;
|
|
||||||
|
|
||||||
@Schema(description = "一级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
|
|
||||||
@NotNull(message = "一级返佣比例不能为空")
|
|
||||||
@Range(min = 0, max = 100, message = "一级返佣比例必须在 0 - 100 之间")
|
|
||||||
private Integer brokerageFirstPercent;
|
|
||||||
|
|
||||||
@Schema(description = "二级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
|
|
||||||
@NotNull(message = "二级返佣比例不能为空")
|
|
||||||
@Range(min = 0, max = 100, message = "二级返佣比例必须在 0 - 100 之间")
|
|
||||||
private Integer brokerageSecondPercent;
|
|
||||||
|
|
||||||
@Schema(description = "用户提现最低金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
|
||||||
@NotNull(message = "用户提现最低金额不能为空")
|
|
||||||
@PositiveOrZero(message = "用户提现最低金额不能是负数")
|
|
||||||
private Integer brokerageWithdrawMinPrice;
|
|
||||||
|
|
||||||
@Schema(description = "提现银行", requiredMode = Schema.RequiredMode.REQUIRED, example = "[0, 1]")
|
|
||||||
@NotEmpty(message = "提现银行不能为空")
|
|
||||||
private List<Integer> brokerageBankNames;
|
|
||||||
|
|
||||||
@Schema(description = "佣金冻结时间(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "7")
|
|
||||||
@NotNull(message = "佣金冻结时间(天)不能为空")
|
|
||||||
@PositiveOrZero(message = "佣金冻结时间不能是负数")
|
|
||||||
private Integer brokerageFrozenDays;
|
|
||||||
|
|
||||||
@Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[0, 1]")
|
|
||||||
@NotNull(message = "提现方式不能为空")
|
|
||||||
@InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现方式必须是 {value}")
|
|
||||||
private List<Integer> brokerageWithdrawType;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.member.dal.dataobject.point;
|
package cn.iocoder.yudao.module.member.dal.dataobject.point;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler;
|
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageBindModeEnum;
|
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageEnabledConditionEnum;
|
|
||||||
import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageWithdrawTypeEnum;
|
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员积分配置 DO
|
* 会员积分配置 DO
|
||||||
*
|
*
|
||||||
@ -53,56 +45,4 @@ public class MemberPointConfigDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private Integer tradeGivePoint;
|
private Integer tradeGivePoint;
|
||||||
|
|
||||||
// ========== 分销相关 ==========
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否启用分佣
|
|
||||||
*/
|
|
||||||
private Boolean brokerageEnabled;
|
|
||||||
/**
|
|
||||||
* 分佣模式
|
|
||||||
*
|
|
||||||
* 枚举 {@link BrokerageEnabledConditionEnum 对应的类}
|
|
||||||
*/
|
|
||||||
private Integer brokerageEnabledCondition;
|
|
||||||
/**
|
|
||||||
* 分销关系绑定模式
|
|
||||||
*
|
|
||||||
* 枚举 {@link BrokerageBindModeEnum 对应的类}
|
|
||||||
*/
|
|
||||||
private Integer brokerageBindMode;
|
|
||||||
/**
|
|
||||||
* 分销海报图地址数组
|
|
||||||
*/
|
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
|
||||||
private List<String> brokeragePostUrls;
|
|
||||||
/**
|
|
||||||
* 一级返佣比例
|
|
||||||
*/
|
|
||||||
private Integer brokerageFirstPercent;
|
|
||||||
/**
|
|
||||||
* 二级返佣比例
|
|
||||||
*/
|
|
||||||
private Integer brokerageSecondPercent;
|
|
||||||
/**
|
|
||||||
* 用户提现最低金额
|
|
||||||
*/
|
|
||||||
private Integer brokerageWithdrawMinPrice;
|
|
||||||
/**
|
|
||||||
* 提现银行
|
|
||||||
*/
|
|
||||||
@TableField(typeHandler = IntegerListTypeHandler.class)
|
|
||||||
private List<Integer> brokerageBankNames;
|
|
||||||
/**
|
|
||||||
* 佣金冻结时间(天)
|
|
||||||
*/
|
|
||||||
private Integer brokerageFrozenDays;
|
|
||||||
/**
|
|
||||||
* 提现方式
|
|
||||||
*
|
|
||||||
* 枚举 {@link BrokerageWithdrawTypeEnum 对应的类}
|
|
||||||
*/
|
|
||||||
@TableField(typeHandler = IntegerListTypeHandler.class)
|
|
||||||
private List<Integer> brokerageWithdrawType;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.member.dal.mysql.user;
|
package cn.iocoder.yudao.module.member.dal.mysql.user;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -63,79 +61,4 @@ public interface MemberUserMapper extends BaseMapperX<MemberUserDO> {
|
|||||||
return selectCount(new LambdaQueryWrapperX<MemberUserDO>()
|
return selectCount(new LambdaQueryWrapperX<MemberUserDO>()
|
||||||
.apply("FIND_IN_SET({0}, tag_ids)", tagId));
|
.apply("FIND_IN_SET({0}, tag_ids)", tagId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户可用佣金(增加)
|
|
||||||
*
|
|
||||||
* @param id 用户编号
|
|
||||||
* @param incrCount 增加佣金(正数)
|
|
||||||
*/
|
|
||||||
default void updateBrokeragePriceIncr(Long id, int incrCount) {
|
|
||||||
Assert.isTrue(incrCount > 0);
|
|
||||||
LambdaUpdateWrapper<MemberUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<MemberUserDO>()
|
|
||||||
.setSql(" brokerage_price = brokerage_price + " + incrCount)
|
|
||||||
.eq(MemberUserDO::getId, id);
|
|
||||||
update(null, lambdaUpdateWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户可用佣金(减少)
|
|
||||||
* 注意:理论上佣金可能已经提现,这时会扣出负数,确保平台不会造成损失
|
|
||||||
*
|
|
||||||
* @param id 用户编号
|
|
||||||
* @param incrCount 增加佣金(负数)
|
|
||||||
*/
|
|
||||||
default void updateBrokeragePriceDecr(Long id, int incrCount) {
|
|
||||||
Assert.isTrue(incrCount < 0);
|
|
||||||
LambdaUpdateWrapper<MemberUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<MemberUserDO>()
|
|
||||||
.setSql(" brokerage_price = brokerage_price + " + incrCount) // 负数,所以使用 + 号
|
|
||||||
.eq(MemberUserDO::getId, id);
|
|
||||||
update(null, lambdaUpdateWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户冻结佣金(增加)
|
|
||||||
*
|
|
||||||
* @param id 用户编号
|
|
||||||
* @param incrCount 增加冻结佣金(正数)
|
|
||||||
*/
|
|
||||||
default void updateFrozenBrokeragePriceIncr(Long id, int incrCount) {
|
|
||||||
Assert.isTrue(incrCount > 0);
|
|
||||||
LambdaUpdateWrapper<MemberUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<MemberUserDO>()
|
|
||||||
.setSql(" frozen_brokerage_price = frozen_brokerage_price + " + incrCount)
|
|
||||||
.eq(MemberUserDO::getId, id);
|
|
||||||
update(null, lambdaUpdateWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户冻结佣金(减少)
|
|
||||||
* 注意:理论上冻结佣金可能已经解冻,这时会扣出负数,确保平台不会造成损失
|
|
||||||
*
|
|
||||||
* @param id 用户编号
|
|
||||||
* @param incrCount 减少冻结佣金(负数)
|
|
||||||
*/
|
|
||||||
default void updateFrozenBrokeragePriceDecr(Long id, int incrCount) {
|
|
||||||
Assert.isTrue(incrCount < 0);
|
|
||||||
LambdaUpdateWrapper<MemberUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<MemberUserDO>()
|
|
||||||
.setSql(" frozen_brokerage_price = frozen_brokerage_price + " + incrCount) // 负数,所以使用 + 号
|
|
||||||
.eq(MemberUserDO::getId, id);
|
|
||||||
update(null, lambdaUpdateWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户冻结佣金(减少), 更新用户佣金(增加)
|
|
||||||
*
|
|
||||||
* @param id 用户编号
|
|
||||||
* @param incrCount 减少冻结佣金(负数)
|
|
||||||
* @return 更新条数
|
|
||||||
*/
|
|
||||||
default int updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(Long id, int incrCount) {
|
|
||||||
Assert.isTrue(incrCount < 0);
|
|
||||||
LambdaUpdateWrapper<MemberUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<MemberUserDO>()
|
|
||||||
.setSql(" frozen_brokerage_price = frozen_brokerage_price + " + incrCount + // 负数,所以使用 + 号
|
|
||||||
", brokerage_price = brokerage_price + " + -incrCount) // 负数,所以使用 - 号
|
|
||||||
.eq(MemberUserDO::getId, id)
|
|
||||||
.ge(MemberUserDO::getFrozenBrokeragePrice, -incrCount); // cas 逻辑
|
|
||||||
return update(null, lambdaUpdateWrapper);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -166,36 +166,4 @@ public interface MemberUserService {
|
|||||||
* @param point 积分数量
|
* @param point 积分数量
|
||||||
*/
|
*/
|
||||||
void updateUserPoint(Long userId, Integer point);
|
void updateUserPoint(Long userId, Integer point);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得用户的推广人
|
|
||||||
*
|
|
||||||
* @param id 用户编号
|
|
||||||
* @return 用户的推广人
|
|
||||||
*/
|
|
||||||
MemberUserDO getBrokerageUser(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户佣金
|
|
||||||
*
|
|
||||||
* @param id 用户编号
|
|
||||||
* @param brokeragePrice 用户可用佣金
|
|
||||||
*/
|
|
||||||
void updateUserBrokeragePrice(Long id, int brokeragePrice);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户冻结佣金
|
|
||||||
*
|
|
||||||
* @param id 用户编号
|
|
||||||
* @param frozenBrokeragePrice 用户冻结佣金
|
|
||||||
*/
|
|
||||||
void updateUserFrozenBrokeragePrice(Long id, int frozenBrokeragePrice);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户冻结佣金(减少), 更新用户佣金(增加)
|
|
||||||
*
|
|
||||||
* @param id 用户编号
|
|
||||||
* @param frozenBrokeragePrice 减少冻结佣金(负数)
|
|
||||||
*/
|
|
||||||
void updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(Long id, int frozenBrokeragePrice);
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.member.service.user;
|
package cn.iocoder.yudao.module.member.service.user;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@ -31,7 +30,6 @@ import javax.validation.Valid;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||||
@ -261,43 +259,4 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||||||
memberUserMapper.updateById(new MemberUserDO().setId(userId).setPoint(point));
|
memberUserMapper.updateById(new MemberUserDO().setId(userId).setPoint(point));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MemberUserDO getBrokerageUser(Long id) {
|
|
||||||
return Optional.ofNullable(id)
|
|
||||||
.map(this::getUser)
|
|
||||||
.map(MemberUserDO::getBrokerageUserId)
|
|
||||||
.map(this::getUser)
|
|
||||||
.orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateUserBrokeragePrice(Long id, int brokeragePrice) {
|
|
||||||
if (brokeragePrice > 0) {
|
|
||||||
memberUserMapper.updateBrokeragePriceIncr(id, brokeragePrice);
|
|
||||||
} else if (brokeragePrice < 0) {
|
|
||||||
memberUserMapper.updateBrokeragePriceDecr(id, brokeragePrice);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateUserFrozenBrokeragePrice(Long id, int frozenBrokeragePrice) {
|
|
||||||
if (frozenBrokeragePrice > 0) {
|
|
||||||
memberUserMapper.updateFrozenBrokeragePriceIncr(id, frozenBrokeragePrice);
|
|
||||||
} else if (frozenBrokeragePrice < 0) {
|
|
||||||
memberUserMapper.updateFrozenBrokeragePriceDecr(id, frozenBrokeragePrice);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(Long id, int frozenBrokeragePrice) {
|
|
||||||
Assert.isTrue(frozenBrokeragePrice < 0);
|
|
||||||
int updateRows = memberUserMapper.updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(id, frozenBrokeragePrice);
|
|
||||||
if (updateRows == 0) {
|
|
||||||
throw exception(MEMBER_FROZEN_BROKERAGE_PRICE_NOT_ENOUGH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user