|
@@ -11,6 +11,9 @@ import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
import cn.ezhizao.project.business.account.domain.BizAccount;
|
|
import cn.ezhizao.project.business.account.domain.BizAccount;
|
|
import cn.ezhizao.project.business.account.service.IBizAccountService;
|
|
import cn.ezhizao.project.business.account.service.IBizAccountService;
|
|
import cn.ezhizao.project.business.collection.domain.BizCollection;
|
|
import cn.ezhizao.project.business.collection.domain.BizCollection;
|
|
|
|
+import cn.ezhizao.project.business.collection.domain.BizCollectionDetail;
|
|
|
|
+import cn.ezhizao.project.business.collection.service.IBizCollectionDetailService;
|
|
|
|
+import cn.ezhizao.project.business.collection.service.IBizCollectionService;
|
|
import cn.ezhizao.project.business.order.domain.BizArchiveInputDetail;
|
|
import cn.ezhizao.project.business.order.domain.BizArchiveInputDetail;
|
|
import cn.ezhizao.project.business.payment.domain.BizPayment;
|
|
import cn.ezhizao.project.business.payment.domain.BizPayment;
|
|
import cn.ezhizao.project.business.company.domain.BizCompany;
|
|
import cn.ezhizao.project.business.company.domain.BizCompany;
|
|
@@ -30,6 +33,7 @@ import cn.ezhizao.project.system.domain.SysUser;
|
|
import cn.ezhizao.project.system.service.ISysFileStorageService;
|
|
import cn.ezhizao.project.system.service.ISysFileStorageService;
|
|
import cn.ezhizao.project.system.service.ISysUserService;
|
|
import cn.ezhizao.project.system.service.ISysUserService;
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
@@ -39,7 +43,9 @@ import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.util.Collection;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -68,6 +74,10 @@ public class BizPaymentController extends BaseController {
|
|
IBizPaymentSubjectService paymentSubjectService;
|
|
IBizPaymentSubjectService paymentSubjectService;
|
|
@Resource
|
|
@Resource
|
|
IBizAccountService accountService;
|
|
IBizAccountService accountService;
|
|
|
|
+ @Resource
|
|
|
|
+ IBizCollectionService collectionService;
|
|
|
|
+ @Resource
|
|
|
|
+ IBizCollectionDetailService collectionDetailService;
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('business:payment:query')")
|
|
@PreAuthorize("@ss.hasPermi('business:payment:query')")
|
|
@GetMapping(value = "/{id}")
|
|
@GetMapping(value = "/{id}")
|
|
@@ -166,8 +176,7 @@ public class BizPaymentController extends BaseController {
|
|
|
|
|
|
@PreAuthorize("@ss.hasAnyPermi('business:payment:query')")
|
|
@PreAuthorize("@ss.hasAnyPermi('business:payment:query')")
|
|
@GetMapping("/listCompany")
|
|
@GetMapping("/listCompany")
|
|
- public TableDataInfo listCompany(BizCompany bizCompany) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
- {
|
|
|
|
|
|
+ public TableDataInfo listCompany(BizCompany bizCompany) throws NoSuchFieldException, IllegalAccessException {
|
|
setTenantId(bizCompany);
|
|
setTenantId(bizCompany);
|
|
startPage();
|
|
startPage();
|
|
List<BizCompany> list = companyService.getList(bizCompany);
|
|
List<BizCompany> list = companyService.getList(bizCompany);
|
|
@@ -175,16 +184,15 @@ public class BizPaymentController extends BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
@ApiOperation("获取合同")
|
|
@ApiOperation("获取合同")
|
|
@GetMapping("/listContract")
|
|
@GetMapping("/listContract")
|
|
@PreAuthorize("@ss.hasPermi('business:payment:query')")
|
|
@PreAuthorize("@ss.hasPermi('business:payment:query')")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
- public TableDataInfo listContract(BizArchiveInput condition) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
- {
|
|
|
|
|
|
+ public TableDataInfo listContract(BizArchiveInput condition) throws NoSuchFieldException, IllegalAccessException {
|
|
setTenantId(condition);
|
|
setTenantId(condition);
|
|
startPage();
|
|
startPage();
|
|
List<BizArchiveInput> list = archiveInputService.getList(condition);
|
|
List<BizArchiveInput> list = archiveInputService.getList(condition);
|
|
|
|
+
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -196,6 +204,30 @@ public class BizPaymentController extends BaseController {
|
|
setTenantId(condition);
|
|
setTenantId(condition);
|
|
startPage();
|
|
startPage();
|
|
List<BizArchiveInputDetail> list = contractDetailService.getList(condition);
|
|
List<BizArchiveInputDetail> list = contractDetailService.getList(condition);
|
|
|
|
+
|
|
|
|
+ Long contractId = condition.getContractId();
|
|
|
|
+ List<BizCollection> collectionList = collectionService.list(new LambdaQueryWrapper<BizCollection>().eq(BizCollection::getContractId, contractId).eq(BizCollection::getStatus, 1).eq(BizCollection::getArriveStatus, 1));
|
|
|
|
+ List<Long> idCollectionList = collectionList.stream().map(m -> m.getId()).collect(Collectors.toList());
|
|
|
|
+ if (idCollectionList.size() > 0) {
|
|
|
|
+ List<BizCollectionDetail> detailList = collectionDetailService.list(new LambdaQueryWrapper<BizCollectionDetail>().in(BizCollectionDetail::getCollectionId, idCollectionList));
|
|
|
|
+ Map<Long, BigDecimal> collect = detailList.stream().collect(Collectors.groupingBy(BizCollectionDetail::getTaskTypeId, Collectors.reducing(BigDecimal.ZERO, BizCollectionDetail::getArriveAmount, BigDecimal::add)));
|
|
|
|
+ for (BizArchiveInputDetail detail : list) {
|
|
|
|
+ BigDecimal bigDecimal = collect.get(detail.getTaskTypeId());
|
|
|
|
+ detail.setReallyAmount(bigDecimal);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<BizPayment> paymentList = paymentService.list(new LambdaQueryWrapper<BizPayment>().eq(BizPayment::getContractId, contractId).eq(BizPayment::getPaymentStatus, 1).eq(BizPayment::getVerifyStatus, 3));
|
|
|
|
+ List<Long> idList = paymentList.stream().map(m -> m.getId()).collect(Collectors.toList());
|
|
|
|
+ if (idList.size() > 0) {
|
|
|
|
+ List<BizPaymentDetail> bizPaymentDetailList = paymentDetailService.list(new LambdaQueryWrapper<BizPaymentDetail>().in(BizPaymentDetail::getPaymentId, idList));
|
|
|
|
+ Map<Long, BigDecimal> taskTypeToTotalAmount = bizPaymentDetailList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(BizPaymentDetail::getTaskTypeId,
|
|
|
|
+ Collectors.reducing(BigDecimal.ZERO, BizPaymentDetail::getPaymentAmount, BigDecimal::add)));
|
|
|
|
+ for (BizArchiveInputDetail detail : list) {
|
|
|
|
+ BigDecimal bigDecimal = taskTypeToTotalAmount.get(detail.getTaskTypeId());
|
|
|
|
+ detail.setPayment(bigDecimal);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -206,7 +238,7 @@ public class BizPaymentController extends BaseController {
|
|
public AjaxResult remove(@PathVariable List<Long> ids) {
|
|
public AjaxResult remove(@PathVariable List<Long> ids) {
|
|
//查询所有需要删除的数据
|
|
//查询所有需要删除的数据
|
|
List<BizPayment> list = paymentService.getByIds(ids);
|
|
List<BizPayment> list = paymentService.getByIds(ids);
|
|
- for (BizPayment l:list){
|
|
|
|
|
|
+ for (BizPayment l : list) {
|
|
//判读是否已经审核
|
|
//判读是否已经审核
|
|
if (l.getVerifyStatus() == 1) {
|
|
if (l.getVerifyStatus() == 1) {
|
|
//已经审核无法删除
|
|
//已经审核无法删除
|
|
@@ -214,7 +246,7 @@ public class BizPaymentController extends BaseController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//全未审核则删除
|
|
//全未审核则删除
|
|
- return toAjax(paymentService.removeBatchByIds(ids)&&paymentService.removePaymentDetail(ids));
|
|
|
|
|
|
+ return toAjax(paymentService.removeBatchByIds(ids) && paymentService.removePaymentDetail(ids));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -233,7 +265,7 @@ public class BizPaymentController extends BaseController {
|
|
payment.setContractAmount(archiveInput.getTrueAmount());
|
|
payment.setContractAmount(archiveInput.getTrueAmount());
|
|
BizPayment payemntConditions = new BizPayment();
|
|
BizPayment payemntConditions = new BizPayment();
|
|
payemntConditions.setContractId(archiveInput.getId());
|
|
payemntConditions.setContractId(archiveInput.getId());
|
|
- payemntConditions.setPaymentStatus((byte)1);
|
|
|
|
|
|
+ payemntConditions.setPaymentStatus((byte) 1);
|
|
List<BizPayment> payed = paymentService.getListByBean(payemntConditions);
|
|
List<BizPayment> payed = paymentService.getListByBean(payemntConditions);
|
|
// payment.setNonpayment(archiveInput.getAmount().subtract(BigDecimal.valueOf(collections.stream().mapToDouble(v -> v.getAmount().doubleValue()).sum())).compareTo(BigDecimal.ZERO) > 0);
|
|
// payment.setNonpayment(archiveInput.getAmount().subtract(BigDecimal.valueOf(collections.stream().mapToDouble(v -> v.getAmount().doubleValue()).sum())).compareTo(BigDecimal.ZERO) > 0);
|
|
payment.setPayedAmount(BigDecimal.valueOf(payed.stream().mapToDouble(v -> v.getAmount().doubleValue()).sum()));
|
|
payment.setPayedAmount(BigDecimal.valueOf(payed.stream().mapToDouble(v -> v.getAmount().doubleValue()).sum()));
|
|
@@ -251,10 +283,45 @@ public class BizPaymentController extends BaseController {
|
|
detailCondition.setPaymentId(payment.getId());
|
|
detailCondition.setPaymentId(payment.getId());
|
|
List<BizPaymentDetail> details = paymentDetailService.getListByBean(detailCondition);
|
|
List<BizPaymentDetail> details = paymentDetailService.getListByBean(detailCondition);
|
|
payment.setDetails(details);
|
|
payment.setDetails(details);
|
|
|
|
+ totalAmountPaid(payment, details);
|
|
|
|
+ totalAmountReceived(payment, details);
|
|
}
|
|
}
|
|
return payment;
|
|
return payment;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void totalAmountReceived(BizPayment payment, List<BizPaymentDetail> details) {
|
|
|
|
+ //-------已收款总金额
|
|
|
|
+ Long contractId = payment.getContractId();
|
|
|
|
+ List<BizCollection> collectionList = collectionService.list(new LambdaQueryWrapper<BizCollection>().eq(BizCollection::getContractId, contractId).eq(BizCollection::getStatus, 1).eq(BizCollection::getArriveStatus, 1));
|
|
|
|
+ List<Long> idCollectionList = collectionList.stream().map(m -> m.getId()).collect(Collectors.toList());
|
|
|
|
+ if (idCollectionList.size() > 0) {
|
|
|
|
+ List<BizCollectionDetail> detailList = collectionDetailService.list(new LambdaQueryWrapper<BizCollectionDetail>().in(BizCollectionDetail::getCollectionId, idCollectionList));
|
|
|
|
+ Map<Long, BigDecimal> collect = detailList.stream().collect(Collectors.groupingBy(BizCollectionDetail::getTaskTypeId, Collectors.reducing(BigDecimal.ZERO, BizCollectionDetail::getArriveAmount, BigDecimal::add)));
|
|
|
|
+ for (BizPaymentDetail detail : details) {
|
|
|
|
+ BigDecimal bigDecimal = collect.get(detail.getTaskTypeId());
|
|
|
|
+ detail.setReallyAmount(bigDecimal);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //-------已收款总金额
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void totalAmountPaid(BizPayment payment, List<BizPaymentDetail> details) {
|
|
|
|
+ //-------已支付总金额
|
|
|
|
+ List<BizPayment> list = paymentService.list(new LambdaQueryWrapper<BizPayment>().eq(BizPayment::getContractId, payment.getContractId()).eq(BizPayment::getPaymentStatus, 1).eq(BizPayment::getVerifyStatus, 3));
|
|
|
|
+ List<Long> idList = list.stream().map(m -> m.getId()).collect(Collectors.toList());
|
|
|
|
+ if (idList.size() > 0) {
|
|
|
|
+ List<BizPaymentDetail> bizPaymentDetailList = paymentDetailService.list(new LambdaQueryWrapper<BizPaymentDetail>().in(BizPaymentDetail::getPaymentId, idList));
|
|
|
|
+ Map<Long, BigDecimal> taskTypeToTotalAmount = bizPaymentDetailList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(BizPaymentDetail::getTaskTypeId,
|
|
|
|
+ Collectors.reducing(BigDecimal.ZERO, BizPaymentDetail::getPaymentAmount, BigDecimal::add)));
|
|
|
|
+ for (BizPaymentDetail detail : details) {
|
|
|
|
+ BigDecimal bigDecimal = taskTypeToTotalAmount.get(detail.getTaskTypeId());
|
|
|
|
+ detail.setPayment(bigDecimal);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //-------
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation("审核")
|
|
@ApiOperation("审核")
|
|
@PostMapping("/verified")
|
|
@PostMapping("/verified")
|
|
@Log(title = "支付审核", businessType = BusinessType.UPDATE)
|
|
@Log(title = "支付审核", businessType = BusinessType.UPDATE)
|
|
@@ -280,8 +347,8 @@ public class BizPaymentController extends BaseController {
|
|
startPage();
|
|
startPage();
|
|
startOrderBy();
|
|
startOrderBy();
|
|
List<BizPayment> list = paymentService.getListByBean(payment);
|
|
List<BizPayment> list = paymentService.getListByBean(payment);
|
|
- list.forEach(l->{
|
|
|
|
- switch(l.getVerifyStatus()){
|
|
|
|
|
|
+ list.forEach(l -> {
|
|
|
|
+ switch (l.getVerifyStatus()) {
|
|
case 0:
|
|
case 0:
|
|
l.setVerifyStatusStr("未审核");
|
|
l.setVerifyStatusStr("未审核");
|
|
break;
|
|
break;
|
|
@@ -299,7 +366,7 @@ public class BizPaymentController extends BaseController {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- switch(l.getPaymentStatus()){
|
|
|
|
|
|
+ switch (l.getPaymentStatus()) {
|
|
case 0:
|
|
case 0:
|
|
l.setPaymentStatusStr("未支付");
|
|
l.setPaymentStatusStr("未支付");
|
|
break;
|
|
break;
|