|
|
@@ -17,30 +17,31 @@
|
|
|
package com.trade.purchase.financing.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import com.trade.purchase.financing.entity.Financing;
|
|
|
+import com.trade.purchase.financing.service.IFinancingService;
|
|
|
+import com.trade.purchase.financing.vo.FinancingVO;
|
|
|
import com.trade.purchase.order.entity.Order;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import javax.validation.Valid;
|
|
|
-
|
|
|
import org.springblade.client.entity.CorpsDesc;
|
|
|
-import org.springblade.client.entity.StorageType;
|
|
|
import org.springblade.client.feign.ICorpsDescClient;
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.trade.purchase.financing.entity.Financing;
|
|
|
-import com.trade.purchase.financing.vo.FinancingVO;
|
|
|
-import com.trade.purchase.financing.service.IFinancingService;
|
|
|
-import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -80,9 +81,9 @@ public class FinancingController extends BladeController {
|
|
|
QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("is_deleted", 0)
|
|
|
.eq("tenant_id", AuthUtil.getTenantId())
|
|
|
- .eq("corp_id", financing.getCorpId())
|
|
|
- .ge("financing_date", financing.getFinancingStartDate())
|
|
|
- .le("financing_date", financing.getFinancingEndDate())
|
|
|
+ .eq(ObjectUtils.isNotNull(financing.getCorpId()), "corp_id", financing.getCorpId())
|
|
|
+ .ge(ObjectUtils.isNotNull(financing.getFinancingStartDate()), "financing_date", financing.getFinancingStartDate())
|
|
|
+ .le(ObjectUtils.isNotNull(financing.getFinancingEndDate()), "financing_date", financing.getFinancingEndDate())
|
|
|
.orderByDesc("create_time");
|
|
|
IPage<Financing> pages = financingService.page(Condition.getPage(query), Condition.getQueryWrapper(financing));
|
|
|
List<Financing> financingList = pages.getRecords();
|
|
|
@@ -203,5 +204,160 @@ public class FinancingController extends BladeController {
|
|
|
return R.success("操作成功");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 融资总账
|
|
|
+ */
|
|
|
+ @GetMapping("/financingAccountList")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "分页", notes = "传入financing")
|
|
|
+ public R<IPage<Financing>> financingAccountList(Financing financing, Query query) {
|
|
|
+ QueryWrapper<Financing> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("is_deleted", 0);
|
|
|
+ queryWrapper.eq("tenant_id", AuthUtil.getTenantId());
|
|
|
+ //判断是否选择客户
|
|
|
+ if (ObjectUtils.isNotNull(financing.getCorpId())) {
|
|
|
+ queryWrapper.eq("corp_id", financing.getCorpId());
|
|
|
+ queryWrapper.apply("date_format(financing_date,'%Y-%m') = date_format(" + financing.getFinancingDate() + ",'%Y-%m')");
|
|
|
+ //查询该客户本月数据
|
|
|
+ List<Financing> financingList = financingService.list(queryWrapper);
|
|
|
+
|
|
|
+ List<Financing> newFinancingList = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取该客户上期结余金额
|
|
|
+ financing.setIsDeleted(0);
|
|
|
+ financing.setTenantId(AuthUtil.getTenantId());
|
|
|
+ BigDecimal lastIssueAmount = financingService.selectlastIssueAmount(financing);
|
|
|
+
|
|
|
+ //本期借款金额
|
|
|
+ BigDecimal currentIssueAmount = new BigDecimal(0);
|
|
|
+
|
|
|
+ //本期还款金额
|
|
|
+ BigDecimal repaymentAmount = new BigDecimal(0);
|
|
|
+
|
|
|
+ //本期结余金额
|
|
|
+ BigDecimal balanceAmount = new BigDecimal(0);
|
|
|
+
|
|
|
+ //便利该客户本月数据 计算借款、还款,结余金额
|
|
|
+ for (Financing financings : financingList) {
|
|
|
+ //本期还款金额
|
|
|
+ if (ObjectUtils.isNotNull(financings.getFinancingType()) && "1".equals(financings.getFinancingType())) {
|
|
|
+ repaymentAmount = repaymentAmount.add(financings.getFinancingAmount());
|
|
|
+ } else if (ObjectUtils.isNotNull(financings.getFinancingType()) && "2".equals(financings.getFinancingType())) {
|
|
|
+ //本期借款金额
|
|
|
+ currentIssueAmount = repaymentAmount.add(financings.getFinancingAmount());
|
|
|
+ }
|
|
|
+ //本期结余金额
|
|
|
+ balanceAmount = balanceAmount.add(financings.getFinancingAmount());
|
|
|
+
|
|
|
+ }
|
|
|
+ Financing financing1 = new Financing();
|
|
|
+ financing1.setCorpId(financingList.get(0).getCorpId());
|
|
|
+ //客户
|
|
|
+ if (ObjectUtils.isNotNull(financingList.get(0).getCorpId())) {
|
|
|
+ R<CorpsDesc> corpsDesc = corpsDescClient.getCorpMessage(financingList.get(0).getCorpId());
|
|
|
+ if (corpsDesc.isSuccess()) {
|
|
|
+ financing1.setCorpName(corpsDesc.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ financing1.setLastIssueAmount((ObjectUtils.isNotNull(lastIssueAmount)) ? new BigDecimal(0) : lastIssueAmount);
|
|
|
+ financing1.setCurrentIssueAmount(currentIssueAmount);
|
|
|
+ financing1.setRepaymentAmount(repaymentAmount);
|
|
|
+ financing1.setBalanceAmount(balanceAmount);
|
|
|
+ newFinancingList.add(financing1);
|
|
|
+
|
|
|
+ //返回数据
|
|
|
+ IPage<Financing> pages = new Page<>();
|
|
|
+ pages.setRecords(newFinancingList);
|
|
|
+ pages.setTotal(1);
|
|
|
+ pages.setSize(1);
|
|
|
+ pages.setCurrent(1);
|
|
|
+ pages.setPages(1);
|
|
|
+ return R.data(pages);
|
|
|
+ } else {
|
|
|
+ financing.setIsDeleted(0);
|
|
|
+ financing.setTenantId(AuthUtil.getTenantId());
|
|
|
+ //通过客户进行分组查询
|
|
|
+ List<Long> corpList = financingService.selectListCorpId(financing);
|
|
|
+
|
|
|
+ List<Financing> financingList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Long corp : corpList) {
|
|
|
+ Financing financings = new Financing();
|
|
|
+ financings.setCorpId(corp);
|
|
|
+ //客户
|
|
|
+ R<CorpsDesc> corpsDesc = corpsDescClient.getCorpMessage(corp);
|
|
|
+ if (corpsDesc.isSuccess()) {
|
|
|
+ financings.setCorpName(corpsDesc.getData().getCname());
|
|
|
+ }
|
|
|
+ queryWrapper.eq("corp_id", financings.getCorpId());
|
|
|
+ queryWrapper.apply("date_format(financing_date,'%Y-%m') = date_format(" + financing.getFinancingDate() + ",'%Y-%m')");
|
|
|
+ List<Financing> financingsList = financingService.list(queryWrapper);
|
|
|
+ financing.setCorpId(financings.getCorpId());
|
|
|
+ financing.setIsDeleted(0);
|
|
|
+ financing.setTenantId(AuthUtil.getTenantId());
|
|
|
+ BigDecimal lastIssueAmount = financingService.selectlastIssueAmount(financing);
|
|
|
+
|
|
|
+ BigDecimal currentIssueAmount = new BigDecimal(0);
|
|
|
+
|
|
|
+ BigDecimal repaymentAmount = new BigDecimal(0);
|
|
|
+
|
|
|
+ BigDecimal balanceAmount = new BigDecimal(0);
|
|
|
+ for (Financing financingss : financingsList) {
|
|
|
+ //本期还款金额
|
|
|
+ if (ObjectUtils.isNotNull(financingss.getFinancingType()) && "1".equals(financingss.getFinancingType())) {
|
|
|
+ repaymentAmount = repaymentAmount.add(financingss.getFinancingAmount());
|
|
|
+ } else if (ObjectUtils.isNotNull(financingss.getFinancingType()) && "2".equals(financingss.getFinancingType())) {
|
|
|
+ //本期借款金额
|
|
|
+ currentIssueAmount = repaymentAmount.add(financingss.getFinancingAmount());
|
|
|
+ }
|
|
|
+ //本期结余金额
|
|
|
+ balanceAmount = balanceAmount.add(financingss.getFinancingAmount());
|
|
|
+ }
|
|
|
+ financings.setLastIssueAmount((ObjectUtils.isNotNull(lastIssueAmount)) ? new BigDecimal(0) : lastIssueAmount);
|
|
|
+ financings.setCurrentIssueAmount(currentIssueAmount);
|
|
|
+ financings.setRepaymentAmount(repaymentAmount);
|
|
|
+ financings.setBalanceAmount(balanceAmount);
|
|
|
+ financingList.add(financings);
|
|
|
+ }
|
|
|
+ //返回数据
|
|
|
+ IPage<Financing> page = new Page<>();
|
|
|
+ page.setRecords(financingList);
|
|
|
+ /*page.setTotal(1);
|
|
|
+ page.setSize(1);
|
|
|
+ page.setCurrent(1);
|
|
|
+ page.setPages(1);*/
|
|
|
+ return R.data(page);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 融资明细
|
|
|
+ */
|
|
|
+ @GetMapping("/financingDetailsList")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "分页", notes = "传入financing")
|
|
|
+ public R<IPage<Financing>> financingDetailsList(Financing financing, Query query) {
|
|
|
+ QueryWrapper<Financing> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("is_deleted", 0);
|
|
|
+ queryWrapper.eq("tenant_id", AuthUtil.getTenantId());
|
|
|
+ queryWrapper.eq("corp_id", financing.getCorpId());
|
|
|
+ queryWrapper.apply("date_format(financing_date,'%Y-%m') = date_format(" + financing.getFinancingDate() + ",'%Y-%m')");
|
|
|
+ IPage<Financing> pages = financingService.page(Condition.getPage(query), queryWrapper);
|
|
|
+ List<Financing> financingList = pages.getRecords();
|
|
|
+ for (Financing financings : financingList) {
|
|
|
+ //客户
|
|
|
+ if (ObjectUtils.isNotNull(financings.getCorpId())) {
|
|
|
+ R<CorpsDesc> corpsDesc = corpsDescClient.getCorpMessage(financings.getCorpId());
|
|
|
+ if (corpsDesc.isSuccess()) {
|
|
|
+ financings.setCorpName(corpsDesc.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(pages);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|