| | |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.account.api.dto.SendCouponDto; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserVipDetailClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.api.vo.GetAppUserVipDetail; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private AppUserVipDetailClient vipDetailClient; |
| | | |
| | | @ApiOperation(value = "当前生效会员信息", tags = {"小程序-个人中心"}) |
| | | @GetMapping("/recent/vipInfo") |
| | | public R<List<VipInfoDto>> recentVipInfo() { |
| | |
| | | if (data.getVipEndTime()!=null&&data.getVipEndTime().isAfter(LocalDateTime.now())) { |
| | | |
| | | List<VipInfoDto> vipInfoDtos = new ArrayList<>(); |
| | | List<TVip> vips = vipService.lambdaQuery().eq(TVip::getId, data.getVipId()).list(); |
| | | |
| | | // List<TVip> vips = vipService.lambdaQuery().eq(TVip::getId, data.getVipId()).list(); |
| | | List<TVip> vips = new ArrayList<>(); |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(userId); |
| | | getAppUserVipDetail.setVipId(data.getVipId()); |
| | | TAppUserVipDetail data1 = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); |
| | | String vipJson = data1.getVipJson(); |
| | | TVip tVip = JSON.parseObject(vipJson, TVip.class); |
| | | vips.add(tVip); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | for (TVip vip : vips) { |
| | | VipInfoDto vipInfoDto = new VipInfoDto(); |
| | |
| | | vipInfoDto.setMallExclusivePrice(vip.getMallExclusivePrice()); |
| | | vipInfoDto.setName(vip.getName()); |
| | | vipInfoDto.setId(vip.getId()); |
| | | List<SendCouponDto> javaList = JSON.parseArray(vip.getCoupon()).toJavaList(SendCouponDto.class); |
| | | List<VipCouponDto> vipCouponDtos = new ArrayList<>(); |
| | | if (!javaList.isEmpty()) { |
| | | for (SendCouponDto sendCouponDto : javaList) { |
| | | VipCouponDto vipCouponDto = new VipCouponDto(); |
| | | TCoupon byId = couponService.getById(sendCouponDto.getId()); |
| | | vipCouponDto.setNum(sendCouponDto.getNumber()); |
| | | vipCouponDto.setTCoupon(byId); |
| | | vipCouponDtos.add(vipCouponDto); |
| | | if (vip.getCoupon()!=null) { |
| | | List<SendCouponDto> javaList = JSON.parseArray(vip.getCoupon()).toJavaList(SendCouponDto.class); |
| | | List<VipCouponDto> vipCouponDtos = new ArrayList<>(); |
| | | if (!javaList.isEmpty()) { |
| | | for (SendCouponDto sendCouponDto : javaList) { |
| | | VipCouponDto vipCouponDto = new VipCouponDto(); |
| | | TCoupon byId = couponService.getById(sendCouponDto.getId()); |
| | | vipCouponDto.setNum(sendCouponDto.getNumber()); |
| | | vipCouponDto.setTCoupon(byId); |
| | | vipCouponDtos.add(vipCouponDto); |
| | | } |
| | | } |
| | | } |
| | | |
| | | vipInfoDto.setVipCouponDtos(vipCouponDtos); |
| | | vipInfoDto.setVipCouponDtos(vipCouponDtos); |
| | | |
| | | //计算总折扣 |
| | | BigDecimal total = BigDecimal.ZERO; |
| | |
| | | total.add(tCoupon.getDiscountAmount()); |
| | | } |
| | | } |
| | | |
| | | vipInfoDto.setTotalDiscount(total); |
| | | |
| | | vipInfoDto.setTimeAmount(vip.getMaximumDeduction().multiply(BigDecimal.valueOf(vip.getDiscountTimes()))); |
| | | vipInfoDtos.add(vipInfoDto); |
| | | } |
| | | } |
| | | return R.ok(vipInfoDtos); |
| | | |