mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 07:11:52 +08:00
【代码修复】MALL:修复订单项取消时,分销未取消所有推广员的推广记录问题
This commit is contained in:
parent
4959479ac6
commit
cf6f3eaa41
@ -50,10 +50,9 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
|
||||
.eq(BrokerageRecordDO::getStatus, status));
|
||||
}
|
||||
|
||||
default BrokerageRecordDO selectByBizTypeAndBizIdAndUserId(Integer bizType, String bizId, Long userId) {
|
||||
return selectOne(BrokerageRecordDO::getBizType, bizType,
|
||||
BrokerageRecordDO::getBizId, bizId,
|
||||
BrokerageRecordDO::getUserId, userId);
|
||||
default List<BrokerageRecordDO> selectListByBizTypeAndBizId(Integer bizType, String bizId) {
|
||||
return selectList(BrokerageRecordDO::getBizType, bizType,
|
||||
BrokerageRecordDO::getBizId, bizId);
|
||||
}
|
||||
|
||||
default List<UserBrokerageSummaryRespBO> selectCountAndSumPriceByUserIdInAndBizTypeAndStatus(Collection<Long> userIds,
|
||||
|
@ -78,11 +78,10 @@ public interface BrokerageRecordService {
|
||||
/**
|
||||
* 取消佣金:将佣金记录,状态修改为已失效
|
||||
*
|
||||
* @param userId 会员编号
|
||||
* @param bizType 业务类型
|
||||
* @param bizId 业务编号
|
||||
*/
|
||||
void cancelBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId);
|
||||
void cancelBrokerage(BrokerageRecordBizTypeEnum bizType, String bizId);
|
||||
|
||||
/**
|
||||
* 解冻佣金:将待结算的佣金记录,状态修改为已结算
|
||||
|
@ -107,27 +107,29 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancelBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId) {
|
||||
BrokerageRecordDO record = brokerageRecordMapper.selectByBizTypeAndBizIdAndUserId(bizType.getType(), bizId, userId);
|
||||
if (record == null) {
|
||||
log.error("[cancelBrokerage][userId({})][bizId({}) 更新为已失效失败:记录不存在]", userId, bizId);
|
||||
public void cancelBrokerage(BrokerageRecordBizTypeEnum bizType, String bizId) {
|
||||
List<BrokerageRecordDO> records = brokerageRecordMapper.selectListByBizTypeAndBizId(bizType.getType(), bizId);
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
log.error("[cancelBrokerage][bizId({}) bizType({}) 更新为已失效失败:记录不存在]", bizId, bizType);
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. 更新佣金记录为已失效
|
||||
BrokerageRecordDO updateObj = new BrokerageRecordDO().setStatus(BrokerageRecordStatusEnum.CANCEL.getStatus());
|
||||
int updateRows = brokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj);
|
||||
if (updateRows == 0) {
|
||||
log.error("[cancelBrokerage][record({}) 更新为已失效失败]", record.getId());
|
||||
return;
|
||||
}
|
||||
records.forEach(record -> {
|
||||
// 1. 更新佣金记录为已失效
|
||||
BrokerageRecordDO updateObj = new BrokerageRecordDO().setStatus(BrokerageRecordStatusEnum.CANCEL.getStatus());
|
||||
int updateRows = brokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj);
|
||||
if (updateRows == 0) {
|
||||
log.error("[cancelBrokerage][record({}) 更新为已失效失败]", record.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 更新用户的佣金
|
||||
if (BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus().equals(record.getStatus())) {
|
||||
brokerageUserService.updateUserFrozenPrice(userId, -record.getPrice());
|
||||
} else if (BrokerageRecordStatusEnum.SETTLEMENT.getStatus().equals(record.getStatus())) {
|
||||
brokerageUserService.updateUserPrice(userId, -record.getPrice());
|
||||
}
|
||||
// 2. 更新用户的佣金
|
||||
if (BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus().equals(record.getStatus())) {
|
||||
brokerageUserService.updateUserFrozenPrice(record.getUserId(), -record.getPrice());
|
||||
} else if (BrokerageRecordStatusEnum.SETTLEMENT.getStatus().equals(record.getStatus())) {
|
||||
brokerageUserService.updateUserPrice(record.getUserId(), -record.getPrice());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,9 +9,6 @@ import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokera
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分销用户 Service 接口
|
||||
*
|
||||
@ -27,14 +24,6 @@ public interface BrokerageUserService {
|
||||
*/
|
||||
BrokerageUserDO getBrokerageUser(Long id);
|
||||
|
||||
/**
|
||||
* 获得分销用户列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 分销用户列表
|
||||
*/
|
||||
List<BrokerageUserDO> getBrokerageUserList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得分销用户分页
|
||||
*
|
||||
|
@ -60,11 +60,6 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
||||
return brokerageUserMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BrokerageUserDO> getBrokerageUserList(Collection<Long> ids) {
|
||||
return brokerageUserMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BrokerageUserDO> getBrokerageUserPage(BrokerageUserPageReqVO pageReqVO) {
|
||||
List<Long> childIds = getChildUserIdsByLevel(pageReqVO.getBindUserId(), pageReqVO.getLevel());
|
||||
@ -130,6 +125,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
||||
|
||||
@Override
|
||||
public BrokerageUserDO getOrCreateBrokerageUser(Long id) {
|
||||
// TODO @芋艿:这块优化下;统一到注册时处理;
|
||||
BrokerageUserDO brokerageUser = brokerageUserMapper.selectById(id);
|
||||
// 特殊:人人分销的情况下,如果分销人为空则创建分销人
|
||||
if (brokerageUser == null && ObjUtil.equal(BrokerageEnabledConditionEnum.ALL.getCondition(),
|
||||
|
@ -83,7 +83,7 @@ public class TradeBrokerageOrderHandler implements TradeOrderHandler {
|
||||
if (order.getBrokerageUserId() == null) {
|
||||
return;
|
||||
}
|
||||
cancelBrokerage(order.getBrokerageUserId(), orderItem.getId());
|
||||
brokerageRecordService.cancelBrokerage(BrokerageRecordBizTypeEnum.ORDER, String.valueOf(orderItem.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,8 +111,4 @@ public class TradeBrokerageOrderHandler implements TradeOrderHandler {
|
||||
brokerageRecordService.addBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, addList);
|
||||
}
|
||||
|
||||
protected void cancelBrokerage(Long userId, Long orderItemId) {
|
||||
brokerageRecordService.cancelBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, String.valueOf(orderItemId));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user