|
|
@@ -992,6 +992,91 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
|
|
|
baseMapper.deleteById(settlementId);*/
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ @GlobalTransactional
|
|
|
+ public void putFund(Settlement settlement)
|
|
|
+ {
|
|
|
+ Settlement select = baseMapper.selectById(settlement.getId());
|
|
|
+ if(select==null)
|
|
|
+ {
|
|
|
+ throw new SecurityException("未查询到款项信息");
|
|
|
+ }
|
|
|
+ if(select.getFoundStatus().equals("核销完成"))
|
|
|
+ {
|
|
|
+ throw new SecurityException("已经核销,禁止操作");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<Items> itemsLambdaQueryWrapper=new LambdaQueryWrapper<>();
|
|
|
+ itemsLambdaQueryWrapper
|
|
|
+ .eq(Items::getPid,settlement.getId())
|
|
|
+ .eq(Items::getTenantId,AuthUtil.getTenantId())
|
|
|
+ .eq(Items::getIsDeleted,0);
|
|
|
+ List<Items> items = itemsMapper.selectList(itemsLambdaQueryWrapper);
|
|
|
+ if(CollectionUtils.isNotEmpty(items))
|
|
|
+ {
|
|
|
+ items.forEach(e->{
|
|
|
+ Long accId = e.getAccId();
|
|
|
+ if(accId==null)
|
|
|
+ {
|
|
|
+ throw new SecurityException("操作失败:发票项明细未绑定账单明细");
|
|
|
+ }
|
|
|
+ Acc acc = accMapper.selectById(accId);
|
|
|
+ if (acc == null) {
|
|
|
+ throw new SecurityException("操作账单失败");
|
|
|
+ }
|
|
|
+ //增加明细开票金额
|
|
|
+ acc.setInvoiceAmount(acc.getInvoiceAmount() != null ? acc.getInvoiceAmount().add(e.getThisAmount()) : new BigDecimal("0").add(e.getThisAmount()));
|
|
|
+ accMapper.updateById(acc);
|
|
|
+ });
|
|
|
+ select.setFoundStatus("核销完成");
|
|
|
+ baseMapper.updateById(select);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ @GlobalTransactional
|
|
|
+ public void cancelFund(Settlement settlement)
|
|
|
+ {
|
|
|
+ Settlement select = baseMapper.selectById(settlement.getId());
|
|
|
+ if(select==null)
|
|
|
+ {
|
|
|
+ throw new SecurityException("未查询到款项信息");
|
|
|
+ }
|
|
|
+ if(select.getFoundStatus().equals("未核销"))
|
|
|
+ {
|
|
|
+ throw new SecurityException("已经撤销过 或者 还未核销,禁止操作");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<Items> itemsLambdaQueryWrapper=new LambdaQueryWrapper<>();
|
|
|
+ itemsLambdaQueryWrapper
|
|
|
+ .eq(Items::getPid,settlement.getId())
|
|
|
+ .eq(Items::getTenantId,AuthUtil.getTenantId())
|
|
|
+ .eq(Items::getIsDeleted,0);
|
|
|
+ List<Items> items = itemsMapper.selectList(itemsLambdaQueryWrapper);
|
|
|
+ if(CollectionUtils.isNotEmpty(items))
|
|
|
+ {
|
|
|
+ items.forEach(e->{
|
|
|
+ Long accId = e.getAccId();
|
|
|
+ if(accId==null)
|
|
|
+ {
|
|
|
+ throw new SecurityException("操作失败:发票项明细未绑定账单明细");
|
|
|
+ }
|
|
|
+ Acc acc = accMapper.selectById(accId);
|
|
|
+ if (acc == null) {
|
|
|
+ throw new SecurityException("操作账单失败");
|
|
|
+ }
|
|
|
+ //减少明细开票金额
|
|
|
+ acc.setInvoiceAmount(acc.getInvoiceAmount() != null ? acc.getInvoiceAmount().subtract(e.getThisAmount()) : (e.getThisAmount()).negate());
|
|
|
+ accMapper.updateById(acc);
|
|
|
+ });
|
|
|
+ select.setFoundStatus("未核销");
|
|
|
+ baseMapper.updateById(select);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//金蝶保存凭证测试
|
|
|
public void toJinDie(Items items,String accountId,String groupName,JdTenant jdTenant) {
|
|
|
//不是某一家 直接返回
|