diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java index 287cc9d6c..1e6e9fce4 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java @@ -3,6 +3,8 @@ package com.bsd.pjcloud.hard.api.vo.order; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.math.BigDecimal; + @Data public class HardDeptTotalVo { @@ -13,7 +15,7 @@ public class HardDeptTotalVo { private String deptName; @Schema(description = "批量充值金额") - private Long walletPrice = 0L; + private BigDecimal walletPrice = BigDecimal.ZERO; @Schema(description = "批量充值次数") private Long walletCount = 0L; @@ -25,37 +27,37 @@ public class HardDeptTotalVo { private Long walletReduceCount = 0L; @Schema(description = "退还各自食堂金额") - private Long walletReturnCanteenPrice = 0L; + private BigDecimal walletReturnCanteenPrice = BigDecimal.ZERO; @Schema(description = "退还各自食堂次数") private Long walletReturnCanteenCount = 0L; @Schema(description = "单次充值金额") - private Long walletOncePrice = 0L; + private BigDecimal walletOncePrice = BigDecimal.ZERO; @Schema(description = "单次充值次数") private Long walletOnceCount = 0L; @Schema(description = "单次扣减金额") - private Long walletOnceReducePrice = 0L; + private BigDecimal walletOnceReducePrice = BigDecimal.ZERO; @Schema(description = "单次扣减次数") private Long walletOnceReduceCount = 0L; @Schema(description = "消费金额") - private Long orderPayPrice = 0L; + private BigDecimal orderPayPrice = BigDecimal.ZERO; @Schema(description = "消费次数") private Long orderPayCount = 0L; @Schema(description = "退款金额") - private Long orderRefundPrice = 0L; + private BigDecimal orderRefundPrice = BigDecimal.ZERO; @Schema(description = "退款次数") private Long orderRefundCont = 0L; @Schema(description = "盈利金额") - private Long orderProfitPrice = 0L; + private BigDecimal orderProfitPrice = BigDecimal.ZERO; @Schema(description = "盈利次数") private Long orderProfitCont = 0L; diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java index 4ca52ffe1..e1a02c57e 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java @@ -427,75 +427,43 @@ public class HardOrderTotalController { lineNumber++; // 批量充值 if (ObjectUtil.isNotEmpty(v.getWalletPrice())) { - walletPriceSum = walletPriceSum.add(BigDecimal.valueOf(v.getWalletPrice())); - v.setWalletPrice(BigDecimal.valueOf(v.getWalletPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); - } - if (ObjectUtil.isNotEmpty(v.getWalletCount())) { - walletCountSum = walletCountSum.add(BigDecimal.valueOf(v.getWalletCount())); - v.setWalletCount(BigDecimal.valueOf(v.getWalletCount()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); + walletPriceSum = walletPriceSum.add(v.getWalletPrice()); + v.setWalletPrice(v.getWalletPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); } // 批量扣减 if (ObjectUtil.isNotEmpty(v.getWalletReducePrice())) { walletReducePriceSum = walletReducePriceSum.add(BigDecimal.valueOf(v.getWalletReducePrice())); v.setWalletReducePrice(BigDecimal.valueOf(v.getWalletReducePrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); } - if (ObjectUtil.isNotEmpty(v.getWalletReduceCount())) { - walletReduceCountSum = walletReduceCountSum.add(BigDecimal.valueOf(v.getWalletReduceCount())); - v.setWalletReduceCount(BigDecimal.valueOf(v.getWalletReduceCount()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); - } // 单次充值 if (ObjectUtil.isNotEmpty(v.getWalletOncePrice())) { - walletOncePriceSum = walletOncePriceSum.add(BigDecimal.valueOf(v.getWalletOncePrice())); - v.setWalletOncePrice(BigDecimal.valueOf(v.getWalletOncePrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); - } - if (ObjectUtil.isNotEmpty(v.getWalletOnceCount())) { - walletOnceCountSum = walletOnceCountSum.add(BigDecimal.valueOf(v.getWalletOnceCount())); - v.setWalletOnceCount(BigDecimal.valueOf(v.getWalletOnceCount()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); + walletOncePriceSum = walletOncePriceSum.add(v.getWalletOncePrice()); + v.setWalletOncePrice(v.getWalletOncePrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); } // 单次扣减 if (ObjectUtil.isNotEmpty(v.getWalletOnceReducePrice())) { - walletOnceReducePriceSum = walletOnceReducePriceSum.add(BigDecimal.valueOf(v.getWalletOnceReducePrice())); - v.setWalletOnceReducePrice(BigDecimal.valueOf(v.getWalletOnceReducePrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); + walletOnceReducePriceSum = walletOnceReducePriceSum.add(v.getWalletOnceReducePrice()); + v.setWalletOnceReducePrice(v.getWalletOnceReducePrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); } - if (ObjectUtil.isNotEmpty(v.getWalletOnceReduceCount())) { - walletOnceReduceCountSum = walletOnceReduceCountSum.add(BigDecimal.valueOf(v.getWalletOnceReduceCount())); - v.setWalletOnceReduceCount(BigDecimal.valueOf(v.getWalletOnceReduceCount()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); - } - // + // 消费金额 if (ObjectUtil.isNotEmpty(v.getOrderPayPrice())) { - orderPayPriceSum = orderPayPriceSum.add(BigDecimal.valueOf(v.getOrderPayPrice())); - v.setOrderPayPrice(BigDecimal.valueOf(v.getOrderPayPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); - } - if (ObjectUtil.isNotEmpty(v.getOrderPayCount())) { - orderPayCountSum = orderPayCountSum.add(BigDecimal.valueOf(v.getOrderPayCount())); - v.setOrderPayCount(BigDecimal.valueOf(v.getOrderPayCount()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); + orderPayPriceSum = orderPayPriceSum.add(v.getOrderPayPrice()); + v.setOrderPayPrice(v.getOrderPayPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); } // if (ObjectUtil.isNotEmpty(v.getOrderRefundPrice())) { - orderRefundPriceSum = orderRefundPriceSum.add(BigDecimal.valueOf(v.getOrderRefundPrice())); - v.setOrderRefundPrice(BigDecimal.valueOf(v.getOrderRefundPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); - } - if (ObjectUtil.isNotEmpty(v.getOrderRefundCont())) { - orderRefundContSum = orderRefundContSum.add(BigDecimal.valueOf(v.getOrderRefundCont())); - v.setOrderRefundCont(BigDecimal.valueOf(v.getOrderRefundCont()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); + orderRefundPriceSum = orderRefundPriceSum.add(v.getOrderRefundPrice()); + v.setOrderRefundPrice(v.getOrderRefundPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); } // if (ObjectUtil.isNotEmpty(v.getOrderProfitPrice())) { - orderProfitPriceSum = orderProfitPriceSum.add(BigDecimal.valueOf(v.getOrderProfitPrice())); - v.setOrderProfitPrice(BigDecimal.valueOf(v.getOrderProfitPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); - } - if (ObjectUtil.isNotEmpty(v.getOrderProfitCont())) { - orderProfitContSum = orderProfitContSum.add(BigDecimal.valueOf(v.getOrderProfitCont())); - v.setOrderProfitCont(BigDecimal.valueOf(v.getOrderProfitCont()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); + orderProfitPriceSum = orderProfitPriceSum.add(v.getOrderProfitPrice()); + v.setOrderProfitPrice(v.getOrderProfitPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); } // 退还各自食堂金额 if (ObjectUtil.isNotEmpty(v.getWalletReturnCanteenPrice())) { - walletReturnCanteenPriceSum = walletReturnCanteenPriceSum.add(BigDecimal.valueOf(v.getWalletReturnCanteenPrice())); - v.setWalletReturnCanteenPrice(BigDecimal.valueOf(v.getWalletReturnCanteenPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); - } - if (ObjectUtil.isNotEmpty(v.getWalletReturnCanteenCount())) { - walletReturnCanteenCountSum = walletReturnCanteenCountSum.add(BigDecimal.valueOf(v.getWalletReturnCanteenCount())); - v.setWalletReturnCanteenCount(BigDecimal.valueOf(v.getWalletReturnCanteenCount()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); + walletReturnCanteenPriceSum = walletReturnCanteenPriceSum.add(v.getWalletReturnCanteenPrice()); + v.setWalletReturnCanteenPrice(v.getWalletReturnCanteenPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); } // 批量充值 map.put("walletPriceSum", walletPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java index 954dd9689..d657a0da1 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java @@ -515,10 +515,10 @@ public class HardAfterSaleServiceImpl extends ServiceImpl ObjectUtil.isNotEmpty(v.getIncrCount()) && v.getIncrCount() > 0).toList(); + }).filter(v -> ObjectUtil.isNotEmpty(v.getIncrCount()) && ObjectUtil.notEqual(v.getIncrCount(), 0.0)).toList(); dto.setItems(list); R updateSkuStockRes = supermarketSpuService.updateSpuStock(dto); if (updateSkuStockRes.getCode() != 0) { @@ -951,6 +949,44 @@ public class HardOrderServiceImpl extends ServiceImpl list = carList.stream().map(v -> { + SkuStockChangeDTO.Item item = new SkuStockChangeDTO.Item(); + item.setId(v.getProductId()); + if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) { + // 按数量 + int prouctCount = v.getProductCount(); + // 如果退款购物车数组里有,就用退款购物车的数量 + if (ObjectUtil.isNotEmpty(refundCarList)) { + HardCarEntity refundCarTarget = refundCarList.stream().filter(i -> ObjectUtil.equals(i.getProductId(), v.getProductId())).findFirst().orElse(null); + if (ObjectUtil.isNotEmpty(refundCarTarget) && ObjectUtil.isNotEmpty(refundCarTarget.getProductCount())) { + prouctCount = refundCarTarget.getProductCount(); + } + } + double count = BigDecimal.valueOf(prouctCount).multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + item.setIncrCount(count); + } else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) { + // 按重量 + BigDecimal productWeight = v.getProductWeight(); + // 如果退款购物车数组里有,就用退款购物车的数量 + if (ObjectUtil.isNotEmpty(refundCarList)) { + HardCarEntity refundCarTarget = refundCarList.stream().filter(i -> ObjectUtil.equals(i.getProductId(), v.getProductId())).findFirst().orElse(null); + if (ObjectUtil.isNotEmpty(refundCarTarget) && ObjectUtil.isNotEmpty(refundCarTarget.getProductCount())) { + productWeight = refundCarTarget.getProductWeight(); + } + } + double weight = productWeight.multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + item.setIncrCount(weight); + } + return item; + }).filter(v -> ObjectUtil.isNotEmpty(v.getIncrCount()) && ObjectUtil.notEqual(v.getIncrCount(), 0.0)).toList(); + dto.setItems(list); + R updateSkuStockRes = remoteShopSkuService.deductStock(dto); + if (updateSkuStockRes.getCode() != 0) { + log.info("|{}|{},失败,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto)); + throw new RuntimeException(CarErrorMsg + "错误"); + } + log.info("|{}|{},成功,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto)); return; } } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java index 4a6304e53..173154fbc 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java @@ -472,13 +472,12 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { for (HardDeptTotalVo v : resultList) { if (ObjectUtil.isNotEmpty(walletBatchList)) { walletBatchList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { - v.setWalletPrice(i.getSum()); + v.setWalletPrice(BigDecimal.valueOf(i.getSum())); v.setWalletCount(i.getCount()); }); } if (ObjectUtil.isNotEmpty(walletReduceList)) { walletReduceList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { - // v.setWalletReducePrice(i.getSum()); v.setWalletReducePrice(Math.abs(i.getSum())); v.setWalletReduceCount(i.getCount()); }); @@ -486,32 +485,31 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { // 退还各自食堂 if (ObjectUtil.isNotEmpty(walletRetrunCanteenList)) { walletRetrunCanteenList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { - v.setWalletReturnCanteenPrice(Math.abs(i.getSum())); + v.setWalletReturnCanteenPrice(BigDecimal.valueOf(Math.abs(i.getSum()))); v.setWalletReturnCanteenCount(i.getCount()); }); } if (ObjectUtil.isNotEmpty(walletOnceBatchList)) { walletOnceBatchList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { - v.setWalletOncePrice(i.getSum()); + v.setWalletOncePrice(BigDecimal.valueOf(i.getSum())); v.setWalletOnceCount(i.getCount()); }); } if (ObjectUtil.isNotEmpty(walletOnceReduceList)) { walletOnceReduceList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { - // v.setWalletOnceReducePrice(i.getSum()); - v.setWalletOnceReducePrice(Math.abs(i.getSum())); + v.setWalletOnceReducePrice(BigDecimal.valueOf(Math.abs(i.getSum()))); v.setWalletOnceReduceCount(i.getCount()); }); } if (ObjectUtil.isNotEmpty(payList)) { payList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { - v.setOrderPayPrice(i.getSum()); + v.setOrderPayPrice(BigDecimal.valueOf(i.getSum())); v.setOrderPayCount(i.getCount()); }); } if (ObjectUtil.isNotEmpty(refundList)) { refundList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { - v.setOrderRefundPrice(i.getSum()); + v.setOrderRefundPrice(BigDecimal.valueOf(i.getSum())); v.setOrderRefundCont(i.getCount()); }); } @@ -520,7 +518,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { for (HardDeptTotalVo v : resultList) { // 流水金额 if (ObjectUtil.isNotEmpty(v.getOrderPayPrice())) { - v.setOrderProfitPrice(v.getOrderPayPrice() - v.getOrderRefundPrice()); + v.setOrderProfitPrice(v.getOrderPayPrice().subtract(v.getOrderRefundPrice())); } // 流水次数 if (ObjectUtil.isNotEmpty(v.getOrderPayCount())) { diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx index 8901e6a61..a3b211e9c 100644 Binary files a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx and b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx differ diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java index 6f6cbd941..5c79e3515 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java @@ -145,6 +145,13 @@ public class WalletTransactionController { return R.ok(walletTransactionService.scopePageList(page, dto, dataScope)); } + @Operation(summary = "分页查询复杂查询(无权限)", description = "分页查询复杂查询(无权限)") + @GetMapping("/public/page-join") + public R publicPageJoin(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) { + return R.ok(walletTransactionService.scopePageList(page, dto, null)); + } + + @Operation(summary = "通过id查询", description = "通过id查询") @GetMapping("/{id}") @PreAuthorize("@pms.hasPermission('wallet_walletTransaction_view')")