| | |
| | | if (data==null){ |
| | | return R.fail("当前优惠券不存在,请刷新后重试"); |
| | | } |
| | | if(data.getDelFlag() == 1 || data.getShelfStatus() == 0){ |
| | | return R.fail("当前优惠券不存在,请刷新后重试"); |
| | | } |
| | | long count = userCouponService.count(new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getCouponId, couponId).eq(UserCoupon::getDelFlag, 0)); |
| | | if(data.getSendNum() <= count){ |
| | | return R.fail("当前优惠券已全部领取完毕"); |
| | |
| | | if(point > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(15); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(point); |
| | | userPoint.setBalance(byId.getLavePoint()); |
| | | userPoint.setAppUserId(userid); |
| | | userPoint.setObjectId(Long.valueOf(data.getId())); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setChangeDirection(-1); |
| | | userPointService.save(userPoint); |
| | | } |
| | | } |
| | |
| | | @PostMapping("/getCouponInfo") |
| | | public R<CouponInfoVo> getCouponInfo(@RequestParam("userCouponId") Long userCouponId){ |
| | | UserCoupon userCoupon = userCouponService.getById(userCouponId); |
| | | CouponInfo data = couponClient.detail(userCoupon.getCouponId()).getData(); |
| | | CouponInfoVo couponInfoVo = new CouponInfoVo(); |
| | | BeanUtils.copyProperties(data, couponInfoVo); |
| | | String jsonStr = userCoupon.getCouponInfo(); |
| | | CouponInfoVo couponInfoVo = JSON.parseObject(jsonStr, CouponInfoVo.class); |
| | | return R.ok(couponInfoVo); |
| | | } |
| | | |