|
@@ -21,7 +21,6 @@ import com.citu.module.menduner.system.dal.mysql.interview.InterviewInviteMapper
|
|
|
import com.citu.module.menduner.system.dal.mysql.job.JobAdvertisedMapper;
|
|
|
import com.citu.module.menduner.system.enums.MathOperationEnum;
|
|
|
import com.citu.module.menduner.system.enums.account.BalanceBizTypeEnum;
|
|
|
-import com.citu.module.menduner.system.enums.account.PointBizTypeEnum;
|
|
|
import com.citu.module.menduner.system.enums.cv.ConversationStatusEnum;
|
|
|
import com.citu.module.menduner.system.enums.interview.InterviewInviteStatusEnum;
|
|
|
import com.citu.module.menduner.system.service.enterprise.bind.EnterpriseUserBindService;
|
|
@@ -294,10 +293,6 @@ public class InterviewInviteServiceImpl implements InterviewInviteService {
|
|
|
priceSettlement(job, ratio, cv);
|
|
|
}
|
|
|
|
|
|
- if (null != job.getHirePoint()) {
|
|
|
- // 积分结算
|
|
|
- pointSettlement(job, ratio, cv);
|
|
|
- }
|
|
|
//TODO 发送推送消息
|
|
|
}
|
|
|
|
|
@@ -309,147 +304,84 @@ public class InterviewInviteServiceImpl implements InterviewInviteService {
|
|
|
* @param cv 投递信息
|
|
|
**/
|
|
|
public void priceSettlement(JobAdvertisedDO job, HireCommissionRatioDO ratio, JobCvRelDO cv) {
|
|
|
- BigDecimal hirePrice = job.getHirePrice();
|
|
|
+ Long hirePrice = job.getHirePrice();
|
|
|
// 总比例
|
|
|
BigDecimal totalRate = BigDecimal.valueOf(100);
|
|
|
// 猎头佣金
|
|
|
- BigDecimal headhuntPrice = hirePrice.multiply(ratio.getHeadhuntRate())
|
|
|
- .divide(totalRate, 2, RoundingMode.HALF_UP);
|
|
|
+ Long headhuntPrice = calculateCommission(hirePrice, ratio.getHeadhuntRate(), totalRate);
|
|
|
// 推荐人佣金
|
|
|
- BigDecimal recommendPrice = hirePrice.multiply(ratio.getRecommendRate())
|
|
|
- .divide(totalRate, 2, RoundingMode.HALF_UP);
|
|
|
+ Long recommendPrice = calculateCommission(hirePrice, ratio.getRecommendRate(), totalRate);
|
|
|
// 投递人佣金
|
|
|
- BigDecimal cvPrice = hirePrice.multiply(ratio.getCvRate())
|
|
|
- .divide(totalRate, 2, RoundingMode.HALF_UP);
|
|
|
+ Long cvPrice =calculateCommission(hirePrice, ratio.getCvRate(), totalRate);
|
|
|
|
|
|
// 猎头 (平台自己)
|
|
|
- if (headhuntPrice.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- userAccountRecordService.createBalanceRecord(
|
|
|
- 1L,
|
|
|
- BalanceBizTypeEnum.PLATFORM_COMMISSION.getName(),
|
|
|
- MathOperationEnum.ADD,
|
|
|
- headhuntPrice,
|
|
|
- BalanceBizTypeEnum.PLATFORM_COMMISSION,
|
|
|
- String.valueOf(job.getId())
|
|
|
- );
|
|
|
+ if (headhuntPrice > 0) {
|
|
|
+// userAccountRecordService.createBalanceRecord(
|
|
|
+// 1L,
|
|
|
+// BalanceBizTypeEnum.PLATFORM_COMMISSION.getName(),
|
|
|
+// MathOperationEnum.ADD,
|
|
|
+// headhuntPrice,
|
|
|
+// BalanceBizTypeEnum.PLATFORM_COMMISSION,
|
|
|
+// String.valueOf(job.getId())
|
|
|
+// );
|
|
|
}
|
|
|
|
|
|
// 如果推荐人ID为空,则将推荐人的佣金也给到猎头
|
|
|
if (null == cv.getRecommendUserId()) {
|
|
|
- userAccountRecordService.createBalanceRecord(
|
|
|
- 1L,
|
|
|
- BalanceBizTypeEnum.NOT_RECOMMENDED.getName(),
|
|
|
- MathOperationEnum.ADD,
|
|
|
- recommendPrice,
|
|
|
- BalanceBizTypeEnum.NOT_RECOMMENDED,
|
|
|
- String.valueOf(job.getId())
|
|
|
- );
|
|
|
+// userAccountRecordService.createBalanceRecord(
|
|
|
+// 1L,
|
|
|
+// BalanceBizTypeEnum.NOT_RECOMMENDED.getName(),
|
|
|
+// MathOperationEnum.ADD,
|
|
|
+// recommendPrice,
|
|
|
+// BalanceBizTypeEnum.NOT_RECOMMENDED,
|
|
|
+// String.valueOf(job.getId())
|
|
|
+// );
|
|
|
}
|
|
|
|
|
|
// 推荐人
|
|
|
- if (headhuntPrice.compareTo(BigDecimal.ZERO) > 0
|
|
|
+ if (headhuntPrice > 0
|
|
|
&& null != cv.getRecommendUserId()) {
|
|
|
- userAccountRecordService.createBalanceRecord(
|
|
|
- cv.getRecommendUserId(),
|
|
|
- BalanceBizTypeEnum.RECOMMENDED_POSITIONS.getName(),
|
|
|
- MathOperationEnum.ADD,
|
|
|
- recommendPrice,
|
|
|
- BalanceBizTypeEnum.RECOMMENDED_POSITIONS,
|
|
|
- String.valueOf(job.getId())
|
|
|
- );
|
|
|
+// userAccountRecordService.createBalanceRecord(
|
|
|
+// cv.getRecommendUserId(),
|
|
|
+// BalanceBizTypeEnum.RECOMMENDED_POSITIONS.getName(),
|
|
|
+// MathOperationEnum.ADD,
|
|
|
+// recommendPrice,
|
|
|
+// BalanceBizTypeEnum.RECOMMENDED_POSITIONS,
|
|
|
+// String.valueOf(job.getId())
|
|
|
+// );
|
|
|
}
|
|
|
|
|
|
// 投递人
|
|
|
- if (headhuntPrice.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- userAccountRecordService.createBalanceRecord(
|
|
|
- cv.getUserId(),
|
|
|
- BalanceBizTypeEnum.DELIVERY_PERSON.getName(),
|
|
|
- MathOperationEnum.ADD,
|
|
|
- cvPrice,
|
|
|
- BalanceBizTypeEnum.DELIVERY_PERSON,
|
|
|
- String.valueOf(job.getId())
|
|
|
- );
|
|
|
+ if (headhuntPrice > 0) {
|
|
|
+// userAccountRecordService.createBalanceRecord(
|
|
|
+// cv.getUserId(),
|
|
|
+// BalanceBizTypeEnum.DELIVERY_PERSON.getName(),
|
|
|
+// MathOperationEnum.ADD,
|
|
|
+// cvPrice,
|
|
|
+// BalanceBizTypeEnum.DELIVERY_PERSON,
|
|
|
+// String.valueOf(job.getId())
|
|
|
+// );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 积分结算
|
|
|
+ * 计算佣金
|
|
|
*
|
|
|
- * @param job 职位信息
|
|
|
- * @param ratio 佣金比例
|
|
|
- * @param cv 投递信息
|
|
|
+ * @param hirePrice 职位价格
|
|
|
+ * @param rate 比例
|
|
|
+ * @param totalRate 总比例
|
|
|
+ * @return 佣金
|
|
|
**/
|
|
|
- public void pointSettlement(JobAdvertisedDO job, HireCommissionRatioDO ratio, JobCvRelDO cv) {
|
|
|
- Integer hirePoint = job.getHirePoint();
|
|
|
- int totalRate = 100; // 总比例
|
|
|
-
|
|
|
- // 猎头佣金
|
|
|
- int headhuntPoint = (int) (hirePoint * ratio.getHeadhuntRate().intValue() / (long) totalRate);
|
|
|
+ public static Long calculateCommission(Long hirePrice, BigDecimal rate, BigDecimal totalRate) {
|
|
|
+ // 将hirePrice转换为BigDecimal
|
|
|
+ BigDecimal hirePriceBD = BigDecimal.valueOf(hirePrice);
|
|
|
|
|
|
- // 推荐人佣金
|
|
|
- int recommendPoint = (int) (hirePoint * ratio.getRecommendRate().intValue() / (long) totalRate);
|
|
|
-
|
|
|
- // 投递人佣金
|
|
|
- int cvPoint = (int) (hirePoint * ratio.getCvRate().intValue() / (long) totalRate);
|
|
|
+ // 计算佣金
|
|
|
+ // 使用 (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);
|
|
|
|
|
|
- // 由于比例之和可能不等于100%,剩余的点数可能需要进行分配或处理
|
|
|
- int remainingPoint = hirePoint - (headhuntPoint + recommendPoint + cvPoint);
|
|
|
-
|
|
|
- // 这里你可以选择将剩余点数分配给任意一方,或者按照比例再次分配
|
|
|
- // 将剩余点数全部分配给猎头
|
|
|
- headhuntPoint += remainingPoint;
|
|
|
-
|
|
|
- // 猎头 (平台自己)
|
|
|
- if (headhuntPoint > 0) {
|
|
|
- userAccountRecordService.createPointRecord(
|
|
|
- 1L,
|
|
|
- "",
|
|
|
- PointBizTypeEnum.PLATFORM_COMMISSION.getName(),
|
|
|
- MathOperationEnum.ADD,
|
|
|
- headhuntPoint,
|
|
|
- PointBizTypeEnum.PLATFORM_COMMISSION,
|
|
|
- String.valueOf(job.getId())
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- // 如果推荐人ID为空,则将推荐人的佣金也给到猎头
|
|
|
- if (null == cv.getRecommendUserId()) {
|
|
|
- userAccountRecordService.createPointRecord(
|
|
|
- 1L,
|
|
|
- "",
|
|
|
- PointBizTypeEnum.NOT_RECOMMENDED.getName(),
|
|
|
- MathOperationEnum.ADD,
|
|
|
- recommendPoint,
|
|
|
- PointBizTypeEnum.NOT_RECOMMENDED,
|
|
|
- String.valueOf(job.getId())
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- // 推荐人
|
|
|
- if (headhuntPoint > 0 && null!= cv.getRecommendUserId()) {
|
|
|
- userAccountRecordService.createPointRecord(
|
|
|
- cv.getRecommendUserId(),
|
|
|
- "",
|
|
|
- PointBizTypeEnum.RECOMMENDED_POSITIONS.getName(),
|
|
|
- MathOperationEnum.ADD,
|
|
|
- recommendPoint,
|
|
|
- PointBizTypeEnum.RECOMMENDED_POSITIONS,
|
|
|
- String.valueOf(job.getId())
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- // 投递人
|
|
|
- if (headhuntPoint > 0) {
|
|
|
- userAccountRecordService.createPointRecord(
|
|
|
- cv.getUserId(),
|
|
|
- "",
|
|
|
- PointBizTypeEnum.RECOMMENDED_POSITIONS.getName(),
|
|
|
- MathOperationEnum.ADD,
|
|
|
- cvPoint,
|
|
|
- PointBizTypeEnum.RECOMMENDED_POSITIONS,
|
|
|
- String.valueOf(job.getId())
|
|
|
- );
|
|
|
- }
|
|
|
+ // 将结果转换为Long类型
|
|
|
+ return commission.longValue();
|
|
|
}
|
|
|
|
|
|
}
|