From 4f97bdbaadcdc19df9dfb0971b930d799c4aeddc Mon Sep 17 00:00:00 2001 From: luofl <1442745593@qq.com> Date: 星期四, 13 三月 2025 14:52:26 +0800 Subject: [PATCH] 迭代版本:2.28 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java | 37 ++++++++++++++++++++++++++++--------- 1 files changed, 28 insertions(+), 9 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java index 7bde80d..0c85501 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java @@ -62,6 +62,10 @@ public R<IPage<CouponInfo>> list(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, CouponInfo couponInfo) { + Integer periodType = couponInfo.getPeriodType(); + if (periodType != null && periodType.equals(0)){ + couponInfo.setPeriodType(null); + } IPage<CouponInfo> couponInfoIPage = couponInfoService.queryCouponInfoPage(Page.of(pageNum, pageSize), couponInfo); for (CouponInfo record : couponInfoIPage.getRecords()) { R<Long> r = userCouponClient.getCouponCount(record.getId()); @@ -76,6 +80,9 @@ @ApiOperation(value = "优惠劵管理-详情", tags = {"管理后台-活动管理"}) public R<CouponInfo> detail(@RequestParam("id") Integer id) { CouponInfo byId = couponInfoService.getById(id); + if (byId == null){ + return R.fail("优惠劵不存在"); + } String forGoodIds = byId.getForGoodIds(); if (!"-1".equals(forGoodIds) && StringUtils.isNotEmpty(forGoodIds)){ List<Goods> goods = goodsService.listByIds(Arrays.asList(forGoodIds.split(","))); @@ -155,9 +162,18 @@ AppUser appUserById = appUserClient.getAppUserById(userid); LocalDateTime now = LocalDateTime.now(); //查出全部可领取的优惠劵 - List<CouponInfo> list = couponInfoService.lambdaQuery().le(CouponInfo::getSendStartTime, now).ge(CouponInfo::getSendEndTime, now).eq(CouponInfo::getPersonType, 1).list(); + List<CouponInfo> list = couponInfoService.lambdaQuery() + .le(CouponInfo::getSendStartTime, now) + .ge(CouponInfo::getSendEndTime, now) + .eq(CouponInfo::getPersonType, 1) + .list(); //查出指定人员可领取优惠券 - List<CouponInfo> list1 = couponInfoService.lambdaQuery().le(CouponInfo::getSendStartTime, now).ge(CouponInfo::getSendEndTime, now).eq(CouponInfo::getPersonType, 2).apply("FIND_IN_SET('" + appUserById.getId() + "', person_ids)").list(); + List<CouponInfo> list1 = couponInfoService.lambdaQuery() + .le(CouponInfo::getSendStartTime, now) + .ge(CouponInfo::getSendEndTime, now) + .eq(CouponInfo::getPersonType, 2) + .apply("FIND_IN_SET('" + appUserById.getId() + "', person_ids)") + .list(); //查出指定会员可领取优惠劵 List<CouponInfo> list2 = couponInfoService.lambdaQuery().le(CouponInfo::getSendStartTime, now).ge(CouponInfo::getSendEndTime, now).eq(CouponInfo::getPersonType, 3).apply("FIND_IN_SET('" + appUserById.getVipId() + "', vip_ids)").list(); List<CouponInfo> returnList = new ArrayList<>(); @@ -170,18 +186,21 @@ private void count(Long userid, List<CouponInfo> list1, List<CouponInfo> returnList) { for (CouponInfo couponInfo : list1) { Long count = appUserClient.getCouponCount(-1L, couponInfo.getId()).getData(); - if(couponInfo.getSendNum() <= count){ - couponInfo.setMaxNum(count.intValue() - couponInfo.getSendNum()); - for (int i = 0; i < couponInfo.getMaxNum(); i++) { - returnList.add(couponInfo); - } + if(count >= couponInfo.getSendNum()){ continue; } count = appUserClient.getCouponCount(userid, couponInfo.getId()).getData(); couponInfo.setMaxNum(couponInfo.getMaxNum() - count.intValue()); - for (int i = 0; i < couponInfo.getMaxNum(); i++) { - returnList.add(couponInfo); + if((couponInfo.getSendNum() - count) >= couponInfo.getMaxNum()){ + for (int i = 0; i < couponInfo.getMaxNum(); i++) { + returnList.add(couponInfo); + } + }else{ + for (int i = 0; i < (couponInfo.getSendNum() - count); i++) { + returnList.add(couponInfo); + } } + } } -- Gitblit v1.7.1