Browse Source

新政策

master
张彭杰 11 months ago
parent
commit
6d28c9854c
11 changed files with 166 additions and 17 deletions
  1. 4
      dating-agency-mall-constant/src/main/java/com/qniao/dam/domian/aggregate/ffpm/constant/FranchiseFeeProfitManagementTypeEnum.java
  2. 6
      dating-agency-mall-constant/src/main/java/com/qniao/dam/domian/aggregate/rewardconfig/constant/RewardTypeEnum.java
  3. 20
      dating-agency-mall-entity/src/main/java/com/qniao/dam/domain/aggregate/ffpm/entity/FranchiseFeeProfitManagement.java
  4. 2
      dating-agency-mall-sdk/src/main/java/com/qniao/dam/application/request/UserAcquireMatchmakerJoinRecommendRewardDto.java
  5. 4
      dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/reward/user/request/UserAcquireMatchmakerJoinRecommendRewardDto.java
  6. 10
      dating-agency-mall-server/src/main/java/com/qniao/dam/application/handler/revenuereward/RevenueRewardEventHandler.java
  7. 98
      dating-agency-mall-server/src/main/java/com/qniao/dam/application/service/reward/RewardApplicationService.java
  8. 2
      dating-agency-mall-server/src/main/java/com/qniao/dam/infrastructure/constant/MqExchange.java
  9. 7
      dating-agency-mall-server/src/main/java/com/qniao/dam/infrastructure/persistent/dao/mntp/MatchmakerNoviceTaskProgressDao.java
  10. 7
      dating-agency-mall-server/src/main/java/com/qniao/dam/query/mntp/MatchmakerNoviceTaskProgressQueryService.java
  11. 23
      dating-agency-mall-server/src/main/java/com/qniao/dam/query/mntp/impl/MatchmakerNoviceTaskProgressQueryServiceImpl.java

4
dating-agency-mall-constant/src/main/java/com/qniao/dam/domian/aggregate/ffpm/constant/FranchiseFeeProfitManagementTypeEnum.java

@ -19,9 +19,7 @@ public enum FranchiseFeeProfitManagementTypeEnum {
*/
SERVICE_PROVIDER_SETTLEMENT(1, "服务商入驻"),
SERVICE_PROVIDER_RECOMMEND_MATCHMAKER(2, "服务商推荐红娘"),
MATCHMAKER_RECOMMEND_MATCHMAKER(3, "红娘推荐红娘");
MATCHMAKER_RECOMMEND_MATCHMAKER(2, "红娘推荐红娘");
@EnumValue
@JsonValue

6
dating-agency-mall-constant/src/main/java/com/qniao/dam/domian/aggregate/rewardconfig/constant/RewardTypeEnum.java

@ -127,7 +127,9 @@ public enum RewardTypeEnum {
OPERATING_RECOMMEND_50(507, "营性质推荐收益-50%"),
OPERATING_RECOMMEND_20(508, "营性质推荐收益-20%");
OPERATING_RECOMMEND_20(508, "营性质推荐收益-20%"),
PAYBACK_SUBSIDY_30(509, "回本补贴-30%");
@EnumValue
@JsonValue
@ -148,4 +150,4 @@ public enum RewardTypeEnum {
}
return null;
}
}
}

20
dating-agency-mall-entity/src/main/java/com/qniao/dam/domain/aggregate/ffpm/entity/FranchiseFeeProfitManagement.java

