From cf44fb3cb2089cb572a923d62749b2e5943f0245 Mon Sep 17 00:00:00 2001 From: "602090531@qq.com" Date: Sun, 20 Mar 2022 17:59:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=9C=AA=E5=88=B0=E7=94=9F?= =?UTF-8?q?=E6=95=88=E6=97=B6=E9=97=B4=E4=BC=98=E6=83=A0=E5=88=B8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../royalcanin/good/service/OrderService.java | 44 ++++++------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/service/OrderService.java b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/service/OrderService.java index 575bdd3d..63fb97bf 100644 --- a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/service/OrderService.java +++ b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/service/OrderService.java @@ -429,8 +429,6 @@ public class OrderService { } } - //得到其它商品的总金额 - BigDecimal total_Other = new BigDecimal("0"); //根据productCodes来判断优惠券的类型,空的话就是通用券,不是空就是指定类别券 if(SmartStringUtil.isNotBlank(jsonObjectData.getString("productCodes"))){ // BigDecimal total_Coupon = new BigDecimal("0"); @@ -453,33 +451,26 @@ public class OrderService { //得出指定类用完优惠券后的金额 total_Coupon = orderService.computeTotal(ordersEntity.getCouponTypeId(), new BigDecimal(ordersEntity.getCouponAmount()), total_Coupon); //得出最终实际的支付金额 - total_fee = total_Other.add(total_Coupon); + total_fee = new BigDecimal(ordersEntity.getOrderAmount()).add(total_Coupon); }else{//通用类优惠券的实际支付逻辑 Map resultMap = addOrdersEntityInfo(ordersEntityList, ordersEntity, couponJson, total_fee); //ordersEntity = (OrdersEntity) resultMap.get("ordersEntity"); - orderDatilListJson = (JSONArray) resultMap.get("orderDetailJson"); + orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson"); //校验当前订单金额小于优惠券金额 if(jsonObjectData.getString("couponAmount") != null ){ BigDecimal couponAmount = new BigDecimal(jsonObjectData.getString("couponAmount")); - BigDecimal orderAmount = new BigDecimal(ordersEntity.getOrderAmount()); - if(orderAmount.compareTo(couponAmount) == -1){ - return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); - } - } - //校验当前订单金额小于优惠券金额 - if(jsonObjectData.getString("couponAmount") != null ){ - BigDecimal couponAmount = new BigDecimal(jsonObjectData.getString("couponAmount")); - if(total_fee.compareTo(couponAmount) == -1){ + if(new BigDecimal(ordersEntity.getOrderAmount()).compareTo(couponAmount) == -1){ return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); } } //设置ordersEntity的参数 addOrdersEntity(jsonObjectData, ordersEntity); //total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_fee); - total_fee = orderService.computeTotal(ordersEntity.getCouponTypeId(), new BigDecimal(ordersEntity.getCouponAmount()),new BigDecimal(ordersEntity.getOrderAmount())); + total_fee = orderService.computeTotal(ordersEntity.getCouponTypeId(), new BigDecimal(ordersEntity.getCouponAmount()), new BigDecimal(ordersEntity.getOrderAmount())); } }else{//没有优惠券的计算总价逻辑 Map resultMap = addOrdersEntityInfo(ordersEntityList, ordersEntity, couponJson, total_fee); + total_fee = new BigDecimal(ordersEntity.getOrderAmount()); } ordersEntity.setMemberId(memberId); @@ -548,8 +539,6 @@ public class OrderService { } } - //得到其它商品的总金额 - BigDecimal total_Other = new BigDecimal("0"); //根据productCodes来判断优惠券的类型,空的话就是通用券,不是空就是指定类别券 if(SmartStringUtil.isNotBlank(jsonObjectData.getString("productCodes"))){ // BigDecimal total_Coupon = new BigDecimal("0"); @@ -572,33 +561,26 @@ public class OrderService { //得出指定类用完优惠券后的金额 total_Coupon = orderService.computeTotal(ordersEntity.getCouponTypeId(), new BigDecimal(ordersEntity.getCouponAmount()), total_Coupon); //得出最终实际的支付金额 - total_fee = total_Other.add(total_Coupon); + total_fee = new BigDecimal(ordersEntity.getOrderAmount()).add(total_Coupon); }else{//通用类优惠券的实际支付逻辑 Map resultMap = addOrdersEntityInfo(ordersEntityList, ordersEntity, couponJson, total_fee); //ordersEntity = (OrdersEntity) resultMap.get("ordersEntity"); - orderDatilListJson = (JSONArray) resultMap.get("orderDetailJson"); + orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson"); //校验当前订单金额小于优惠券金额 if(jsonObjectData.getString("couponAmount") != null ){ BigDecimal couponAmount = new BigDecimal(jsonObjectData.getString("couponAmount")); - BigDecimal orderAmount = new BigDecimal(ordersEntity.getOrderAmount()); - if(orderAmount.compareTo(couponAmount) == -1){ - return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); - } - } - //校验当前订单金额小于优惠券金额 - if(jsonObjectData.getString("couponAmount") != null ){ - BigDecimal couponAmount = new BigDecimal(jsonObjectData.getString("couponAmount")); - if(total_fee.compareTo(couponAmount) == -1){ + if(new BigDecimal(ordersEntity.getOrderAmount()).compareTo(couponAmount) == -1){ return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); } } //设置ordersEntity的参数 addOrdersEntity(jsonObjectData, ordersEntity); //total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_fee); - total_fee = orderService.computeTotal(ordersEntity.getCouponTypeId(), new BigDecimal(ordersEntity.getCouponAmount()),new BigDecimal(ordersEntity.getOrderAmount())); + total_fee = orderService.computeTotal(ordersEntity.getCouponTypeId(), new BigDecimal(ordersEntity.getCouponAmount()), new BigDecimal(ordersEntity.getOrderAmount())); } }else{//没有优惠券的计算总价逻辑 Map resultMap = addOrdersEntityInfo(ordersEntityList, ordersEntity, couponJson, total_fee); + total_fee = new BigDecimal(ordersEntity.getOrderAmount()); } ordersEntity.setMemberId(memberId); @@ -676,15 +658,15 @@ public class OrderService { ordersEntity.setOrderAddress(orderAddress); ordersEntity.setCouponAmount(ordersEntity.getCouponAmount()); - ordersEntity.setOrderAmount(StringUtil.toString(total_fee)); ordersEntity.setBuyCount(buyCount); ordersEntity.setBasePoint(basePoint); ordersEntity.setPhoneNumber(mobile); + ordersEntity.setOrderAmount(StringUtil.toString(total_fee)); ordersEntity.setProductCode(productId.substring(0, productId.length()-1)); ordersEntity.setProductName(productName.substring(0, productName.length()-1)); map.put("ordersEntity", ordersEntity); - map.put("orderDetailJson", orderDatilListJson); - map.put("total_Coupon", "total_Coupon"); + map.put("orderDatilListJson", orderDatilListJson); + map.put("total_Coupon", total_Coupon); return map; }