From 2f6092005b09aac72896f67adab6716aa2363083 Mon Sep 17 00:00:00 2001 From: owen Date: Tue, 5 Sep 2023 18:54:00 +0800 Subject: [PATCH 1/9] =?UTF-8?q?member:=20=E4=BD=A3=E9=87=91=E8=A7=A3?= =?UTF-8?q?=E5=86=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/enums/ErrorCodeConstants.java | 1 + .../record/MemberBrokerageRecordMapper.java | 15 +++++ .../dal/mysql/user/MemberUserMapper.java | 16 ++++++ .../MemberBrokerageRecordUnfreezeJob.java | 29 ++++++++++ .../record/MemberBrokerageRecordService.java | 8 +++ .../MemberBrokerageRecordServiceImpl.java | 57 +++++++++++++++++++ .../service/user/MemberUserService.java | 4 +- .../service/user/MemberUserServiceImpl.java | 9 ++- 8 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/job/brokerage/MemberBrokerageRecordUnfreezeJob.java diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java index ba283ab0c..dc6439e74 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java +++ b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java @@ -13,6 +13,7 @@ public interface ErrorCodeConstants { ErrorCode USER_NOT_EXISTS = new ErrorCode(1004001000, "用户不存在"); ErrorCode USER_MOBILE_NOT_EXISTS = new ErrorCode(1004001001, "手机号未注册用户"); ErrorCode USER_MOBILE_USED = new ErrorCode(1004001002, "修改手机失败,该手机号({})已经被使用"); + ErrorCode MEMBER_FROZEN_BROKERAGE_PRICE_NOT_ENOUGH = new ErrorCode(1004001003, "用户冻结佣金({})数量不足"); // ========== AUTH 模块 1004003000 ========== ErrorCode AUTH_LOGIN_BAD_CREDENTIALS = new ErrorCode(1004003000, "登录失败,账号密码不正确"); 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java index 52f85c1a1..fd3ce05fc 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java @@ -5,8 +5,12 @@ 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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.apache.ibatis.annotations.Mapper; +import java.time.LocalDateTime; +import java.util.List; + /** * 佣金记录 Mapper * @@ -24,4 +28,15 @@ public interface MemberBrokerageRecordMapper extends BaseMapperX selectListByStatusAndUnfreezeTimeLt(Integer status, LocalDateTime unfreezeTime) { + return selectList(new LambdaQueryWrapper() + .eq(MemberBrokerageRecordDO::getStatus, status) + .lt(MemberBrokerageRecordDO::getUnfreezeTime, unfreezeTime)); + } + + default int updateByIdAndStatus(Integer id, Integer status, MemberBrokerageRecordDO updateObj) { + return update(updateObj, new LambdaQueryWrapper() + .eq(MemberBrokerageRecordDO::getId, id) + .eq(MemberBrokerageRecordDO::getStatus, status)); + } } 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 39a7307c1..cafe10285 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 @@ -92,4 +92,20 @@ public interface MemberUserMapper extends BaseMapperX { update(null, lambdaUpdateWrapper); } + /** + * 更新用户冻结佣金(减少) + * + * @param id 用户编号 + * @param incrCount 减少冻结佣金(负数) + * @return 更新条数 + */ + default int updateFrozenBrokeragePriceDecr(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/job/brokerage/MemberBrokerageRecordUnfreezeJob.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/job/brokerage/MemberBrokerageRecordUnfreezeJob.java new file mode 100644 index 000000000..f4512cf08 --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/job/brokerage/MemberBrokerageRecordUnfreezeJob.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.member.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 org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * 佣金解冻 Job + * + * @author owen + */ +@Component +@TenantJob +public class MemberBrokerageRecordUnfreezeJob implements JobHandler { + + @Resource + private MemberBrokerageRecordService memberBrokerageRecordService; + + @Override + public String execute(String param) { + int count = memberBrokerageRecordService.unfreezeRecord(); + return StrUtil.format("解冻佣金 {} 个", count); + } + +} 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordService.java index 16b82f78f..1d0f4e816 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordService.java @@ -37,4 +37,12 @@ public interface MemberBrokerageRecordService { * @param list 请求参数列表 */ void addBrokerage(Long userId, List list); + + /** + * 解冻佣金:将待结算的佣金记录,状态修改为已结算 + * + * @return 解冻佣金的数量 + */ + int unfreezeRecord(); + } 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImpl.java index 80c753fb5..58dc25af5 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImpl.java @@ -1,8 +1,10 @@ package cn.iocoder.yudao.module.member.service.brokerage.record; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.BooleanUtil; 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; @@ -11,10 +13,12 @@ import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrok 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.BrokerageRecordStatusEnum; import cn.iocoder.yudao.module.member.service.point.MemberPointConfigService; import cn.iocoder.yudao.module.member.service.user.MemberUserService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; @@ -52,6 +56,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe } @Override + @Transactional(rollbackFor = Exception.class) public void addBrokerage(Long buyerId, List list) { MemberPointConfigDO memberConfig = memberConfigService.getPointConfig(); // 0 未启用分销功能 @@ -148,4 +153,56 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe } } + @Override + public int unfreezeRecord() { + // 1. 查询待结算的佣金记录 + List records = memberBrokerageRecordMapper.selectListByStatusAndUnfreezeTimeLt( + BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus(), LocalDateTime.now()); + if (CollUtil.isEmpty(records)) { + return 0; + } + + // 2. 遍历执行 + int count = 0; + for (MemberBrokerageRecordDO record : records) { + try { + boolean successful = getSelf().unfreezeRecord(record); + if (successful) { + count++; + } + } catch (Exception e) { + log.error("[unfreezeRecord][record({}) 更新为已结算失败]", record.getId(), e); + } + } + return count; + } + + @Transactional(rollbackFor = Exception.class) + public boolean unfreezeRecord(MemberBrokerageRecordDO record) { + // 更新记录状态 + MemberBrokerageRecordDO updateObj = new MemberBrokerageRecordDO() + .setStatus(BrokerageRecordStatusEnum.SETTLEMENT.getStatus()) + .setUnfreezeTime(LocalDateTime.now()); + int updateRows = memberBrokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); + if (updateRows == 0) { + log.error("[unfreezeRecord][record({}) 更新为已结算失败]", record.getId()); + return false; + } + + // 更新用户冻结佣金 + memberUserService.updateUserFrozenBrokeragePrice(record.getUserId(), record.getPrice()); + + log.info("[unfreezeRecord][record({}) 更新为已结算成功]", record.getId()); + return true; + } + + /** + * 获得自身的代理对象,解决 AOP 生效问题 + * + * @return 自己 + */ + private MemberBrokerageRecordServiceImpl getSelf() { + return SpringUtil.getBean(getClass()); + } + } 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 206f9f1c7..380ad2c6c 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 @@ -176,7 +176,7 @@ public interface MemberUserService { MemberUserDO getBrokerageUser(Long id); /** - * 增加用户佣金 + * 更新用户佣金 * * @param id 用户编号 * @param brokeragePrice 用户可用佣金 @@ -184,7 +184,7 @@ public interface MemberUserService { void updateUserBrokeragePrice(Long id, int brokeragePrice); /** - * 增加用户佣金 + * 更新用户冻结佣金 * * @param id 用户编号 * @param 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 db80661c6..0bd17facf 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 @@ -278,7 +278,14 @@ public class MemberUserServiceImpl implements MemberUserService { @Override @Transactional(rollbackFor = Exception.class) public void updateUserFrozenBrokeragePrice(Long id, int frozenBrokeragePrice) { - memberUserMapper.updateFrozenBrokeragePriceIncr(id, frozenBrokeragePrice); + if (frozenBrokeragePrice > 0) { + memberUserMapper.updateFrozenBrokeragePriceIncr(id, frozenBrokeragePrice); + } else if (frozenBrokeragePrice < 0) { + int updateRows = memberUserMapper.updateFrozenBrokeragePriceDecr(id, frozenBrokeragePrice); + if (updateRows == 0) { + throw exception(MEMBER_FROZEN_BROKERAGE_PRICE_NOT_ENOUGH); + } + } } } From a708521b9d010bb960eb3434c8007df7ead9e21f Mon Sep 17 00:00:00 2001 From: owen Date: Tue, 5 Sep 2023 19:05:01 +0800 Subject: [PATCH 2/9] =?UTF-8?q?member:=20=E4=BD=A3=E9=87=91=E8=A7=A3?= =?UTF-8?q?=E5=86=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../brokerage/record/MemberBrokerageRecordServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImpl.java index 58dc25af5..c3d6bcebc 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImpl.java @@ -190,7 +190,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe } // 更新用户冻结佣金 - memberUserService.updateUserFrozenBrokeragePrice(record.getUserId(), record.getPrice()); + memberUserService.updateUserFrozenBrokeragePrice(record.getUserId(), -record.getPrice()); log.info("[unfreezeRecord][record({}) 更新为已结算成功]", record.getId()); return true; From 9eb7837b67c0ed8b9d4e85efac33372a0a79ae27 Mon Sep 17 00:00:00 2001 From: owen Date: Tue, 5 Sep 2023 19:43:07 +0800 Subject: [PATCH 3/9] =?UTF-8?q?member:=20=E4=BD=A3=E9=87=91=E5=A4=B1?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/TradeOrderUpdateServiceImpl.java | 9 ++++-- .../api/brokerage/BrokerageApiImpl.java | 2 +- .../record/MemberBrokerageRecordMapper.java | 5 +++ .../dal/mysql/user/MemberUserMapper.java | 32 ++++++++++++++++++- .../record/MemberBrokerageRecordService.java | 10 ++++-- .../MemberBrokerageRecordServiceImpl.java | 26 ++++++++++++++- .../service/user/MemberUserService.java | 8 +++++ .../service/user/MemberUserServiceImpl.java | 22 ++++++++++--- 8 files changed, 102 insertions(+), 12 deletions(-) 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 afb125e08..e2a0f6baf 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 @@ -635,12 +635,12 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { .setRefundStatus(TradeOrderRefundStatusEnum.PART.getStatus()).setRefundPrice(orderRefundPrice)); } - // TODO 芋艿:未来如果有分佣,需要更新相关分佣订单为已失效 - // 扣减用户积分 getSelf().reduceUserPointAsync(order.getUserId(), orderRefundPrice, afterSaleId); // 扣减用户经验 getSelf().reduceUserExperienceAsync(order.getUserId(), orderRefundPrice, afterSaleId); + // 更新分佣记录为已失效 + getSelf().cancelBrokerageAsync(order.getUserId(), id); } @Override @@ -757,6 +757,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { brokerageApi.addBrokerage(userId, list); } + @Async + protected void cancelBrokerageAsync(Long userId, Long orderItemId) { + brokerageApi.cancelBrokerage(userId, String.valueOf(orderItemId)); + } + /** * 获得自身的代理对象,解决 AOP 生效问题 * 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 index 2891bdcc1..662c5165a 100644 --- 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 @@ -27,6 +27,6 @@ public class BrokerageApiImpl implements BrokerageApi { @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/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java index fd3ce05fc..52154aea5 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java @@ -39,4 +39,9 @@ public interface MemberBrokerageRecordMapper extends BaseMapperX { 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); + } + /** * 更新用户冻结佣金(增加) * @@ -94,12 +109,27 @@ public interface MemberUserMapper extends BaseMapperX { /** * 更新用户冻结佣金(减少) + * 注意:理论上冻结佣金可能已经解冻,这时会扣出负数,确保平台不会造成损失 + * + * @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 updateFrozenBrokeragePriceDecr(Long id, int incrCount) { + default int updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(Long id, int incrCount) { Assert.isTrue(incrCount < 0); LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() .setSql(" frozen_brokerage_price = frozen_brokerage_price + " + incrCount + // 负数,所以使用 + 号 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordService.java index 1d0f4e816..cd966e670 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordService.java @@ -33,16 +33,22 @@ public interface MemberBrokerageRecordService { /** * 增加佣金 * - * @param userId 会员ID + * @param userId 会员编号 * @param list 请求参数列表 */ void addBrokerage(Long userId, List list); + /** + * 取消佣金:将佣金记录,状态修改为已失效 + * @param userId 会员编号 + * @param bizId 业务编号 + */ + void cancelBrokerage(Long userId, String bizId); + /** * 解冻佣金:将待结算的佣金记录,状态修改为已结算 * * @return 解冻佣金的数量 */ int unfreezeRecord(); - } 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImpl.java index c3d6bcebc..32656910c 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-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/brokerage/record/MemberBrokerageRecordServiceImpl.java @@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.brokerage.record.MemberBrok 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; @@ -85,6 +86,29 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe addBrokerage(secondUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageSecondPercent(), BrokerageAddReqDTO::getSkuSecondBrokeragePrice); } + @Override + @Transactional(rollbackFor = Exception.class) + public void cancelBrokerage(Long userId, String bizId) { + MemberBrokerageRecordDO record = memberBrokerageRecordMapper.selectByUserIdAndBizTypeAndBizId(BrokerageRecordBizTypeEnum.ORDER.getType(), bizId); + if (record == null || ObjectUtil.notEqual(record.getUserId(), userId)) { + log.error("[cancelBrokerage][userId({})][bizId({}) 更新为已失效失败:记录不存在]", userId, bizId); + return; + } + + MemberBrokerageRecordDO updateObj = new MemberBrokerageRecordDO().setStatus(BrokerageRecordStatusEnum.CANCEL.getStatus()); + int updateRows = memberBrokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); + if (updateRows == 0) { + log.error("[cancelBrokerage][record({}) 更新为已失效失败]", record.getId()); + return; + } + + if (BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus().equals(record.getStatus())) { + memberUserService.updateUserFrozenBrokeragePrice(userId, -record.getPrice()); + } else if (BrokerageRecordStatusEnum.SETTLEMENT.getStatus().equals(record.getStatus())) { + memberUserService.updateUserBrokeragePrice(userId, -record.getPrice()); + } + } + /** * 计算佣金 * @@ -190,7 +214,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe } // 更新用户冻结佣金 - memberUserService.updateUserFrozenBrokeragePrice(record.getUserId(), -record.getPrice()); + memberUserService.updateFrozenBrokeragePriceDecrAndBrokeragePriceIncr(record.getUserId(), -record.getPrice()); log.info("[unfreezeRecord][record({}) 更新为已结算成功]", record.getId()); return true; 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 380ad2c6c..7f599a049 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 @@ -190,4 +190,12 @@ public interface MemberUserService { * @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 0bd17facf..53b452d7c 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,5 +1,6 @@ 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; @@ -272,7 +273,11 @@ public class MemberUserServiceImpl implements MemberUserService { @Override @Transactional(rollbackFor = Exception.class) public void updateUserBrokeragePrice(Long id, int brokeragePrice) { - memberUserMapper.updateBrokeragePriceIncr(id, brokeragePrice); + if (brokeragePrice > 0) { + memberUserMapper.updateBrokeragePriceIncr(id, brokeragePrice); + } else if (brokeragePrice < 0) { + memberUserMapper.updateBrokeragePriceDecr(id, brokeragePrice); + } } @Override @@ -281,10 +286,17 @@ public class MemberUserServiceImpl implements MemberUserService { if (frozenBrokeragePrice > 0) { memberUserMapper.updateFrozenBrokeragePriceIncr(id, frozenBrokeragePrice); } else if (frozenBrokeragePrice < 0) { - int updateRows = memberUserMapper.updateFrozenBrokeragePriceDecr(id, frozenBrokeragePrice); - if (updateRows == 0) { - throw exception(MEMBER_FROZEN_BROKERAGE_PRICE_NOT_ENOUGH); - } + 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); } } From 64745027380a7e4d99cda3d5af2d393c084171c5 Mon Sep 17 00:00:00 2001 From: owen Date: Tue, 5 Sep 2023 22:31:36 +0800 Subject: [PATCH 4/9] =?UTF-8?q?trade:=20=E5=A2=9E=E5=8A=A0=E4=BA=A4?= =?UTF-8?q?=E6=98=93=E4=B8=AD=E5=BF=83=E9=85=8D=E7=BD=AE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/brokerage.sql | 55 +++++++----- .../admin/config/TradeConfigController.java | 45 ++++++++++ .../admin/config/vo/TradeConfigBaseVO.java | 71 +++++++++++++++ .../admin/config/vo/TradeConfigRespVO.java | 17 ++++ .../admin/config/vo/TradeConfigSaveReqVO.java | 14 +++ .../convert/config/TradeConfigConvert.java | 23 +++++ .../dal/dataobject/config/TradeConfigDO.java | 90 +++++++++++++++++++ .../dal/mysql/config/TradeConfigMapper.java | 15 ++++ .../service/config/TradeConfigService.java | 30 +++++++ .../config/TradeConfigServiceImpl.java | 44 +++++++++ 10 files changed, 384 insertions(+), 20 deletions(-) create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java diff --git a/sql/mysql/brokerage.sql b/sql/mysql/brokerage.sql index 187e07621..ed8c5fcbe 100644 --- a/sql/mysql/brokerage.sql +++ b/sql/mysql/brokerage.sql @@ -1,24 +1,25 @@ -- 增加配置 -alter table member_point_config - add column brokerage_enabled bit default 1 not null comment '是否启用分佣'; -alter table member_point_config - add column brokerage_enabled_condition tinyint default 0 not null comment '分佣模式:0-人人分销 1-指定分销'; -alter table member_point_config - add column brokerage_bind_mode tinyint default 0 not null comment '分销关系绑定模式: 0-没有推广人,1-新用户'; -alter table member_point_config - add column brokerage_post_urls varchar(2000) null comment '分销海报图地址数组'; -alter table member_point_config - add column brokerage_first_percent int not null comment '一级返佣比例'; -alter table member_point_config - add column brokerage_second_percent int not null comment '二级返佣比例'; -alter table member_point_config - add column brokerage_withdraw_min_price int not null comment '用户提现最低金额'; -alter table member_point_config - add column brokerage_bank_names varchar(200) not null comment '提现银行(字典类型=brokerage_bank_name)'; -alter table member_point_config - add column brokerage_frozen_days int default 7 not null comment '佣金冻结时间(天)'; -alter table member_point_config - add column brokerage_withdraw_type varchar(32) default '1,2,3,4' not null comment '提现方式:1-钱包;2-银行卡;3-微信;4-支付宝'; +create table trade_config +( + id bigint auto_increment comment '自增主键' + primary key, + brokerage_enabled bit default 1 not null comment '是否启用分佣', + brokerage_enabled_condition tinyint default 0 not null comment '分佣模式:0-人人分销 1-指定分销', + brokerage_bind_mode tinyint default 0 not null comment '分销关系绑定模式: 0-没有推广人,1-新用户', + brokerage_post_urls varchar(2000) default '' null comment '分销海报图地址数组', + brokerage_first_percent int default 0 not null comment '一级返佣比例', + brokerage_second_percent int default 0 not null comment '二级返佣比例', + brokerage_withdraw_min_price int default 0 not null comment '用户提现最低金额', + brokerage_bank_names varchar(200) default '' not null comment '提现银行(字典类型=brokerage_bank_name)', + brokerage_frozen_days int default 7 not null comment '佣金冻结时间(天)', + brokerage_withdraw_type varchar(32) default '1,2,3,4' not null comment '提现方式:1-钱包;2-银行卡;3-微信;4-支付宝', + creator varchar(64) collate utf8mb4_unicode_ci default '' null comment '创建者', + create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updater varchar(64) collate utf8mb4_unicode_ci default '' null comment '更新者', + update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + deleted bit default b'0' not null comment '是否删除', + tenant_id bigint default 0 not null comment '租户编号' +) comment '交易中心配置'; -- 用户表增加分销相关字段 alter table member_user @@ -187,3 +188,17 @@ SELECT @parentId := LAST_INSERT_ID(); -- 按钮 SQL INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) VALUES ('佣金提现查询', 'member:brokerage-withdraw:query', 3, 1, @parentId, '', '', '', 0); + +-- 交易中心配置:菜单 SQL +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) +VALUES ('交易中心配置', '', 2, 0, 2072, 'config', '', 'trade/config/index', 0, 'TradeConfig'); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) +VALUES ('交易中心配置查询', 'trade:config:query', 3, 1, @parentId, '', '', '', 0); +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) +VALUES ('交易中心配置保存', 'trade:config:save', 3, 2, @parentId, '', '', '', 0); \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java new file mode 100644 index 000000000..e41f98081 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java @@ -0,0 +1,45 @@ +package cn.iocoder.yudao.module.trade.controller.admin.config; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigRespVO; +import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; +import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; +import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; +import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 交易中心配置") +@RestController +@RequestMapping("/trade/config") +@Validated +public class TradeConfigController { + + @Resource + private TradeConfigService tradeConfigService; + + @PutMapping("/save") + @Operation(summary = "更新交易中心配置") + @PreAuthorize("@ss.hasPermission('trade:config:save')") + public CommonResult updateConfig(@Valid @RequestBody TradeConfigSaveReqVO updateReqVO) { + tradeConfigService.saveTradeConfig(updateReqVO); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得交易中心配置") + @PreAuthorize("@ss.hasPermission('trade:config:query')") + public CommonResult getConfig() { + TradeConfigDO config = tradeConfigService.getTradeConfig(); + return success(TradeConfigConvert.INSTANCE.convert(config)); + } + +} 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 new file mode 100644 index 000000000..4ee51e3b8 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java @@ -0,0 +1,71 @@ +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 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 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class TradeConfigBaseVO { + + // ========== 分销相关 ========== + + @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-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java new file mode 100644 index 000000000..52aff751f --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.module.trade.controller.admin.config.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 交易中心配置 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class TradeConfigRespVO extends TradeConfigBaseVO { + + @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java new file mode 100644 index 000000000..03a0c41df --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.trade.controller.admin.config.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 交易中心配置更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class TradeConfigSaveReqVO extends TradeConfigBaseVO { + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java new file mode 100644 index 000000000..031f1198a --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.trade.convert.config; + +import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigRespVO; +import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * 交易中心配置 Convert + * + * @author owen + */ +@Mapper +public interface TradeConfigConvert { + + TradeConfigConvert INSTANCE = Mappers.getMapper(TradeConfigConvert.class); + + TradeConfigDO convert(TradeConfigSaveReqVO bean); + + TradeConfigRespVO convert(TradeConfigDO bean); + +} 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 new file mode 100644 index 000000000..5538186e1 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java @@ -0,0 +1,90 @@ +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 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 + * + * @author owen + */ +@TableName(value = "trade_config", autoResultMap = true) +@KeySequence("trade_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TradeConfigDO extends BaseDO { + + /** + * 自增主键 + */ + @TableId + private Long id; + + // ========== 分销相关 ========== + + /** + * 是否启用分佣 + */ + 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-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java new file mode 100644 index 000000000..18a3f4df7 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.module.trade.dal.mysql.config; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 交易中心配置 Mapper + * + * @author owen + */ +@Mapper +public interface TradeConfigMapper extends BaseMapperX { + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java new file mode 100644 index 000000000..c00825f2e --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.trade.service.config; + +import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; + +import javax.validation.Valid; + +/** + * 交易中心配置 Service 接口 + * + * @author owen + */ +public interface TradeConfigService { + + + /** + * 更新交易中心配置 + * + * @param updateReqVO 更新信息 + */ + void saveTradeConfig(@Valid TradeConfigSaveReqVO updateReqVO); + + /** + * 获得交易中心配置 + * + * @return 交易中心配置 + */ + TradeConfigDO getTradeConfig(); + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java new file mode 100644 index 000000000..c859cdee6 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.trade.service.config; + +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; +import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; +import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; +import cn.iocoder.yudao.module.trade.dal.mysql.config.TradeConfigMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 交易中心配置 Service 实现类 + * + * @author owen + */ +@Service +@Validated +public class TradeConfigServiceImpl implements TradeConfigService { + + @Resource + private TradeConfigMapper tradeConfigMapper; + + @Override + public void saveTradeConfig(TradeConfigSaveReqVO saveReqVO) { + // 存在,则进行更新 + TradeConfigDO dbConfig = getTradeConfig(); + if (dbConfig != null) { + tradeConfigMapper.updateById(TradeConfigConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId())); + return; + } + // 不存在,则进行插入 + tradeConfigMapper.insert(TradeConfigConvert.INSTANCE.convert(saveReqVO)); + } + + @Override + public TradeConfigDO getTradeConfig() { + List list = tradeConfigMapper.selectList(); + return CollectionUtils.getFirst(list); + } + +} From a68691f2d93623404628fce2d7f222c4240cec5d Mon Sep 17 00:00:00 2001 From: owen Date: Tue, 5 Sep 2023 23:45:53 +0800 Subject: [PATCH 5/9] =?UTF-8?q?trade:=20=E5=A2=9E=E5=8A=A0=E5=88=86?= =?UTF-8?q?=E9=94=80=E7=94=A8=E6=88=B7=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/brokerage.sql | 133 ++++++++++-------- .../trade/enums/ErrorCodeConstants.java | 4 + .../user/TradeBrokerageUserController.java | 71 ++++++++++ .../user/vo/TradeBrokerageUserBaseVO.java | 43 ++++++ ...eBrokerageUserClearBrokerageUserReqVO.java | 18 +++ .../user/vo/TradeBrokerageUserPageReqVO.java | 30 ++++ .../user/vo/TradeBrokerageUserRespVO.java | 22 +++ ...kerageUserUpdateBrokerageEnabledReqVO.java | 22 +++ ...BrokerageUserUpdateBrokerageUserReqVO.java | 22 +++ .../user/TradeBrokerageUserConvert.java | 27 ++++ .../brokerage/user/TradeBrokerageUserDO.java | 56 ++++++++ .../user/TradeBrokerageUserMapper.java | 26 ++++ .../user/TradeBrokerageUserService.java | 56 ++++++++ .../user/TradeBrokerageUserServiceImpl.java | 63 +++++++++ .../TradeBrokerageUserServiceImplTest.java | 64 +++++++++ .../src/test/resources/sql/clean.sql | 1 + .../src/test/resources/sql/create_tables.sql | 18 +++ 17 files changed, 616 insertions(+), 60 deletions(-) create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/TradeBrokerageUserController.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserBaseVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserClearBrokerageUserReqVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserPageReqVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserRespVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserUpdateBrokerageEnabledReqVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserUpdateBrokerageUserReqVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/user/TradeBrokerageUserConvert.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/user/TradeBrokerageUserDO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/TradeBrokerageUserMapper.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserService.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImpl.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImplTest.java diff --git a/sql/mysql/brokerage.sql b/sql/mysql/brokerage.sql index ed8c5fcbe..161dfa256 100644 --- a/sql/mysql/brokerage.sql +++ b/sql/mysql/brokerage.sql @@ -1,8 +1,7 @@ --- 增加配置 +-- 增加配置表 create table trade_config ( - id bigint auto_increment comment '自增主键' - primary key, + id bigint auto_increment comment '自增主键' primary key, brokerage_enabled bit default 1 not null comment '是否启用分佣', brokerage_enabled_condition tinyint default 0 not null comment '分佣模式:0-人人分销 1-指定分销', brokerage_bind_mode tinyint default 0 not null comment '分销关系绑定模式: 0-没有推广人,1-新用户', @@ -21,22 +20,26 @@ create table trade_config tenant_id bigint default 0 not null comment '租户编号' ) comment '交易中心配置'; --- 用户表增加分销相关字段 -alter table member_user - add column brokerage_user_id bigint not null comment '推广员编号'; -alter table member_user - add column brokerage_bind_time datetime null comment '推广员绑定时间'; -alter table member_user - add column brokerage_enabled bit default 1 not null comment '是否成为推广员'; -alter table member_user - add column brokerage_time datetime null comment '成为分销员时间'; -alter table member_user - add column brokerage_price int default 0 not null comment '可用佣金'; -alter table member_user - add column frozen_brokerage_price int default 0 not null comment '冻结佣金'; +-- 增加分销用户扩展表 +create table trade_brokerage_user +( + id bigint auto_increment comment '用户编号' primary key, + brokerage_user_id bigint not null comment '推广员编号', + brokerage_bind_time datetime null comment '推广员绑定时间', + brokerage_enabled bit default 1 not null comment '是否成为推广员', + brokerage_time datetime null comment '成为分销员时间', + brokerage_price int default 0 not null comment '可用佣金', + frozen_brokerage_price int default 0 not null comment '冻结佣金', + creator varchar(64) collate utf8mb4_unicode_ci default '' null comment '创建者', + create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updater varchar(64) collate utf8mb4_unicode_ci default '' null comment '更新者', + update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + deleted bit default b'0' not null comment '是否删除', + tenant_id bigint default 0 not null comment '租户编号' +) comment '分销用户'; -create index idx_invite_user_id on member_user (brokerage_user_id) comment '推广员编号'; -create index idx_agent on member_user (brokerage_enabled) comment '是否成为推广员'; +create index idx_invite_user_id on trade_brokerage_user (brokerage_user_id) comment '推广员编号'; +create index idx_agent on trade_brokerage_user (brokerage_enabled) comment '是否成为推广员'; create table member_brokerage_record @@ -150,55 +153,65 @@ values ('brokerage_bank_name', '工商银行', 0, 0), ('brokerage_bank_name', '交通银行', 4, 4), ('brokerage_bank_name', '招商银行', 5, 5); --- 增加菜单:分销员管理 -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) -VALUES ('分销员', '', 2, 7, 2262, 'brokerage', 'user', 'member/brokerage/user/index', 0, 'MemberBrokerageUser'); --- 按钮父菜单ID -SELECT @parentId := LAST_INSERT_ID(); --- 按钮 SQL -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) -VALUES ('分销员查询', 'member:brokerage-user:query', 3, 1, @parentId, '', '', '', 0); -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) -VALUES ('分销员创建', 'member:brokerage-user:create', 3, 2, @parentId, '', '', '', 0); -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) -VALUES ('分销员更新', 'member:brokerage-user:update', 3, 3, @parentId, '', '', '', 0); -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) -VALUES ('分销员删除', 'member:brokerage-user:delete', 3, 4, @parentId, '', '', '', 0); - --- 增加菜单:佣金记录 -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) -VALUES ('佣金记录', '', 2, 8, 2262, 'brokerage-record', 'list', 'member/brokerage/record/index', 0, - 'MemberBrokerageRecord'); --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); --- 按钮 SQL -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) -VALUES ('佣金记录查询', 'member:member-brokerage-record:query', 3, 1, @parentId, '', 'table', '', 0); - --- 增加菜单:佣金提现 -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) -VALUES ('佣金提现', '', 2, 9, 2262, 'brokerage-withdraw', '', 'member/brokerage/withdraw/index', 0, - 'MemberBrokerageWithdraw'); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) -VALUES ('佣金提现查询', 'member:brokerage-withdraw:query', 3, 1, @parentId, '', '', '', 0); -- 交易中心配置:菜单 SQL INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) -VALUES ('交易中心配置', '', 2, 0, 2072, 'config', '', 'trade/config/index', 0, 'TradeConfig'); - +VALUES ('交易中心配置', '', 2, 0, 2072, 'config', 'ep:setting', 'trade/config/index', 0, 'TradeConfig'); -- 按钮父菜单ID -- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 SELECT @parentId := LAST_INSERT_ID(); - -- 按钮 SQL INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) VALUES ('交易中心配置查询', 'trade:config:query', 3, 1, @parentId, '', '', '', 0); INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) -VALUES ('交易中心配置保存', 'trade:config:save', 3, 2, @parentId, '', '', '', 0); \ No newline at end of file +VALUES ('交易中心配置保存', 'trade:config:save', 3, 2, @parentId, '', '', '', 0); + + +-- 增加菜单:分销 +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) +VALUES ('分销', '', 1, 5, 2072, 'brokerage', 'fa-solid:project-diagram', '', 0, ''); +-- 按钮父菜单ID +SELECT @brokerageMenuId := LAST_INSERT_ID(); + +-- 增加菜单:分销员 +-- 菜单 SQL +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) +VALUES ('分销用户', '', 2, 0, @brokerageMenuId, 'brokerage-user', 'fa-solid:user-tie', 'trade/brokerage/user/index', 0, + 'TradeBrokerageUser'); +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); +-- 按钮 SQL +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) +VALUES ('分销用户查询', 'trade:brokerage-user:query', 3, 1, @parentId, '', '', '', 0); +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) +VALUES ('分销用户修改推广员', 'trade:brokerage-user:update-brokerage-user', 3, 2, @parentId, '', '', '', 0); +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) +VALUES ('分销用户清除推广员', 'trade:brokerage-user:clear-brokerage-user', 3, 3, @parentId, '', '', '', 0); +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) +VALUES ('分销用户修改推广资格', 'trade:brokerage-user:update-brokerage-enable', 3, 4, @parentId, '', '', '', 0); + + +-- 增加菜单:佣金记录 +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) +VALUES ('佣金记录', '', 2, 1, @brokerageMenuId, 'brokerage-record', 'fa:money', 'trade/brokerage/record/index', 0, + 'TradeBrokerageRecord'); +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); +-- 按钮 SQL +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) +VALUES ('佣金记录查询', 'trade:brokerage-record:query', 3, 1, @parentId, '', '', '', 0); + +-- 增加菜单:佣金提现 +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) +VALUES ('佣金提现', '', 2, 2, @brokerageMenuId, 'brokerage-withdraw', 'fa:credit-card', + 'trade/brokerage/withdraw/index', 0, 'TradeBrokerageWithdraw'); +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); +-- 按钮 SQL +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) +VALUES ('佣金提现查询', 'trade:brokerage-withdraw:query', 3, 1, @parentId, '', '', '', 0); +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) +VALUES ('佣金提现审核', 'trade:brokerage-withdraw:audit', 3, 2, @parentId, '', '', '', 0); \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java index 40f604e94..3107dbedf 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java @@ -74,4 +74,8 @@ public interface ErrorCodeConstants { // ========== 物流 PICK_UP 模块 1011006000 ========== ErrorCode PICK_UP_STORE_NOT_EXISTS = new ErrorCode(1011006000, "自提门店不存在"); + + // ========== 分销 分销用户 模块 1011007000 ========== + ErrorCode BROKERAGE_USER_NOT_EXISTS = new ErrorCode(1011007000, "分销用户不存在"); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/TradeBrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/TradeBrokerageUserController.java new file mode 100644 index 000000000..e4cc63fb9 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/TradeBrokerageUserController.java @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.*; +import cn.iocoder.yudao.module.trade.convert.brokerage.user.TradeBrokerageUserConvert; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO; +import cn.iocoder.yudao.module.trade.service.brokerage.user.TradeBrokerageUserService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 分销用户") +@RestController +@RequestMapping("/trade/brokerage-user") +@Validated +public class TradeBrokerageUserController { + + @Resource + private TradeBrokerageUserService brokerageUserService; + + @PutMapping("/update-brokerage-user") + @Operation(summary = "修改推广员") + @PreAuthorize("@ss.hasPermission('trade:brokerage-user:update-brokerage-user')") + public CommonResult updateBrokerageUser(@Valid @RequestBody TradeBrokerageUserUpdateBrokerageUserReqVO updateReqVO) { + brokerageUserService.updateBrokerageUserId(updateReqVO.getId(), updateReqVO.getBrokerageUserId()); + return success(true); + } + + @PutMapping("/clear-brokerage-user") + @Operation(summary = "清除推广员") + @PreAuthorize("@ss.hasPermission('trade:brokerage-user:clear-brokerage-user')") + public CommonResult clearBrokerageUser(@Valid @RequestBody TradeBrokerageUserClearBrokerageUserReqVO updateReqVO) { + brokerageUserService.updateBrokerageUserId(updateReqVO.getId(), null); + return success(true); + } + + @PutMapping("/update-brokerage-enable") + @Operation(summary = "修改推广资格") + @PreAuthorize("@ss.hasPermission('trade:brokerage-user:update-brokerage-enable')") + public CommonResult updateBrokerageEnabled(@Valid @RequestBody TradeBrokerageUserUpdateBrokerageEnabledReqVO updateReqVO) { + brokerageUserService.updateBrokerageEnabled(updateReqVO.getId(), updateReqVO.getBrokerageEnabled()); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得分销用户") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')") + public CommonResult getBrokerageUser(@RequestParam("id") Long id) { + TradeBrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(id); + return success(TradeBrokerageUserConvert.INSTANCE.convert(brokerageUser)); + } + + @GetMapping("/page") + @Operation(summary = "获得分销用户分页") + @PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')") + public CommonResult> getBrokerageUserPage(@Valid TradeBrokerageUserPageReqVO pageVO) { + PageResult pageResult = brokerageUserService.getBrokerageUserPage(pageVO); + return success(TradeBrokerageUserConvert.INSTANCE.convertPage(pageResult)); + } + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserBaseVO.java new file mode 100644 index 000000000..d75e6a1b1 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserBaseVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 分销用户 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class TradeBrokerageUserBaseVO { + + @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587") + @NotNull(message = "推广员编号不能为空") + private Long brokerageUserId; + + @Schema(description = "推广员绑定时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime brokerageBindTime; + + @Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "推广资格不能为空") + private Boolean brokerageEnabled; + + @Schema(description = "成为分销员时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime brokerageTime; + + @Schema(description = "可用佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "11089") + @NotNull(message = "可用佣金不能为空") + private Integer brokeragePrice; + + @Schema(description = "冻结佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "30916") + @NotNull(message = "冻结佣金不能为空") + private Integer frozenBrokeragePrice; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserClearBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserClearBrokerageUserReqVO.java new file mode 100644 index 000000000..18a5a5e85 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserClearBrokerageUserReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.ToString; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 分销用户 - 清除推广员 Request VO") +@Data +@ToString(callSuper = true) +public class TradeBrokerageUserClearBrokerageUserReqVO { + + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") + @NotNull(message = "用户编号不能为空") + private Long id; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserPageReqVO.java new file mode 100644 index 000000000..ec63775d3 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserPageReqVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 分销用户分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class TradeBrokerageUserPageReqVO extends PageParam { + + @Schema(description = "推广员编号", example = "4587") + private Long brokerageUserId; + + @Schema(description = "推广资格") + private Boolean brokerageEnabled; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserRespVO.java new file mode 100644 index 000000000..090eb04b5 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserRespVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 分销用户 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class TradeBrokerageUserRespVO extends TradeBrokerageUserBaseVO { + + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserUpdateBrokerageEnabledReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserUpdateBrokerageEnabledReqVO.java new file mode 100644 index 000000000..002eed371 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserUpdateBrokerageEnabledReqVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.ToString; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") +@Data +@ToString(callSuper = true) +public class TradeBrokerageUserUpdateBrokerageEnabledReqVO { + + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") + @NotNull(message = "用户编号不能为空") + private Long id; + + @Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "推广资格不能为空") + private Boolean brokerageEnabled; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserUpdateBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserUpdateBrokerageUserReqVO.java new file mode 100644 index 000000000..28ea301c1 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserUpdateBrokerageUserReqVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.ToString; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") +@Data +@ToString(callSuper = true) +public class TradeBrokerageUserUpdateBrokerageUserReqVO { + + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") + @NotNull(message = "用户编号不能为空") + private Long id; + + @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587") + @NotNull(message = "推广员编号不能为空") + private Long brokerageUserId; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/user/TradeBrokerageUserConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/user/TradeBrokerageUserConvert.java new file mode 100644 index 000000000..1a62bded0 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/user/TradeBrokerageUserConvert.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.trade.convert.brokerage.user; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserRespVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 分销用户 Convert + * + * @author owen + */ +@Mapper +public interface TradeBrokerageUserConvert { + + TradeBrokerageUserConvert INSTANCE = Mappers.getMapper(TradeBrokerageUserConvert.class); + + TradeBrokerageUserRespVO convert(TradeBrokerageUserDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/user/TradeBrokerageUserDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/user/TradeBrokerageUserDO.java new file mode 100644 index 000000000..0bc552dca --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/user/TradeBrokerageUserDO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.time.LocalDateTime; + +/** + * 分销用户 DO + * + * @author owen + */ +@TableName("trade_brokerage_user") +@KeySequence("trade_brokerage_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TradeBrokerageUserDO extends BaseDO { + + /** + * 用户编号 + */ + @TableId + private Long id; + /** + * 推广员编号 + */ + private Long brokerageUserId; + /** + * 推广员绑定时间 + */ + private LocalDateTime brokerageBindTime; + /** + * 推广资格 + */ + private Boolean brokerageEnabled; + /** + * 成为分销员时间 + */ + private LocalDateTime brokerageTime; + /** + * 可用佣金 + */ + private Integer brokeragePrice; + /** + * 冻结佣金 + */ + private Integer frozenBrokeragePrice; + +} 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 new file mode 100644 index 000000000..93656837a --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/TradeBrokerageUserMapper.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user; + +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 org.apache.ibatis.annotations.Mapper; + +/** + * 分销用户 Mapper + * + * @author owen + */ +@Mapper +public interface TradeBrokerageUserMapper extends BaseMapperX { + + default PageResult selectPage(TradeBrokerageUserPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(TradeBrokerageUserDO::getBrokerageUserId, reqVO.getBrokerageUserId()) + .eqIfPresent(TradeBrokerageUserDO::getBrokerageEnabled, reqVO.getBrokerageEnabled()) + .betweenIfPresent(TradeBrokerageUserDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(TradeBrokerageUserDO::getId)); + } + +} 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 new file mode 100644 index 000000000..58970d724 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserService.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.trade.service.brokerage.user; + +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 java.util.Collection; +import java.util.List; + +/** + * 分销用户 Service 接口 + * + * @author owen + */ +public interface TradeBrokerageUserService { + + /** + * 获得分销用户 + * + * @param id 编号 + * @return 分销用户 + */ + TradeBrokerageUserDO getBrokerageUser(Long id); + + /** + * 获得分销用户列表 + * + * @param ids 编号 + * @return 分销用户列表 + */ + List getBrokerageUserList(Collection ids); + + /** + * 获得分销用户分页 + * + * @param pageReqVO 分页查询 + * @return 分销用户分页 + */ + PageResult getBrokerageUserPage(TradeBrokerageUserPageReqVO pageReqVO); + + /** + * 修改推广员编号 + * + * @param id 用户编号 + * @param brokerageUserId 推广员编号 + */ + void updateBrokerageUserId(Long id, Long brokerageUserId); + + /** + * 修改推广资格 + * + * @param id 用户编号 + * @param brokerageEnabled 推广资格 + */ + void updateBrokerageEnabled(Long id, Boolean brokerageEnabled); +} 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 new file mode 100644 index 000000000..acbda456b --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImpl.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.trade.service.brokerage.user; + +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.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_USER_NOT_EXISTS; + +/** + * 分销用户 Service 实现类 + * + * @author owen + */ +@Service +@Validated +public class TradeBrokerageUserServiceImpl implements TradeBrokerageUserService { + + @Resource + private TradeBrokerageUserMapper brokerageUserMapper; + + private void validateBrokerageUserExists(Long id) { + if (brokerageUserMapper.selectById(id) == null) { + throw exception(BROKERAGE_USER_NOT_EXISTS); + } + } + + @Override + public TradeBrokerageUserDO getBrokerageUser(Long id) { + return brokerageUserMapper.selectById(id); + } + + @Override + public List getBrokerageUserList(Collection ids) { + return brokerageUserMapper.selectBatchIds(ids); + } + + @Override + public PageResult getBrokerageUserPage(TradeBrokerageUserPageReqVO pageReqVO) { + return brokerageUserMapper.selectPage(pageReqVO); + } + + @Override + public void updateBrokerageUserId(Long id, Long brokerageUserId) { + // 校验存在 + validateBrokerageUserExists(id); + + } + + @Override + public void updateBrokerageEnabled(Long id, Boolean brokerageEnabled) { + // 校验存在 + validateBrokerageUserExists(id); + } + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImplTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImplTest.java new file mode 100644 index 000000000..49e8aa351 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImplTest.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.module.trade.service.brokerage.user; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +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.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * {@link TradeBrokerageUserServiceImpl} 的单元测试类 + * + * @author owen + */ +@Import(TradeBrokerageUserServiceImpl.class) +public class TradeBrokerageUserServiceImplTest extends BaseDbUnitTest { + + @Resource + private TradeBrokerageUserServiceImpl brokerageUserService; + + @Resource + private TradeBrokerageUserMapper brokerageUserMapper; + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBrokerageUserPage() { + // mock 数据 + TradeBrokerageUserDO dbBrokerageUser = randomPojo(TradeBrokerageUserDO.class, o -> { // 等会查询到 + o.setBrokerageUserId(null); + o.setBrokerageEnabled(null); + o.setCreateTime(null); + }); + brokerageUserMapper.insert(dbBrokerageUser); + // 测试 brokerageUserId 不匹配 + brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setBrokerageUserId(null))); + // 测试 brokerageEnabled 不匹配 + brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setBrokerageEnabled(null))); + // 测试 createTime 不匹配 + brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setCreateTime(null))); + // 准备参数 + TradeBrokerageUserPageReqVO reqVO = new TradeBrokerageUserPageReqVO(); + reqVO.setBrokerageUserId(null); + reqVO.setBrokerageEnabled(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = brokerageUserService.getBrokerageUserPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbBrokerageUser, pageResult.getList().get(0)); + } + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql index dfa4a5b42..b0715ca16 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql @@ -2,3 +2,4 @@ DELETE FROM trade_order; DELETE FROM trade_order_item; DELETE FROM trade_after_sale; DELETE FROM trade_after_sale_log; +DELETE FROM "trade_brokerage_user"; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql index e30b0d225..df68fd53b 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql @@ -125,3 +125,21 @@ CREATE TABLE IF NOT EXISTS "trade_after_sale_log" ( "deleted" bit NOT NULL DEFAULT FALSE, PRIMARY KEY ("id") ) COMMENT '交易售后日志'; + +CREATE TABLE IF NOT EXISTS "trade_brokerage_user" +( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "brokerage_user_id" bigint NOT NULL, + "brokerage_bind_time" varchar, + "brokerage_enabled" bit NOT NULL, + "brokerage_time" varchar, + "brokerage_price" int NOT NULL, + "frozen_brokerage_price" int NOT NULL, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint NOT NULL DEFAULT '0', + PRIMARY KEY ("id") +) COMMENT '分销用户'; \ No newline at end of file From 9336a0a1024ccdc5dd30a1d56cf054a884082477 Mon Sep 17 00:00:00 2001 From: owen Date: Wed, 6 Sep 2023 00:16:47 +0800 Subject: [PATCH 6/9] =?UTF-8?q?trade:=20=E5=88=86=E9=94=80=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E4=BB=8E=20member=20=E6=A8=A1=E5=9D=97=20=E8=BD=AC?= =?UTF-8?q?=E7=A7=BB=E5=88=B0=20trade=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../brokerage/BrokerageBindModeEnum.java | 2 +- .../BrokerageEnabledConditionEnum.java | 2 +- .../brokerage/BrokerageRecordBizTypeEnum.java | 2 +- .../brokerage/BrokerageRecordStatusEnum.java | 2 +- .../BrokerageWithdrawStatusEnum.java | 2 +- .../brokerage/BrokerageWithdrawTypeEnum.java | 2 +- .../yudao-module-trade-biz/pom.xml | 4 + .../MemberBrokerageRecordController.java | 14 ++-- .../vo/MemberBrokerageRecordBaseVO.java | 2 +- .../vo/MemberBrokerageRecordPageReqVO.java | 2 +- .../vo/MemberBrokerageRecordRespVO.java | 2 +- .../admin/config/vo/TradeConfigBaseVO.java | 6 +- .../record/MemberBrokerageRecordConvert.java | 14 ++-- .../convert/order/TradeOrderConvert.java | 2 +- .../record/MemberBrokerageRecordDO.java | 6 +- .../dal/dataobject/config/TradeConfigDO.java | 6 +- .../record/MemberBrokerageRecordMapper.java | 6 +- .../user/TradeBrokerageUserMapper.java | 77 +++++++++++++++++++ .../MemberBrokerageRecordUnfreezeJob.java | 4 +- .../record/MemberBrokerageRecordService.java | 8 +- .../MemberBrokerageRecordServiceImpl.java | 46 +++++------ .../record/bo}/BrokerageAddReqDTO.java | 2 +- .../user/TradeBrokerageUserService.java | 32 ++++++++ .../user/TradeBrokerageUserServiceImpl.java | 43 +++++++++++ .../order/TradeOrderUpdateServiceImpl.java | 10 +-- .../MemberBrokerageRecordServiceImplTest.java | 16 ++-- .../member/api/brokerage/BrokerageApi.java | 30 -------- .../api/brokerage/BrokerageApiImpl.java | 32 -------- .../vo/config/MemberPointConfigBaseVO.java | 57 -------------- .../dataobject/point/MemberPointConfigDO.java | 60 --------------- .../dal/mysql/user/MemberUserMapper.java | 77 ------------------- .../service/user/MemberUserService.java | 32 -------- .../service/user/MemberUserServiceImpl.java | 41 ---------- 33 files changed, 235 insertions(+), 408 deletions(-) rename {yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade}/enums/brokerage/BrokerageBindModeEnum.java (93%) rename {yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade}/enums/brokerage/BrokerageEnabledConditionEnum.java (93%) rename {yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade}/enums/brokerage/BrokerageRecordBizTypeEnum.java (94%) rename {yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade}/enums/brokerage/BrokerageRecordStatusEnum.java (92%) rename {yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade}/enums/brokerage/BrokerageWithdrawStatusEnum.java (93%) rename {yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade}/enums/brokerage/BrokerageWithdrawTypeEnum.java (92%) rename {yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade}/controller/admin/brokerage/record/MemberBrokerageRecordController.java (76%) rename {yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade}/controller/admin/brokerage/record/vo/MemberBrokerageRecordBaseVO.java (96%) rename {yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade}/controller/admin/brokerage/record/vo/MemberBrokerageRecordPageReqVO.java (92%) rename {yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade}/controller/admin/brokerage/record/vo/MemberBrokerageRecordRespVO.java (89%) rename {yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade}/convert/brokerage/record/MemberBrokerageRecordConvert.java (70%) rename {yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade}/dal/dataobject/brokerage/record/MemberBrokerageRecordDO.java (86%) rename {yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade}/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java (88%) rename {yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade}/job/brokerage/MemberBrokerageRecordUnfreezeJob.java (81%) rename {yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade}/service/brokerage/record/MemberBrokerageRecordService.java (76%) rename {yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade}/service/brokerage/record/MemberBrokerageRecordServiceImpl.java (79%) rename {yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/dto => yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo}/BrokerageAddReqDTO.java (89%) rename {yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member => yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade}/service/brokerage/record/MemberBrokerageRecordServiceImplTest.java (87%) delete mode 100644 yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/BrokerageApi.java delete mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/brokerage/BrokerageApiImpl.java 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); - } - } - } From fa53a3b15e4f214df3cddf8950907b4232b39649 Mon Sep 17 00:00:00 2001 From: owen Date: Wed, 6 Sep 2023 00:35:40 +0800 Subject: [PATCH 7/9] =?UTF-8?q?trade:=20MemberBrokerageRecord=20=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E4=B8=BA=20TradeBrokerageRecord?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/brokerage.sql | 14 ++--- ...va => TradeBrokerageRecordController.java} | 32 +++++----- ...O.java => TradeBrokerageRecordBaseVO.java} | 2 +- ...ava => TradeBrokerageRecordPageReqVO.java} | 2 +- ...O.java => TradeBrokerageRecordRespVO.java} | 2 +- ....java => TradeBrokerageRecordConvert.java} | 18 +++--- .../convert/order/TradeOrderConvert.java | 6 +- ...ordDO.java => TradeBrokerageRecordDO.java} | 6 +- .../record/MemberBrokerageRecordMapper.java | 47 --------------- .../record/TradeBrokerageRecordMapper.java | 47 +++++++++++++++ ...a => TradeBrokerageRecordUnfreezeJob.java} | 8 +-- ....java => TradeBrokerageRecordService.java} | 14 ++--- ...a => TradeBrokerageRecordServiceImpl.java} | 58 +++++++++---------- ...eAddReqDTO.java => BrokerageAddReqBO.java} | 4 +- .../order/TradeOrderUpdateServiceImpl.java | 12 ++-- ... TradeBrokerageRecordServiceImplTest.java} | 42 +++++++------- .../src/test/resources/sql/clean.sql | 3 +- .../src/test/resources/sql/create_tables.sql | 23 +++++++- .../src/test/resources/sql/clean.sql | 3 +- .../src/test/resources/sql/create_tables.sql | 23 +------- 20 files changed, 183 insertions(+), 183 deletions(-) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/{MemberBrokerageRecordController.java => TradeBrokerageRecordController.java} (51%) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/{MemberBrokerageRecordBaseVO.java => TradeBrokerageRecordBaseVO.java} (98%) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/{MemberBrokerageRecordPageReqVO.java => TradeBrokerageRecordPageReqVO.java} (94%) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/{MemberBrokerageRecordRespVO.java => TradeBrokerageRecordRespVO.java} (88%) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/{MemberBrokerageRecordConvert.java => TradeBrokerageRecordConvert.java} (69%) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/record/{MemberBrokerageRecordDO.java => TradeBrokerageRecordDO.java} (85%) delete mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/TradeBrokerageRecordMapper.java rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/{MemberBrokerageRecordUnfreezeJob.java => TradeBrokerageRecordUnfreezeJob.java} (63%) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/{MemberBrokerageRecordService.java => TradeBrokerageRecordService.java} (74%) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/{MemberBrokerageRecordServiceImpl.java => TradeBrokerageRecordServiceImpl.java} (78%) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo/{BrokerageAddReqDTO.java => BrokerageAddReqBO.java} (90%) rename yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/record/{MemberBrokerageRecordServiceImplTest.java => TradeBrokerageRecordServiceImplTest.java} (66%) diff --git a/sql/mysql/brokerage.sql b/sql/mysql/brokerage.sql index 161dfa256..127fcb728 100644 --- a/sql/mysql/brokerage.sql +++ b/sql/mysql/brokerage.sql @@ -42,7 +42,7 @@ create index idx_invite_user_id on trade_brokerage_user (brokerage_user_id) comm create index idx_agent on trade_brokerage_user (brokerage_enabled) comment '是否成为推广员'; -create table member_brokerage_record +create table trade_brokerage_record ( id int auto_increment comment '编号' primary key, @@ -65,12 +65,12 @@ create table member_brokerage_record ) comment '佣金记录'; -create index idx_user_id on member_brokerage_record (user_id) comment '用户编号'; -create index idx_biz on member_brokerage_record (biz_type, biz_id) comment '业务'; -create index idx_status on member_brokerage_record (status) comment '状态'; +create index idx_user_id on trade_brokerage_record (user_id) comment '用户编号'; +create index idx_biz on trade_brokerage_record (biz_type, biz_id) comment '业务'; +create index idx_status on trade_brokerage_record (status) comment '状态'; -create table member_brokerage_withdraw +create table trade_brokerage_withdraw ( id int auto_increment comment '编号' primary key, @@ -97,8 +97,8 @@ create table member_brokerage_withdraw ) comment '佣金提现'; -create index idx_user_id on member_brokerage_withdraw (user_id) comment '用户编号'; -create index idx_audit_status on member_brokerage_withdraw (status) comment '状态'; +create index idx_user_id on trade_brokerage_withdraw (user_id) comment '用户编号'; +create index idx_audit_status on trade_brokerage_withdraw (status) comment '状态'; -- 增加字典 insert into system_dict_type(type, name) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordController.java similarity index 51% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordController.java index c4bc9bb37..38b2f4d71 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordController.java @@ -2,11 +2,11 @@ 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.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 cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.TradeBrokerageRecordPageReqVO; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.TradeBrokerageRecordRespVO; +import cn.iocoder.yudao.module.trade.convert.brokerage.record.TradeBrokerageRecordConvert; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.TradeBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.service.brokerage.record.TradeBrokerageRecordService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -24,28 +24,28 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 佣金记录") @RestController -@RequestMapping("/trade/member-brokerage-record") +@RequestMapping("/trade/brokerage-record") @Validated -public class MemberBrokerageRecordController { +public class TradeBrokerageRecordController { @Resource - private MemberBrokerageRecordService memberBrokerageRecordService; + private TradeBrokerageRecordService tradeBrokerageRecordService; @GetMapping("/get") @Operation(summary = "获得佣金记录") @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:member-brokerage-record:query')") - public CommonResult getMemberBrokerageRecord(@RequestParam("id") Integer id) { - MemberBrokerageRecordDO memberBrokerageRecord = memberBrokerageRecordService.getMemberBrokerageRecord(id); - return success(MemberBrokerageRecordConvert.INSTANCE.convert(memberBrokerageRecord)); + @PreAuthorize("@ss.hasPermission('trade:brokerage-record:query')") + public CommonResult getBrokerageRecord(@RequestParam("id") Integer id) { + TradeBrokerageRecordDO tradeBrokerageRecord = tradeBrokerageRecordService.getBrokerageRecord(id); + return success(TradeBrokerageRecordConvert.INSTANCE.convert(tradeBrokerageRecord)); } @GetMapping("/page") @Operation(summary = "获得佣金记录分页") - @PreAuthorize("@ss.hasPermission('member:member-brokerage-record:query')") - public CommonResult> getMemberBrokerageRecordPage(@Valid MemberBrokerageRecordPageReqVO pageVO) { - PageResult pageResult = memberBrokerageRecordService.getMemberBrokerageRecordPage(pageVO); - return success(MemberBrokerageRecordConvert.INSTANCE.convertPage(pageResult)); + @PreAuthorize("@ss.hasPermission('trade:brokerage-record:query')") + public CommonResult> getBrokerageRecordPage(@Valid TradeBrokerageRecordPageReqVO pageVO) { + PageResult pageResult = tradeBrokerageRecordService.getBrokerageRecordPage(pageVO); + return success(TradeBrokerageRecordConvert.INSTANCE.convertPage(pageResult)); } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordBaseVO.java similarity index 98% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordBaseVO.java index 51cd4a631..1fb87f294 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordBaseVO.java @@ -14,7 +14,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data -public class MemberBrokerageRecordBaseVO { +public class TradeBrokerageRecordBaseVO { @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25973") @NotNull(message = "用户编号不能为空") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordPageReqVO.java similarity index 94% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordPageReqVO.java index 3a5e05527..abd948f09 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordPageReqVO.java @@ -15,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class MemberBrokerageRecordPageReqVO extends PageParam { +public class TradeBrokerageRecordPageReqVO extends PageParam { @Schema(description = "用户编号", example = "25973") private Long userId; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordRespVO.java similarity index 88% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordRespVO.java index 3550a64ba..724d7d3e5 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordRespVO.java @@ -11,7 +11,7 @@ import java.time.LocalDateTime; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class MemberBrokerageRecordRespVO extends MemberBrokerageRecordBaseVO { +public class TradeBrokerageRecordRespVO extends TradeBrokerageRecordBaseVO { @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28896") private Integer id; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/MemberBrokerageRecordConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/TradeBrokerageRecordConvert.java similarity index 69% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordConvert.java index 48af52cf5..b84e51354 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/MemberBrokerageRecordConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/TradeBrokerageRecordConvert.java @@ -2,8 +2,8 @@ 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.trade.controller.admin.brokerage.record.vo.MemberBrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.MemberBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.TradeBrokerageRecordRespVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.TradeBrokerageRecordDO; 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; @@ -19,22 +19,22 @@ import java.util.List; * @author owen */ @Mapper -public interface MemberBrokerageRecordConvert { +public interface TradeBrokerageRecordConvert { - MemberBrokerageRecordConvert INSTANCE = Mappers.getMapper(MemberBrokerageRecordConvert.class); + TradeBrokerageRecordConvert INSTANCE = Mappers.getMapper(TradeBrokerageRecordConvert.class); - MemberBrokerageRecordRespVO convert(MemberBrokerageRecordDO bean); + TradeBrokerageRecordRespVO convert(TradeBrokerageRecordDO bean); - List convertList(List list); + List convertList(List list); - PageResult convertPage(PageResult page); + PageResult convertPage(PageResult page); - default MemberBrokerageRecordDO convert(TradeBrokerageUserDO user, String bizId, int brokerageFrozenDays, int brokerage, LocalDateTime unfreezeTime) { + default TradeBrokerageRecordDO convert(TradeBrokerageUserDO user, String bizId, int brokerageFrozenDays, int brokerage, LocalDateTime unfreezeTime) { // 不冻结时,佣金直接就是结算状态 Integer status = brokerageFrozenDays > 0 ? BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus() : BrokerageRecordStatusEnum.SETTLEMENT.getStatus(); - return new MemberBrokerageRecordDO() + return new TradeBrokerageRecordDO() .setUserId(user.getId()) .setBizType(BrokerageRecordBizTypeEnum.ORDER.getType()) .setBizId(bizId) 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 d17b81124..f42af2d73 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.trade.service.brokerage.record.bo.BrokerageAddReqDTO; +import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqBO; 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; @@ -275,8 +275,8 @@ public interface TradeOrderConvert { TradeOrderDO convert(TradeOrderRemarkReqVO reqVO); - default BrokerageAddReqDTO convert(TradeOrderItemDO item, ProductSkuRespDTO sku) { - return new BrokerageAddReqDTO().setBizId(String.valueOf(item.getId())) + default BrokerageAddReqBO convert(TradeOrderItemDO item, ProductSkuRespDTO sku) { + return new BrokerageAddReqBO().setBizId(String.valueOf(item.getId())) .setPayPrice(item.getPayPrice()).setCount(item.getCount()) .setSkuFirstBrokeragePrice(sku.getSubCommissionFirstPrice()) .setSkuSecondBrokeragePrice(sku.getSubCommissionSecondPrice()); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordDO.java similarity index 85% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordDO.java index 94d37ff89..0bf7c0cf2 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordDO.java @@ -15,15 +15,15 @@ import java.time.LocalDateTime; * * @author owen */ -@TableName("member_brokerage_record") -@KeySequence("member_brokerage_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@TableName("trade_brokerage_record") +@KeySequence("trade_brokerage_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @Builder @NoArgsConstructor @AllArgsConstructor -public class MemberBrokerageRecordDO extends BaseDO { +public class TradeBrokerageRecordDO extends BaseDO { /** * 编号 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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 deleted file mode 100644 index da89b8bba..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/MemberBrokerageRecordMapper.java +++ /dev/null @@ -1,47 +0,0 @@ -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.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; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 佣金记录 Mapper - * - * @author owen - */ -@Mapper -public interface MemberBrokerageRecordMapper extends BaseMapperX { - - default PageResult selectPage(MemberBrokerageRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MemberBrokerageRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(MemberBrokerageRecordDO::getBizType, reqVO.getBizType()) - .eqIfPresent(MemberBrokerageRecordDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(MemberBrokerageRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberBrokerageRecordDO::getId)); - } - - default List selectListByStatusAndUnfreezeTimeLt(Integer status, LocalDateTime unfreezeTime) { - return selectList(new LambdaQueryWrapper() - .eq(MemberBrokerageRecordDO::getStatus, status) - .lt(MemberBrokerageRecordDO::getUnfreezeTime, unfreezeTime)); - } - - default int updateByIdAndStatus(Integer id, Integer status, MemberBrokerageRecordDO updateObj) { - return update(updateObj, new LambdaQueryWrapper() - .eq(MemberBrokerageRecordDO::getId, id) - .eq(MemberBrokerageRecordDO::getStatus, status)); - } - - default MemberBrokerageRecordDO selectByUserIdAndBizTypeAndBizId(Integer bizType, String bizId) { - return selectOne(MemberBrokerageRecordDO::getBizType, bizType, - MemberBrokerageRecordDO::getBizId, bizId); - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/TradeBrokerageRecordMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/TradeBrokerageRecordMapper.java new file mode 100644 index 000000000..78efbc53a --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/TradeBrokerageRecordMapper.java @@ -0,0 +1,47 @@ +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.trade.controller.admin.brokerage.record.vo.TradeBrokerageRecordPageReqVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.TradeBrokerageRecordDO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.apache.ibatis.annotations.Mapper; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * 佣金记录 Mapper + * + * @author owen + */ +@Mapper +public interface TradeBrokerageRecordMapper extends BaseMapperX { + + default PageResult selectPage(TradeBrokerageRecordPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(TradeBrokerageRecordDO::getUserId, reqVO.getUserId()) + .eqIfPresent(TradeBrokerageRecordDO::getBizType, reqVO.getBizType()) + .eqIfPresent(TradeBrokerageRecordDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(TradeBrokerageRecordDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(TradeBrokerageRecordDO::getId)); + } + + default List selectListByStatusAndUnfreezeTimeLt(Integer status, LocalDateTime unfreezeTime) { + return selectList(new LambdaQueryWrapper() + .eq(TradeBrokerageRecordDO::getStatus, status) + .lt(TradeBrokerageRecordDO::getUnfreezeTime, unfreezeTime)); + } + + default int updateByIdAndStatus(Integer id, Integer status, TradeBrokerageRecordDO updateObj) { + return update(updateObj, new LambdaQueryWrapper() + .eq(TradeBrokerageRecordDO::getId, id) + .eq(TradeBrokerageRecordDO::getStatus, status)); + } + + default TradeBrokerageRecordDO selectByUserIdAndBizTypeAndBizId(Integer bizType, String bizId) { + return selectOne(TradeBrokerageRecordDO::getBizType, bizType, + TradeBrokerageRecordDO::getBizId, bizId); + } +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/MemberBrokerageRecordUnfreezeJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/TradeBrokerageRecordUnfreezeJob.java similarity index 63% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/MemberBrokerageRecordUnfreezeJob.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/TradeBrokerageRecordUnfreezeJob.java index d41bc840c..94218d47e 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/MemberBrokerageRecordUnfreezeJob.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/TradeBrokerageRecordUnfreezeJob.java @@ -3,7 +3,7 @@ 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.trade.service.brokerage.record.MemberBrokerageRecordService; +import cn.iocoder.yudao.module.trade.service.brokerage.record.TradeBrokerageRecordService; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -15,14 +15,14 @@ import javax.annotation.Resource; */ @Component @TenantJob -public class MemberBrokerageRecordUnfreezeJob implements JobHandler { +public class TradeBrokerageRecordUnfreezeJob implements JobHandler { @Resource - private MemberBrokerageRecordService memberBrokerageRecordService; + private TradeBrokerageRecordService tradeBrokerageRecordService; @Override public String execute(String param) { - int count = memberBrokerageRecordService.unfreezeRecord(); + int count = tradeBrokerageRecordService.unfreezeRecord(); return StrUtil.format("解冻佣金 {} 个", count); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/TradeBrokerageRecordService.java similarity index 74% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordService.java index 5cdd9e1b5..6b83bdbc0 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/TradeBrokerageRecordService.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.module.trade.service.brokerage.record; import cn.iocoder.yudao.framework.common.pojo.PageResult; -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 cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.TradeBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqBO; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.TradeBrokerageRecordPageReqVO; import java.util.List; @@ -12,7 +12,7 @@ import java.util.List; * * @author owen */ -public interface MemberBrokerageRecordService { +public interface TradeBrokerageRecordService { /** * 获得佣金记录 @@ -20,7 +20,7 @@ public interface MemberBrokerageRecordService { * @param id 编号 * @return 佣金记录 */ - MemberBrokerageRecordDO getMemberBrokerageRecord(Integer id); + TradeBrokerageRecordDO getBrokerageRecord(Integer id); /** * 获得佣金记录分页 @@ -28,7 +28,7 @@ public interface MemberBrokerageRecordService { * @param pageReqVO 分页查询 * @return 佣金记录分页 */ - PageResult getMemberBrokerageRecordPage(MemberBrokerageRecordPageReqVO pageReqVO); + PageResult getBrokerageRecordPage(TradeBrokerageRecordPageReqVO pageReqVO); /** * 增加佣金 @@ -36,7 +36,7 @@ public interface MemberBrokerageRecordService { * @param userId 会员编号 * @param list 请求参数列表 */ - void addBrokerage(Long userId, List list); + void addBrokerage(Long userId, List list); /** * 取消佣金:将佣金记录,状态修改为已失效 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/TradeBrokerageRecordServiceImpl.java similarity index 78% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordServiceImpl.java index e56ae5dab..5502bcbf7 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/TradeBrokerageRecordServiceImpl.java @@ -6,13 +6,13 @@ 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.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.convert.brokerage.record.TradeBrokerageRecordConvert; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.TradeBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqBO; +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.TradeBrokerageRecordPageReqVO; import cn.iocoder.yudao.module.trade.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.dal.mysql.brokerage.record.TradeBrokerageRecordMapper; 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; @@ -37,28 +37,28 @@ import java.util.function.Function; @Slf4j @Service @Validated -public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordService { +public class TradeBrokerageRecordServiceImpl implements TradeBrokerageRecordService { @Resource - private MemberBrokerageRecordMapper memberBrokerageRecordMapper; + private TradeBrokerageRecordMapper tradeBrokerageRecordMapper; @Resource private TradeConfigService tradeConfigService; @Resource private TradeBrokerageUserService tradeBrokerageUserService; @Override - public MemberBrokerageRecordDO getMemberBrokerageRecord(Integer id) { - return memberBrokerageRecordMapper.selectById(id); + public TradeBrokerageRecordDO getBrokerageRecord(Integer id) { + return tradeBrokerageRecordMapper.selectById(id); } @Override - public PageResult getMemberBrokerageRecordPage(MemberBrokerageRecordPageReqVO pageReqVO) { - return memberBrokerageRecordMapper.selectPage(pageReqVO); + public PageResult getBrokerageRecordPage(TradeBrokerageRecordPageReqVO pageReqVO) { + return tradeBrokerageRecordMapper.selectPage(pageReqVO); } @Override @Transactional(rollbackFor = Exception.class) - public void addBrokerage(Long buyerId, List list) { + public void addBrokerage(Long buyerId, List list) { TradeConfigDO memberConfig = tradeConfigService.getTradeConfig(); // 0 未启用分销功能 if (memberConfig == null || !BooleanUtil.isTrue(memberConfig.getBrokerageEnabled())) { @@ -73,7 +73,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe } // 1.2 计算一级分佣 - addBrokerage(firstUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageFirstPercent(), BrokerageAddReqDTO::getSkuFirstBrokeragePrice); + addBrokerage(firstUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageFirstPercent(), BrokerageAddReqBO::getSkuFirstBrokeragePrice); // 2.1 获得二级推广员 @@ -83,20 +83,20 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe } // 2.2 计算二级分佣 - addBrokerage(secondUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageSecondPercent(), BrokerageAddReqDTO::getSkuSecondBrokeragePrice); + addBrokerage(secondUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageSecondPercent(), BrokerageAddReqBO::getSkuSecondBrokeragePrice); } @Override @Transactional(rollbackFor = Exception.class) public void cancelBrokerage(Long userId, String bizId) { - MemberBrokerageRecordDO record = memberBrokerageRecordMapper.selectByUserIdAndBizTypeAndBizId(BrokerageRecordBizTypeEnum.ORDER.getType(), bizId); + TradeBrokerageRecordDO record = tradeBrokerageRecordMapper.selectByUserIdAndBizTypeAndBizId(BrokerageRecordBizTypeEnum.ORDER.getType(), bizId); if (record == null || ObjectUtil.notEqual(record.getUserId(), userId)) { log.error("[cancelBrokerage][userId({})][bizId({}) 更新为已失效失败:记录不存在]", userId, bizId); return; } - MemberBrokerageRecordDO updateObj = new MemberBrokerageRecordDO().setStatus(BrokerageRecordStatusEnum.CANCEL.getStatus()); - int updateRows = memberBrokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); + TradeBrokerageRecordDO updateObj = new TradeBrokerageRecordDO().setStatus(BrokerageRecordStatusEnum.CANCEL.getStatus()); + int updateRows = tradeBrokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); if (updateRows == 0) { log.error("[cancelBrokerage][record({}) 更新为已失效失败]", record.getId()); return; @@ -140,8 +140,8 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe * @param brokeragePercent 佣金比例 * @param skuBrokeragePriceFun 商品 SKU 设置的佣金 */ - private void addBrokerage(TradeBrokerageUserDO user, List list, Integer brokerageFrozenDays, - Integer brokeragePercent, Function skuBrokeragePriceFun) { + private void addBrokerage(TradeBrokerageUserDO user, List list, Integer brokerageFrozenDays, + Integer brokeragePercent, Function skuBrokeragePriceFun) { // 处理冻结时间 brokerageFrozenDays = ObjectUtil.defaultIfNull(brokerageFrozenDays, 0); LocalDateTime unfreezeTime = null; @@ -151,12 +151,12 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe // 计算分佣 int totalBrokerage = 0; - List records = new ArrayList<>(); - for (BrokerageAddReqDTO dto : list) { + List records = new ArrayList<>(); + for (BrokerageAddReqBO dto : list) { int brokeragePerItem = calculateBrokerage(dto.getPayPrice(), brokeragePercent, skuBrokeragePriceFun.apply(dto)); if (brokeragePerItem > 0) { int brokerage = brokeragePerItem * dto.getCount(); - records.add(MemberBrokerageRecordConvert.INSTANCE.convert(user, dto.getBizId(), brokerageFrozenDays, brokerage, unfreezeTime)); + records.add(TradeBrokerageRecordConvert.INSTANCE.convert(user, dto.getBizId(), brokerageFrozenDays, brokerage, unfreezeTime)); totalBrokerage += brokerage; } } @@ -166,7 +166,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe } // 保存佣金记录 - memberBrokerageRecordMapper.insertBatch(records); + tradeBrokerageRecordMapper.insertBatch(records); if (brokerageFrozenDays > 0) { // 更新用户冻结佣金 @@ -180,7 +180,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe @Override public int unfreezeRecord() { // 1. 查询待结算的佣金记录 - List records = memberBrokerageRecordMapper.selectListByStatusAndUnfreezeTimeLt( + List records = tradeBrokerageRecordMapper.selectListByStatusAndUnfreezeTimeLt( BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus(), LocalDateTime.now()); if (CollUtil.isEmpty(records)) { return 0; @@ -188,7 +188,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe // 2. 遍历执行 int count = 0; - for (MemberBrokerageRecordDO record : records) { + for (TradeBrokerageRecordDO record : records) { try { boolean successful = getSelf().unfreezeRecord(record); if (successful) { @@ -202,12 +202,12 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe } @Transactional(rollbackFor = Exception.class) - public boolean unfreezeRecord(MemberBrokerageRecordDO record) { + public boolean unfreezeRecord(TradeBrokerageRecordDO record) { // 更新记录状态 - MemberBrokerageRecordDO updateObj = new MemberBrokerageRecordDO() + TradeBrokerageRecordDO updateObj = new TradeBrokerageRecordDO() .setStatus(BrokerageRecordStatusEnum.SETTLEMENT.getStatus()) .setUnfreezeTime(LocalDateTime.now()); - int updateRows = memberBrokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); + int updateRows = tradeBrokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); if (updateRows == 0) { log.error("[unfreezeRecord][record({}) 更新为已结算失败]", record.getId()); return false; @@ -225,7 +225,7 @@ public class MemberBrokerageRecordServiceImpl implements MemberBrokerageRecordSe * * @return 自己 */ - private MemberBrokerageRecordServiceImpl getSelf() { + private TradeBrokerageRecordServiceImpl getSelf() { return SpringUtil.getBean(getClass()); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo/BrokerageAddReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo/BrokerageAddReqBO.java similarity index 90% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo/BrokerageAddReqDTO.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo/BrokerageAddReqBO.java index a15ef76c0..a968d14ea 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo/BrokerageAddReqDTO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/bo/BrokerageAddReqBO.java @@ -5,13 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * 佣金 增加 Request DTO + * 佣金 增加 Request BO * @author owen */ @Data @NoArgsConstructor @AllArgsConstructor -public class BrokerageAddReqDTO { +public class BrokerageAddReqBO { /** * 业务ID */ 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 9ab4842b8..b75b7ac7c 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.trade.service.brokerage.record.MemberBrokerageRecordService; -import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqDTO; +import cn.iocoder.yudao.module.trade.service.brokerage.record.TradeBrokerageRecordService; +import cn.iocoder.yudao.module.trade.service.brokerage.record.bo.BrokerageAddReqBO; 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 MemberBrokerageRecordService memberBrokerageRecordService; + private TradeBrokerageRecordService tradeBrokerageRecordService; @Resource private ProductCommentApi productCommentApi; @@ -752,14 +752,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Async protected void addBrokerageAsync(Long userId, Long orderId) { List orderItems = tradeOrderItemMapper.selectListByOrderId(orderId); - List list = convertList(orderItems, + List list = convertList(orderItems, item -> TradeOrderConvert.INSTANCE.convert(item, productSkuApi.getSku(item.getSkuId()))); - memberBrokerageRecordService.addBrokerage(userId, list); + tradeBrokerageRecordService.addBrokerage(userId, list); } @Async protected void cancelBrokerageAsync(Long userId, Long orderItemId) { - memberBrokerageRecordService.cancelBrokerage(userId, String.valueOf(orderItemId)); + tradeBrokerageRecordService.cancelBrokerage(userId, String.valueOf(orderItemId)); } /** diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordServiceImplTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/record/TradeBrokerageRecordServiceImplTest.java similarity index 66% rename from yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/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/TradeBrokerageRecordServiceImplTest.java index ae367ae63..a6d8dffb1 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/record/MemberBrokerageRecordServiceImplTest.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/record/TradeBrokerageRecordServiceImplTest.java @@ -3,9 +3,9 @@ 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.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.controller.admin.brokerage.record.vo.TradeBrokerageRecordPageReqVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.TradeBrokerageRecordDO; +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.record.TradeBrokerageRecordMapper; 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; @@ -26,17 +26,17 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static org.junit.jupiter.api.Assertions.assertEquals; /** - * {@link MemberBrokerageRecordServiceImpl} 的单元测试类 + * {@link TradeBrokerageRecordServiceImpl} 的单元测试类 * * @author owen */ -@Import(MemberBrokerageRecordServiceImpl.class) -public class MemberBrokerageRecordServiceImplTest extends BaseDbUnitTest { +@Import(TradeBrokerageRecordServiceImpl.class) +public class TradeBrokerageRecordServiceImplTest extends BaseDbUnitTest { @Resource - private MemberBrokerageRecordServiceImpl memberBrokerageRecordService; + private TradeBrokerageRecordServiceImpl tradeBrokerageRecordService; @Resource - private MemberBrokerageRecordMapper memberBrokerageRecordMapper; + private TradeBrokerageRecordMapper tradeBrokerageRecordMapper; @MockBean private TradeConfigService tradeConfigService; @@ -45,36 +45,36 @@ public class MemberBrokerageRecordServiceImplTest extends BaseDbUnitTest { @Test @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetMemberBrokerageRecordPage() { + public void testGetBrokerageRecordPage() { // mock 数据 - MemberBrokerageRecordDO dbMemberBrokerageRecord = randomPojo(MemberBrokerageRecordDO.class, o -> { // 等会查询到 + TradeBrokerageRecordDO dbBrokerageRecord = randomPojo(TradeBrokerageRecordDO.class, o -> { // 等会查询到 o.setUserId(null); o.setBizType(null); o.setStatus(null); o.setCreateTime(null); }); - memberBrokerageRecordMapper.insert(dbMemberBrokerageRecord); + tradeBrokerageRecordMapper.insert(dbBrokerageRecord); // 测试 userId 不匹配 - memberBrokerageRecordMapper.insert(cloneIgnoreId(dbMemberBrokerageRecord, o -> o.setUserId(null))); + tradeBrokerageRecordMapper.insert(cloneIgnoreId(dbBrokerageRecord, o -> o.setUserId(null))); // 测试 bizType 不匹配 - memberBrokerageRecordMapper.insert(cloneIgnoreId(dbMemberBrokerageRecord, o -> o.setBizType(null))); + tradeBrokerageRecordMapper.insert(cloneIgnoreId(dbBrokerageRecord, o -> o.setBizType(null))); // 测试 status 不匹配 - memberBrokerageRecordMapper.insert(cloneIgnoreId(dbMemberBrokerageRecord, o -> o.setStatus(null))); + tradeBrokerageRecordMapper.insert(cloneIgnoreId(dbBrokerageRecord, o -> o.setStatus(null))); // 测试 createTime 不匹配 - memberBrokerageRecordMapper.insert(cloneIgnoreId(dbMemberBrokerageRecord, o -> o.setCreateTime(null))); + tradeBrokerageRecordMapper.insert(cloneIgnoreId(dbBrokerageRecord, o -> o.setCreateTime(null))); // 准备参数 - MemberBrokerageRecordPageReqVO reqVO = new MemberBrokerageRecordPageReqVO(); + TradeBrokerageRecordPageReqVO reqVO = new TradeBrokerageRecordPageReqVO(); reqVO.setUserId(null); reqVO.setBizType(null); reqVO.setStatus(null); reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); // 调用 - PageResult pageResult = memberBrokerageRecordService.getMemberBrokerageRecordPage(reqVO); + PageResult pageResult = tradeBrokerageRecordService.getBrokerageRecordPage(reqVO); // 断言 assertEquals(1, pageResult.getTotal()); assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbMemberBrokerageRecord, pageResult.getList().get(0)); + assertPojoEquals(dbBrokerageRecord, pageResult.getList().get(0)); } @Test @@ -84,7 +84,7 @@ public class MemberBrokerageRecordServiceImplTest extends BaseDbUnitTest { Integer percent = randomInt(1, 101); Integer skuBrokeragePrice = randomInt(); // 调用 - int brokerage = memberBrokerageRecordService.calculateBrokerage(payPrice, percent, skuBrokeragePrice); + int brokerage = tradeBrokerageRecordService.calculateBrokerage(payPrice, percent, skuBrokeragePrice); // 断言 assertEquals(brokerage, skuBrokeragePrice); } @@ -97,7 +97,7 @@ public class MemberBrokerageRecordServiceImplTest extends BaseDbUnitTest { Integer skuBrokeragePrice = randomEle(new Integer[]{0, null}); System.out.println("skuBrokeragePrice=" + skuBrokeragePrice); // 调用 - int brokerage = memberBrokerageRecordService.calculateBrokerage(payPrice, percent, skuBrokeragePrice); + int brokerage = tradeBrokerageRecordService.calculateBrokerage(payPrice, percent, skuBrokeragePrice); // 断言 assertEquals(brokerage, NumberUtil.div(NumberUtil.mul(payPrice, percent), 100, 0, RoundingMode.DOWN).intValue()); } @@ -109,7 +109,7 @@ public class MemberBrokerageRecordServiceImplTest extends BaseDbUnitTest { Integer percent = null; Integer skuBrokeragePrice = null; // 调用 - int brokerage = memberBrokerageRecordService.calculateBrokerage(payPrice, percent, skuBrokeragePrice); + int brokerage = tradeBrokerageRecordService.calculateBrokerage(payPrice, percent, skuBrokeragePrice); // 断言 assertEquals(brokerage, 0); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql index b0715ca16..f02fdcaf1 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql @@ -2,4 +2,5 @@ DELETE FROM trade_order; DELETE FROM trade_order_item; DELETE FROM trade_after_sale; DELETE FROM trade_after_sale_log; -DELETE FROM "trade_brokerage_user"; +DELETE FROM trade_brokerage_user; +DELETE FROM trade_brokerage_record; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql index df68fd53b..02045d2c2 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql @@ -142,4 +142,25 @@ CREATE TABLE IF NOT EXISTS "trade_brokerage_user" "deleted" bit NOT NULL DEFAULT FALSE, "tenant_id" bigint NOT NULL DEFAULT '0', PRIMARY KEY ("id") -) COMMENT '分销用户'; \ No newline at end of file +) COMMENT '分销用户'; +CREATE TABLE IF NOT EXISTS "trade_brokerage_record" +( + "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "user_id" bigint NOT NULL, + "biz_id" varchar NOT NULL, + "biz_type" varchar NOT NULL, + "title" varchar NOT NULL, + "price" int NOT NULL, + "total_price" int NOT NULL, + "description" varchar NOT NULL, + "status" varchar NOT NULL, + "frozen_days" int NOT NULL, + "unfreeze_time" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint not null default '0', + PRIMARY KEY ("id") +) COMMENT '佣金记录'; \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/clean.sql b/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/clean.sql index 6981982c4..f972e048d 100644 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/clean.sql @@ -2,5 +2,4 @@ DELETE FROM "member_user"; DELETE FROM "member_address"; DELETE FROM "member_tag"; DELETE FROM "member_level"; -DELETE FROM "member_group"; -DELETE FROM "member_brokerage_record"; \ No newline at end of file +DELETE FROM "member_group"; \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql b/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql index ccefc4bf1..5fdc526b0 100644 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql @@ -89,25 +89,4 @@ CREATE TABLE IF NOT EXISTS "member_group" "deleted" bit NOT NULL DEFAULT FALSE, "tenant_id" bigint not null default '0', PRIMARY KEY ("id") -) COMMENT '用户分组'; -CREATE TABLE IF NOT EXISTS "member_brokerage_record" -( - "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "biz_id" varchar NOT NULL, - "biz_type" varchar NOT NULL, - "title" varchar NOT NULL, - "price" int NOT NULL, - "total_price" int NOT NULL, - "description" varchar NOT NULL, - "status" varchar NOT NULL, - "frozen_days" int NOT NULL, - "unfreeze_time" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '佣金记录'; \ No newline at end of file +) COMMENT '用户分组'; \ No newline at end of file From 3f51be6a2d26650f103f88d95a4cbe9ad942e2c3 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Wed, 6 Sep 2023 08:50:22 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E9=92=B1=E5=8C=85=E3=80=82=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=B8=8D=E9=9C=80=E8=A6=81=E7=9A=84=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/delegate/DelegatePayClient.java | 63 ------------------- .../core/client/impl/mock/MockPayClient.java | 5 +- .../client/impl/mock/MockPayClientConfig.java | 28 --------- .../core/enums/channel/PayChannelEnum.java | 3 +- .../admin/order/PayOrderController.java | 1 + 5 files changed, 5 insertions(+), 95 deletions(-) delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/delegate/DelegatePayClient.java delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/delegate/DelegatePayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/delegate/DelegatePayClient.java deleted file mode 100644 index 65958d5a3..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/delegate/DelegatePayClient.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.delegate; - -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; - -import java.util.Map; - -// TODO @jason:其它模块,主要是无法 pay client 初始化存在问题,所以我感觉,是不是可以搞个 PayClientInitializer 接口。这样,PayClientFactory 去 get 这个支付模式对应的 PayClientInitializer,通过它来创建。具体注入的地方,可以在 PayChannel init 方法那; -/** - * 代理支付 Client 的抽象类。 - * - * 用于支付 Client 由其它模块实现,例如钱包支付 - * - * @author jason - */ -public abstract class DelegatePayClient extends AbstractPayClient { - - private final DelegatePayClient delegate; - - public DelegatePayClient(Long channelId, String channelCode, PayClientConfig config) { - super(channelId, channelCode, config); - delegate = this; - } - - @Override - protected void doInit() { - delegate.doInit(); - } - - @Override - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - return delegate.doUnifiedOrder(reqDTO); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) { - return delegate.doGetOrder(outTradeNo); - } - - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - return delegate.doUnifiedRefund(reqDTO); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { - return delegate.doGetRefund(outTradeNo, outRefundNo); - } - - @Override - protected PayRefundRespDTO doParseRefundNotify(Map params, String body) { - return delegate.doParseRefundNotify(params, body); - } - - @Override - protected PayOrderRespDTO doParseOrderNotify(Map params, String body) { - return delegate.doParseOrderNotify(params, body); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java index 1d3f4d48b..f26e76c28 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDT import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; +import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import java.time.LocalDateTime; @@ -17,11 +18,11 @@ import java.util.Map; * * @author jason */ -public class MockPayClient extends AbstractPayClient { +public class MockPayClient extends AbstractPayClient { private static final String MOCK_RESP_SUCCESS_DATA = "MOCK_SUCCESS"; - public MockPayClient(Long channelId, MockPayClientConfig config) { + public MockPayClient(Long channelId, NonePayClientConfig config) { super(channelId, PayChannelEnum.MOCK.getCode(), config); } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java deleted file mode 100644 index 3e35c52dc..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.mock; - -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import javax.validation.Validator; - -/** - * 模拟支付的 PayClientConfig 实现类 - * - * @author jason - */ -@Data -public class MockPayClientConfig implements PayClientConfig { - - /** - * 配置名称 - * - * 如果不加任何属性,JsonUtils.parseObject2 解析会报错,所以暂时加个名称 - */ - private String name; - - @Override - public void validate(Validator validator) { - // 模拟支付配置无需校验 - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java index cbe0a242a..411644153 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java @@ -4,7 +4,6 @@ import cn.hutool.core.util.ArrayUtil; import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; import lombok.AllArgsConstructor; import lombok.Getter; @@ -30,7 +29,7 @@ public enum PayChannelEnum { ALIPAY_QR("alipay_qr", "支付宝扫码支付", AlipayPayClientConfig.class), ALIPAY_BAR("alipay_bar", "支付宝条码支付", AlipayPayClientConfig.class), - MOCK("mock", "模拟支付", MockPayClientConfig.class), + MOCK("mock", "模拟支付", NonePayClientConfig.class), WALLET("wallet", "钱包支付", NonePayClientConfig.class); diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java index 3350b5877..a47031a2a 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java @@ -70,6 +70,7 @@ public class PayOrderController { @PostMapping("/submit") @Operation(summary = "提交支付订单") public CommonResult submitPayOrder(@RequestBody PayOrderSubmitReqVO reqVO) { + // 钱包支付需要 额外传 user_id 和 user_type if (Objects.equals(reqVO.getChannelCode(), PayChannelEnum.WALLET.getCode())) { Map channelExtras = reqVO.getChannelExtras() == null ? new HashMap<>(8) : reqVO.getChannelExtras(); channelExtras.put("user_id", String.valueOf(WebFrameworkUtils.getLoginUserId())); From 9074312fe301b54a093448427209529622e7b4d9 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Wed, 6 Sep 2023 10:34:24 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=8E=A5=E5=85=A5?= =?UTF-8?q?=E9=92=B1=E5=8C=85=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-admin/src/utils/constants.js | 4 ++ ...nnelForm.vue => noneConfigChannelForm.vue} | 53 ++++++++++--------- yudao-ui-admin/src/views/pay/app/index.vue | 25 +++++++-- .../src/views/pay/cashier/index.vue | 4 ++ 4 files changed, 56 insertions(+), 30 deletions(-) rename yudao-ui-admin/src/views/pay/app/components/{mockChannelForm.vue => noneConfigChannelForm.vue} (71%) diff --git a/yudao-ui-admin/src/utils/constants.js b/yudao-ui-admin/src/utils/constants.js index d62b1f8fc..2ce6d0041 100644 --- a/yudao-ui-admin/src/utils/constants.js +++ b/yudao-ui-admin/src/utils/constants.js @@ -163,6 +163,10 @@ export const PayChannelEnum = { MOCK : { "code": "mock", "name": "模拟支付" + }, + WALLET : { + "code": "wallet", + "name": "钱包支付" } } diff --git a/yudao-ui-admin/src/views/pay/app/components/mockChannelForm.vue b/yudao-ui-admin/src/views/pay/app/components/noneConfigChannelForm.vue similarity index 71% rename from yudao-ui-admin/src/views/pay/app/components/mockChannelForm.vue rename to yudao-ui-admin/src/views/pay/app/components/noneConfigChannelForm.vue index e2d6162f1..51fcc53dd 100644 --- a/yudao-ui-admin/src/views/pay/app/components/mockChannelForm.vue +++ b/yudao-ui-admin/src/views/pay/app/components/noneConfigChannelForm.vue @@ -5,7 +5,8 @@ + :label="parseInt(dict.value)" + > {{ dict.label }} @@ -22,16 +23,16 @@ diff --git a/yudao-ui-admin/src/views/pay/app/index.vue b/yudao-ui-admin/src/views/pay/app/index.vue index 67a15fe66..6819af711 100644 --- a/yudao-ui-admin/src/views/pay/app/index.vue +++ b/yudao-ui-admin/src/views/pay/app/index.vue @@ -170,6 +170,19 @@ + + + + + @@ -228,14 +241,14 @@ import { createApp, updateApp, changeAppStatus, deleteApp, getApp, getAppPage } import { PayChannelEnum, CommonStatusEnum } from "@/utils/constants"; import weixinChannelForm from "@/views/pay/app/components/weixinChannelForm"; import alipayChannelForm from "@/views/pay/app/components/alipayChannelForm"; -import mockChannelForm from '@/views/pay/app/components/mockChannelForm'; +import noneConfigChannelForm from '@/views/pay/app/components/noneConfigChannelForm'; export default { name: "PayApp", components: { weixinChannelForm, alipayChannelForm, - mockChannelForm + noneConfigChannelForm }, data() { return { @@ -391,7 +404,11 @@ export default { return } if (code === 'mock') { - this.$refs['mockChannelFormRef'].open(row.id, code); + this.$refs['noneConfigChannelFormRef'].open(row.id, code); + return + } + if (code === 'wallet') { + this.$refs['noneConfigChannelFormRef'].open(row.id, code); return } }, diff --git a/yudao-ui-admin/src/views/pay/cashier/index.vue b/yudao-ui-admin/src/views/pay/cashier/index.vue index 85d702760..c10c154aa 100644 --- a/yudao-ui-admin/src/views/pay/cashier/index.vue +++ b/yudao-ui-admin/src/views/pay/cashier/index.vue @@ -136,6 +136,10 @@ export default { name: '模拟支付', icon: require("@/assets/images/pay/icon/mock.svg"), code: "mock" + }, { + name: '钱包支付', + icon: require("@/assets/images/pay/icon/mock.svg"), + code: "wallet" }], submitLoading: false, // 提交支付的 loading interval: undefined, // 定时任务,轮询是否完成支付