liujie
昨天 f7ef2230af6dc8a55c2b5bd6505eed8586c87f75
cloud-server-other/src/main/java/com/dsh/other/controller/TVipController.java
@@ -58,13 +58,19 @@
            List<TicketVipResp> ticketVipRespList = new ArrayList<>();
            String couponJson = vip.getCouponJson();
            JSONArray couponJsonArray = JSONArray.parseArray(couponJson);
            if(couponJsonArray==null){
                continue;
            }
            for (Object o : couponJsonArray) {
                JSONObject couponJsonObject = (JSONObject) o;
                // 优惠券id
                Integer id = Integer.valueOf(couponJsonObject.getString("id"));
                // 优惠券数量
                Integer value = Integer.valueOf(couponJsonObject.getString("value"));
                Coupon coupon = coupons.stream().filter(e -> e.getId().equals(id)).findFirst().orElse(new Coupon());
                Coupon coupon = coupons.stream().filter(e -> e.getId().equals(id)).findFirst().orElse(null);
                if (coupon==null){
                    continue;
                }
                CouponVipResp couponVipResp = new CouponVipResp();
                couponVipResp.setId(coupon.getId());
                couponVipResp.setName(coupon.getName());
@@ -153,22 +159,23 @@
            }
            vip.setCouponList(couponVipRespList);
            String ticketJson = vip.getTicketJson();
            JSONArray ticketJsonArray = JSONArray.parseArray(ticketJson);
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            for (Object o : ticketJsonArray) {
                JSONObject ticketJsonObject = (JSONObject) o;
                TicketVipResp ticketVipResp = new TicketVipResp();
                Integer count = ticketJsonObject.getInteger("count");
                ticketVipResp.setName(ticketJsonObject.getString("name"));
                ticketVipResp.setTime(ticketJsonObject.getInteger("time"));
                ticketVipResp.setCount(ticketJsonObject.getInteger("count"));
                ticketVipResp.setStartTime(simpleDateFormat.format(new Date()));
                Date date = new Date();
                // 给这个date加X天
                date.setTime(date.getTime() + ticketJsonObject.getInteger("time") * 24 * 60 * 60 * 1000);
                ticketVipResp.setEffectiveTime(simpleDateFormat.format(date));
                ticketVipRespList.add(ticketVipResp);
            if(ticketJson!=null && !"".equals(ticketJson)){
                JSONArray ticketJsonArray = JSONArray.parseArray(ticketJson);
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                for (Object o : ticketJsonArray) {
                    JSONObject ticketJsonObject = (JSONObject) o;
                    TicketVipResp ticketVipResp = new TicketVipResp();
                    Integer count = ticketJsonObject.getInteger("count");
                    ticketVipResp.setName(ticketJsonObject.getString("name"));
                    ticketVipResp.setTime(ticketJsonObject.getInteger("time"));
                    ticketVipResp.setCount(ticketJsonObject.getInteger("count"));
                    ticketVipResp.setStartTime(simpleDateFormat.format(new Date()));
                    Date date = new Date();
                    // 给这个date加X天
                    date.setTime(date.getTime() + ticketJsonObject.getInteger("time") * 24 * 60 * 60 * 1000);
                    ticketVipResp.setEffectiveTime(simpleDateFormat.format(date));
                    ticketVipRespList.add(ticketVipResp);
                }
            }
            vip.setTicketList(ticketVipRespList);
        }