|
|
@@ -169,8 +169,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
insPlyIncome.setCreateTime(LocalDate.now());
|
|
|
insPlyIncome.setDocumentaryFeesStatus("0");
|
|
|
insPlyIncome.setHandlingFeesStatus("0");
|
|
|
- insPlyIncome.setNoNoTaxPremium(insPlyIncome.getNoNoTaxPremium());
|
|
|
- insPlyIncome.setNoPremium(insPlyIncome.getNoPremium());
|
|
|
+ insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium());
|
|
|
+ insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium());
|
|
|
insPlyIncome.setIsNotCar("1");
|
|
|
insPlyIncome.setIsNotDocumentary("1");
|
|
|
insPlyIncome.setJqStartDate(insAreaCompany.getJqStartDate());
|
|
|
@@ -1416,11 +1416,32 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public HttpResult batchBalance(InsPlyIncomeVo insPlyIncomeVo) {
|
|
|
-// 通过ids 查出跟单非结算单
|
|
|
- BigDecimal allAmount = BigDecimal.ZERO;
|
|
|
// 分批结算
|
|
|
SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();
|
|
|
|
|
|
+
|
|
|
+ String id = insPlyIncomeVo.getId(); // 开票id
|
|
|
+ SettlementDocumentaryFeesEntity settlementDocumentaryFeesServiceById = settlementDocumentaryFeesService.getById(id); //
|
|
|
+ BigDecimal allAmount = settlementDocumentaryFeesServiceById.getTotalAmount();
|
|
|
+
|
|
|
+
|
|
|
+ HashMap<String, Object> params = new HashMap<>();
|
|
|
+ params.put("id",insPlyIncomeVo.getId());
|
|
|
+ params.put("handlingFeesStatus", "1");
|
|
|
+ SettlementDocumentaryFeesEntity parentSettlementDocumentaryFeesEntity = settlementDocumentaryFeesService.getByParentSettlementAmount(params);
|
|
|
+
|
|
|
+ if(ObjectUtils.isNotEmpty(parentSettlementDocumentaryFeesEntity)){ // 多次结算
|
|
|
+ BigDecimal totalAmount = parentSettlementDocumentaryFeesEntity.getTotalAmount();
|
|
|
+ totalAmount=totalAmount.add(insPlyIncomeVo.getSettlementAmount());
|
|
|
+ if(allAmount.compareTo(totalAmount) <0){
|
|
|
+ return HttpResult.error("结算金额超出开票金额");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(allAmount.compareTo(insPlyIncomeVo.getSettlementAmount()) <0){
|
|
|
+ return HttpResult.error("结算金额超出开票金额");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getInvoicId()); //开票号
|
|
|
settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime()); //结算时间
|
|
|
settlementDocumentaryFeesVo.setSettlementStatus("2"); //2为结算状态
|
|
|
@@ -1599,26 +1620,42 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public HttpResult<Object> batchBxBalance(InsPlyIncomeVo insPlyIncomeVo) {
|
|
|
+
|
|
|
// 表内总金额
|
|
|
- BigDecimal invoicCommissionFeevalue = insPlyIncomeVo.getInvoicCommissionFeevalue();
|
|
|
- BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount();
|
|
|
+ BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount(); //结算金额
|
|
|
|
|
|
+ SettlementDocumentaryFeesEntity byIdSettlementDocumentaryFeesEntity = settlementDocumentaryFeesService.getById(insPlyIncomeVo.getId());
|
|
|
+ BigDecimal invoicAmount = byIdSettlementDocumentaryFeesEntity.getTotalAmount();
|
|
|
|
|
|
HashMap<String, Object> params = new HashMap<>();
|
|
|
- params = this.saveParams(insPlyIncomeVo,params);
|
|
|
- params.put("handlingFeesStatus",insPlyIncomeVo.getHandlingFeesStatus());
|
|
|
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
|
|
|
- for (InsPlyIncome item : insPlyIncomes){
|
|
|
- if(settlementAmount.compareTo(invoicCommissionFeevalue) ==0){
|
|
|
- item.setHandlingFeesStatus("1");
|
|
|
- baseMapper.updateById(item);
|
|
|
+ params.put("id",insPlyIncomeVo.getId());
|
|
|
+ params.put("handlingFeesStatus", "0");
|
|
|
+ SettlementDocumentaryFeesEntity parentSettlementDocumentaryFeesEntity = settlementDocumentaryFeesService.getByParentSettlementAmount(params);
|
|
|
+
|
|
|
+ if(ObjectUtils.isNotEmpty(parentSettlementDocumentaryFeesEntity)){ // 多次结算
|
|
|
+ BigDecimal totalAmount = parentSettlementDocumentaryFeesEntity.getTotalAmount();
|
|
|
+ totalAmount = totalAmount.add(insPlyIncomeVo.getSettlementAmount());
|
|
|
+ if(invoicAmount .compareTo(totalAmount)<0){
|
|
|
+ return HttpResult.error("结算金额大于开票金额");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(invoicAmount.compareTo(insPlyIncomeVo.getSettlementAmount()) <0){
|
|
|
+ return HttpResult.error("结算金额大于开票金额");
|
|
|
+ } else if (invoicAmount.compareTo(insPlyIncomeVo.getSettlementAmount()) ==0) {
|
|
|
+ HashMap<String, Object> incomeParams = new HashMap<>();
|
|
|
+ incomeParams = this.saveParams(insPlyIncomeVo,incomeParams);
|
|
|
+ incomeParams.put("handlingFeesStatus",insPlyIncomeVo.getHandlingFeesStatus());
|
|
|
+ List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(incomeParams);
|
|
|
+ for (InsPlyIncome item : insPlyIncomes){
|
|
|
+ item.setHandlingFeesStatus("1");
|
|
|
+ baseMapper.updateById(item);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// 分批结算
|
|
|
SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();
|
|
|
- String id = String.valueOf(new SnowFlakeUtil().nextId());
|
|
|
- settlementDocumentaryFeesVo.setId(id);
|
|
|
settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getInvoicId()); //开票号
|
|
|
settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime()); //结算时间
|
|
|
settlementDocumentaryFeesVo.setSettlementStatus("2"); //2为结算状态
|
|
|
@@ -1631,7 +1668,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
|
|
|
settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());
|
|
|
settlementDocumentaryFeesVo.setHandlingFeesStatus("0");
|
|
|
- settlementDocumentaryFeesVo.setParentId(id);
|
|
|
+ settlementDocumentaryFeesVo.setParentId(insPlyIncomeVo.getId());
|
|
|
+ settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId());
|
|
|
settlementDocumentaryFeesVo.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
|
|
|
settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
|
|
|
settlementDocumentaryFeesVo.setAgreementType("2"); //1平台 2 保险
|
|
|
@@ -1639,21 +1677,6 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
|
|
|
- private void changeHandStatus(String ids, InsPlyIncomeVo insPlyIncomeVo) {
|
|
|
- String[] split = ids.split(",");
|
|
|
-
|
|
|
- SettlementDocumentaryFeesEntity byId = settlementDocumentaryFeesService.getById(insPlyIncomeVo.getId());
|
|
|
- BigDecimal totalAmount = byId.getTotalAmount(); //开票总金额
|
|
|
- BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount(); //本次结算金额
|
|
|
- //多次结算 表中已经结算的金额
|
|
|
- SettlementDocumentaryFeesEntity settlementAmountEntity = settlementDocumentaryFeesService.getByParentSettlementAmount(insPlyIncomeVo.getId());
|
|
|
- if(ObjectUtils.isNotEmpty(settlementAmountEntity)){
|
|
|
- BigDecimal all = settlementAmount.add(settlementAmountEntity.getTotalAmount());
|
|
|
- if(all.equals(totalAmount)){
|
|
|
- baseMapper.updateByIds(split);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public HttpResult<InsPlyIncome> querySettInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
|
|
|
@@ -1687,7 +1710,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
|
|
|
|
|
|
params.put("partnerCompaniesId", item.getPartnerCompaniesId());
|
|
|
-
|
|
|
+ params.remove("handlingFeesStatus");
|
|
|
List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params); // 总跟单费
|
|
|
for (InsPlyIncome all : insPlyIncomes) {
|
|
|
otherFeevalue = otherFeevalue.add(all.getOtherFeevalue());
|
|
|
@@ -1770,7 +1793,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
|
|
|
settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
|
|
|
settlementDocumentaryFeesVo.setAgreementId(insPlyIncomeVo.getAgreementId());
|
|
|
- settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue()); //其他费用金额
|
|
|
+ settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getSettlementAmount()); //其他费用金额
|
|
|
settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
|
|
|
settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
|
|
|
settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
|
|
|
@@ -2240,6 +2263,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
params.put("isOther","1");
|
|
|
InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
|
|
|
if(byBxLicenseno.getNoOtherCostsProportion().compareTo(item.getNoOtherCostsProportion()) !=0 ){
|
|
|
+ HashMap<String, Object> newMap = new HashMap<>();
|
|
|
+
|
|
|
// 如果比例不相等
|
|
|
BigDecimal noOtherCostsProportion = item.getNoOtherCostsProportion();
|
|
|
|
|
|
@@ -2251,18 +2276,18 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
byBxLicenseno.setOtherFeerate(this.calculateTotal(noOtherCostsProportion,null ,null));
|
|
|
baseMapper.updateById(byBxLicenseno);
|
|
|
|
|
|
- resultMap.put("licenseno",item.getLicenseno());
|
|
|
- resultMap.put("noPolicyno",item.getNoPolicyno());
|
|
|
- resultMap.put("noOtherCostsPremium",noOtherAmount);
|
|
|
+ newMap.put("licenseno",item.getLicenseno());
|
|
|
+ newMap.put("noPolicyno",item.getNoPolicyno());
|
|
|
+ newMap.put("noOtherCostsPremium",noOtherAmount);
|
|
|
|
|
|
- resultMap.put("otherFeevalue",byBxLicenseno.getOtherFeevalue());
|
|
|
- resultMap.put("otherFeerate",byBxLicenseno.getOtherFeerate());
|
|
|
- resultList.add(resultMap);
|
|
|
+ newMap.put("otherFeevalue",byBxLicenseno.getOtherFeevalue());
|
|
|
+ newMap.put("otherFeerate",byBxLicenseno.getOtherFeerate());
|
|
|
+ resultList.add(newMap);
|
|
|
allAmount = allAmount.add(noOtherAmount);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
resultMap.put("allAmount",allAmount);
|
|
|
+ resultMap.put("resultList",resultList);
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|