来款
This commit is contained in:
+9
-9
@@ -9,7 +9,7 @@
|
||||
from pay_common_project c
|
||||
where
|
||||
(c.receivable_amount <![CDATA[>]]> c.paid_amount
|
||||
or c.paid_amount is null)
|
||||
or (c.receivable_amount is not null and c.paid_amount is null))
|
||||
<if test="payCommonProject.principalId != null and payCommonProject.principalId != ''">
|
||||
AND c.principal_id = #{payCommonProject.principalId}
|
||||
</if>
|
||||
@@ -23,10 +23,10 @@
|
||||
UNION ALL
|
||||
select gsub.id,g.working_group_project, gsub.charge_use, g.principal_id_a,g.principal_name_a,gsub.charge_company_temporary_name,gsub.receivable_amount,gsub.paid_amount,gsub.need_invoice,gsub.pack,gsub.in_account,gsub.make_invoice,gsub.mail,gsub.create_time,2
|
||||
from pay_working_group g
|
||||
left join pay_working_group_subitem gsub on g.id = gsub.charge_company_id
|
||||
inner join pay_working_group_subitem gsub on g.id = gsub.charge_company_id
|
||||
where
|
||||
(gsub.receivable_amount <![CDATA[>]]> gsub.paid_amount
|
||||
or gsub.paid_amount is null)
|
||||
or (gsub.receivable_amount is not null and gsub.paid_amount is null))
|
||||
<if test="payCommonProject.principalId != null and payCommonProject.principalId != ''">
|
||||
AND g.principal_id_a = #{payCommonProject.principalId}
|
||||
</if>
|
||||
@@ -40,10 +40,10 @@
|
||||
UNION ALL
|
||||
select sit.id,meeting.meeting_name,sit.charge_use, meeting.director_id, meeting.director_name,sit.company_name,sit.amount_receivable,sit.paid_amount,sit.need_invoice,sit.pack,sit.in_account,sit.make_invoice,sit.mail,sit.create_time,3
|
||||
from pay_meeting meeting
|
||||
left join pay_meeting_situation sit on meeting.id = sit.meeting_id
|
||||
inner join pay_meeting_situation sit on meeting.id = sit.meeting_id
|
||||
where
|
||||
(sit.amount_receivable <![CDATA[>]]> sit.paid_amount
|
||||
or sit.paid_amount is null)
|
||||
or (sit.amount_receivable is not null and sit.paid_amount is null))
|
||||
<if test="payCommonProject.principalId != null and payCommonProject.principalId != ''">
|
||||
AND meeting.director_id = #{payCommonProject.principalId}
|
||||
</if>
|
||||
@@ -57,10 +57,10 @@
|
||||
UNION ALL
|
||||
select msub.id,member.project_name,msub.charge_use,member.director_id,member.director_name,msub.company_name,msub.amount_receivable,msub.paid_amount,msub.need_invoice,msub.pack,msub.in_account,msub.make_invoice,msub.mail,msub.create_time,4
|
||||
from pay_member_project member
|
||||
left join pay_member_project_subitem msub on member.id=msub.project_id
|
||||
inner join pay_member_project_subitem msub on member.id=msub.project_id
|
||||
where
|
||||
(msub.amount_receivable <![CDATA[>]]> msub.paid_amount
|
||||
or msub.paid_amount is null)
|
||||
or (msub.amount_receivable is not null and msub.paid_amount is null))
|
||||
<if test="payCommonProject.principalId != null and payCommonProject.principalId != ''">
|
||||
AND member.director_id = #{payCommonProject.principalId}
|
||||
</if>
|
||||
@@ -74,10 +74,10 @@
|
||||
UNION ALL
|
||||
select tmsub.id,tmember.project_name,tmsub.charge_use,'','',tmsub.company_name,tmsub.amount_receivable,tmsub.paid_amount,tmsub.invoice_requirements,tmsub.pack,tmsub.in_account,tmsub.make_invoice,tmsub.mail,tmsub.create_time,5
|
||||
from tb_member_project tmember
|
||||
left join tb_member_project_subitem tmsub on tmember.id=tmsub.project_id
|
||||
inner join tb_member_project_subitem tmsub on tmember.id=tmsub.project_id
|
||||
where
|
||||
(tmsub.amount_receivable <![CDATA[>]]> tmsub.paid_amount
|
||||
or tmsub.paid_amount is null)
|
||||
or (tmsub.amount_receivable is not null and tmsub.paid_amount))
|
||||
<if test="payCommonProject.chargeProject != null and payCommonProject.chargeProject != ''">
|
||||
AND tmember.project_name = #{payCommonProject.chargeProject}
|
||||
</if>
|
||||
|
||||
+97
-12
@@ -8,6 +8,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.contract.common.PayIncomeContractCommon;
|
||||
import com.jero.meeting.entity.PayMeetingSituation;
|
||||
import com.jero.meeting.mapper.PayMeetingSituationMapper;
|
||||
import com.jero.member.entity.PayMemberProjectSubitem;
|
||||
import com.jero.member.entity.TbMemberProjectSubitem;
|
||||
import com.jero.member.mapper.PayMemberProjectSubitemMapper;
|
||||
import com.jero.member.mapper.TbMemberProjectSubitemMapper;
|
||||
import com.jero.payment.entity.PayPaymentRecord;
|
||||
import com.jero.payment.mapper.PayPaymentRecordMapper;
|
||||
import com.jero.payment.service.IPayPaymentRecordService;
|
||||
@@ -15,6 +21,7 @@ import com.jero.project.entity.PayCommonProject;
|
||||
import com.jero.project.entity.PayWorkingGroup;
|
||||
import com.jero.project.entity.PayWorkingGroupSubItem;
|
||||
import com.jero.project.mapper.PayCommonProjectMapper;
|
||||
import com.jero.project.mapper.PayWorkingGroupSubItemMapper;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -39,6 +46,14 @@ public class PayPaymentRecordServiceImpl extends ServiceImpl<PayPaymentRecordMap
|
||||
private PayPaymentRecordMapper payPaymentRecordMapper;
|
||||
@Resource
|
||||
private PayCommonProjectMapper payCommonProjectMapper;
|
||||
@Resource
|
||||
private PayWorkingGroupSubItemMapper payWorkingGroupSubItemMapper;
|
||||
@Resource
|
||||
private PayMeetingSituationMapper payMeetingSituationMapper;
|
||||
@Resource
|
||||
private PayMemberProjectSubitemMapper payMemberProjectSubitemMapper;
|
||||
@Resource
|
||||
private TbMemberProjectSubitemMapper tbMemberProjectSubitemMapper;
|
||||
|
||||
/**
|
||||
* 到账开票主列表
|
||||
@@ -58,7 +73,10 @@ public class PayPaymentRecordServiceImpl extends ServiceImpl<PayPaymentRecordMap
|
||||
*/
|
||||
public Result<?> addPhase(PayPaymentRecord payPaymentRecord){
|
||||
payPaymentRecordMapper.insert(payPaymentRecord);
|
||||
|
||||
|
||||
BigDecimal receivableAmount;
|
||||
Boolean isAdd;
|
||||
BigDecimal newPaidAmount;
|
||||
//累加主列表实收金额
|
||||
switch (String.valueOf(payPaymentRecord.getProjectType())){
|
||||
|
||||
@@ -66,19 +84,13 @@ public class PayPaymentRecordServiceImpl extends ServiceImpl<PayPaymentRecordMap
|
||||
case PayIncomeContractCommon.PROJECT_TYPE1:
|
||||
PayCommonProject payCommonProject = payCommonProjectMapper.selectById(payPaymentRecord.getProjectId());
|
||||
|
||||
BigDecimal receivableAmount = payCommonProject.getReceivableAmount();//应收
|
||||
receivableAmount = payCommonProject.getReceivableAmount();//应收
|
||||
|
||||
//是否还能再添加来款
|
||||
Boolean isAdd = isAdd(receivableAmount, payPaymentRecord.getAmountReceived());
|
||||
isAdd = isAdd(receivableAmount, payPaymentRecord.getAmountReceived());
|
||||
if(isAdd){
|
||||
BigDecimal paidAmount = payCommonProject.getPaidAmount();//实收
|
||||
|
||||
if(paidAmount == null){
|
||||
paidAmount = new BigDecimal("0");
|
||||
}
|
||||
//累加,四舍五入
|
||||
BigDecimal newPaidAmount = paidAmount.add(payPaymentRecord.getAmountReceived()).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
//累加实收
|
||||
newPaidAmount =addPaidAmount(payCommonProject.getPaidAmount(),payPaymentRecord.getAmountReceived());
|
||||
//更新主列表
|
||||
payCommonProject.setPaidAmount(newPaidAmount);
|
||||
payCommonProjectMapper.updateById(payCommonProject);
|
||||
@@ -86,18 +98,77 @@ public class PayPaymentRecordServiceImpl extends ServiceImpl<PayPaymentRecordMap
|
||||
return Result.error("到账金额大于当前欠款金额,不可提交!");
|
||||
}
|
||||
break;
|
||||
|
||||
// 工作组项目
|
||||
case PayIncomeContractCommon.PROJECT_TYPE2:
|
||||
PayWorkingGroupSubItem payWorking = payWorkingGroupSubItemMapper.selectById(payPaymentRecord.getProjectId());
|
||||
|
||||
receivableAmount = payWorking.getReceivableAmount();//应收
|
||||
|
||||
//是否还能再添加来款
|
||||
isAdd = isAdd(receivableAmount, payPaymentRecord.getAmountReceived());
|
||||
if(isAdd){
|
||||
//累加实收
|
||||
newPaidAmount =addPaidAmount(payWorking.getPaidAmount(),payPaymentRecord.getAmountReceived());
|
||||
//更新主列表
|
||||
payWorking.setPaidAmount(newPaidAmount);
|
||||
payWorkingGroupSubItemMapper.updateById(payWorking);
|
||||
}else{
|
||||
return Result.error("到账金额大于当前欠款金额,不可提交!");
|
||||
}
|
||||
break;
|
||||
//会议项目
|
||||
case PayIncomeContractCommon.PROJECT_TYPE3:
|
||||
PayMeetingSituation meeting = payMeetingSituationMapper.selectById(payPaymentRecord.getProjectId());
|
||||
|
||||
receivableAmount = meeting.getAmountReceivable();//应收
|
||||
|
||||
//是否还能再添加来款
|
||||
isAdd = isAdd(receivableAmount, payPaymentRecord.getAmountReceived());
|
||||
if(isAdd){
|
||||
//累加实收
|
||||
newPaidAmount =addPaidAmount(meeting.getPaidAmount(),payPaymentRecord.getAmountReceived());
|
||||
//更新主列表
|
||||
meeting.setPaidAmount(newPaidAmount);
|
||||
payMeetingSituationMapper.updateById(meeting);
|
||||
}else{
|
||||
return Result.error("到账金额大于当前欠款金额,不可提交!");
|
||||
}
|
||||
break;
|
||||
//会员项目
|
||||
case PayIncomeContractCommon.PROJECT_TYPE4:
|
||||
PayMemberProjectSubitem member = payMemberProjectSubitemMapper.selectById(payPaymentRecord.getProjectId());
|
||||
|
||||
receivableAmount = member.getAmountReceivable();//应收
|
||||
|
||||
//是否还能再添加来款
|
||||
isAdd = isAdd(receivableAmount, payPaymentRecord.getAmountReceived());
|
||||
if(isAdd){
|
||||
//累加实收
|
||||
newPaidAmount =addPaidAmount(member.getPaidAmount(),payPaymentRecord.getAmountReceived());
|
||||
//更新主列表
|
||||
member.setPaidAmount(newPaidAmount);
|
||||
payMemberProjectSubitemMapper.updateById(member);
|
||||
}else{
|
||||
return Result.error("到账金额大于当前欠款金额,不可提交!");
|
||||
}
|
||||
break;
|
||||
//标协会员
|
||||
case PayIncomeContractCommon.PROJECT_TYPE5:
|
||||
TbMemberProjectSubitem tbMember = tbMemberProjectSubitemMapper.selectById(payPaymentRecord.getProjectId());
|
||||
|
||||
receivableAmount = tbMember.getAmountReceivable();//应收
|
||||
|
||||
//是否还能再添加来款
|
||||
isAdd = isAdd(receivableAmount, payPaymentRecord.getAmountReceived());
|
||||
if(isAdd){
|
||||
//累加实收
|
||||
newPaidAmount =addPaidAmount(tbMember.getPaidAmount(),payPaymentRecord.getAmountReceived());
|
||||
//更新主列表
|
||||
tbMember.setPaidAmount(newPaidAmount);
|
||||
tbMemberProjectSubitemMapper.updateById(tbMember);
|
||||
}else{
|
||||
return Result.error("到账金额大于当前欠款金额,不可提交!");
|
||||
}
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
@@ -124,4 +195,18 @@ public class PayPaymentRecordServiceImpl extends ServiceImpl<PayPaymentRecordMap
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 累加实收并四舍五入
|
||||
* @param paidAmount 实收
|
||||
* @param amountReceived 到账
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal addPaidAmount(BigDecimal paidAmount,BigDecimal amountReceived){
|
||||
|
||||
if(paidAmount == null){
|
||||
paidAmount = new BigDecimal("0");
|
||||
}
|
||||
return paidAmount.add(amountReceived).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user