| | |
| | | package com.dsh.activity.controller; |
| | | |
| | | |
| | | import com.alipay.api.domain.ArrangementVORes; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.activity.entity.*; |
| | |
| | | private ICouponService couponService; |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/pointMerchars/getDetailsOfExchange") |
| | | public ExchangeDetailsVo getIntegralExchangeDetails(@RequestBody Integer appUserId) { |
| | | public ExchangeDetailsVo getIntegralExchangeDetails(@RequestBody Integer appUserId) throws ParseException { |
| | | ExchangeDetailsVo detailsVo = new ExchangeDetailsVo(); |
| | | List<ExchangeDetailsResponse> responses = new ArrayList<>(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | List<UserPointsMerchandise> pointsMerchandises = upmseService.list(new QueryWrapper<UserPointsMerchandise>() |
| | | .eq("userId", appUserId).eq("payStatus", 2)); |
| | | |
| | | List<PointsMerchandiseStore> pointsMerchandiseStoreList = pointsMerchandiseStoreService.list(); |
| | | Map<Integer, List<PointsMerchandiseStore>> pointsMerchandiseStoreMap = pointsMerchandiseStoreList.stream().collect(Collectors.groupingBy(PointsMerchandiseStore::getPointsMerchandiseId)); |
| | | |
| | | List<Coupon> list1 = couponService.list(); |
| | | List<Integer> ids = new ArrayList<>(); |
| | |
| | | } |
| | | List<UserCoupon> userCoupons = new ArrayList<>(); |
| | | if (ids.size() > 0) { |
| | | userCoupons = userCouponService.list(new QueryWrapper<UserCoupon>().eq("userId", appUserId).in("couponId", ids)); |
| | | userCoupons = userCouponService.list(new QueryWrapper<UserCoupon>().eq("userId", appUserId).in("couponId", ids) |
| | | .ne("status",3)); |
| | | } |
| | | if (pointsMerchandises.size() > 0) { |
| | | for (UserPointsMerchandise pointsMerchandise : pointsMerchandises) { |
| | |
| | | if (merchandise == null) { |
| | | continue; |
| | | } |
| | | |
| | | ExchangeDetailsResponse detailsResponse = new ExchangeDetailsResponse(); |
| | | detailsResponse.setDetailsId(pointsMerchandise.getId()); |
| | | detailsResponse.setGoodName(merchandise.getName()); |
| | |
| | | } |
| | | } |
| | | } |
| | | if (detailsResponse.getRid()==null){ |
| | | List<Integer> integers = stoClient.querySiteIdById(collect); |
| | | detailsResponse.setRid(integers); |
| | | } |
| | | //====================================================== |
| | | } |
| | | }else{ |
| | |
| | | } |
| | | detailsResponse.setRid(list4); |
| | | detailsResponse.setSid(list3); |
| | | System.err.println("门票rid"+list4); |
| | | System.err.println("门票sid"+list3); |
| | | } |
| | | |
| | | |
| | | if (merchandise.getCardType() == 1) { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(pointsMerchandise.getInsertTime()); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 1); |
| | | Date end = calendar.getTime(); |
| | | String startDate = dateFormat.format(pointsMerchandise.getInsertTime()); |
| | | String endDate = dateFormat.format(end); |
| | | detailsResponse.setStartTime(startDate); |
| | | detailsResponse.setEndTime(startDate); |
| | | Date now = new Date(); |
| | | Calendar cal1 = Calendar.getInstance(); |
| | | cal1.setTime(pointsMerchandise.getInsertTime()); |
| | | Calendar cal2 = Calendar.getInstance(); |
| | | cal2.setTime(now); |
| | | // Compare the year, month, and day of the two Calendar instances |
| | | boolean isSameDate = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && |
| | | cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) && |
| | | cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH); |
| | | // 日卡开始时间和结束时间根据门店营业时间来 |
| | | // 查询门店 |
| | | List<Integer> storeIds = pointsMerchandiseStoreMap.get(merchandise.getId()).stream().map(PointsMerchandiseStore::getStoreId) |
| | | .collect(Collectors.toList()); |
| | | List<Store> stores = storeClient.queryStoreByIds(storeIds); |
| | | String startTime = ""; |
| | | String endTime = ""; |
| | | |
| | | // Print the result |
| | | if (isSameDate) { |
| | | } else { |
| | | System.out.println("The two dates do not have the same date."); |
| | | detailsResponse.setUseStatus(3); |
| | | if (stores != null && !stores.isEmpty()) { |
| | | // 初始化为第一个门店的时间 |
| | | startTime = stores.get(0).getStartTime(); |
| | | endTime = stores.get(0).getEndTime(); |
| | | // 遍历所有门店,找出最早的开始时间和最晚的结束时间 |
| | | for (Store store : stores) { |
| | | String storeStartTime = store.getStartTime(); |
| | | String storeEndTime = store.getEndTime(); |
| | | |
| | | if (storeStartTime != null && startTime != null) { |
| | | // 比较开始时间,找出最早的 |
| | | if (storeStartTime.compareTo(startTime) < 0) { |
| | | startTime = storeStartTime; |
| | | } |
| | | } |
| | | |
| | | if (storeEndTime != null && endTime != null) { |
| | | // 比较结束时间,找出最晚的 |
| | | if (storeEndTime.compareTo(endTime) > 0) { |
| | | endTime = storeEndTime; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | String format = simpleDateFormat1.format(pointsMerchandise.getInsertTime()); |
| | | detailsResponse.setStartTime(format+" "+startTime+":00"); |
| | | detailsResponse.setEndTime(format+" "+endTime+":00"); |
| | | if (simpleDateFormat.parse(format+" "+endTime+":00").before(new Date())){ |
| | | System.err.println("过期了,当前门店中最晚营业时间为"+format+" "+endTime+":00"); |
| | | detailsResponse.setUseStatus(3); |
| | | } |
| | | } else if (merchandise.getCardType() == 2) { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(pointsMerchandise.getInsertTime()); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 31); |
| | |
| | | } |
| | | |
| | | } else if (merchandise.getCardType() == 3) { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(pointsMerchandise.getInsertTime()); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 93); |
| | |
| | | } |
| | | |
| | | } else if (merchandise.getCardType() == 4) { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(pointsMerchandise.getInsertTime()); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 372); |
| | |
| | | |
| | | |
| | | } |
| | | detailsResponse.setIsVipCode(0); |
| | | responses.add(detailsResponse); |
| | | } |
| | | detailsVo.setDetailsResponses(responses); |
| | |
| | | detailsResponse.setGoodName(vipDetail.getTicketName()); |
| | | detailsResponse.setStartTime(simpleDateFormat.format(vipDetail.getStartTime())); |
| | | detailsResponse.setEndTime(simpleDateFormat.format(vipDetail.getEndTime())); |
| | | detailsResponse.setIsVipCode(1); |
| | | detailsResponse.setUseStatus(vipDetail.getStatus()); |
| | | detailsResponse.setUseStatus(vipDetail.getStatus()==1?2:1); |
| | | detailsResponse.setGoodType(3); |
| | | // 表明是会员赠送的门票 |
| | | detailsResponse.setExchangeType(3); |
| | | detailsResponse.setExchangeType(4); |
| | | // 全国通用 |
| | | detailsResponse.setRid(Collections.singletonList(0)); |
| | | detailsResponse.setSid(Collections.singletonList(0)); |
| | |
| | | detailsResponse.setCash(c.getCash()); |
| | | } |
| | | if (userCoupon.getIsVipGrant()!=null && userCoupon.getIsVipGrant()==1){ |
| | | detailsResponse.setExchangeType(3); |
| | | detailsResponse.setExchangeType(4); |
| | | } |
| | | detailsResponse.setStartTime(simpleDateFormat.format(c.getStartTime())); |
| | | detailsResponse.setEndTime(simpleDateFormat.format(c.getEndTime())); |
| | | detailsResponse.setUseStatus(userCoupon.getStatus() == 1 ? 2 : 1); |
| | | detailsResponse.setGoodType(4); |
| | | detailsResponse.setIsVipCode(0); |
| | | responses.add(detailsResponse); |
| | | } |
| | | Comparator<ExchangeDetailsResponse> comparator = Comparator.comparing(ExchangeDetailsResponse::getStartTime).reversed(); |
| | |
| | | PointDetailsVo detailsVo = new PointDetailsVo(); |
| | | |
| | | if (speMercharsId.toString().contains("-1")){ |
| | | // 会员门票 |
| | | // 会员优惠券 |
| | | VipDetail vipDetail = vipDetailService.getById(Math.abs(speMercharsId)); |
| | | if (vipDetail.getType()==1){ |
| | | Coupon coupon = iCouponService.getById(vipDetail.getCouponId()); |