From 7bb6b8e2d079eef38f1215f7148d7254de9746a8 Mon Sep 17 00:00:00 2001 From: "602090531@qq.com" Date: Mon, 21 Mar 2022 18:23:03 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E6=9C=80=E4=BD=8E=E9=87=91=E9=A2=9D=E3=80=81=E6=9C=80?= =?UTF-8?q?=E4=BD=8E=E8=B4=AD=E4=B9=B0=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../royalcanin/good/service/OrderService.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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 7eb064e6..1e25037e 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 @@ -437,6 +437,7 @@ public class OrderService { orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson"); //得到当前能用优惠券的商品总金额 BigDecimal total_Coupon = (BigDecimal) resultMap.get("total_Coupon"); + BigDecimal minCount = (BigDecimal) resultMap.get("minCount"); //校验当前订单金额小于优惠券金额 if(jsonObjectData.getString("couponAmount") != null ){ @@ -445,6 +446,20 @@ public class OrderService { return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); } } + + //校验当前指定商品的总数量有没有大于等于minCount + if(jsonObjectData.getString("minCount") != null ){ + if(minCount.compareTo(new BigDecimal(jsonObjectData.getString("minCount"))) == -1){ + return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); + } + } + //校验当前指定商品的总购买数量有没有大于等于minPrice + if(jsonObjectData.getString("minPrice") != null ){ + if(total_Coupon.compareTo(new BigDecimal(jsonObjectData.getString("minPrice"))) == -1){ + return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); + } + } + //设置ordersEntity的参数 addOrdersEntity(jsonObjectData, ordersEntity); //total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_Coupon); @@ -548,6 +563,7 @@ public class OrderService { orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson"); //得到当前能用优惠券的商品总金额 BigDecimal total_Coupon = (BigDecimal) resultMap.get("total_Coupon"); + BigDecimal minCount = (BigDecimal) resultMap.get("minCount"); //校验当前订单金额小于优惠券金额 if(jsonObjectData.getString("couponAmount") != null ){ @@ -556,6 +572,19 @@ public class OrderService { return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); } } + //校验当前指定商品的总数量有没有大于等于minCount + if(jsonObjectData.getString("minCount") != null ){ + if(minCount.compareTo(new BigDecimal(jsonObjectData.getString("minCount"))) == -1){ + return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); + } + } + //校验当前指定商品的总购买数量有没有大于等于minPrice + if(jsonObjectData.getString("minPrice") != null ){ + if(total_Coupon.compareTo(new BigDecimal(jsonObjectData.getString("minPrice"))) == -1){ + return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); + } + } + //设置ordersEntity的参数 addOrdersEntity(jsonObjectData, ordersEntity); //total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_Coupon); @@ -626,6 +655,7 @@ public class OrderService { double basePoint = 0 ; String mobile = ""; int buyCount = 0; + int minCount = 0; //判断是否属于指定类 if(couponJson != null && SmartStringUtil.isNotBlank(couponJson.getString("productCodes"))){ @@ -646,6 +676,7 @@ public class OrderService { if(isExist && Arrays.asList(productCodes).contains(goodsObject.get("productCode"))){ //计算商品价格、数量、basepoint相关信息 total_Coupon = calculationTotal(order, goodsObject, total_Coupon); + minCount = minCount + order.getBuyCount(); }else{ //计算商品价格、数量、basepoint相关信息 total_fee = calculationTotal(order, goodsObject, total_fee); @@ -668,6 +699,7 @@ public class OrderService { map.put("ordersEntity", ordersEntity); map.put("orderDatilListJson", orderDatilListJson); map.put("total_Coupon", total_Coupon); + map.put("minCount", minCount); return map; } From e8f076477c66995b17fe9bfebaf48925c6658c69 Mon Sep 17 00:00:00 2001 From: "602090531@qq.com" Date: Mon, 21 Mar 2022 18:49:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=9C=AA=E5=88=B0?= =?UTF-8?q?=E7=94=9F=E6=95=88=E6=97=B6=E9=97=B4=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E6=98=BE=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 --- .../system/royalcanin/good/service/OrderService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 1e25037e..c625d3e5 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 @@ -437,7 +437,7 @@ public class OrderService { orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson"); //得到当前能用优惠券的商品总金额 BigDecimal total_Coupon = (BigDecimal) resultMap.get("total_Coupon"); - BigDecimal minCount = (BigDecimal) resultMap.get("minCount"); + int minCount = (int) resultMap.get("minCount"); //校验当前订单金额小于优惠券金额 if(jsonObjectData.getString("couponAmount") != null ){ @@ -449,7 +449,8 @@ public class OrderService { //校验当前指定商品的总数量有没有大于等于minCount if(jsonObjectData.getString("minCount") != null ){ - if(minCount.compareTo(new BigDecimal(jsonObjectData.getString("minCount"))) == -1){ + int count = Integer.parseInt(jsonObjectData.getString("minCount")); + if(minCount < count ){ return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); } } @@ -563,7 +564,7 @@ public class OrderService { orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson"); //得到当前能用优惠券的商品总金额 BigDecimal total_Coupon = (BigDecimal) resultMap.get("total_Coupon"); - BigDecimal minCount = (BigDecimal) resultMap.get("minCount"); + int minCount = (int) resultMap.get("minCount"); //校验当前订单金额小于优惠券金额 if(jsonObjectData.getString("couponAmount") != null ){ @@ -574,7 +575,8 @@ public class OrderService { } //校验当前指定商品的总数量有没有大于等于minCount if(jsonObjectData.getString("minCount") != null ){ - if(minCount.compareTo(new BigDecimal(jsonObjectData.getString("minCount"))) == -1){ + int count = Integer.parseInt(jsonObjectData.getString("minCount")); + if(minCount < count ){ return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL); } }