| | |
| | | package com.ruoyi.member.controller.miniapp; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.goods.api.domain.GetLotteryEventList; |
| | | import com.ruoyi.goods.api.domain.TLotteryEvent; |
| | | import com.ruoyi.goods.api.service.LotteryEventClient; |
| | | import com.ruoyi.member.domain.dto.AppMemberCouponPageDto; |
| | |
| | | vo.setDiscountMoney(coupon.getDiscountMoney()); |
| | | vo.setValidType(coupon.getValidTimeType()); |
| | | vo.setValidDays(coupon.getValidDay()); |
| | | vo.setValidStartTime(sdf.format(coupon.getValidStartTime())); |
| | | vo.setValidEndTime(sdf.format(coupon.getValidEndTime())); |
| | | if (2 != coupon.getValidTimeType()) { |
| | | vo.setValidStartTime(sdf.format(coupon.getValidStartTime())); |
| | | vo.setValidEndTime(sdf.format(coupon.getValidEndTime())); |
| | | } |
| | | vo.setPropagandaPoster(coupon.getPropagandaPoster()); |
| | | vo.setSharePassage(coupon.getSharePassage()); |
| | | vo.setSharePic(coupon.getSharePic()); |
| | | vo.setUseGoods(""); |
| | | //构建特定商品数据 |
| | | if (StringUtils.isNotEmpty(coupon.getRelGoodsIds())) { |
| | |
| | | } |
| | | vo.setUseGoods(sb.substring(0, sb.length() - 1)); |
| | | } |
| | | vo.setLaveNum(coupon.getSendLimitFlag()); |
| | | vo.setLimitFlag(coupon.getSendLimitFlag()); |
| | | vo.setReceiveNum(coupon.getSendLimitNumber()); |
| | | int count = memberCouponService.count(new QueryWrapper<MemberCoupon>().eq("coupon_id", couponId).eq("del_flag", 0)); |
| | | vo.setLaveNum(coupon.getSendLimitNumber() - count); |
| | | MemberCoupon one = memberCouponService.getOne(new QueryWrapper<MemberCoupon>().eq("coupon_id", couponId).eq("user_id", SecurityUtils.getUserId())); |
| | | if (one != null) { |
| | | vo.setStatus(one.getCouponStatus()); |
| | | } |
| | | Long userId = SecurityUtils.getUserId(); |
| | | List<MemberCoupon> list = memberCouponService.list(new QueryWrapper<MemberCoupon>().eq("coupon_id", couponId).eq("user_id", userId).eq("del_flag", 0)); |
| | | vo.setStatus(list.isEmpty() ? null : list.get(0).getCouponStatus()); |
| | | return R.ok(vo); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "优惠券id", required = true, dataType = "String", paramType = "path") |
| | | }) |
| | | public R<Boolean> shareCoupon(@PathVariable("couponId") String couponId) { |
| | | public R<String> shareCoupon(@PathVariable("couponId") String couponId) { |
| | | //检测是否可以抽奖 |
| | | List<TLotteryEvent> data = lotteryEventClient.getLotteryEventList(3).getData(); |
| | | GetLotteryEventList getLotteryEventList = new GetLotteryEventList(); |
| | | getLotteryEventList.setActivityType(3); |
| | | getLotteryEventList.setUserId(SecurityUtils.getUserId()); |
| | | List<TLotteryEvent> data = lotteryEventClient.getLotteryEventList(getLotteryEventList).getData(); |
| | | if (data.size() > 0) { |
| | | return R.ok(true); |
| | | return R.ok(data.get(0).getId()); |
| | | } |
| | | return R.ok(false); |
| | | return R.ok(); |
| | | } |
| | | } |