From 34c21f1c938ba3659c5d50201a0e64f747ee4545 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期六, 24 八月 2024 09:48:27 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TVipServiceImpl.java |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TVipServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TVipServiceImpl.java
index f0d8245..d15b333 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TVipServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TVipServiceImpl.java
@@ -9,8 +9,10 @@
 import com.ruoyi.other.mapper.TVipMapper;
 import com.ruoyi.other.service.TVipService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.poi.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import java.util.List;
 
@@ -34,18 +36,20 @@
 
         for (TVip tVip : list) {
             String coupon = tVip.getCoupon();
-            JSONArray jsonArray = JSONObject.parseArray(coupon);
-            StringBuilder stringBuilder = new StringBuilder();
-            for (int i = 0; i < jsonArray.size(); i++) {
-                JSONObject jsonObject = jsonArray.getJSONObject(i);
-                Integer id = jsonObject.getInteger("id");
-                Integer number = jsonObject.getInteger("number");
-                TCoupon tCoupon = tCouponMapper.selectById(id);
-                if (tCoupon!=null){
-                    stringBuilder.append(tCoupon.getName()).append("*").append(number).append(";");
+            if (StringUtils.hasLength(coupon)){
+                JSONArray jsonArray = JSONObject.parseArray(coupon);
+                StringBuilder stringBuilder = new StringBuilder();
+                for (int i = 0; i < jsonArray.size(); i++) {
+                    JSONObject jsonObject = jsonArray.getJSONObject(i);
+                    Integer id = jsonObject.getInteger("id");
+                    Integer number = jsonObject.getInteger("number");
+                    TCoupon tCoupon = tCouponMapper.selectById(id);
+                    if (tCoupon!=null){
+                        stringBuilder.append(tCoupon.getName()).append("*").append(number).append(";");
+                    }
                 }
+                tVip.setCouponName(stringBuilder.toString());
             }
-            tVip.setCouponName(stringBuilder.toString());
         }
         pageInfo.setRecords(list);
         return pageInfo;

--
Gitblit v1.7.1