diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java index b4d32395..650b9408 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java @@ -172,6 +172,33 @@ public class HighCouponController { } } + @RequestMapping(value = "/getUserNewCouponDetail", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取用户最新的卡卷详细") + public ResponseData getUserNewCouponDetail(@RequestParam(name = "couponId", required = true) Long couponId, + HttpServletRequest request) { + try { + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + // 查询最新一张可用的卡券 + HighUserCoupon newCoupon = highUserCouponService.getUserNewCoupon(userInfoModel.getHighUser().getId(), couponId); + + if (newCoupon != null) { + Map map = new HashMap<>(); + map.put("highUserCoupon", newCoupon); + map.put("couponInfo", highCouponService.getCouponById(newCoupon.getCouponId())); + map.put("couponCodeInfo", highCouponCodeService.getCouponCodeById(newCoupon.getCouponCodeId())); + return ResponseMsgUtil.success(map); + } + return ResponseMsgUtil.success(null); + + } catch (Exception e) { + log.error("HighCouponController --> getUserNewCouponDetail() error!", e); + return ResponseMsgUtil.exception(e); + } + } @RequestMapping(value = "/againReceiveCoupon", method = RequestMethod.GET) @ResponseBody diff --git a/hai-service/src/main/java/com/hai/service/HighUserCouponService.java b/hai-service/src/main/java/com/hai/service/HighUserCouponService.java index cff57a88..5591e76e 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserCouponService.java @@ -49,6 +49,13 @@ public interface HighUserCouponService { **/ HighUserCoupon getDetailById(Long userCouponId); + /** + * @Author 胡锐 + * @Description 查询最新一张可用的卡券 + * @Date 2021/4/20 21:01 + **/ + HighUserCoupon getUserNewCoupon(Long userId,Long couponId); + /** * @Author 胡锐 * @Description 查询用户列表 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java index 1d31fe51..5648a6f3 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java @@ -76,6 +76,18 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { return highUserCouponMapper.selectByPrimaryKey(userCouponId); } + @Override + public HighUserCoupon getUserNewCoupon(Long userId, Long couponId) { + HighUserCouponExample example = new HighUserCouponExample(); + example.createCriteria().andUserIdEqualTo(userId).andCouponIdEqualTo(couponId).andStatusEqualTo(1); + example.setOrderByClause("create_time desc"); + List couponList = highUserCouponMapper.selectByExample(example); + if (couponList != null && couponList.size() > 0) { + return couponList.get(0); + } + return null; + } + @Override public List getUserCouponList(Map map) { HighUserCouponExample example = new HighUserCouponExample();