|
|
@@ -0,0 +1,179 @@
|
|
|
+package org.springblade.client.corps.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.client.corps.service.ICorpsDescService;
|
|
|
+import org.springblade.client.dto.CorpsDescDto;
|
|
|
+import org.springblade.client.entity.CorpsDesc;
|
|
|
+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.secure.utils.SecureUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.purchase.sales.entity.Order;
|
|
|
+import org.springblade.purchase.sales.feign.IOrderDescClient;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 客户详情 控制器(配件系统)
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2021-09-13
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/partsCorps")
|
|
|
+@Api(value = "客户详情", tags = "客户详情接口")
|
|
|
+public class CorpsDescPartsController extends BladeController {
|
|
|
+
|
|
|
+ private final ICorpsDescService corpsDescService;
|
|
|
+ private final IOrderDescClient orderDescClient;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情
|
|
|
+ */
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "详情", notes = "传入corpsDesc")
|
|
|
+ public R<CorpsDesc> detail(CorpsDesc corpsDesc) {
|
|
|
+ CorpsDesc detail = corpsDescService.getMessageByID(corpsDesc);
|
|
|
+ return R.data(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自定义分页 客户详情
|
|
|
+ */
|
|
|
+ @GetMapping("/page")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "分页", notes = "传入corpsDesc")
|
|
|
+ public R<IPage<CorpsDescDto>> page(CorpsDescDto corpsDescDto, Query query) {
|
|
|
+ corpsDescDto.setIsDeleted(0);//默认查有效的
|
|
|
+ corpsDescDto.setTenantId(SecureUtil.getTenantId());
|
|
|
+ IPage<CorpsDescDto> pages = corpsDescService.selectPartsCorpsDescPage(Condition.getPage(query), corpsDescDto);
|
|
|
+ for (CorpsDescDto corpsDescDto1 : pages.getRecords()) {
|
|
|
+ Order order = new Order();
|
|
|
+ order.setCorpId(corpsDescDto1.getId());
|
|
|
+ order.setBillType("XS");
|
|
|
+ order.setTradeType("JXS");
|
|
|
+ order.setStartTime(corpsDescDto.getStartTime());
|
|
|
+ order.setEndTime(corpsDescDto.getEndTime());
|
|
|
+ List<Order> orderList = orderDescClient.getByBillNo(order);
|
|
|
+ if (ObjectUtils.isNotNull(orderList)) {
|
|
|
+ //未收账款
|
|
|
+ corpsDescDto1.setBalanceAmount(orderList.stream().map(Order::getBalanceAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ //应收账款
|
|
|
+ corpsDescDto1.setDebitAmount(orderList.stream().map(Order::getDebitAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ //已收账款
|
|
|
+ corpsDescDto1.setSettlmentAmount(orderList.stream().map(Order::getSettlmentAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ //预(收)付款
|
|
|
+ corpsDescDto1.setAdvancePayment(orderList.stream().map(Order::getAdvancePayment).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ } else {
|
|
|
+ //未收账款
|
|
|
+ corpsDescDto1.setBalanceAmount(new BigDecimal(0));
|
|
|
+ //应收账款
|
|
|
+ corpsDescDto1.setDebitAmount(new BigDecimal(0));
|
|
|
+ //已收账款
|
|
|
+ corpsDescDto1.setSettlmentAmount(new BigDecimal(0));
|
|
|
+ //预(收)付款
|
|
|
+ corpsDescDto1.setAdvancePayment(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(pages);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自定义分页 客户详情(统计)
|
|
|
+ */
|
|
|
+ @GetMapping("/pageStatistics")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "分页", notes = "传入corpsDesc")
|
|
|
+ public R<Map<String, Object>> pageStatistics(CorpsDescDto corpsDescDto) {
|
|
|
+ corpsDescDto.setIsDeleted(0);//默认查有效的
|
|
|
+ corpsDescDto.setTenantId(SecureUtil.getTenantId());
|
|
|
+ List<CorpsDescDto> corpsDescDtoList = corpsDescService.selectPartsCorpsStatistics(corpsDescDto);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ //应收账款
|
|
|
+ BigDecimal debitAmount = new BigDecimal("0.00");
|
|
|
+ //已收账款
|
|
|
+ BigDecimal settlmentAmount = new BigDecimal("0.00");
|
|
|
+ //未收账款
|
|
|
+ BigDecimal balanceAmount = new BigDecimal("0.00");
|
|
|
+ // 预(收)付款
|
|
|
+ BigDecimal advancePayment = new BigDecimal("0.00");
|
|
|
+ for (CorpsDescDto corpsDescDto1 : corpsDescDtoList) {
|
|
|
+ Order order = new Order();
|
|
|
+ order.setCorpId(corpsDescDto1.getId());
|
|
|
+ order.setBillType("XS");
|
|
|
+ order.setTradeType("JXS");
|
|
|
+ order.setStartTime(corpsDescDto.getStartTime());
|
|
|
+ order.setEndTime(corpsDescDto.getEndTime());
|
|
|
+ List<Order> orderList = orderDescClient.getByBillNo(order);
|
|
|
+ if (ObjectUtils.isNotNull(orderList)) {
|
|
|
+ //未收账款
|
|
|
+ balanceAmount = balanceAmount.add(orderList.stream().map(Order::getBalanceAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ //应收账款
|
|
|
+ debitAmount = debitAmount.add(orderList.stream().map(Order::getDebitAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ //已收账款
|
|
|
+ settlmentAmount = settlmentAmount.add(orderList.stream().map(Order::getSettlmentAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ //预(收)付款
|
|
|
+ advancePayment = advancePayment.add(orderList.stream().map(Order::getAdvancePayment).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ } else {
|
|
|
+ //未收账款
|
|
|
+ corpsDescDto1.setBalanceAmount(new BigDecimal(0));
|
|
|
+ //应收账款
|
|
|
+ corpsDescDto1.setDebitAmount(new BigDecimal(0));
|
|
|
+ //已收账款
|
|
|
+ corpsDescDto1.setSettlmentAmount(new BigDecimal(0));
|
|
|
+ //预(收)付款
|
|
|
+ corpsDescDto1.setAdvancePayment(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //未收账款
|
|
|
+ map.put("balanceAmount", balanceAmount);
|
|
|
+ //应收账款
|
|
|
+ map.put("debitAmount", debitAmount);
|
|
|
+ //已收账款
|
|
|
+ map.put("settlmentAmount", settlmentAmount);
|
|
|
+ //预(收)付款
|
|
|
+ map.put("advancePayment", advancePayment);
|
|
|
+ //已送货
|
|
|
+ map.put("deliveringAmount", new BigDecimal(0));
|
|
|
+ return R.data(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户下拉选
|
|
|
+ */
|
|
|
+ @GetMapping("/getCorpsAll")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "", notes = "")
|
|
|
+ public R<List<Map<String, Object>>> getCorpsAll() {
|
|
|
+ LambdaQueryWrapper<CorpsDesc> corpsDescQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ corpsDescQueryWrapper.eq(CorpsDesc::getIsDeleted, 0).eq(CorpsDesc::getTenantId, AuthUtil.getTenantId()).eq(CorpsDesc::getCorpType, "KH");
|
|
|
+ List<CorpsDesc> corpsDescDtoList = corpsDescService.list(corpsDescQueryWrapper);
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ for (CorpsDesc corpsDesc : corpsDescDtoList) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("value", corpsDesc.getId());
|
|
|
+ if (ObjectUtils.isNotNull(corpsDesc.getTel())) {
|
|
|
+ map.put("label", corpsDesc.getCname() + "(" + corpsDesc.getTel() + ")");
|
|
|
+ } else {
|
|
|
+ map.put("label", corpsDesc.getCname());
|
|
|
+ }
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|