From dca981467ef809c577b77eb32375755bef220072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Wed, 24 May 2023 01:12:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E5=8D=95=E6=8D=AE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=BB=B7=E6=A0=BC=E5=B1=8F=E8=94=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/controller/DepotHeadController.java | 2 +- .../erp/controller/DepotItemController.java | 29 ++++++---- .../service/depotHead/DepotHeadService.java | 56 +++++++++++++++---- .../com/jsh/erp/service/role/RoleService.java | 24 ++++++++ 4 files changed, 88 insertions(+), 23 deletions(-) diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java index 4f6cffd6..0a4fba87 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java @@ -383,7 +383,7 @@ public class DepotHeadController { BaseResponseInfo res = new BaseResponseInfo(); DepotHeadVo4List dhl = new DepotHeadVo4List(); try { - List list = depotHeadService.getDetailByNumber(number); + List list = depotHeadService.getDetailByNumber(number, request); if(list.size()>0) { dhl = list.get(0); } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java index 109675b7..71afb795 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java @@ -15,6 +15,7 @@ import com.jsh.erp.service.material.MaterialService; import com.jsh.erp.service.role.RoleService; import com.jsh.erp.service.systemConfig.SystemConfigService; import com.jsh.erp.service.unit.UnitService; +import com.jsh.erp.service.user.UserService; import com.jsh.erp.utils.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -63,6 +64,9 @@ public class DepotItemController { @Resource private RoleService roleService; + @Resource + private UserService userService; + @Resource private SystemConfigService systemConfigService; @@ -186,7 +190,10 @@ public class DepotItemController { HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { - List dataList = new ArrayList(); + Long userId = userService.getUserId(request); + String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit(); + List dataList = new ArrayList<>(); + String billCategory = depotHeadService.getBillCategory(depotHeadService.getDepotHead(headerId).getSubType()); if(headerId != 0) { dataList = depotItemService.getDetailList(headerId); } @@ -234,15 +241,15 @@ public class DepotItemController { item.put("basicNumber", diEx.getBasicNumber()); item.put("preNumber", diEx.getOperNumber()); //原数量 item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialExtendId(), diEx.getId(), diEx.getHeaderId(), unitInfo, materialUnit, linkType)); //已入库|已出库 - item.put("purchaseDecimal", diEx.getPurchaseDecimal()); //采购价 + item.put("purchaseDecimal", roleService.parseBillPriceByLimit(diEx.getPurchaseDecimal(), billCategory, priceLimit, request)); //采购价 if("basic".equals(linkType)) { //正常情况显示金额,而以销定购的情况不能显示金额 - item.put("unitPrice", diEx.getUnitPrice()); - item.put("taxUnitPrice", diEx.getTaxUnitPrice()); - item.put("allPrice", diEx.getAllPrice()); - item.put("taxRate", diEx.getTaxRate()); - item.put("taxMoney", diEx.getTaxMoney()); - item.put("taxLastMoney", diEx.getTaxLastMoney()); + item.put("unitPrice", roleService.parseBillPriceByLimit(diEx.getUnitPrice(), billCategory, priceLimit, request)); + item.put("taxUnitPrice", roleService.parseBillPriceByLimit(diEx.getTaxUnitPrice(), billCategory, priceLimit, request)); + item.put("allPrice", roleService.parseBillPriceByLimit(diEx.getAllPrice(), billCategory, priceLimit, request)); + item.put("taxRate", roleService.parseBillPriceByLimit(diEx.getTaxRate(), billCategory, priceLimit, request)); + item.put("taxMoney", roleService.parseBillPriceByLimit(diEx.getTaxMoney(), billCategory, priceLimit, request)); + item.put("taxLastMoney", roleService.parseBillPriceByLimit(diEx.getTaxLastMoney(), billCategory, priceLimit, request)); } BigDecimal allWeight = diEx.getBasicNumber()==null||diEx.getWeight()==null?BigDecimal.ZERO:diEx.getBasicNumber().multiply(diEx.getWeight()); item.put("weight", allWeight); @@ -265,9 +272,9 @@ public class DepotItemController { if(StringUtil.isNotEmpty(isReadOnly) && "1".equals(isReadOnly)) { JSONObject footItem = new JSONObject(); footItem.put("operNumber", totalOperNumber); - footItem.put("allPrice", totalAllPrice); - footItem.put("taxMoney", totalTaxMoney); - footItem.put("taxLastMoney", totalTaxLastMoney); + footItem.put("allPrice", roleService.parseBillPriceByLimit(totalAllPrice, billCategory, priceLimit, request)); + footItem.put("taxMoney", roleService.parseBillPriceByLimit(totalTaxMoney, billCategory, priceLimit, request)); + footItem.put("taxLastMoney", roleService.parseBillPriceByLimit(totalTaxLastMoney, billCategory, priceLimit, request)); footItem.put("weight", totalWeight); dataArray.add(footItem); } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index f14377a8..edfaca7f 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -107,6 +107,10 @@ public class DepotHeadService { String beginTime, String endTime, String materialParam, Long organId, Long creator, Long depotId, Long accountId, String remark, int offset, int rows) throws Exception { List resList = new ArrayList<>(); try{ + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + Long userId = userService.getUserId(request); + String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit(); + String billCategory = getBillCategory(subType); String [] depotArray = getDepotArray(subType); String [] creatorArray = getCreatorArray(roleType); String [] statusArray = StringUtil.isNotEmpty(status) ? status.split(",") : null; @@ -145,26 +149,33 @@ public class DepotHeadService { dh.setAccountMoneyList(accountmoneylistStr); } if(dh.getChangeAmount() != null) { - dh.setChangeAmount(dh.getChangeAmount().abs()); + dh.setChangeAmount(roleService.parseBillPriceByLimit(dh.getChangeAmount().abs(), billCategory, priceLimit, request)); } else { dh.setChangeAmount(BigDecimal.ZERO); } if(dh.getTotalPrice() != null) { - dh.setTotalPrice(dh.getTotalPrice().abs()); + dh.setTotalPrice(roleService.parseBillPriceByLimit(dh.getTotalPrice().abs(), billCategory, priceLimit, request)); } + BigDecimal discountLastMoney = dh.getDiscountLastMoney()!=null?dh.getDiscountLastMoney():BigDecimal.ZERO; + dh.setDiscountLastMoney(roleService.parseBillPriceByLimit(discountLastMoney, billCategory, priceLimit, request)); + BigDecimal backAmount = dh.getBackAmount()!=null?dh.getBackAmount():BigDecimal.ZERO; + dh.setBackAmount(roleService.parseBillPriceByLimit(backAmount, billCategory, priceLimit, request)); if(dh.getDeposit() == null) { dh.setDeposit(BigDecimal.ZERO); + } else { + dh.setDeposit(roleService.parseBillPriceByLimit(dh.getDeposit(), billCategory, priceLimit, request)); } //已经完成的欠款 if(finishDepositMap!=null) { - dh.setFinishDeposit(finishDepositMap.get(dh.getNumber()) != null ? finishDepositMap.get(dh.getNumber()) : BigDecimal.ZERO); + BigDecimal finishDeposit = finishDepositMap.get(dh.getNumber()) != null ? finishDepositMap.get(dh.getNumber()) : BigDecimal.ZERO; + dh.setFinishDeposit(roleService.parseBillPriceByLimit(finishDeposit, billCategory, priceLimit, request)); } //欠款计算 - BigDecimal discountLastMoney = dh.getDiscountLastMoney()!=null?dh.getDiscountLastMoney():BigDecimal.ZERO; BigDecimal otherMoney = dh.getOtherMoney()!=null?dh.getOtherMoney():BigDecimal.ZERO; BigDecimal deposit = dh.getDeposit()!=null?dh.getDeposit():BigDecimal.ZERO; BigDecimal changeAmount = dh.getChangeAmount()!=null?dh.getChangeAmount():BigDecimal.ZERO; - dh.setDebt(discountLastMoney.add(otherMoney).subtract((deposit.add(changeAmount)))); + BigDecimal debt = discountLastMoney.add(otherMoney).subtract((deposit.add(changeAmount))); + dh.setDebt(roleService.parseBillPriceByLimit(debt, billCategory, priceLimit, request)); //是否有付款单或收款单 if(financialBillNoMap!=null) { Integer financialBillNoSize = financialBillNoMap.get(dh.getId()); @@ -725,9 +736,11 @@ public class DepotHeadService { return list; } - public List getDetailByNumber(String number)throws Exception { - List resList = new ArrayList(); + public List getDetailByNumber(String number, HttpServletRequest request)throws Exception { + List resList = new ArrayList<>(); try{ + Long userId = userService.getUserId(request); + String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit(); Map personMap = personService.getPersonMap(); Map accountMap = accountService.getAccountMap(); List list = depotHeadMapperEx.getDetailByNumber(number); @@ -743,6 +756,7 @@ public class DepotHeadService { Map billSizeMap = getBillSizeMapByLinkNumberList(numberList); Map materialsListMap = findMaterialsListMapByHeaderIdList(idList); DepotHeadVo4List dh = list.get(0); + String billCategory = getBillCategory(dh.getSubType()); if(accountMap!=null && StringUtil.isNotEmpty(dh.getAccountIdList()) && StringUtil.isNotEmpty(dh.getAccountMoneyList())) { String accountStr = accountService.getAccountStrByIdAndMoney(accountMap, dh.getAccountIdList(), dh.getAccountMoneyList()); dh.setAccountName(accountStr); @@ -756,17 +770,28 @@ public class DepotHeadService { dh.setAccountMoneyList(accountmoneylistStr); } if(dh.getChangeAmount() != null) { - dh.setChangeAmount(dh.getChangeAmount().abs()); + dh.setChangeAmount(roleService.parseBillPriceByLimit(dh.getChangeAmount().abs(), billCategory, priceLimit, request)); + } else { + dh.setChangeAmount(BigDecimal.ZERO); } if(dh.getTotalPrice() != null) { - dh.setTotalPrice(dh.getTotalPrice().abs()); + dh.setTotalPrice(roleService.parseBillPriceByLimit(dh.getTotalPrice().abs(), billCategory, priceLimit, request)); + } + BigDecimal discountLastMoney = dh.getDiscountLastMoney()!=null?dh.getDiscountLastMoney():BigDecimal.ZERO; + dh.setDiscountLastMoney(roleService.parseBillPriceByLimit(discountLastMoney, billCategory, priceLimit, request)); + BigDecimal backAmount = dh.getBackAmount()!=null?dh.getBackAmount():BigDecimal.ZERO; + dh.setBackAmount(roleService.parseBillPriceByLimit(backAmount, billCategory, priceLimit, request)); + if(dh.getDeposit() == null) { + dh.setDeposit(BigDecimal.ZERO); + } else { + dh.setDeposit(roleService.parseBillPriceByLimit(dh.getDeposit(), billCategory, priceLimit, request)); } //欠款计算 - BigDecimal discountLastMoney = dh.getDiscountLastMoney()!=null?dh.getDiscountLastMoney():BigDecimal.ZERO; BigDecimal otherMoney = dh.getOtherMoney()!=null?dh.getOtherMoney():BigDecimal.ZERO; BigDecimal deposit = dh.getDeposit()!=null?dh.getDeposit():BigDecimal.ZERO; BigDecimal changeAmount = dh.getChangeAmount()!=null?dh.getChangeAmount():BigDecimal.ZERO; - dh.setDebt(discountLastMoney.add(otherMoney).subtract((deposit.add(changeAmount)))); + BigDecimal debt = discountLastMoney.add(otherMoney).subtract((deposit.add(changeAmount))); + dh.setDebt(roleService.parseBillPriceByLimit(debt, billCategory, priceLimit, request)); //是否有付款单或收款单 if(financialBillNoMap!=null) { Integer financialBillNoSize = financialBillNoMap.get(dh.getId()); @@ -1233,6 +1258,15 @@ public class DepotHeadService { JshException.readFail(logger, e); } return total; + } + public String getBillCategory(String subType) { + if(subType.equals("零售") || subType.equals("零售退货")) { + return "retail"; + } else if(subType.equals("销售订单") || subType.equals("销售") || subType.equals("销售退货")) { + return "sale"; + } else { + return "buy"; + } } } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/role/RoleService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/role/RoleService.java index 1ef45779..41d83bc2 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/role/RoleService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/role/RoleService.java @@ -241,6 +241,30 @@ public class RoleService { return price; } + /** + * 根据权限进行屏蔽价格-单据 + * @param price + * @param billCategory + * @param priceLimit + * @param request + * @return + * @throws Exception + */ + public BigDecimal parseBillPriceByLimit(BigDecimal price, String billCategory, String priceLimit, HttpServletRequest request) throws Exception { + if(StringUtil.isNotEmpty(priceLimit)) { + if("buy".equals(billCategory) && priceLimit.contains("1")) { + return BigDecimal.ZERO; + } + if("retail".equals(billCategory) && priceLimit.contains("2")) { + return BigDecimal.ZERO; + } + if("sale".equals(billCategory) && priceLimit.contains("3")) { + return BigDecimal.ZERO; + } + } + return price; + } + public String getCurrentPriceLimit(HttpServletRequest request) throws Exception { Long userId = userService.getUserId(request); return userService.getRoleTypeByUserId(userId).getPriceLimit();