| | |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | record.setCouponInfoVo(vo); |
| | | if (record.getUseTime()==null){ |
| | | record.setStatus(1); |
| | |
| | | }else { |
| | | record.setStatus(2); |
| | | } |
| | | |
| | | |
| | | AppUser appUser = appUserService.getById(record.getAppUserId()); |
| | | record.setUserName(appUser.getName()); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | record.setCouponInfoVo(vo); |
| | | if (record.getUseTime()==null){ |
| | | record.setStatus(1); |
| | |
| | | }else { |
| | | record.setStatus(2); |
| | | } |
| | | |
| | | |
| | | AppUser appUser = appUserService.getById(record.getAppUserId()); |
| | | record.setUserName(appUser.getName()); |
| | |
| | | if (data==null){ |
| | | 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("当前优惠券已全部领取完毕"); |
| | | } |
| | | count = userCouponService.count(new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getCouponId, couponId) |
| | | .eq(UserCoupon::getAppUserId, userid).eq(UserCoupon::getDelFlag, 0)); |
| | | if(data.getMaxNum() <= count){ |
| | | return R.fail("当前优惠券已达到最大领取限制"); |
| | | } |
| | | |
| | | if (data.getSendType()!=1&& byId.getLavePoint().compareTo(data.getNeedPoint().intValue()) < 0){ |
| | | return R.fail("当前积分不足,兑换失败"); |
| | | } |
| | |
| | | appUserService.updateById(byId); |
| | | |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(4); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(point); |
| | | userPoint.setBalance(byId.getLavePoint()); |
| | |
| | | userCouponService.updateById(userCoupon); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户优惠券详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/getUserCoupon") |
| | | public R<UserCoupon> getUserCoupon(@RequestParam("id") Long id){ |
| | | UserCoupon userCoupon = userCouponService.getById(id); |
| | | return R.ok(userCoupon); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑用户优惠券 |
| | | * @return |
| | | */ |
| | | @PostMapping("/editUserCoupon") |
| | | public R editUserCoupon(@RequestBody UserCoupon userCoupon){ |
| | | userCouponService.updateById(userCoupon); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |