diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageBindModeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java similarity index 93% rename from yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageBindModeEnum.java rename to yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java index 2ee7e891f..6946167bc 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageBindModeEnum.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java @@ -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 lombok.AllArgsConstructor; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageEnabledConditionEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java similarity index 93% rename from yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageEnabledConditionEnum.java rename to yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java index 5422b98b7..6d984a284 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageEnabledConditionEnum.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java @@ -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 lombok.AllArgsConstructor; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageRecordBizTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java similarity index 94% rename from yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageRecordBizTypeEnum.java rename to yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java index d30758a88..ce449f0b8 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageRecordBizTypeEnum.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java @@ -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 lombok.AllArgsConstructor; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageRecordStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java similarity index 92% rename from yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageRecordStatusEnum.java rename to yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java index 75ddc9e0a..827390998 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageRecordStatusEnum.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java @@ -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 lombok.AllArgsConstructor; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageWithdrawStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java similarity index 93% rename from yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageWithdrawStatusEnum.java rename to yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java index 6d0232deb..a80aad02a 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageWithdrawStatusEnum.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java @@ -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 lombok.AllArgsConstructor; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageWithdrawTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java similarity index 92% rename from yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageWithdrawTypeEnum.java rename to yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java index 21d0712b9..46edf010e 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/brokerage/BrokerageWithdrawTypeEnum.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java @@ -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 lombok.AllArgsConstructor; diff --git a/yudao-module-mall/yudao-module-trade-biz/pom.xml b/yudao-module-mall/yudao-module-trade-biz/pom.xml index 810446fa9..02f31a9f0 100644 --- a/yudao-module-mall/yudao-module-trade-biz/pom.xml +++ b/yudao-module-mall/yudao-module-trade-biz/pom.xml @@ -54,6 +54,10 @@ cn.iocoder.boot yudao-spring-boot-starter-biz-operatelog + + cn.iocoder.boot + yudao-spring-boot-starter-biz-tenant + cn.iocoder.boot yudao-spring-boot-starter-biz-ip diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/MemberBrokerageRecordController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/MemberBrokerageRecordController.java similarity index 76% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/MemberBrokerageRecordController.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/MemberBrokerageRecordController.java index 92cb0ae1a..c4bc9bb37 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/MemberBrokerageRecordController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/MemberBrokerageRecordController.java @@ -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.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordRespVO; -import cn.iocoder.yudao.module.member.convert.brokerage.record.MemberBrokerageRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; -import cn.iocoder.yudao.module.member.service.brokerage.record.MemberBrokerageRecordService; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordRespVO; +import cn.iocoder.yudao.module.trade.convert.brokerage.record.MemberBrokerageRecordConvert; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.service.brokerage.record.MemberBrokerageRecordService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -24,7 +24,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 佣金记录") @RestController -@RequestMapping("/member/member-brokerage-record") +@RequestMapping("/trade/member-brokerage-record") @Validated public class MemberBrokerageRecordController { diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/vo/MemberBrokerageRecordBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/MemberBrokerageRecordBaseVO.java similarity index 96% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/vo/MemberBrokerageRecordBaseVO.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/MemberBrokerageRecordBaseVO.java index ef6762be1..51cd4a631 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/vo/MemberBrokerageRecordBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/MemberBrokerageRecordBaseVO.java @@ -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 lombok.Data; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/vo/MemberBrokerageRecordPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/MemberBrokerageRecordPageReqVO.java similarity index 92% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/vo/MemberBrokerageRecordPageReqVO.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/MemberBrokerageRecordPageReqVO.java index 04a9ed94c..3a5e05527 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/vo/MemberBrokerageRecordPageReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/MemberBrokerageRecordPageReqVO.java @@ -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 io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/vo/MemberBrokerageRecordRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/MemberBrokerageRecordRespVO.java similarity index 89% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/vo/MemberBrokerageRecordRespVO.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/MemberBrokerageRecordRespVO.java index 417b5320d..3550a64ba 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/brokerage/record/vo/MemberBrokerageRecordRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/MemberBrokerageRecordRespVO.java @@ -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 lombok.Data; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java index 4ee51e3b8..ee20156f1 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.module.trade.controller.admin.config.vo; 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 cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.hibernate.validator.constraints.Range; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/brokerage/record/MemberBrokerageRecordConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/MemberBrokerageRecordConvert.java similarity index 70% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/brokerage/record/MemberBrokerageRecordConvert.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/MemberBrokerageRecordConvert.java index 393bacb72..48af52cf5 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/brokerage/record/MemberBrokerageRecordConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/MemberBrokerageRecordConvert.java @@ -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.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordStatusEnum; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordRespVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -29,7 +29,7 @@ public interface MemberBrokerageRecordConvert { PageResult convertPage(PageResult 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 ? BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus() diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java index e46ce66b6..d17b81124 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java @@ -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.ip.core.utils.AreaUtils; 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.pay.api.order.dto.PayOrderCreateReqDTO; import cn.iocoder.yudao.module.pay.enums.DictTypeConstants; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/brokerage/record/MemberBrokerageRecordDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/record/MemberBrokerageRecordDO.java similarity index 86% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/brokerage/record/MemberBrokerageRecordDO.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/record/MemberBrokerageRecordDO.java index 88e6ba7d9..94d37ff89 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/brokerage/record/MemberBrokerageRecordDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/record/MemberBrokerageRecordDO.java @@ -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.module.member.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordStatusEnum; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java index 5538186e1..a0c6d3858 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java @@ -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.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 cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java similarity index 88% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java index 52154aea5..da89b8bba 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java @@ -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.mybatis.core.mapper.BaseMapperX; 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.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.apache.ibatis.annotations.Mapper; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/TradeBrokerageUserMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/TradeBrokerageUserMapper.java index 93656837a..f0c221311 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/TradeBrokerageUserMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/TradeBrokerageUserMapper.java @@ -1,10 +1,12 @@ 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.mybatis.core.mapper.BaseMapperX; 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.dal.dataobject.brokerage.user.TradeBrokerageUserDO; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.apache.ibatis.annotations.Mapper; /** @@ -23,4 +25,79 @@ public interface TradeBrokerageUserMapper extends BaseMapperX 0); + LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() + .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 lambdaUpdateWrapper = new LambdaUpdateWrapper() + .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 lambdaUpdateWrapper = new LambdaUpdateWrapper() + .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 lambdaUpdateWrapper = new LambdaUpdateWrapper() + .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 lambdaUpdateWrapper = new LambdaUpdateWrapper() + .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); + } + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/job/brokerage/MemberBrokerageRecordUnfreezeJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/MemberBrokerageRecordUnfreezeJob.java similarity index 81% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/job/brokerage/MemberBrokerageRecordUnfreezeJob.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/MemberBrokerageRecordUnfreezeJob.java index f4512cf08..d41bc840c 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/job/brokerage/MemberBrokerageRecordUnfreezeJob.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/MemberBrokerageRecordUnfreezeJob.java @@ -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.iocoder.yudao.framework.quartz.core.handler.JobHandler; 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 javax.annotation.Resource; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordService.java similarity index 76% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordService.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordService.java index cd966e670..5cdd9e1b5 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordService.java @@ -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.module.member.api.brokerage.dto.BrokerageAddReqDTO; -import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqDTO; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; import java.util.List; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordServiceImpl.java similarity index 79% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImpl.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordServiceImpl.java index 32656910c..e56ae5dab 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordServiceImpl.java @@ -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.util.BooleanUtil; @@ -6,17 +6,17 @@ import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.spring.SpringUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.brokerage.dto.BrokerageAddReqDTO; -import cn.iocoder.yudao.module.member.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.member.convert.brokerage.record.MemberBrokerageRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointConfigDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.brokerage.record.MemberBrokerageRecordMapper; -import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.member.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.member.service.point.MemberPointConfigService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; +import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqDTO; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO; +import cn.iocoder.yudao.module.trade.convert.brokerage.record.MemberBrokerageRecordConvert; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.record.MemberBrokerageRecordMapper; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; +import cn.iocoder.yudao.module.trade.service.brokerage.user.TradeBrokerageUserService; +import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -42,9 +42,9 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe @Resource private MemberBrokerageRecordMapper memberBrokerageRecordMapper; @Resource - private MemberPointConfigService memberConfigService; + private TradeConfigService tradeConfigService; @Resource - private MemberUserService memberUserService; + private TradeBrokerageUserService tradeBrokerageUserService; @Override public MemberBrokerageRecordDO getMemberBrokerageRecord(Integer id) { @@ -59,7 +59,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe @Override @Transactional(rollbackFor = Exception.class) public void addBrokerage(Long buyerId, List list) { - MemberPointConfigDO memberConfig = memberConfigService.getPointConfig(); + TradeConfigDO memberConfig = tradeConfigService.getTradeConfig(); // 0 未启用分销功能 if (memberConfig == null || !BooleanUtil.isTrue(memberConfig.getBrokerageEnabled())) { log.warn("[addBrokerage][增加佣金失败:brokerageEnabled 未配置,buyerId({})", buyerId); @@ -67,7 +67,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe } // 1.1 获得一级推广人 - MemberUserDO firstUser = memberUserService.getBrokerageUser(buyerId); + TradeBrokerageUserDO firstUser = tradeBrokerageUserService.getInviteBrokerageUser(buyerId); if (firstUser == null || !BooleanUtil.isTrue(firstUser.getBrokerageEnabled())) { return; } @@ -77,7 +77,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe // 2.1 获得二级推广员 - MemberUserDO secondUser = memberUserService.getUser(firstUser.getBrokerageUserId()); + TradeBrokerageUserDO secondUser = tradeBrokerageUserService.getBrokerageUser(firstUser.getBrokerageUserId()); if (secondUser == null || !BooleanUtil.isTrue(secondUser.getBrokerageEnabled())) { return; } @@ -103,9 +103,9 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe } 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())) { - memberUserService.updateUserBrokeragePrice(userId, -record.getPrice()); + tradeBrokerageUserService.updateUserBrokeragePrice(userId, -record.getPrice()); } } @@ -140,7 +140,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe * @param brokeragePercent 佣金比例 * @param skuBrokeragePriceFun 商品 SKU 设置的佣金 */ - private void addBrokerage(MemberUserDO user, List list, Integer brokerageFrozenDays, + private void addBrokerage(TradeBrokerageUserDO user, List list, Integer brokerageFrozenDays, Integer brokeragePercent, Function skuBrokeragePriceFun) { // 处理冻结时间 brokerageFrozenDays = ObjectUtil.defaultIfNull(brokerageFrozenDays, 0); @@ -170,10 +170,10 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe if (brokerageFrozenDays > 0) { // 更新用户冻结佣金 - memberUserService.updateUserFrozenBrokeragePrice(user.getId(), totalBrokerage); + tradeBrokerageUserService.updateUserFrozenBrokeragePrice(user.getId(), totalBrokerage); } 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()); return true; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/dto/BrokerageAddReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo/BrokerageAddReqDTO.java similarity index 89% rename from yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/dto/BrokerageAddReqDTO.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo/BrokerageAddReqDTO.java index c46645201..a15ef76c0 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/dto/BrokerageAddReqDTO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo/BrokerageAddReqDTO.java @@ -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.Data; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserService.java index 58970d724..773342e55 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserService.java @@ -53,4 +53,36 @@ public interface TradeBrokerageUserService { * @param 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); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImpl.java index acbda456b..9691a8154 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImpl.java @@ -1,17 +1,21 @@ 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.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.mysql.brokerage.user.TradeBrokerageUserMapper; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.Collection; import java.util.List; +import java.util.Optional; 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; /** @@ -60,4 +64,43 @@ public class TradeBrokerageUserServiceImpl implements TradeBrokerageUserService 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); + } + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java index e2a0f6baf..9ab4842b8 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java @@ -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.module.member.api.address.AddressApi; import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; -import cn.iocoder.yudao.module.member.api.brokerage.BrokerageApi; -import cn.iocoder.yudao.module.member.api.brokerage.dto.BrokerageAddReqDTO; +import cn.iocoder.yudao.module.trade.service.brokerage.record.MemberBrokerageRecordService; +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.point.MemberPointApi; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; @@ -120,7 +120,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Resource private MemberPointApi memberPointApi; @Resource - private BrokerageApi brokerageApi; + private MemberBrokerageRecordService memberBrokerageRecordService; @Resource private ProductCommentApi productCommentApi; @@ -754,12 +754,12 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { List orderItems = tradeOrderItemMapper.selectListByOrderId(orderId); List list = convertList(orderItems, item -> TradeOrderConvert.INSTANCE.convert(item, productSkuApi.getSku(item.getSkuId()))); - brokerageApi.addBrokerage(userId, list); + memberBrokerageRecordService.addBrokerage(userId, list); } @Async protected void cancelBrokerageAsync(Long userId, Long orderItemId) { - brokerageApi.cancelBrokerage(userId, String.valueOf(orderItemId)); + memberBrokerageRecordService.cancelBrokerage(userId, String.valueOf(orderItemId)); } /** diff --git a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImplTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordServiceImplTest.java similarity index 87% rename from yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImplTest.java rename to yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordServiceImplTest.java index d5991b4e8..ae367ae63 100644 --- a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImplTest.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordServiceImplTest.java @@ -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.iocoder.yudao.framework.common.pojo.PageResult; 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.member.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; -import cn.iocoder.yudao.module.member.dal.mysql.brokerage.record.MemberBrokerageRecordMapper; -import cn.iocoder.yudao.module.member.service.point.MemberPointConfigService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordPageReqVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.record.MemberBrokerageRecordMapper; +import cn.iocoder.yudao.module.trade.service.brokerage.user.TradeBrokerageUserService; +import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; @@ -39,9 +39,9 @@ public class MemberBrokerageRecordServiceImplTest extends BaseDbUnitTest { private MemberBrokerageRecordMapper memberBrokerageRecordMapper; @MockBean - private MemberPointConfigService memberPointConfigService; + private TradeConfigService tradeConfigService; @MockBean - private MemberUserService memberUserService; + private TradeBrokerageUserService tradeBrokerageUserService; @Test @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/BrokerageApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/BrokerageApi.java deleted file mode 100644 index d01ce5845..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/BrokerageApi.java +++ /dev/null @@ -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 list); - - /** - * 取消佣金 - * - * @param userId 会员ID - * @param bizId 业务编号 - */ - void cancelBrokerage(Long userId, String bizId); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/BrokerageApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/BrokerageApiImpl.java deleted file mode 100644 index 662c5165a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/BrokerageApiImpl.java +++ /dev/null @@ -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 list) { - memberBrokerageRecordService.addBrokerage(userId, list); - } - - @Override - public void cancelBrokerage(Long userId, String bizId) { - memberBrokerageRecordService.cancelBrokerage(userId, bizId); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/config/MemberPointConfigBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/config/MemberPointConfigBaseVO.java index acdadb6bc..f946e4a27 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/config/MemberPointConfigBaseVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/config/MemberPointConfigBaseVO.java @@ -1,17 +1,9 @@ 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 lombok.Data; -import org.hibernate.validator.constraints.Range; -import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; -import javax.validation.constraints.PositiveOrZero; -import java.util.List; /** * 会员积分配置 Base VO,提供给添加、修改、详细的子 VO 使用 @@ -36,53 +28,4 @@ public class MemberPointConfigBaseVO { @NotNull(message = "1 元赠送积分不能为空") 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 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 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 brokerageWithdrawType; - - } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointConfigDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointConfigDO.java index 8f44bd948..4a6354b03 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointConfigDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointConfigDO.java @@ -1,19 +1,11 @@ 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.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.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.*; -import java.util.List; - /** * 会员积分配置 DO * @@ -53,56 +45,4 @@ public class MemberPointConfigDO extends BaseDO { */ private Integer tradeGivePoint; - // ========== 分销相关 ========== - - /** - * 是否启用分佣 - */ - private Boolean brokerageEnabled; - /** - * 分佣模式 - * - * 枚举 {@link BrokerageEnabledConditionEnum 对应的类} - */ - private Integer brokerageEnabledCondition; - /** - * 分销关系绑定模式 - * - * 枚举 {@link BrokerageBindModeEnum 对应的类} - */ - private Integer brokerageBindMode; - /** - * 分销海报图地址数组 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List brokeragePostUrls; - /** - * 一级返佣比例 - */ - private Integer brokerageFirstPercent; - /** - * 二级返佣比例 - */ - private Integer brokerageSecondPercent; - /** - * 用户提现最低金额 - */ - private Integer brokerageWithdrawMinPrice; - /** - * 提现银行 - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List brokerageBankNames; - /** - * 佣金冻结时间(天) - */ - private Integer brokerageFrozenDays; - /** - * 提现方式 - * - * 枚举 {@link BrokerageWithdrawTypeEnum 对应的类} - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List brokerageWithdrawType; - } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java index 2dc47be90..7e35cdf2a 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java @@ -1,14 +1,12 @@ package cn.iocoder.yudao.module.member.dal.mysql.user; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 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.dal.dataobject.user.MemberUserDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -63,79 +61,4 @@ public interface MemberUserMapper extends BaseMapperX { return selectCount(new LambdaQueryWrapperX() .apply("FIND_IN_SET({0}, tag_ids)", tagId)); } - - /** - * 更新用户可用佣金(增加) - * - * @param id 用户编号 - * @param incrCount 增加佣金(正数) - */ - default void updateBrokeragePriceIncr(Long id, int incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .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 lambdaUpdateWrapper = new LambdaUpdateWrapper() - .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 lambdaUpdateWrapper = new LambdaUpdateWrapper() - .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 lambdaUpdateWrapper = new LambdaUpdateWrapper() - .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 lambdaUpdateWrapper = new LambdaUpdateWrapper() - .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); - } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java index 7f599a049..f1a0a7265 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java @@ -166,36 +166,4 @@ public interface MemberUserService { * @param 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); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java index 53b452d7c..c5b674cc8 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java @@ -1,6 +1,5 @@ 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.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -31,7 +30,6 @@ import javax.validation.Valid; import java.time.LocalDateTime; import java.util.Collection; 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.util.servlet.ServletUtils.getClientIP; @@ -261,43 +259,4 @@ public class MemberUserServiceImpl implements MemberUserService { 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); - } - } - }