Browse Source

线下收益

master
张彭杰 1 year ago
parent
commit
f609dc0956
1 changed files with 56 additions and 54 deletions
  1. 110
      dating-agency-mall-server/src/main/java/com/qniao/dam/application/service/reward/RewardApplicationService.java

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

@ -416,56 +416,25 @@ public class RewardApplicationService extends BaseApplicationService {
if (CollUtil.isNotEmpty(revenueRewardRecordList)) {
revenueRewardRecordList.forEach(record -> {
RevenueReward revenueReward = revenueRewardDao.selectById(record.getRevenueRewardId());
//判断是否个人收入
if (IdentityTypeEnum.INDIVIDUAL.equals(revenueReward.getIdentityType())) {
List<RevenueRewardAssociateOrderRecord> associateOrderList = revenueRewardQueryService.listAssociateOrderBy(record.getId());
if (CollUtil.isNotEmpty(associateOrderList)) {
List<RevenueRewardAssociateOrderRecord> allAssociateOrderList = revenueRewardQueryService.listAssociateOrderByOrderId(associateOrderList.get(0).getAssociateOrderId());
if (allAssociateOrderList.size() == 1) {
//服务没有关联订单可以补充
Matchmaker matchmaker = matchmakerQueryService.queryByUserId(revenueReward.getUserId());
if (Objects.nonNull(matchmaker)) {
//门店提成
if (Objects.nonNull(matchmaker.getStoreId())) {
Store store = storeQueryService.queryById(matchmaker.getStoreId());
if (!store.getAdministratorId().equals(revenueReward.getUserId())) {
synchronized (store.getOrgId().toString().intern()) {
RewardConfig recommendRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.MATCHMAKER_JOIN_RECOMMEND_STORE);
if (Objects.nonNull(recommendRewardConfig)) {
//收益信息
RevenueReward storeRevenueReward = revenueRewardQueryService.queryByOrgId(store.getOrgId());
//营收额
BigDecimal revenue = recommendRewardConfig.calculateReward(record.getTotalAssociateOrderAmount());
RevenueRewardRecord revenueRewardRecord = RevenueRewardRecord.build(TradeTypeEnum.MATCHMAKER_JOIN_RECOMMEND_FEE, TradeSceneEnum.ONLINE,
revenue, new BigDecimal(recommendRewardConfig.getValue()), BigDecimal.ZERO, revenue, record.getTotalAssociateOrderAmount());
revenueRewardRecord.setContent(record.getContent());
revenueRewardRecord.setCreateTime(record.getCreateTime());
RevenueRewardAssociateOrderRecord associateOrderRecord = RevenueRewardAssociateOrderRecord.build(associateOrderList.get(0).getId(), record.getTotalAssociateOrderAmount());
revenueRewardRecord.setAssociateOrderRecordList(Collections.singletonList(associateOrderRecord));
storeRevenueReward.setRecordList(Collections.singletonList(revenueRewardRecord));
//钱包信息
WalletAccount walletAccount = walletAccountQueryService.queryByType(store.getOrgId(), IdentityTypeEnum.ORGANIZATION);
BigDecimal originalBalance = walletAccount.getTotalBalance();
walletAccount.setAvailableBalance(walletAccount.getAvailableBalance().add(revenue));
walletAccount.setTotalBalance(walletAccount.getAvailableBalance().add(walletAccount.getFrozenBalance()));
WalletAccountRecord storeRecord = WalletAccountRecord.build(TradeTypeEnum.MATCHMAKER_JOIN_RECOMMEND_FEE, revenue, true, originalBalance, walletAccount.getTotalBalance());
storeRecord.setCreateTime(record.getCreateTime());
walletAccount.setRecordList(Collections.singletonList(storeRecord));
acquireRevenueRewardDomainService.handle(storeRevenueReward, walletAccount);
}
}
}
//运营中心提成
if (Objects.nonNull(store.getOperationCenterOrgId())) {
OperationCenter operationCenter = operationCenterQueryService.queryByOrg(store.getOperationCenterOrgId());
if (!operationCenter.getAdministratorId().equals(revenueReward.getUserId())) {
synchronized (store.getOperationCenterOrgId().toString().intern()) {
RewardConfig recommendRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.MATCHMAKER_JOIN_RECOMMEND_OPERATION_CENTER);
if (Objects.nonNull(revenueReward)) {
//判断是否个人收入
if (IdentityTypeEnum.INDIVIDUAL.equals(revenueReward.getIdentityType())) {
List<RevenueRewardAssociateOrderRecord> associateOrderList = revenueRewardQueryService.listAssociateOrderBy(record.getId());
if (CollUtil.isNotEmpty(associateOrderList)) {
List<RevenueRewardAssociateOrderRecord> allAssociateOrderList = revenueRewardQueryService.listAssociateOrderByOrderId(associateOrderList.get(0).getAssociateOrderId());
if (allAssociateOrderList.size() == 1) {
//服务没有关联订单可以补充
Matchmaker matchmaker = matchmakerQueryService.queryByUserId(revenueReward.getUserId());
if (Objects.nonNull(matchmaker)) {
//门店提成
if (Objects.nonNull(matchmaker.getStoreId())) {
Store store = storeQueryService.queryById(matchmaker.getStoreId());
if (!store.getAdministratorId().equals(revenueReward.getUserId())) {
synchronized (store.getOrgId().toString().intern()) {
RewardConfig recommendRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.MATCHMAKER_JOIN_RECOMMEND_STORE);
if (Objects.nonNull(recommendRewardConfig)) {
//收益信息
RevenueReward ocRevenueReward = revenueRewardQueryService.queryByOrgId(store.getOperationCenterOrgId());
RevenueReward storeRevenueReward = revenueRewardQueryService.queryByOrgId(store.getOrgId());
//营收额
BigDecimal revenue = recommendRewardConfig.calculateReward(record.getTotalAssociateOrderAmount());
RevenueRewardRecord revenueRewardRecord = RevenueRewardRecord.build(TradeTypeEnum.MATCHMAKER_JOIN_RECOMMEND_FEE, TradeSceneEnum.ONLINE,
@ -474,17 +443,50 @@ public class RewardApplicationService extends BaseApplicationService {
revenueRewardRecord.setCreateTime(record.getCreateTime());
RevenueRewardAssociateOrderRecord associateOrderRecord = RevenueRewardAssociateOrderRecord.build(associateOrderList.get(0).getId(), record.getTotalAssociateOrderAmount());
revenueRewardRecord.setAssociateOrderRecordList(Collections.singletonList(associateOrderRecord));
ocRevenueReward.setRecordList(Collections.singletonList(revenueRewardRecord));
storeRevenueReward.setRecordList(Collections.singletonList(revenueRewardRecord));
//钱包信息
WalletAccount walletAccount = walletAccountQueryService.queryByType(store.getOperationCenterOrgId(), IdentityTypeEnum.ORGANIZATION);
WalletAccount walletAccount = walletAccountQueryService.queryByType(store.getOrgId(), IdentityTypeEnum.ORGANIZATION);
BigDecimal originalBalance = walletAccount.getTotalBalance();
walletAccount.setAvailableBalance(walletAccount.getAvailableBalance().add(revenue));
walletAccount.setTotalBalance(walletAccount.getAvailableBalance().add(walletAccount.getFrozenBalance()));
WalletAccountRecord ocRecord = WalletAccountRecord.build(TradeTypeEnum.MATCHMAKER_JOIN_RECOMMEND_FEE, revenue, true, originalBalance, walletAccount.getTotalBalance());
ocRecord.setCreateTime(record.getCreateTime());
walletAccount.setRecordList(Collections.singletonList(ocRecord));
acquireRevenueRewardDomainService.handle(ocRevenueReward, walletAccount);
WalletAccountRecord storeRecord = WalletAccountRecord.build(TradeTypeEnum.MATCHMAKER_JOIN_RECOMMEND_FEE, revenue, true, originalBalance, walletAccount.getTotalBalance());
storeRecord.setCreateTime(record.getCreateTime());
walletAccount.setRecordList(Collections.singletonList(storeRecord));
acquireRevenueRewardDomainService.handle(storeRevenueReward, walletAccount);
}
}
}
//运营中心提成
if (Objects.nonNull(store.getOperationCenterOrgId())) {
OperationCenter operationCenter = operationCenterQueryService.queryByOrg(store.getOperationCenterOrgId());
if (!operationCenter.getAdministratorId().equals(revenueReward.getUserId())) {
synchronized (store.getOperationCenterOrgId().toString().intern()) {
RewardConfig recommendRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.MATCHMAKER_JOIN_RECOMMEND_OPERATION_CENTER);
if (Objects.nonNull(recommendRewardConfig)) {
//收益信息
RevenueReward ocRevenueReward = revenueRewardQueryService.queryByOrgId(store.getOperationCenterOrgId());
//营收额
BigDecimal revenue = recommendRewardConfig.calculateReward(record.getTotalAssociateOrderAmount());
RevenueRewardRecord revenueRewardRecord = RevenueRewardRecord.build(TradeTypeEnum.MATCHMAKER_JOIN_RECOMMEND_FEE, TradeSceneEnum.ONLINE,
revenue, new BigDecimal(recommendRewardConfig.getValue()), BigDecimal.ZERO, revenue, record.getTotalAssociateOrderAmount());
revenueRewardRecord.setContent(record.getContent());
revenueRewardRecord.setCreateTime(record.getCreateTime());
RevenueRewardAssociateOrderRecord associateOrderRecord = RevenueRewardAssociateOrderRecord.build(associateOrderList.get(0).getId(), record.getTotalAssociateOrderAmount());
revenueRewardRecord.setAssociateOrderRecordList(Collections.singletonList(associateOrderRecord));
ocRevenueReward.setRecordList(Collections.singletonList(revenueRewardRecord));
//钱包信息
WalletAccount walletAccount = walletAccountQueryService.queryByType(store.getOperationCenterOrgId(), IdentityTypeEnum.ORGANIZATION);
BigDecimal originalBalance = walletAccount.getTotalBalance();
walletAccount.setAvailableBalance(walletAccount.getAvailableBalance().add(revenue));
walletAccount.setTotalBalance(walletAccount.getAvailableBalance().add(walletAccount.getFrozenBalance()));
WalletAccountRecord ocRecord = WalletAccountRecord.build(TradeTypeEnum.MATCHMAKER_JOIN_RECOMMEND_FEE, revenue, true, originalBalance, walletAccount.getTotalBalance());
ocRecord.setCreateTime(record.getCreateTime());
walletAccount.setRecordList(Collections.singletonList(ocRecord));
acquireRevenueRewardDomainService.handle(ocRevenueReward, walletAccount);
}
}
}
}

Loading…
Cancel
Save