@ -18,6 +18,9 @@ import com.qniao.domain.Entity;
@TableName("da_franchise_fee_profit_management")
public class FranchiseFeeProfitManagement extends Entity<FranchiseFeeProfitManagement> {
@ApiModelProperty("发起人唯一标识")
private Long initiatorId;
@ApiModelProperty("用户唯一标识")
private Long userId;
@ -35,10 +38,12 @@ public class FranchiseFeeProfitManagement extends Entity<FranchiseFeeProfitManag
@ApiModelProperty("关联订单ID")
private Long associatedOrderId;
public static FranchiseFeeProfitManagement initOrg(Long orgId,
public static FranchiseFeeProfitManagement initOrg(Long initiatorId,
Long orgId,
FranchiseFeeProfitManagementTypeEnum type,
Long associatedOrderId) {
FranchiseFeeProfitManagement management = new FranchiseFeeProfitManagement();
management.setInitiatorId(initiatorId);
management.setOrgId(orgId);
management.setIdentityType(IdentityTypeEnum.ORGANIZATION);
management.setType(type);
@ -47,4 +52,17 @@ public class FranchiseFeeProfitManagement extends Entity<FranchiseFeeProfitManag
return management;
}
public static FranchiseFeeProfitManagement initUser(Long initiatorId,
Long userId,
FranchiseFeeProfitManagementTypeEnum type,
Long associatedOrderId) {
FranchiseFeeProfitManagement management = new FranchiseFeeProfitManagement();
management.setInitiatorId(initiatorId);
management.setUserId(userId);
management.setIdentityType(IdentityTypeEnum.INDIVIDUAL);
management.setType(type);
management.setIsFinish(false);
management.setAssociatedOrderId(associatedOrderId);
return management;
}
}

2
dating-agency-mall-sdk/src/main/java/com/qniao/dam/application/request/UserAcquireMatchmakerJoinRecommendRewardDto.java

@ -1,5 +1,6 @@
package com.qniao.dam.application.request;
import com.qniao.dam.domian.aggregate.product.constant.ProductSubCategoryEnum;
import com.qniao.dau.domian.aggregate.matchmaker.constant.MatchmakerLevelEnum;
import com.qniao.dau.domian.aggregate.matchmakeraudit.constant.MatchmakerAuditBehaviorEnum;
import lombok.AllArgsConstructor;
@ -13,6 +14,7 @@ public class UserAcquireMatchmakerJoinRecommendRewardDto {
private Long initiatorUserId;
private Long receiveUserId;
private String receiveUserName;
private ProductSubCategoryEnum matchmakerType;
private Long associateOrderId;
private MatchmakerLevelEnum initiatorLevel;
private MatchmakerLevelEnum receiveLevel;

4
dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/reward/user/request/UserAcquireMatchmakerJoinRecommendRewardDto.java

@ -1,5 +1,6 @@
package com.qniao.dam.api.command.reward.user.request;
import com.qniao.dam.domian.aggregate.product.constant.ProductSubCategoryEnum;
import com.qniao.dau.domian.aggregate.matchmaker.constant.MatchmakerLevelEnum;
import com.qniao.dau.domian.aggregate.matchmakeraudit.constant.MatchmakerAuditBehaviorEnum;
import io.swagger.annotations.ApiModelProperty;
@ -17,6 +18,9 @@ public class UserAcquireMatchmakerJoinRecommendRewardDto {
@ApiModelProperty("接收用户名称")
private String receiveUserName;
@ApiModelProperty("加盟红娘类型")
private ProductSubCategoryEnum matchmakerType;
@ApiModelProperty("关联订单")
private Long associateOrderId;

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

@ -113,7 +113,7 @@ public class RevenueRewardEventHandler extends BaseApplicationService {
//推荐服务商回本后 先提取50%,剩余20需要被推荐服务商回本50%后才能提取
handleServiceProviderManagementFee(mq.getRecommendServiceProviderOrgId(), mq.getStoreName(), mq.getFranchiseFee(), RewardTypeEnum.OPERATING_RECOMMEND_50);
//补充 入驻费分佣管理
FranchiseFeeProfitManagement franchiseFeeProfitManagement = FranchiseFeeProfitManagement.initOrg(mq.getOrgId(), FranchiseFeeProfitManagementTypeEnum.SERVICE_PROVIDER_SETTLEMENT,
FranchiseFeeProfitManagement franchiseFeeProfitManagement = FranchiseFeeProfitManagement.initOrg(mq.getRecommendServiceProviderOrgId(), mq.getOrgId(), FranchiseFeeProfitManagementTypeEnum.SERVICE_PROVIDER_SETTLEMENT,
null);
franchiseFeeProfitManagementAggregate.create(franchiseFeeProfitManagement);
}
@ -129,10 +129,10 @@ public class RevenueRewardEventHandler extends BaseApplicationService {
}
}
private void handleServiceProviderManagementFee(Long orgId,
String serviceProviderName,
BigDecimal franchiseFee,
RewardTypeEnum rewardType) {
public void handleServiceProviderManagementFee(Long orgId,
String serviceProviderName,
BigDecimal franchiseFee,
RewardTypeEnum rewardType) {
//服务商管理费
RewardConfig rewardConfig = rewardConfigQueryService.queryByRewardType(rewardType);
RevenueReward revenueReward = revenueRewardQueryService.queryByOrgId(orgId);

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

@ -5,20 +5,29 @@ import cn.hutool.core.util.StrUtil;
import com.qniao.dam.api.command.reward.user.request.AcquireMatchmakerConfirmMatchRewardDto;
import com.qniao.dam.api.command.reward.user.request.AcquireMatchmakerConfirmMeetingRewardDto;
import com.qniao.dam.api.command.reward.user.request.UserAcquireMatchmakerJoinRecommendRewardDto;
import com.qniao.dam.application.handler.revenuereward.RevenueRewardEventHandler;
import com.qniao.dam.application.service.revenuereward.RevenueRewardApplicationService;
import com.qniao.dam.domain.aggregate.ffpm.FranchiseFeeProfitManagementAggregate;
import com.qniao.dam.domain.aggregate.ffpm.entity.FranchiseFeeProfitManagement;
import com.qniao.dam.domain.aggregate.marriagebounty.entity.MarriageBountyOrder;
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.RevenueRewardAssociateOrderRecord;
import com.qniao.dam.domain.aggregate.revenuereward.valueobj.RevenueRewardRecord;
import com.qniao.dam.domain.aggregate.revenuereward.valueobj.RevenueRewardRecoveredRecord;
import com.qniao.dam.domain.service.revenuereward.AcquireRevenueRewardDomainService;
import com.qniao.dam.domian.aggregate.ffpm.constant.FranchiseFeeProfitManagementTypeEnum;
import com.qniao.dam.domian.aggregate.matchmaker.event.MatchmakerFranchiseFeeRewardEvent;
import com.qniao.dam.domian.aggregate.pointaccount.event.PointRewardCreatedMQ;
import com.qniao.dam.domian.aggregate.prc.constant.PointRewardConfigTypeEnum;
import com.qniao.dam.domian.aggregate.product.constant.ProductSubCategoryEnum;
import com.qniao.dam.domian.aggregate.revenuereward.event.RevenueRewardUpdatedEvent;
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.matchmaker.MatchmakerQueryService;
import com.qniao.dam.query.mntp.MatchmakerNoviceTaskProgressQueryService;
import com.qniao.dam.query.operationcenter.OperationCenterQueryService;
import com.qniao.dam.query.revenuereward.RevenueRewardQueryService;
import com.qniao.dam.query.store.StoreQueryService;
@ -33,9 +42,11 @@ import com.qniao.dam.domian.aggregate.walletaccount.constant.TradeTypeEnum;
import com.qniao.dam.query.order.OrderQueryService;
import com.qniao.dam.query.rewardconfig.RewardConfigQueryService;
import com.qniao.das.domian.aggregate.marriageinformation.MarriageInformation;
import com.qniao.das.domian.aggregate.mntp.entity.MatchmakerNoviceTaskProgress;
import com.qniao.dau.domain.aggregate.matchmaker.entity.Matchmaker;
import com.qniao.dau.domain.aggregate.operationcenter.entity.OperationCenter;
import com.qniao.dau.domain.aggregate.store.entity.Store;
import com.qniao.dau.domian.aggregate.matchmaker.event.MatchmakerInvitedMQ;
import com.qniao.dau.domian.aggregate.matchmakeraudit.constant.MatchmakerAuditBehaviorEnum;
import com.qniao.domain.BaseApplicationService;
import org.springframework.amqp.core.AmqpTemplate;
@ -70,6 +81,16 @@ public class RewardApplicationService extends BaseApplicationService {
private AmqpTemplate amqpTemplate;
@Resource
private RevenueRewardDao revenueRewardDao;
@Resource
private RevenueRewardAggregate revenueRewardAggregate;
@Resource
private RevenueRewardRecoveredRecordDao revenueRewardRecoveredRecordDao;
@Resource
private RevenueRewardApplicationService revenueRewardApplicationService;
@Resource
private MatchmakerNoviceTaskProgressQueryService matchmakerNoviceTaskProgressQueryService;
@Resource
private FranchiseFeeProfitManagementAggregate franchiseFeeProfitManagementAggregate;
/**
* 获得红娘推荐奖励 新政策
@ -78,11 +99,12 @@ public class RewardApplicationService extends BaseApplicationService {
//红娘加盟订单
Order associateOrder = orderDao.selectById(dto.getAssociateOrderId());
if (Objects.nonNull(associateOrder)) {
Matchmaker initiatorMatchmaker = null;
BigDecimal rewardAmount = associateOrder.getSettlementAmount();
//推荐的红娘
if (Objects.nonNull(dto.getInitiatorUserId())) {
synchronized (dto.getInitiatorUserId().toString().intern()) {
Matchmaker initiatorMatchmaker = matchmakerQueryService.queryByUserId(dto.getInitiatorUserId());
initiatorMatchmaker = matchmakerQueryService.queryByUserId(dto.getInitiatorUserId());
//邀请红娘在有效期内才能拿到佣金+积分奖励
if (Objects.nonNull(initiatorMatchmaker) && initiatorMatchmaker.checkEnable()) {
//奖励百分比
@ -148,20 +170,84 @@ public class RewardApplicationService extends BaseApplicationService {
//门店回本前 拿100% 20%推荐费+50%门店费用30%直接拿+20%新手任务完成+ 30%回本补贴
//门店回本后 拿70% 20%推荐费+50%门店费用30%直接拿+20%新手任务完成
RevenueReward storeRevenueReward = revenueRewardQueryService.queryByOrgId(dto.getStoreOrgId());
if (!storeRevenueReward.getAllRecoveryRequirement()){
//未回本 拿100% 20%推荐费+50%门店费用30%直接拿+20%新手任务完成+ 30%回本补贴
if (!storeRevenueReward.getAllRecoveryRequirement()) {
//未回本 拿100% 20%推荐费+50%门店费用+ 30%回本补贴
handleStoreRecommendMatchmakerFee(store.getOrgId(), dto.getReceiveUserName(), rewardAmount, RewardTypeEnum.OPERATING_RECOMMEND_50);
handleStoreRecommendMatchmakerFee(store.getOrgId(), dto.getReceiveUserName(), rewardAmount, RewardTypeEnum.PAYBACK_SUBSIDY_30);
} else {
//回本后 拿70% 20%推荐费+50%门店费用
handleStoreRecommendMatchmakerFee(store.getOrgId(), dto.getReceiveUserName(), rewardAmount, RewardTypeEnum.OPERATING_RECOMMEND_50);
//区域分润
handleStoreRecommendMatchmakerFee(store.getOperationCenterOrgId(), dto.getReceiveUserName(), rewardAmount, RewardTypeEnum.SERVICE_PROVIDER_MANAGEMENT_FEE);
}
}else{
} else {
//红娘推荐的话
//门店回本前+红娘没有完成新手任务 红娘直接拿20%+30%回本补贴+对照新手任务奖励
//门店回本后 红娘直接拿20%+30%回本补贴+对照新手任务奖励
if (Objects.nonNull(initiatorMatchmaker)) {
MatchmakerNoviceTaskProgress matchmakerNoviceTaskProgress = matchmakerNoviceTaskProgressQueryService.queryByMatchmakerId(initiatorMatchmaker.getId());
if (Objects.nonNull(matchmakerNoviceTaskProgress)) {
if (matchmakerNoviceTaskProgress.getIsFinish()) {
// 红娘已完成新手任务 门店拿50%, 没回本再拿30%回本补贴
RevenueReward storeRevenueReward = revenueRewardQueryService.queryByOrgId(dto.getStoreOrgId());
if (!storeRevenueReward.getAllRecoveryRequirement()) {
//未回本 门店拿50% + 30%回本补贴
handleStoreRecommendMatchmakerFee(store.getOrgId(), dto.getReceiveUserName(), rewardAmount, RewardTypeEnum.OPERATING_RECOMMEND_50);
handleStoreRecommendMatchmakerFee(store.getOrgId(), dto.getReceiveUserName(), rewardAmount, RewardTypeEnum.PAYBACK_SUBSIDY_30);
} else {
//已回本 门店拿50%
handleStoreRecommendMatchmakerFee(store.getOrgId(), dto.getReceiveUserName(), rewardAmount, RewardTypeEnum.OPERATING_RECOMMEND_50);
//区域分润
handleStoreRecommendMatchmakerFee(store.getOperationCenterOrgId(), dto.getReceiveUserName(), rewardAmount, RewardTypeEnum.SERVICE_PROVIDER_MANAGEMENT_FEE);
}
} else {
// 红娘未完成 记录到 入驻费分佣管理中
FranchiseFeeProfitManagement franchiseFeeProfitManagement = FranchiseFeeProfitManagement.initUser(dto.getInitiatorUserId(), dto.getReceiveUserId(),
FranchiseFeeProfitManagementTypeEnum.MATCHMAKER_RECOMMEND_MATCHMAKER,
dto.getAssociateOrderId());
franchiseFeeProfitManagementAggregate.create(franchiseFeeProfitManagement);
MatchmakerInvitedMQ matchmakerInvitedMQ = new MatchmakerInvitedMQ();
matchmakerInvitedMQ.setInitiatorMatchmakerUserId(dto.getInitiatorUserId());
matchmakerInvitedMQ.setReceiveMatchmakerType(dto.getMatchmakerType());
matchmakerInvitedMQ.setAssociateOrderId(dto.getAssociateOrderId());
amqpTemplate.convertAndSend(MqExchange.MATCHMAKER_INVITED, null, matchmakerInvitedMQ);
}
}
}
}
}
}
private void handleStoreRecommendMatchmakerFee(Long orgId,
String serviceProviderName,
BigDecimal franchiseFee,
RewardTypeEnum rewardType) {
//服务商管理费
RewardConfig rewardConfig = rewardConfigQueryService.queryByRewardType(rewardType);
RevenueReward revenueReward = revenueRewardQueryService.queryByOrgId(orgId);
BigDecimal revenue = RewardConfig.calculatePct(franchiseFee, new BigDecimal(rewardConfig.getValue()));
//线下收益
RevenueRewardRecord revenueRewardRecord = RevenueRewardRecord.build(TradeTypeEnum.MATCHMAKER_JOIN_RECOMMEND_FEE, TradeSceneEnum.ONLINE,
revenue, new BigDecimal(rewardConfig.getValue()), BigDecimal.ZERO, revenue, franchiseFee);
revenueRewardRecord.handleContent(Collections.singletonList(serviceProviderName));
revenueReward.setRecordList(Collections.singletonList(revenueRewardRecord));
//计算本次回本金额
revenueReward.handleRevenueReward(revenue);
revenueRewardAggregate.save(revenueReward);
//配置回本数据
RevenueRewardRecoveredRecord recoveredRecord = RevenueRewardRecoveredRecord.build(revenueReward.getId(), revenueRewardRecord.getId());
revenueRewardRecoveredRecordDao.insert(recoveredRecord);
//补充管道收益 PIPELINE_REVENUE 全回本后才有管道收益
if (revenueReward.getAllRecoveryRequirement()) {
revenueRewardApplicationService.pipeLineRevenue(orgId, revenueRewardRecord, TradeSceneEnum.OFFLINE);
}
//发送事件 检查是否满足回本要求
RevenueRewardUpdatedEvent reEvent = new RevenueRewardUpdatedEvent(revenueReward.getId());
this.sendEvent(reEvent);
}
/**
* 获得红娘推荐奖励 老政策
*/

2
dating-agency-mall-server/src/main/java/com/qniao/dam/infrastructure/constant/MqExchange.java

@ -29,4 +29,6 @@ public interface MqExchange {
String STORE_CREATED = "fanout.storeCreated";
String OPERATION_CENTER_CREATED = "fanout.operationCenterCreated";
String MATCHMAKER_INVITED = "fanout.MatchmakerInvited";
}

7
dating-agency-mall-server/src/main/java/com/qniao/dam/infrastructure/persistent/dao/mntp/MatchmakerNoviceTaskProgressDao.java

@ -0,0 +1,7 @@
package com.qniao.dam.infrastructure.persistent.dao.mntp;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qniao.das.domian.aggregate.mntp.entity.MatchmakerNoviceTaskProgress;
public interface MatchmakerNoviceTaskProgressDao extends BaseMapper<MatchmakerNoviceTaskProgress> {
}

7
dating-agency-mall-server/src/main/java/com/qniao/dam/query/mntp/MatchmakerNoviceTaskProgressQueryService.java

@ -0,0 +1,7 @@
package com.qniao.dam.query.mntp;
import com.qniao.das.domian.aggregate.mntp.entity.MatchmakerNoviceTaskProgress;
public interface MatchmakerNoviceTaskProgressQueryService {
MatchmakerNoviceTaskProgress queryByMatchmakerId(Long matchmakerId);
}

23
dating-agency-mall-server/src/main/java/com/qniao/dam/query/mntp/impl/MatchmakerNoviceTaskProgressQueryServiceImpl.java

@ -0,0 +1,23 @@
package com.qniao.dam.query.mntp.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qniao.dam.infrastructure.persistent.dao.mntp.MatchmakerNoviceTaskProgressDao;
import com.qniao.dam.query.mntp.MatchmakerNoviceTaskProgressQueryService;
import com.qniao.das.domian.aggregate.mntp.entity.MatchmakerNoviceTaskProgress;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class MatchmakerNoviceTaskProgressQueryServiceImpl implements MatchmakerNoviceTaskProgressQueryService {
@Resource
private MatchmakerNoviceTaskProgressDao matchmakerNoviceTaskProgressDao;
@Override
public MatchmakerNoviceTaskProgress queryByMatchmakerId(Long matchmakerId) {
return matchmakerNoviceTaskProgressDao.selectOne(new LambdaQueryWrapper<MatchmakerNoviceTaskProgress>()
.eq(MatchmakerNoviceTaskProgress::getMatchmakerId, matchmakerId)
.last("limit 1"));
}
}
Loading…
Cancel
Save