From 22ab448873d921fdcad0eacc20288e8ff17cf5c6 Mon Sep 17 00:00:00 2001
From: 1098226878@qq.com <1098226878@qq.com>
Date: 星期二, 11 一月 2022 16:13:33 +0800
Subject: [PATCH] 优化代码

---
 service-fee/src/main/java/com/java110/fee/cmd/tempCarFee/GetTempCarFeeOrderCmd.java |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/service-fee/src/main/java/com/java110/fee/cmd/tempCarFee/GetTempCarFeeOrderCmd.java b/service-fee/src/main/java/com/java110/fee/cmd/tempCarFee/GetTempCarFeeOrderCmd.java
index e156b7d..fd80a6f 100644
--- a/service-fee/src/main/java/com/java110/fee/cmd/tempCarFee/GetTempCarFeeOrderCmd.java
+++ b/service-fee/src/main/java/com/java110/fee/cmd/tempCarFee/GetTempCarFeeOrderCmd.java
@@ -22,6 +22,7 @@
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -46,6 +47,7 @@
 
         Assert.hasKeyAndValue(reqJson, "paId", "paId涓嶈兘涓虹┖");
         Assert.hasKeyAndValue(reqJson, "carNum", "carNum涓嶈兘涓虹┖");
+        Assert.hasKeyAndValue(reqJson, "couponIds", "couponIds涓嶈兘涓虹┖");
 
     }
 
@@ -82,24 +84,23 @@
         fee.put("oId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_oId));
         fee.putAll(reqJson);
         CommonCache.setValue("getTempCarFeeOrder" + fee.getString("oId"), fee.toJSONString(), 24 * 60 * 60);
-        cmdDataFlowContext.setResponseEntity(responseEntity);
+        ResponseEntity<String> responseEntitys = new ResponseEntity<>(fee.toJSONString(), HttpStatus.OK);
+        cmdDataFlowContext.setResponseEntity(responseEntitys);
     }
 
     private double checkCouponUser(JSONObject paramObj) {
-        JSONArray couponList = paramObj.getJSONArray("couponList");
-        BigDecimal couponPrice = new BigDecimal(0.0);
-        List<String> couponIds = new ArrayList<String>();
 
-        if (couponList == null || couponList.size() < 1) {
+        BigDecimal couponPrice = new BigDecimal(0.0);
+        String couponIds = paramObj.getString("couponIds");
+        if (couponIds == null || "".equals(couponIds)) {
             paramObj.put("couponPrice", couponPrice.doubleValue());
             paramObj.put("couponUserDtos", new JSONArray()); //杩欓噷鑰冭檻绌�
             return couponPrice.doubleValue();
         }
-        for (int couponIndex = 0; couponIndex < couponList.size(); couponIndex++) {
-            couponIds.add(couponList.getJSONObject(couponIndex).getString("couponId"));
-        }
+
+        List<String> result = Arrays.asList(couponIds.split(","));
         CouponUserDto couponUserDto = new CouponUserDto();
-        couponUserDto.setCouponIds(couponIds.toArray(new String[couponIds.size()]));
+        couponUserDto.setCouponIds(result.toArray(new String[result.size()]));
         List<CouponUserDto> couponUserDtos = couponUserV1InnerServiceSMOImpl.queryCouponUsers(couponUserDto);
         if (couponUserDtos == null || couponUserDtos.size() < 1) {
             paramObj.put("couponPrice", couponPrice.doubleValue());

--
Gitblit v1.8.0