From dcbafae95453669e45cf3035a3575f675e37fc38 Mon Sep 17 00:00:00 2001 From: "kuang.yife" Date: Tue, 7 Feb 2023 10:58:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A3=E7=82=B9=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/order/OrderController.java | 79 ++++++++++++++++++- .../templates/goods/deptcategory/edit.html | 2 +- 2 files changed, 78 insertions(+), 3 deletions(-) diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderController.java b/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderController.java index ce84f52e..cb45f9d2 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderController.java @@ -352,8 +352,11 @@ public class OrderController extends BaseController { financialMasterService.insertFinancialMaster(financialMaster); Assert.notNull(financialMaster.getId(), "FinancialMaster.id is null!"); + +// createFinancialDetail(goodsList.get(0).getDeptGoodsCategoryId(), deptId, customer, payMoney, financialMaster); + //生成财务子单 - createFinancialDetail(goodsList.get(0).getDeptGoodsCategoryId(), deptId, customer, payMoney, financialMaster); + createFinancialDetail(appGoodsList,deptId, customer, payMoney, financialMaster); // 生成商品订单 Map goodsMap = goodsList.stream().filter(Objects::nonNull) @@ -368,6 +371,76 @@ public class OrderController extends BaseController { return AjaxResult.success(orderMaster); } + private void createFinancialDetail(List appGoodsList, Long deptId, Customer customer, BigDecimal payMoney, FinancialMaster financialMaster){ + // 平台 + BigDecimal deptMoney = BigDecimal.ZERO; + // 一级分销 + BigDecimal oneMoney = BigDecimal.ZERO; + // 二级分销 + BigDecimal twoMoney = BigDecimal.ZERO; + // 三级分销 + BigDecimal threeMoney = BigDecimal.ZERO; + // 截流扣点 + BigDecimal specialMoney = BigDecimal.ZERO; + for(AppGoodsRequest goodsRequest : appGoodsList){ + // 商品规格-提成额 + GoodsStandard goodsStandard = goodsStandardService.selectById(goodsRequest.getGoodsStandardId()); + // 扣点设置类目 + DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.get(goodsStandard.getDeptGoodsCategoryId()); + for (int index = 0; index < goodsRequest.getNum(); index++){ + // 一级分销 = 商品单价 * 扣点比例 + oneMoney = oneMoney + .add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(Double.parseDouble(deptGoodsCategory.getOneRate())))); + // 二级分销 = 商品单价 * 扣点比例 + twoMoney = twoMoney.add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(Double.parseDouble(deptGoodsCategory.getTwoRate())))); + // 三级分销 = 提成额 + 商品单价 * 扣点比例 + threeMoney = threeMoney.add(goodsStandard.getExtMoney()) + .add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(Double.parseDouble(deptGoodsCategory.getThreeRate())))); + // 平台扣点 = 平台金额 + 商品单价 * 扣点比例 + deptMoney = deptMoney.add(deptGoodsCategory.getDeptMoney()) + .add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(Double.parseDouble(deptGoodsCategory.getDeptRate())))); + // 截流扣点 = 截流金额 + 商品单价 * 扣点比例 + specialMoney = specialMoney.add(deptGoodsCategory.getRetainMoney()) + .add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(Double.parseDouble(deptGoodsCategory.getRetainRate())))); + } + } + // 平台扣点记录 + FinancialDetail deptDetail = new FinancialDetail(deptId, financialDetailService.createCode(), + financialMaster.getId(), financialMaster.getCode(), deptMoney, FinancialDetailType.PLATFORM_FEE.getCode(), null); + financialDetailService.insertFinancialDetail(deptDetail); + + // 截流扣点记录 + FinancialDetail retainDetail = new FinancialDetail(deptId, financialDetailService.createCode(), + financialMaster.getId(), financialMaster.getCode(), specialMoney, FinancialDetailType.PLATFORM_FEE.getCode(), null); + financialDetailService.insertFinancialDetail(retainDetail); + + // 分销扣点记录 + Long customerPlaceId = customer.getCustomerPlace(); + // 一级分销 + if (customerPlaceId != null) { + FinancialDetail financialDetail = new FinancialDetail(deptId, financialDetailService.createCode(), + financialMaster.getId(), financialMaster.getCode(), threeMoney, FinancialDetailType.PLACE_FEE.getCode(), customerPlaceId); + financialDetailService.insertFinancialDetail(financialDetail); + } else { + oneMoney = oneMoney.add(threeMoney); + } + + // 二级分销 + Long parentCustomerPlaceId = customer.getParentCustomerPlace(); + if (parentCustomerPlaceId != null) { + FinancialDetail financialDetail = new FinancialDetail(deptId, financialDetailService.createCode(), + financialMaster.getId(), financialMaster.getCode(), twoMoney, FinancialDetailType.PLACE_FEE.getCode(), parentCustomerPlaceId); + financialDetailService.insertFinancialDetail(financialDetail); + } else { + oneMoney = oneMoney.add(twoMoney); + } + + // 平台分销 + FinancialDetail financialDetail = new FinancialDetail(deptId, financialDetailService.createCode(), + financialMaster.getId(), financialMaster.getCode(), oneMoney, FinancialDetailType.PLACE_FEE.getCode(), null); + financialDetailService.insertFinancialDetail(financialDetail); + } + /** * 生成财务子单 * @@ -973,7 +1046,9 @@ public class OrderController extends BaseController { List records = afterServiceRecordService.selectAfterServiceRecordList(afterServiceRecordQry); afterServiceRecords.addAll(records); }); - if (Boolean.TRUE.equals(orderMaster.getIsOverTime()) && timeoutRecords.size() == 0) continue; + if (Boolean.TRUE.equals(orderMaster.getIsOverTime()) && timeoutRecords.size() == 0) { + continue; + } for (OrderGoods orderGoods : orderStandardList) { OrderStandard orderStandard = new OrderStandard(); diff --git a/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html b/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html index 01208e67..69d4c715 100644 --- a/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html +++ b/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html @@ -110,8 +110,8 @@