|
@@ -42,8 +42,8 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
|
|
|
@Override
|
|
|
public Page<CommissionVo> getPage(CommissionSelectDto dto) {
|
|
|
QueryWrapper<Object> query = Wrappers.query();
|
|
|
- query.eq(ObjectUtil.isNotEmpty(dto.getUserId()),"c.user_id",dto.getUserId());
|
|
|
- query.eq(ObjectUtil.isNotEmpty(dto.getTime()),"DATE_FORMAT(c.create_time,'%Y-%m')",dto.getTime());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getUserId()), "c.user_id", dto.getUserId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getTime()), "DATE_FORMAT(c.create_time,'%Y')", dto.getTime());
|
|
|
query.orderByDesc("c.create_time");
|
|
|
Page<CommissionVo> page = this.baseMapper.getPage(dto.getPage(), query);
|
|
|
return page;
|
|
@@ -55,7 +55,7 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
|
|
|
*/
|
|
|
@Override
|
|
|
public void settlement(CommissionDto commissionDto) {
|
|
|
- if (ObjectUtil.isEmpty(commissionDto.getCommissionRule()) || ObjectUtil.isEmpty(commissionDto.getSettlementStatus())){
|
|
|
+ if (ObjectUtil.isEmpty(commissionDto.getSettlementStatus())){
|
|
|
throw new ServiceException("参数缺失:结算状态或业绩提成规则表不能为null");
|
|
|
}
|
|
|
|
|
@@ -73,9 +73,13 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
|
|
|
//如果为未结算则删除业绩提成表与业绩提成规则表的信息
|
|
|
if (commissionDto.getSettlementStatus() == 0){
|
|
|
//如果是取消结算,业绩表肯定有值
|
|
|
- baseMapper.deleteById(commission.getId());
|
|
|
+ Commission cm = baseMapper.selectOne(Wrappers.<Commission>query().lambda().eq(Commission::getContractId,commission.getContractId()));
|
|
|
+ if(ObjectUtil.isEmpty(cm)){
|
|
|
+ throw new ServiceException("数据异常,当前没有业绩提成数据,不能取消结算");
|
|
|
+ }
|
|
|
+ baseMapper.deleteById(cm.getId());
|
|
|
commissionRuleService.remove(Wrappers.<CommissionRule>lambdaQuery()
|
|
|
- .eq(CommissionRule::getCommissionId,commission.getId())
|
|
|
+ .eq(CommissionRule::getCommissionId,cm.getId())
|
|
|
);
|
|
|
}else if (commissionDto.getSettlementStatus() == 1){
|
|
|
saveOrUpdate(commissionDto);
|
|
@@ -90,7 +94,7 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
|
|
|
private void saveOrUpdate(CommissionDto commissionDto){
|
|
|
CommissionRule commissionRule = new CommissionRule();
|
|
|
if (ObjectUtil.isNotEmpty(commissionDto.getCommissionRule())){
|
|
|
- commissionRule = commissionDto.getCommissionRule();
|
|
|
+ commissionRule = commissionDto.getCommissionRule();
|
|
|
}else {
|
|
|
commissionRule.setAfterSalesRatio(new BigDecimal(4));
|
|
|
commissionRule.setDepartmentalRatio(new BigDecimal(33));
|
|
@@ -101,19 +105,19 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
|
|
|
|
|
|
|
|
|
//计算售后金额:到账金额 * 售后占比(保留两位小数向上取整)
|
|
|
- commissionDto.setAfterSalesAmount(commissionDto.getContractArrival()
|
|
|
+ commissionDto.setAfterSalesAmount(commissionDto.getTotalIncome()
|
|
|
.multiply(commissionRule.getAfterSalesRatio())
|
|
|
.divide(new BigDecimal(100))
|
|
|
.setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
//计算公共金额:到账金额 * 公共占比
|
|
|
- commissionDto.setPublicAmount(commissionDto.getContractArrival()
|
|
|
+ commissionDto.setPublicAmount(commissionDto.getTotalIncome()
|
|
|
.multiply(commissionRule.getPublicRatio())
|
|
|
.divide(new BigDecimal(100))
|
|
|
.setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
//计算总办金额:到账金额 * 总办占比
|
|
|
- commissionDto.setHaveOverallAmount(commissionDto.getContractArrival()
|
|
|
+ commissionDto.setHaveOverallAmount(commissionDto.getTotalIncome()
|
|
|
.multiply(commissionRule.getHaveOverallRatio())
|
|
|
.divide(new BigDecimal(100))
|
|
|
.setScale(2,BigDecimal.ROUND_HALF_UP));
|