From b3cc17a8b060bc1b24bb0ed526359f36ed2efadd Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Tue, 5 Dec 2023 16:28:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=BF=90=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/controller/BuyOrderController.java | 65 ++++++++++++++----- .../modules/book/entity/ShopProduct.java | 2 +- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java b/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java index 498b4529..ca82cd1c 100644 --- a/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java +++ b/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java @@ -389,27 +389,62 @@ public class BuyOrderController { */ @RequestMapping(path = "/calculateTransportPrice", method = RequestMethod.POST) public R getTransportPrice(@RequestBody ProductTransportVo vo) { + //商品列表和收货区域编码 String regionCode = vo.getRegionCode(); List products = vo.getProducts(); - BigDecimal totalWeight = new BigDecimal(0); + //查询默认快递公司代码 defaultExpress.getParamValue() + QueryWrapper configQueryWrapper = new QueryWrapper<>(); + configQueryWrapper.eq("param_key", "DEFAULT_EXPRESS"); + SysConfigEntity defaultExpress = sysConfigService.getOne(configQueryWrapper); + if (defaultExpress == null) { + return R.error("未设置默认快递"); + } + //总运费 + BigDecimal totalExpressFee = new BigDecimal(0); + BigDecimal totalWeight01 = new BigDecimal(0); + BigDecimal totalWeight02 = new BigDecimal(0); + BigDecimal totalWeight04 = new BigDecimal(0); for (ProductRequestVo product : products) { - ShopProduct shopProduct = shopProductService.getById(product.getProductId()); - if(shopProduct.getIsFreeMail()==0){ - continue; + ShopProduct p = shopProductService.getById(product.getProductId()); + if (p != null) { + //包邮 + if(p.getIsFreeMail()==0){ + continue; + }else { + BigDecimal weight = BigDecimal.valueOf(Double.valueOf(p.getWeight()) / 1000.0); + BigDecimal totalWeight = weight.multiply(new BigDecimal(product.getQuantity())); + if ("01".equals(p.getGoodsType())){ + totalWeight01 = totalWeight01.add(totalWeight); + } + if ("02".equals(p.getGoodsType())){ + totalWeight02 = totalWeight02.add(totalWeight); + } + //预售书单独计算 + if ("03".equals(p.getGoodsType())){ + totalExpressFee = totalExpressFee.add( + expressFeeService.calculateExpressFee(defaultExpress.getParamValue(), totalWeight.setScale(0, RoundingMode.UP), regionCode)); + } + if ("04".equals(p.getGoodsType())){ + totalWeight04 = totalWeight04.add(totalWeight); + } + } + }else { + return R.error("未查询到商品"); } - BigDecimal weight = BigDecimal.valueOf(Double.valueOf(shopProduct.getWeight()) / 1000.0); - totalWeight = totalWeight.add(weight.multiply(new BigDecimal(product.getQuantity()))); } - BigDecimal expressFee = new BigDecimal(0); - if(totalWeight.compareTo(BigDecimal.ZERO)!=0){ - totalWeight = totalWeight.setScale(0, RoundingMode.UP); - QueryWrapper configQueryWrapper = new QueryWrapper<>(); - configQueryWrapper.eq("param_key", "DEFAULT_EXPRESS"); - SysConfigEntity config = sysConfigService.getOne(configQueryWrapper); - expressFee = expressFeeService.calculateExpressFee(config.getParamValue(), totalWeight, regionCode); + if(totalWeight01.compareTo(BigDecimal.ZERO)!=0){ + totalExpressFee = totalExpressFee.add( + expressFeeService.calculateExpressFee(defaultExpress.getParamValue(), totalWeight01.setScale(0, RoundingMode.UP), regionCode)); } - - return R.ok().put("result", expressFee); + if(totalWeight02.compareTo(BigDecimal.ZERO)!=0){ + totalExpressFee = totalExpressFee.add( + expressFeeService.calculateExpressFee(defaultExpress.getParamValue(), totalWeight02.setScale(0, RoundingMode.UP), regionCode)); + } + if(totalWeight04.compareTo(BigDecimal.ZERO)!=0){ + totalExpressFee = totalExpressFee.add( + expressFeeService.calculateExpressFee(defaultExpress.getParamValue(), totalWeight04.setScale(0, RoundingMode.UP), regionCode)); + } + return R.ok().put("result", totalExpressFee); } /** diff --git a/src/main/java/com/peanut/modules/book/entity/ShopProduct.java b/src/main/java/com/peanut/modules/book/entity/ShopProduct.java index 295c1915..296d8547 100644 --- a/src/main/java/com/peanut/modules/book/entity/ShopProduct.java +++ b/src/main/java/com/peanut/modules/book/entity/ShopProduct.java @@ -129,7 +129,7 @@ public class ShopProduct implements Serializable { */ private Integer sumSales; /** - * 商品类型 1: 画册 2:书 3:仪器,4:预售书 + * 商品类型 01: 画册 02:书 04:仪器,03:预售书 */ private String goodsType; private String goodsTypeCode; From 38e5bfce20541a63d2c001fd3491af7eccf84851 Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Wed, 6 Dec 2023 09:19:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=B4=AD=E4=B9=B0=E7=9A=84=E4=B9=A6=E7=B1=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/peanut/modules/book/entity/BookTeachEntity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/peanut/modules/book/entity/BookTeachEntity.java b/src/main/java/com/peanut/modules/book/entity/BookTeachEntity.java index ca1fe6fe..64736107 100644 --- a/src/main/java/com/peanut/modules/book/entity/BookTeachEntity.java +++ b/src/main/java/com/peanut/modules/book/entity/BookTeachEntity.java @@ -25,6 +25,8 @@ public class BookTeachEntity { private String voices; + private String images; + private String content; @TableField("create_time")