From e058a649d8f6c78afd8f73d157058d5106aa6925 Mon Sep 17 00:00:00 2001 From: luodangjia <luodangjia> Date: 星期一, 13 一月 2025 19:47:10 +0800 Subject: [PATCH] 12.18 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 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 f7de2e1..7bde80d 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 @@ -159,19 +159,25 @@ //查出指定人员可领取优惠券 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() + "', 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<>(); count(userid, list, returnList); count(userid, list1, returnList); count(userid, list2, returnList); - - return R.ok(returnList); } private void count(Long userid, List<CouponInfo> list1, List<CouponInfo> returnList) { for (CouponInfo couponInfo : list1) { - Long count = appUserClient.getCouponCount(userid, couponInfo.getId()).getData(); + 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); + } + 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); @@ -205,9 +211,14 @@ } - - - + /** + * 根据类型获取有效优惠券列表 + */ + @PostMapping("/getCouponInfoByPersonType") + public R<List<CouponInfo>> getCouponInfoByPersonType(@RequestParam("personType") Integer personType){ + List<CouponInfo> list = couponInfoService.list(new LambdaUpdateWrapper<CouponInfo>().eq(CouponInfo::getPersonType, personType).eq(CouponInfo::getDelFlag, 0).eq(CouponInfo::getShelfStatus, 1).last(" and now() between period_start_time and period_end_time")); + return R.ok(list); + } } -- Gitblit v1.7.1