Browse Source

补充新手任务奖励

master
188814092560 11 months ago
parent
commit
a02dce36e4
4 changed files with 93 additions and 7 deletions
  1. 70
      dating-agency-mall-server/src/main/java/com/qniao/dam/application/handler/revenuereward/RevenueRewardEventHandler.java
  2. 12
      dating-agency-mall-server/src/main/java/com/qniao/dam/application/service/reward/RewardApplicationService.java
  3. 5
      dating-agency-mall-server/src/main/java/com/qniao/dam/query/ffpm/FranchiseFeeProfitManagementQueryService.java
  4. 13
      dating-agency-mall-server/src/main/java/com/qniao/dam/query/ffpm/impl/FranchiseFeeProfitManagementQueryServiceImpl.java

70
dating-agency-mall-server/src/main/java/com/qniao/dam/application/handler/revenuereward/RevenueRewardEventHandler.java

@ -1,9 +1,12 @@
package com.qniao.dam.application.handler.revenuereward;
import cn.hutool.core.collection.CollUtil;
import com.google.common.eventbus.Subscribe;
import com.qniao.dam.application.service.revenuereward.RevenueRewardApplicationService;
import com.qniao.dam.application.service.reward.RewardApplicationService;
import com.qniao.dam.domain.aggregate.ffpm.FranchiseFeeProfitManagementAggregate;
import com.qniao.dam.domain.aggregate.ffpm.entity.FranchiseFeeProfitManagement;
import com.qniao.dam.domain.aggregate.order.entity.Order;
import com.qniao.dam.domain.aggregate.revenuereward.RevenueRewardAggregate;
import com.qniao.dam.domain.aggregate.revenuereward.entity.RevenueReward;
import com.qniao.dam.domain.aggregate.revenuereward.valueobj.RevenueRewardRecord;
@ -18,14 +21,17 @@ import com.qniao.dam.domian.aggregate.walletaccount.constant.TradeSceneEnum;
import com.qniao.dam.domian.aggregate.walletaccount.constant.TradeTypeEnum;
import com.qniao.dam.infrastructure.constant.MqExchange;
import com.qniao.dam.infrastructure.constant.MqQueue;
import com.qniao.dam.infrastructure.persistent.dao.domain.OrderDao;
import com.qniao.dam.infrastructure.persistent.dao.domain.RevenueRewardDao;
import com.qniao.dam.infrastructure.persistent.dao.domain.RevenueRewardRecoveredRecordDao;
import com.qniao.dam.infrastructure.persistent.dao.domain.StoreDao;
import com.qniao.dam.infrastructure.persistent.dao.org.OrganizationDao;
import com.qniao.dam.query.ffpm.FranchiseFeeProfitManagementQueryService;
import com.qniao.dam.query.operationcenter.OperationCenterQueryService;
import com.qniao.dam.query.revenuereward.RevenueRewardQueryService;
import com.qniao.dam.query.rewardconfig.RewardConfigQueryService;
import com.qniao.dam.query.store.StoreQueryService;
import com.qniao.das.domian.aggregate.mntp.event.MatchmakerNoviceTaskProgressFinishedMQ;
import com.qniao.dau.domain.aggregate.operationcenter.entity.OperationCenter;
import com.qniao.dau.domain.aggregate.organization.entity.Organization;
import com.qniao.dau.domain.aggregate.store.entity.Store;
@ -45,6 +51,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@Component
@ -56,6 +63,8 @@ public class RevenueRewardEventHandler extends BaseApplicationService {
@Resource
private RevenueRewardQueryService revenueRewardQueryService;
@Resource
private OrderDao orderDao;
@Resource
private RevenueRewardAggregate revenueRewardAggregate;
@Resource
private RevenueRewardRecoveredRecordDao revenueRewardRecoveredRecordDao;
@ -73,6 +82,10 @@ public class RevenueRewardEventHandler extends BaseApplicationService {
private FranchiseFeeProfitManagementAggregate franchiseFeeProfitManagementAggregate;
@Resource
private FranchiseFeeProfitManagementQueryService franchiseFeeProfitManagementQueryService;
@Resource
private RewardApplicationService rewardApplicationService;
@Resource
private StoreDao storeDao;
@RabbitListener(bindings = @QueueBinding(value = @Queue(MqQueue.OPERATION_CENTER_CREATED),
exchange = @Exchange(value = MqExchange.OPERATION_CENTER_CREATED,
@ -150,7 +163,7 @@ public class RevenueRewardEventHandler extends BaseApplicationService {
revenueRewardRecoveredRecordDao.insert(recoveredRecord);
//补充管道收益 PIPELINE_REVENUE 全回本后才有管道收益
if (revenueReward.getAllRecoveryRequirement()) {
revenueRewardApplicationService.pipeLineRevenue(orgId, revenueRewardRecord, TradeSceneEnum.OFFLINE,revenueRewardRecord.getContent());
revenueRewardApplicationService.pipeLineRevenue(orgId, revenueRewardRecord, TradeSceneEnum.OFFLINE, revenueRewardRecord.getContent());
}
//发送事件 检查是否满足回本要求
RevenueRewardUpdatedEvent reEvent = new RevenueRewardUpdatedEvent(revenueReward.getId());
@ -224,4 +237,59 @@ public class RevenueRewardEventHandler extends BaseApplicationService {
log.error("服务商回本事件处理异常");
}
}
/**
* 新手任务完成
*
* @param mq
*/
@RabbitListener(bindings = @QueueBinding(value = @Queue(MqQueue.OPERATION_CENTER_CREATED),
exchange = @Exchange(value = MqExchange.OPERATION_CENTER_CREATED,
type = ExchangeTypes.FANOUT)))
public void handle(MatchmakerNoviceTaskProgressFinishedMQ mq) {
try {
//红娘新手任务完成 卡在平台的加盟收益要分润出去
//将新手任务阶段的红娘入驻的分佣分给站点最后红娘的额外奖励由站点支付
List<FranchiseFeeProfitManagement> franchiseFeeProfitManagementList = franchiseFeeProfitManagementQueryService
.listByInitiatorId(mq.getMatchmakerUserId(), IdentityTypeEnum.INDIVIDUAL, false);
if (CollUtil.isNotEmpty(franchiseFeeProfitManagementList)) {
//站点分佣金
Store store = storeDao.selectById(mq.getStoreId());
for (FranchiseFeeProfitManagement franchiseFeeProfitManagement : franchiseFeeProfitManagementList) {
Order associateOrder = orderDao.selectById(franchiseFeeProfitManagement.getAssociatedOrderId());
RevenueReward storeRevenueReward = revenueRewardQueryService.queryByOrgId(store.getOrgId());
if (!storeRevenueReward.getAllRecoveryRequirement()) {
//未回本 拿100% 20%推荐费+50%门店费用+ 30%回本补贴
rewardApplicationService.handleStoreRecommendMatchmakerFee(store.getOrgId(), mq.getMatchmakerName(), associateOrder.getSettlementAmount(), RewardTypeEnum.OPERATING_RECOMMEND_50);
rewardApplicationService.handleStoreRecommendMatchmakerFee(store.getOrgId(), mq.getMatchmakerName(), associateOrder.getSettlementAmount(), RewardTypeEnum.PAYBACK_SUBSIDY_30);
//发送事件 检查是否满足回本要求
RevenueReward stRevenueReward = revenueRewardQueryService.queryByOrgId(store.getOrgId());
RevenueRewardUpdatedEvent storeReEvent = new RevenueRewardUpdatedEvent(stRevenueReward.getId());
handle(storeReEvent);
} else {
//回本后 拿70% 20%推荐费+50%门店费用
rewardApplicationService.handleStoreRecommendMatchmakerFee(store.getOrgId(), mq.getMatchmakerName(), associateOrder.getSettlementAmount(), RewardTypeEnum.OPERATING_RECOMMEND_50);
//发送事件 检查是否满足回本要求
RevenueReward stRevenueReward = revenueRewardQueryService.queryByOrgId(store.getOrgId());
RevenueRewardUpdatedEvent storeReEvent = new RevenueRewardUpdatedEvent(stRevenueReward.getId());
handle(storeReEvent);
//区域分润
rewardApplicationService.handleStoreRecommendMatchmakerFee(store.getOperationCenterOrgId(), mq.getMatchmakerName(), associateOrder.getSettlementAmount(), RewardTypeEnum.SERVICE_PROVIDER_MANAGEMENT_FEE);
//发送事件 检查是否满足回本要求
RevenueReward operationCenterRevenueReward = revenueRewardQueryService.queryByOrgId(store.getOperationCenterOrgId());
RevenueRewardUpdatedEvent operationCenterReEvent = new RevenueRewardUpdatedEvent(operationCenterRevenueReward.getId());
handle(operationCenterReEvent);
}
}
//todo 推荐的红娘不在一个门店中收益是否归门店
//todo 红娘的新手任务奖励
}
} catch (Exception e) {
log.error("新手任务完成事件处理异常", e);
}
}
}

12
dating-agency-mall-server/src/main/java/com/qniao/dam/application/service/reward/RewardApplicationService.java

@ -23,6 +23,7 @@ import com.qniao.dam.domian.aggregate.walletaccount.constant.IdentityTypeEnum;
import com.qniao.dam.domian.aggregate.walletaccount.constant.TradeSceneEnum;
import com.qniao.dam.infrastructure.constant.MqExchange;
import com.qniao.dam.infrastructure.persistent.dao.domain.*;
import com.qniao.dam.query.ffpm.FranchiseFeeProfitManagementQueryService;
import com.qniao.dam.query.matchmaker.MatchmakerQueryService;
import com.qniao.dam.query.mntp.MatchmakerNoviceTaskProgressQueryService;
import com.qniao.dam.query.operationcenter.OperationCenterQueryService;
@ -86,7 +87,6 @@ public class RewardApplicationService extends BaseApplicationService {
private MatchmakerNoviceTaskProgressQueryService matchmakerNoviceTaskProgressQueryService;
@Resource
private FranchiseFeeProfitManagementAggregate franchiseFeeProfitManagementAggregate;
/**
* 获得红娘推荐奖励 新政策
*/
@ -184,8 +184,8 @@ public class RewardApplicationService extends BaseApplicationService {
handleStoreRecommendMatchmakerFee(store.getOperationCenterOrgId(), dto.getReceiveUserName(), rewardAmount, RewardTypeEnum.SERVICE_PROVIDER_MANAGEMENT_FEE);
//发送事件 检查是否满足回本要求
RevenueReward operationCenterRevenueReward = revenueRewardQueryService.queryByOrgId(store.getOperationCenterOrgId());
RevenueRewardUpdatedEvent OperationCenterReEvent = new RevenueRewardUpdatedEvent(operationCenterRevenueReward.getId());
this.sendEvent(OperationCenterReEvent);
RevenueRewardUpdatedEvent operationCenterReEvent = new RevenueRewardUpdatedEvent(operationCenterRevenueReward.getId());
this.sendEvent(operationCenterReEvent);
}
} else {
//红娘推荐的话
@ -217,8 +217,8 @@ public class RewardApplicationService extends BaseApplicationService {
handleStoreRecommendMatchmakerFee(store.getOperationCenterOrgId(), dto.getReceiveUserName(), rewardAmount, RewardTypeEnum.SERVICE_PROVIDER_MANAGEMENT_FEE);
//发送事件 检查是否满足回本要求
RevenueReward operationCenterRevenueReward = revenueRewardQueryService.queryByOrgId(store.getOperationCenterOrgId());
RevenueRewardUpdatedEvent OperationCenterReEvent = new RevenueRewardUpdatedEvent(operationCenterRevenueReward.getId());
this.sendEvent(OperationCenterReEvent);
RevenueRewardUpdatedEvent operationCenterReEvent = new RevenueRewardUpdatedEvent(operationCenterRevenueReward.getId());
this.sendEvent(operationCenterReEvent);
}
} else {
// 红娘未完成 记录到 入驻费分佣管理中
@ -240,7 +240,7 @@ public class RewardApplicationService extends BaseApplicationService {
}
}
private void handleStoreRecommendMatchmakerFee(Long orgId,
public void handleStoreRecommendMatchmakerFee(Long orgId,
String serviceProviderName,
BigDecimal franchiseFee,
RewardTypeEnum rewardType) {

5
dating-agency-mall-server/src/main/java/com/qniao/dam/query/ffpm/FranchiseFeeProfitManagementQueryService.java

@ -1,8 +1,13 @@
package com.qniao.dam.query.ffpm;
import com.qniao.dam.domain.aggregate.ffpm.entity.FranchiseFeeProfitManagement;
import com.qniao.dam.domian.aggregate.walletaccount.constant.IdentityTypeEnum;
import java.util.List;
public interface FranchiseFeeProfitManagementQueryService {
FranchiseFeeProfitManagement queryByOrg(Long orgId);
List<FranchiseFeeProfitManagement> listByInitiatorId(Long matchmakerUserId, IdentityTypeEnum identityType, Boolean isFinish);
}

13
dating-agency-mall-server/src/main/java/com/qniao/dam/query/ffpm/impl/FranchiseFeeProfitManagementQueryServiceImpl.java

@ -2,11 +2,13 @@ package com.qniao.dam.query.ffpm.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qniao.dam.domain.aggregate.ffpm.entity.FranchiseFeeProfitManagement;
import com.qniao.dam.domian.aggregate.walletaccount.constant.IdentityTypeEnum;
import com.qniao.dam.infrastructure.persistent.dao.ffpm.FranchiseFeeProfitManagementDao;
import com.qniao.dam.query.ffpm.FranchiseFeeProfitManagementQueryService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class FranchiseFeeProfitManagementQueryServiceImpl implements FranchiseFeeProfitManagementQueryService {
@ -20,4 +22,15 @@ public class FranchiseFeeProfitManagementQueryServiceImpl implements FranchiseFe
.eq(FranchiseFeeProfitManagement::getOrgId, orgId)
.last("limit 1"));
}
@Override
public List<FranchiseFeeProfitManagement> listByInitiatorId(Long matchmakerUserId,
IdentityTypeEnum identityType,
Boolean isFinish) {
return franchiseFeeProfitManagementDao.selectList(new LambdaQueryWrapper<FranchiseFeeProfitManagement>()
.eq(FranchiseFeeProfitManagement::getInitiatorId, identityType)
.eq(FranchiseFeeProfitManagement::getIdentityType, identityType)
.eq(FranchiseFeeProfitManagement::getIsFinish, isFinish)
.orderByAsc(FranchiseFeeProfitManagement::getCreateTime));
}
}
Loading…
Cancel
Save