|
@@ -29,6 +29,7 @@ import com.citu.module.menduner.system.service.job.JobCvRelService;
|
|
|
import com.citu.module.pay.api.wallet.PayWalletApi;
|
|
|
import com.citu.module.pay.api.wallet.dto.PayWalletAddBalanceDTO;
|
|
|
import com.citu.module.pay.enums.wallet.PayWalletBizTypeEnum;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
@@ -49,6 +50,7 @@ import static com.citu.module.menduner.system.util.RecruitAnalysisUtils.generate
|
|
|
*
|
|
|
* @author Rayson
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@Validated
|
|
|
public class InterviewInviteServiceImpl implements InterviewInviteService {
|
|
@@ -70,6 +72,10 @@ public class InterviewInviteServiceImpl implements InterviewInviteService {
|
|
|
|
|
|
@Resource
|
|
|
private JobAdvertisedService jobAdvertisedService;
|
|
|
+ /**
|
|
|
+ * 比例倍数 1:10 (点数转钱包的比例)
|
|
|
+ **/
|
|
|
+ private static final Integer RATIO_MULTIPLE = 10;
|
|
|
|
|
|
/**
|
|
|
* 计算佣金
|
|
@@ -84,8 +90,12 @@ public class InterviewInviteServiceImpl implements InterviewInviteService {
|
|
|
BigDecimal hirePriceBD = BigDecimal.valueOf(hirePrice);
|
|
|
|
|
|
// 计算佣金
|
|
|
- // 使用 (hirePrice * rate + totalRate / 2) / totalRate 来确保四舍五入
|
|
|
- BigDecimal commission = hirePriceBD.multiply(rate).add(totalRate.divide(BigDecimal.valueOf(2), 0, RoundingMode.HALF_UP)).divide(totalRate, 0, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal commission = hirePriceBD.multiply(rate).divide(totalRate, 0, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ // 确保佣金不会超过hirePrice
|
|
|
+ if (commission.compareTo(hirePriceBD) > 0) {
|
|
|
+ commission = hirePriceBD;
|
|
|
+ }
|
|
|
|
|
|
// 将结果转换为Long类型
|
|
|
return commission.longValue();
|
|
@@ -363,12 +373,26 @@ public class InterviewInviteServiceImpl implements InterviewInviteService {
|
|
|
Long hirePrice = job.getHirePrice();
|
|
|
// 总比例
|
|
|
BigDecimal totalRate = BigDecimal.valueOf(100);
|
|
|
- // 猎头佣金
|
|
|
- Long headhuntPrice = calculateCommission(hirePrice, ratio.getHeadhuntRate(), totalRate);
|
|
|
- // 推荐人佣金
|
|
|
- Long recommendPrice = calculateCommission(hirePrice, ratio.getRecommendRate(), totalRate);
|
|
|
- // 投递人佣金
|
|
|
- Long cvPrice = calculateCommission(hirePrice, ratio.getCvRate(), totalRate);
|
|
|
+ // 猎头佣金 计算并转换为钱包货币
|
|
|
+ long headhuntPrice = calculateCommission(hirePrice, ratio.getHeadhuntRate(), totalRate)*RATIO_MULTIPLE;
|
|
|
+ // 推荐人佣金 计算并转换为钱包货币
|
|
|
+ long recommendPrice = calculateCommission(hirePrice, ratio.getRecommendRate(), totalRate)*RATIO_MULTIPLE;
|
|
|
+ // 投递人佣金 计算并转换为钱包货币
|
|
|
+ long cvPrice = calculateCommission(hirePrice, ratio.getCvRate(), totalRate)*RATIO_MULTIPLE;
|
|
|
+
|
|
|
+ // 复制出现三者相加>hirePrice的情况
|
|
|
+ log.info("职位ID:{},佣金分配情况,总金额:{},猎头佣金:{},推荐人佣金:{},投递人佣金:{}",
|
|
|
+ job.getId(),
|
|
|
+ hirePrice/100,
|
|
|
+ headhuntPrice/100,
|
|
|
+ recommendPrice/100,
|
|
|
+ cvPrice/100
|
|
|
+ );
|
|
|
+ if((headhuntPrice+recommendPrice+cvPrice)>hirePrice) {
|
|
|
+ log.error("佣金比例计算错误,职位ID:{}", job.getId());
|
|
|
+ throw exception(INTERVIEW_INVITE_STATUS_NOT_SETTLEMENT);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 猎头 (平台自己)
|
|
|
if (headhuntPrice > 0) {
|