| | |
| | | public R<Page<UserCoupon>> minelist(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @ApiParam("1未使用2已使用3已过期") Integer status) { |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | LambdaQueryChainWrapper<UserCoupon> chainWrapper = userCouponService.lambdaQuery() |
| | | .eq(UserCoupon::getAppUserId, userid); |
| | | .eq(UserCoupon::getAppUserId, userid) |
| | | .isNotNull(UserCoupon::getCouponInfo); |
| | | if(null != status && 1 == status){ |
| | | chainWrapper.isNull(UserCoupon::getUseTime).gt(UserCoupon::getEndTime, LocalDateTime.now()); |
| | | } |
| | |
| | | CouponInfoVo vo = JSON.parseObject(couponInfo, CouponInfoVo.class); |
| | | // BeanUtils.copyProperties(data,vo); |
| | | //如果是商品券,将商品名称返回 |
| | | if (vo.getCouponType()==4){ |
| | | if (vo != null && vo.getCouponType()==4){ |
| | | List<String> goodNames = new ArrayList<>(); |
| | | if (vo.getForGoodIds().equals("-1")){ |
| | | List<Goods> data1 = goodsClient.getAllGoods().getData(); |
| | |
| | | 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); |
| | | } |
| | | |