BD和BDLEADER工资入账处理
This commit is contained in:
parent
289da0f2b8
commit
d9015a6675
@ -22,6 +22,8 @@ import com.red.circle.tool.core.date.TimestampUtils;
|
|||||||
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||||
import com.red.circle.wallet.inner.endpoint.bank.UserBankBalanceClient;
|
import com.red.circle.wallet.inner.endpoint.bank.UserBankBalanceClient;
|
||||||
import com.red.circle.wallet.inner.endpoint.bank.UserBankRunningWaterClient;
|
import com.red.circle.wallet.inner.endpoint.bank.UserBankRunningWaterClient;
|
||||||
|
import com.red.circle.wallet.inner.endpoint.salary.UserSalaryAccountClient;
|
||||||
|
import com.red.circle.wallet.inner.model.cmd.SalaryIssueInnerCmd;
|
||||||
import com.red.circle.wallet.inner.model.cmd.UserBankBalanceIncrCmd;
|
import com.red.circle.wallet.inner.model.cmd.UserBankBalanceIncrCmd;
|
||||||
import com.red.circle.wallet.inner.model.dto.UserBankRunningWaterDTO;
|
import com.red.circle.wallet.inner.model.dto.UserBankRunningWaterDTO;
|
||||||
import com.red.circle.wallet.inner.model.enums.UserBankWaterEvent;
|
import com.red.circle.wallet.inner.model.enums.UserBankWaterEvent;
|
||||||
@ -52,7 +54,7 @@ public class BdLeaderSalarySettlementServiceImpl implements BdLeaderSalarySettle
|
|||||||
private final BdLeaderSalaryPolicyService bdLeaderSalaryPolicyService;
|
private final BdLeaderSalaryPolicyService bdLeaderSalaryPolicyService;
|
||||||
private final BdLeaderSalarySettlementRecordService bdLeaderSalarySettlementRecordService;
|
private final BdLeaderSalarySettlementRecordService bdLeaderSalarySettlementRecordService;
|
||||||
private final UserBankBalanceClient userBankBalanceClient;
|
private final UserBankBalanceClient userBankBalanceClient;
|
||||||
private final UserBankRunningWaterClient userBankRunningWaterClient;
|
private final UserSalaryAccountClient userSalaryAccountClient;
|
||||||
private final UserProfileGateway userProfileGateway;
|
private final UserProfileGateway userProfileGateway;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -261,35 +263,16 @@ public class BdLeaderSalarySettlementServiceImpl implements BdLeaderSalarySettle
|
|||||||
* 发放工资到美元账户.
|
* 发放工资到美元账户.
|
||||||
*/
|
*/
|
||||||
private void issueSalary(Long bdLeaderUserId, BdLeaderSalarySettlementRecord record) {
|
private void issueSalary(Long bdLeaderUserId, BdLeaderSalarySettlementRecord record) {
|
||||||
// 1. 增加美元余额
|
SalaryIssueInnerCmd innerCmd = new SalaryIssueInnerCmd();
|
||||||
userBankBalanceClient.incr(new UserBankBalanceIncrCmd()
|
innerCmd.setBillBelong(record.getBillBelong());
|
||||||
.setUserId(bdLeaderUserId)
|
innerCmd.setUserId(bdLeaderUserId);
|
||||||
.setSysOrigin(record.getSysOrigin())
|
innerCmd.setSysOrigin(record.getSysOrigin());
|
||||||
.setAmount(com.red.circle.tool.core.tuple.PennyAmount.ofDollar(record.getSettlementSalary()))
|
innerCmd.setSalaryType("BD_LEADER_SALARY");
|
||||||
);
|
innerCmd.setEventDesc("SALARY_BD_LEADER");
|
||||||
|
innerCmd.setAmount(record.getSettlementSalary());
|
||||||
// 2. 插入流水记录
|
innerCmd.setTrackId(record.getId());
|
||||||
String remark = String.format("结算周期:%s,等级:%d,基础工资:%s USD",
|
innerCmd.setBdId(bdLeaderUserId);
|
||||||
record.getBillTitle(), record.getHitLevel(), record.getBasicSalary());
|
userSalaryAccountClient.issueSalary(innerCmd);
|
||||||
if (record.getRewardEligible()) {
|
|
||||||
remark += String.format(",奖励:%s USD", record.getRewardAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
userBankRunningWaterClient.add(new UserBankRunningWaterDTO()
|
|
||||||
.setId(IdWorkerUtils.getId())
|
|
||||||
.setUserId(bdLeaderUserId)
|
|
||||||
.setSysOrigin(record.getSysOrigin())
|
|
||||||
.setType(ReceiptType.INCOME.getType())
|
|
||||||
.setAmount(record.getSettlementSalary())
|
|
||||||
.setEvent(UserBankWaterEvent.BD_LEADER_SALARY_SETTLEMENT.name())
|
|
||||||
.setEventDescribe("BD Leader工资结算")
|
|
||||||
.setTrackId(record.getId())
|
|
||||||
.setRemark(remark)
|
|
||||||
.setBalance(userBankBalanceClient.getBalance(bdLeaderUserId).getBody().getAccurateBalance())
|
|
||||||
.setCreateTime(TimestampUtils.now())
|
|
||||||
.setCreateUser(0L)
|
|
||||||
.setCreateUserOrigin(0)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -28,6 +28,8 @@ import com.red.circle.order.inner.endpoint.api.InAppPurchaseDetailsClientApi;
|
|||||||
import com.red.circle.order.inner.model.dto.inapp.BatchUserRechargeStatisticsDTO;
|
import com.red.circle.order.inner.model.dto.inapp.BatchUserRechargeStatisticsDTO;
|
||||||
import com.red.circle.wallet.inner.endpoint.bank.UserBankBalanceClient;
|
import com.red.circle.wallet.inner.endpoint.bank.UserBankBalanceClient;
|
||||||
import com.red.circle.wallet.inner.endpoint.bank.UserBankRunningWaterClient;
|
import com.red.circle.wallet.inner.endpoint.bank.UserBankRunningWaterClient;
|
||||||
|
import com.red.circle.wallet.inner.endpoint.salary.UserSalaryAccountClient;
|
||||||
|
import com.red.circle.wallet.inner.model.cmd.SalaryIssueInnerCmd;
|
||||||
import com.red.circle.wallet.inner.model.cmd.UserBankBalanceIncrCmd;
|
import com.red.circle.wallet.inner.model.cmd.UserBankBalanceIncrCmd;
|
||||||
import com.red.circle.wallet.inner.model.dto.UserBankRunningWaterDTO;
|
import com.red.circle.wallet.inner.model.dto.UserBankRunningWaterDTO;
|
||||||
import com.red.circle.wallet.inner.model.enums.UserBankWaterEvent;
|
import com.red.circle.wallet.inner.model.enums.UserBankWaterEvent;
|
||||||
@ -57,10 +59,9 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
|||||||
private final TeamMemberTargetService teamMemberTargetService;
|
private final TeamMemberTargetService teamMemberTargetService;
|
||||||
private final BdSalaryPolicyService bdSalaryPolicyService;
|
private final BdSalaryPolicyService bdSalaryPolicyService;
|
||||||
private final BdSalarySettlementRecordService bdSalarySettlementRecordService;
|
private final BdSalarySettlementRecordService bdSalarySettlementRecordService;
|
||||||
private final UserBankBalanceClient userBankBalanceClient;
|
|
||||||
private final UserBankRunningWaterClient userBankRunningWaterClient;
|
|
||||||
private final InAppPurchaseDetailsClientApi inAppPurchaseDetailsClientApi;
|
private final InAppPurchaseDetailsClientApi inAppPurchaseDetailsClientApi;
|
||||||
private final UserProfileGateway userProfileGateway;
|
private final UserProfileGateway userProfileGateway;
|
||||||
|
private final UserSalaryAccountClient userSalaryAccountClient;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -437,30 +438,16 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
|||||||
* 发放工资到美元账户.
|
* 发放工资到美元账户.
|
||||||
*/
|
*/
|
||||||
private void issueSalary(Long bdUserId, BdSalarySettlementRecord record) {
|
private void issueSalary(Long bdUserId, BdSalarySettlementRecord record) {
|
||||||
// 1. 增加美元余额
|
SalaryIssueInnerCmd innerCmd = new SalaryIssueInnerCmd();
|
||||||
userBankBalanceClient.incr(new UserBankBalanceIncrCmd()
|
innerCmd.setBillBelong(record.getBillBelong());
|
||||||
.setUserId(bdUserId)
|
innerCmd.setUserId(bdUserId);
|
||||||
.setSysOrigin(record.getSysOrigin())
|
innerCmd.setSysOrigin(record.getSysOrigin());
|
||||||
.setAmount(com.red.circle.tool.core.tuple.PennyAmount.ofDollar(record.getSettlementSalary()))
|
innerCmd.setSalaryType("BD_SALARY");
|
||||||
);
|
innerCmd.setEventDesc("SALARY_BD");
|
||||||
|
innerCmd.setAmount(record.getSettlementSalary());
|
||||||
// 2. 插入流水记录
|
innerCmd.setTrackId(record.getId());
|
||||||
userBankRunningWaterClient.add(new UserBankRunningWaterDTO()
|
innerCmd.setBdId(bdUserId);
|
||||||
.setId(IdWorkerUtils.getId())
|
userSalaryAccountClient.issueSalary(innerCmd);
|
||||||
.setUserId(bdUserId)
|
|
||||||
.setSysOrigin(record.getSysOrigin())
|
|
||||||
.setType(ReceiptType.INCOME.getType())
|
|
||||||
.setAmount(record.getSettlementSalary())
|
|
||||||
.setEvent(UserBankWaterEvent.BD_SALARY_SETTLEMENT.name())
|
|
||||||
.setEventDescribe("BD工资结算")
|
|
||||||
.setTrackId(record.getId())
|
|
||||||
.setRemark(String.format("结算周期:%s,等级:%d,提成比例:%s%%",
|
|
||||||
record.getBillTitle(), record.getHitLevel(), record.getCommissionRate()))
|
|
||||||
.setBalance(userBankBalanceClient.getBalance(bdUserId).getBody().getAccurateBalance())
|
|
||||||
.setCreateTime(TimestampUtils.now())
|
|
||||||
.setCreateUser(0L)
|
|
||||||
.setCreateUserOrigin(0)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2,10 +2,15 @@ import com.red.circle.OtherServiceApplication;
|
|||||||
import com.red.circle.other.app.scheduler.BdLeaderSalarySettlementTask;
|
import com.red.circle.other.app.scheduler.BdLeaderSalarySettlementTask;
|
||||||
import com.red.circle.other.app.scheduler.BdSalarySettlementTask;
|
import com.red.circle.other.app.scheduler.BdSalarySettlementTask;
|
||||||
import com.red.circle.other.app.scheduler.TeamBillTask;
|
import com.red.circle.other.app.scheduler.TeamBillTask;
|
||||||
|
import com.red.circle.other.infra.database.mongo.entity.bd.BdLeaderSalarySettlementRecord;
|
||||||
import com.red.circle.other.infra.database.mongo.entity.bd.BdSalaryPolicy;
|
import com.red.circle.other.infra.database.mongo.entity.bd.BdSalaryPolicy;
|
||||||
|
import com.red.circle.other.infra.database.mongo.entity.bd.BdSalarySettlementRecord;
|
||||||
import com.red.circle.other.infra.database.mongo.service.bd.BdSalaryPolicyService;
|
import com.red.circle.other.infra.database.mongo.service.bd.BdSalaryPolicyService;
|
||||||
import com.red.circle.other.infra.database.mongo.service.team.TeamBillCycleUtils;
|
import com.red.circle.other.infra.database.mongo.service.team.TeamBillCycleUtils;
|
||||||
import com.red.circle.other.infra.enums.BdPolicyType;
|
import com.red.circle.other.infra.enums.BdPolicyType;
|
||||||
|
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||||
|
import com.red.circle.wallet.inner.endpoint.salary.UserSalaryAccountClient;
|
||||||
|
import com.red.circle.wallet.inner.model.cmd.SalaryIssueInnerCmd;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -16,6 +21,7 @@ import org.springframework.data.mongodb.core.query.Criteria;
|
|||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SpringBootTest(classes = OtherServiceApplication.class)
|
@SpringBootTest(classes = OtherServiceApplication.class)
|
||||||
@ -30,6 +36,8 @@ public class BdSettlementTest {
|
|||||||
private BdSalaryPolicyService bdSalaryPolicyService;
|
private BdSalaryPolicyService bdSalaryPolicyService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MongoTemplate mongoTemplate;
|
private MongoTemplate mongoTemplate;
|
||||||
|
@Autowired
|
||||||
|
private UserSalaryAccountClient userSalaryAccountClient;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,5 +62,57 @@ public class BdSettlementTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIssueSalary() {
|
||||||
|
// Long bdUserId = 1963790037740466178L;
|
||||||
|
// BdSalarySettlementRecord bdSalarySettlementRecord = new BdSalarySettlementRecord();
|
||||||
|
// bdSalarySettlementRecord.setBillBelong(20251116);
|
||||||
|
// bdSalarySettlementRecord.setSysOrigin("LIKEI");
|
||||||
|
// bdSalarySettlementRecord.setSettlementSalary(new BigDecimal(111));
|
||||||
|
// bdSalarySettlementRecord.setId(IdWorkerUtils.getIdStr());
|
||||||
|
// issueSalary(bdUserId, bdSalarySettlementRecord);
|
||||||
|
|
||||||
|
|
||||||
|
Long bdLeaderUserId = 1963790037740466178L;
|
||||||
|
BdLeaderSalarySettlementRecord bdLeaderSalarySettlementRecord = new BdLeaderSalarySettlementRecord();
|
||||||
|
bdLeaderSalarySettlementRecord.setBillBelong(20251116);
|
||||||
|
bdLeaderSalarySettlementRecord.setSysOrigin("LIKEI");
|
||||||
|
bdLeaderSalarySettlementRecord.setSettlementSalary(new BigDecimal(2));
|
||||||
|
bdLeaderSalarySettlementRecord.setId(IdWorkerUtils.getIdStr());
|
||||||
|
issueSalary(bdLeaderUserId, bdLeaderSalarySettlementRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发放BD工资
|
||||||
|
*/
|
||||||
|
private void issueSalary(Long bdUserId, BdSalarySettlementRecord record) {
|
||||||
|
SalaryIssueInnerCmd innerCmd = new SalaryIssueInnerCmd();
|
||||||
|
innerCmd.setBillBelong(record.getBillBelong());
|
||||||
|
innerCmd.setUserId(bdUserId);
|
||||||
|
innerCmd.setSysOrigin(record.getSysOrigin());
|
||||||
|
innerCmd.setSalaryType("BD_SALARY");
|
||||||
|
innerCmd.setEventDesc("SALARY_BD");
|
||||||
|
innerCmd.setAmount(record.getSettlementSalary());
|
||||||
|
innerCmd.setTrackId(record.getId());
|
||||||
|
innerCmd.setBdId(bdUserId);
|
||||||
|
userSalaryAccountClient.issueSalary(innerCmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发放BDLEADER工资
|
||||||
|
*/
|
||||||
|
private void issueSalary(Long bdLeaderUserId, BdLeaderSalarySettlementRecord record) {
|
||||||
|
SalaryIssueInnerCmd innerCmd = new SalaryIssueInnerCmd();
|
||||||
|
innerCmd.setBillBelong(record.getBillBelong());
|
||||||
|
innerCmd.setUserId(bdLeaderUserId);
|
||||||
|
innerCmd.setSysOrigin(record.getSysOrigin());
|
||||||
|
innerCmd.setSalaryType("BD_LEADER_SALARY");
|
||||||
|
innerCmd.setEventDesc("SALARY_BD_LEADER");
|
||||||
|
innerCmd.setAmount(record.getSettlementSalary());
|
||||||
|
innerCmd.setTrackId(record.getId());
|
||||||
|
innerCmd.setBdId(bdLeaderUserId);
|
||||||
|
userSalaryAccountClient.issueSalary(innerCmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@ public class SalaryAccountInnerConvertor {
|
|||||||
cmd.setTeamId(innerCmd.getTeamId());
|
cmd.setTeamId(innerCmd.getTeamId());
|
||||||
cmd.setBdId(innerCmd.getBdId());
|
cmd.setBdId(innerCmd.getBdId());
|
||||||
cmd.setAgentId(innerCmd.getAgentId());
|
cmd.setAgentId(innerCmd.getAgentId());
|
||||||
|
cmd.setSalaryEvent(innerCmd.getEventDesc());
|
||||||
cmd.setEventDesc(innerCmd.getEventDesc());
|
cmd.setEventDesc(innerCmd.getEventDesc());
|
||||||
cmd.setRemark(innerCmd.getRemark());
|
cmd.setRemark(innerCmd.getRemark());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user